// app/interfaces/answer.ts - 前端和本地 API 之间使用的响应类型 /** OCS 支持的题型;空字符串表示不指定题型,交给模型根据题目判断 */ export type QuestionType = | "" | "single" | "multiple" | "judgement" | "completion"; /** 答题接口请求体,字段名保持旧 Python 服务和 OCS AnswererWrapper 兼容 */ export interface ISearchRequest { /** 题目正文,必填 */ title: string; /** 题型,可能为空字符串 */ type: QuestionType | string; /** 选项文本,多行或 JSON 字符串均按旧逻辑透传给服务端解析 */ options: string; } /** 答题成功时返回给 OCS 和前端的结构 */ export interface ISearchSuccessResponse { /** OCS 约定:1 表示找到答案 */ code: 1; /** 原题目正文 */ question: string; /** 最终答案;多选题继续使用 `#` 分隔 */ answer: string; } /** 答题失败时返回给 OCS 和前端的结构 */ export interface ISearchErrorResponse { /** OCS 约定:0 表示失败 */ code: 0; /** 本地安全错误文案,不包含上游细节 */ msg: string; } /** 答题接口联合响应 */ export type ISearchResponse = ISearchSuccessResponse | ISearchErrorResponse; /** 健康检查响应,只暴露非敏感运行信息 */ export interface IHealthResponse { /** 服务状态,正常时为 ok */ status: "ok"; /** 本地状态文案 */ message: string; /** 服务版本 */ version: string; /** 当前是否启用内存缓存 */ cache_enabled: boolean; /** 当前模型名,不包含 API Key 或 baseURL */ model: string; } /** 服务统计响应,来自当前 Nuxt 进程的内存状态 */ export interface IStatsResponse { /** 服务版本 */ version: string; /** 进程运行秒数 */ uptime: number; /** 当前模型名 */ model: string; /** 当前是否启用内存缓存 */ cache_enabled: boolean; /** 当前有效缓存数量 */ cache_size: number; /** 当前进程内问答记录数量 */ qa_records_count: number; } /** 最近问答记录,字段来自 server/utils/runtimeState.ts */ export interface IQaRecord { /** 本地可读时间 */ time: string; /** ISO 时间,方便排序和调试 */ timestamp: string; /** 题目正文 */ question: string; /** 题型 */ type: string; /** 选项文本 */ options: string; /** 最终返回给 OCS 的答案 */ answer: string; } /** 最近问答记录接口响应 */ export interface IRecordsResponse { /** 管理接口是否成功 */ success: boolean; /** 失败时的本地安全文案 */ message?: string; /** 当前进程内最近问答记录,最新在前 */ records: IQaRecord[]; } /** 清空缓存接口响应 */ export interface IClearCacheResponse { /** 是否清理成功;缓存关闭时为 false */ success: boolean; /** 本地状态文案 */ message: string; }