/** * 统一聊天消息类型定义 */ /** * 聊天消息基础接口 */ export interface ChatMessage { role: 'system' | 'user' | 'assistant' | 'tool'; content: string; timestamp?: number; isComplete?: boolean; toolCalls?: ToolCall[]; tool_calls?: Tool_CallParams[]; tool_call_id?: string; } export interface Tool_CallParams { id: string; type: "function"; function: { name: string; arguments: any; }; } /** * 工具调用接口 */ export interface ToolCall { name: string; params: any; result?: any; error?: string; success: boolean; timestamp: number; } /** * 聊天历史项 */ export interface ChatHistoryItem { id: string; title: string; date: string; messages: ChatMessage[]; /** * 历史对话来源模式: * - 'earthServer':EarthServer 统一 AI 服务,id 即服务端 sessionId,复聊时带对应 X-Session-Id * - 'default':OpenAI 直连模式 * 缺省(旧数据无该字段)视为 'default'。 */ type?: 'earthServer' | 'default'; } /** * 消息分组(用于渲染) */ export interface MessageGroup { user?: ChatMessage; assistant?: ChatMessage; }