import { ESTool } from '../MCPClients/type'; /** * 可用模型项 */ export interface AvailableModel { /** 厂商名称 */ provider: string; baseUrl: string; apiKey: string; /** 模型 ID */ models: string[]; } /** * EarthServer 统一 AI 服务配置 * * 接入说明见 CustomAI.md: * - 鉴权三段式:宿主登录拿到 token -> /api/sessions 拿 sessionId -> /api/chat/completions 流式聊天 * - 客户端不要自行对接账号系统,token 由宿主(产品客户端)登录后传入 * - 聊天响应头 X-Session-Id 需同步更新本地会话 ID(由 EarthServerLLMService 自动处理) */ export interface EarthServerConfig { /** 服务 API 根路径,如 https://ai.bjxbsj.cn/api */ apiBase: string; /** 管理员分配的产品 Key,全局唯一 */ productKey: string; /** 产品版本号(仅登录接口需要;宿主传 token 时可省略) */ productVersion?: string; /** 模型 ID,默认 deepseek-chat */ model?: string; /** 宿主登录后传入的 token(静态) */ token?: string; /** * 动态获取 token,每次请求前调用,便于宿主刷新。 * 与 token 二选一;同时存在时优先使用 getToken。 */ getToken?: () => string | Promise; /** token 失效(401)回调,宿主可在此重新登录并更新 token */ onTokenExpired?: () => void; } /** * 聊天组件配置类型 */ export interface NewChatProps { /** * MCP 工具调用配置 */ mcp?: { enable?: boolean; servers?: { name: string; url: string; }[]; custom_tools?: ESTool[]; }; /** * 自定义系统提示词 */ systemPrompt?: string; /** * 发送之前添加消息的钩子 */ beforeSendAddMessage?: () => Promise<{ role: 'assistant' | 'user'; content: string; }>; /** * AI 回答完成后添加消息的钩子 */ afterAIAnswerAddMessage?: () => Promise<{ role: 'assistant' | 'user'; content: string; }>; /** * 发送之前更新系统提示词的钩子 */ beforeSendUpdateSystemPrompt?: () => Promise; /** * AI 回答完成后更新系统提示词的钩子 */ afterAIAnswerUpdateSystemPrompt?: () => Promise; /** * 示例问题列表 */ exampleQuestions?: string[]; /** * 可用模型列表,用于下拉选择。 * option 显示格式为 "厂商-模型"。 * EarthServer 模式(配置了 earthServer)下可不传。 */ availableModels?: AvailableModel[]; /** * EarthServer 统一 AI 服务配置。 * 存在时优先走 EarthServer 流程(登录态 + 会话 + 流式聊天), * 否则使用 availableModels 的 OpenAI 直连模式。二者按配置切换、向后兼容。 */ earthServer?: EarthServerConfig; } /** * 模型配置 */ export interface ModelInfo { id: string; baseUrl: string; apiKey: string; modelId: string; } export declare const DEFAULT_NEW_CHAT_PROPS: NewChatProps;