/** * { * "modelClassId": 41, * "modelMcpId": 56, * "message": [ * { * "role": "user", * "timestamp": 1719242380731, * "id": "88", * "content": "分析一下最近10条登录日志" * } * ], * "UserId": 10 * } */ // 消息类型定义 export type Message = { id: number role: 'user' | 'assistant' | 'system' | 'meta' | 'tool' //仅markdown渲染器需要 render_content: string //实际传给AI的内容 content: string timestamp: number //仅role为tool时需要 name?: string tool_call_id?: string //仅role为assistant时需要 like?: boolean tool_calls?: FunctionCall[] //仅role为user时需要 files?: Array | undefined } export type UploadFile = { size: number path: string name: string type: string full_path: string } export type FunctionCall = { id: string type: 'function' function: { name: string arguments: string } } export type ChatRequest = { session_id: number modelClassId?: number modelEmbeddingId?: number modelMcpId?: number[] message: Message[] } export type ChatResponseType = 'message' | 'toolcall' | 'toolres' | 'error' | 'datamsg' | 'structdata' export type ChatResponseBase = { type: T } export type Text = ChatResponseBase<'message'> & { message: string } export type ToolCallRequest = ChatResponseBase<'toolcall'> & { request: { id: string name: string data: string } } export type ToolCallResponse = ChatResponseBase<'toolres'> & { response: { id: string name: string data: string } } export type ErrorResponse = ChatResponseBase<'error'> & { error: string } export type MetaResponse = ChatResponseBase<'meta'> & { meta: string } export type DataResponse = ChatResponseBase<'datamsg'> & { data: string } export type StructDataResponse = ChatResponseBase<'structdata'> & { uuid: string } export type ChatResponse = Text | ToolCallRequest | ToolCallResponse | ErrorResponse | DataResponse | StructDataResponse export type ModelType = 'embedding' | 'chat' // 大语言模型配置相关类型定义 // 大语言模型配置列表查询参数 export type LmConfigListParams = { keyWord?: string // 搜索关键字 dateRange?: string[] // 日期范围 OrderBy?: string // 排序 pageNum?: number // 分页号码,默认1 pageSize?: number // 分页数量,最大500,默认10 modelClass?: string // 模型分类 modelName?: string // 模型名称 modelType?: ModelType // 模型类型 status?: string // 是否启用 createdAt?: string // 创建时间 } // 大语言模型配置基础信息 export type LmConfigInfo = { id?: number modelClass?: string // 模型分类 modelName?: string // 模型名称 apiKey?: string // API密钥 baseUrl?: string // 基础URL modelType?: ModelType // 模型类型 isCallFun?: boolean // 是否调用函数 maxToken?: number // 最大令牌数 status: boolean // 是否启用 createdAt?: string // 创建时间 updatedAt?: string // 更新时间 createdBy?: number // 创建者ID updatedBy?: number // 更新者ID createdUser?: any // 创建用户信息 actionBtn?: any // 操作按钮 [key: string]: any // 允许其他字段 } // 大语言模型配置添加请求 export type LmConfigAddReq = Omit // 大语言模型配置编辑请求 export type LmConfigEditReq = LmConfigInfo & { id: number // 编辑时ID必须 } // 大语言模型配置状态设置请求 export type LmConfigStatusReq = { id: number status: string } // 删除请求参数 export type LmConfigDeleteParams = { ids: number[] } // 获取单个配置参数 export type LmConfigGetParams = { id: number } export type LmSession = { session_id: number title: string } // 会话消息列表查询参数 export type SessionMessagesListParams = { sessionId: number } // 保存会话消息请求 export type SessionMessagesSaveReq = { sessionId: number messages: Message[] } export type LmDashboard = { id: number title: string data: string remark?: string // 备注 createdAt?: string // 创建时间 updatedAt?: string // 更新时间 createdBy?: number // 创建者ID updatedBy?: number // 更新者ID } export type Prompt = { id: number title: string prompt: string placeholder?: string createdAt?: string // 创建时间 updatedAt?: string // 更新时间 createdBy?: number // 创建者ID updatedBy?: number // 更新者ID } // Prompt列表查询参数 export type PromptListParams = { keyWord?: string // 搜索关键字 dateRange?: string[] // 日期范围 OrderBy?: string // 排序 pageNum?: number // 分页号码,默认1 pageSize?: number // 分页数量,最大500,默认10 title?: string // 标题 createdAt?: string // 创建时间 } // Prompt添加请求 export type PromptAddReq = Omit // Prompt编辑请求 export type PromptEditReq = Prompt & { id: number // 编辑时ID必须 } // Prompt删除请求参数 export type PromptDeleteParams = { ids: number[] } // 获取单个Prompt参数 export type PromptGetParams = { id: number }