feat: 升级至 v0.3.4 — 接入 Xiaomi MiMo Provider + 文档全量校准
新增 MiMo (小米) LLM Provider 适配器,支持 mimo-v2.5-pro 和 mimo-v2.5 两个文本模型,复用 OpenAI 兼容 SSE 流式解析,支持 Thinking 模式和 Function Calling。同步校准全量 docs 文档与 README 使其与实际代码一致。 主要变更: - 新增 mimo.adapter.ts 适配器(SSE + thinking.type + max_completion_tokens) - 修复 thinking 逻辑 bug:禁用思考时未传 temperature/top_p - 补全 sse-stream.ts 的 MiMo 缓存字段映射(prompt_tokens_details.cached_tokens) - 补全 sse-stream.ts 的 finish_reason 映射(repetition_truncation) - 注册 MiMo 适配器到 adapters/index.ts、main.ts 工厂 - handlers.ts 添加 mimo.contextWindow 热重载触发 - database.service.ts seed 添加 mimo 默认配置 - SettingsModal/OnboardingWizard/Header 添加 MiMo Provider UI - constants.ts PROVIDER_LABELS 添加 mimo - .env.example 添加 MIMO_API_KEY/MIMO_BASE_URL - 反向修改 4 个 docs HTML 设计文档(工具数量/版本日期/适配器列表/数据库表) - 反向修改 Agent网络工具通用设计-v2.md 附录 B 文件索引 - 完全重写 README.md(v0.3.4、27 工具、4 适配器、9 表)
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
* OpenAI 兼容 API 格式构建工具
|
||||
*
|
||||
* 将 MetonaRequest 转换为 OpenAI /chat/completions 兼容的原生请求格式。
|
||||
* DeepSeek 和 Agnes AI 共享此工具,各自 Adapter 只需处理 Provider 特有的差异参数。
|
||||
* DeepSeek、Agnes AI 和 MiMo 共享此工具,各自 Adapter 只需处理 Provider 特有的差异参数。
|
||||
*
|
||||
* @see electron/harness/types/metona-request.ts — MetonaRequest 定义
|
||||
* @see apis/deepseek-api-docs-20260518.html
|
||||
* @see apis/agnes-ai-api-docs-20260625.html
|
||||
* @see apis/mimo-api-docs-20260715.html
|
||||
*/
|
||||
|
||||
import type { MetonaRequest, MetonaToolDef } from '../../types';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* SSE 流式解析工具
|
||||
*
|
||||
* 解析 OpenAI 兼容的 Server-Sent Events (SSE) 流式响应,
|
||||
* 产出 MetonaStreamEvent。DeepSeek 和 Agnes AI 共享此工具。
|
||||
* 产出 MetonaStreamEvent。DeepSeek、Agnes AI 和 MiMo 共享此工具。
|
||||
*
|
||||
* SSE 格式:data: {json}\n\n
|
||||
* 结束标记:data: [DONE]
|
||||
@@ -174,7 +174,10 @@ export async function* parseSSEStream(
|
||||
outputTokens: chunk.usage.completion_tokens ?? 0,
|
||||
totalTokens: chunk.usage.total_tokens ?? 0,
|
||||
reasoningTokens: chunk.usage.completion_tokens_details?.reasoning_tokens,
|
||||
cacheHitTokens: chunk.usage.prompt_cache_hit_tokens,
|
||||
// DeepSeek: prompt_cache_hit_tokens / prompt_cache_miss_tokens
|
||||
// MiMo: prompt_tokens_details.cached_tokens
|
||||
cacheHitTokens: chunk.usage.prompt_cache_hit_tokens
|
||||
?? chunk.usage.prompt_tokens_details?.cached_tokens,
|
||||
cacheMissTokens: chunk.usage.prompt_cache_miss_tokens,
|
||||
};
|
||||
|
||||
@@ -252,7 +255,9 @@ export function parseOpenAICompatibleResponse(
|
||||
outputTokens: (usage?.completion_tokens as number) ?? 0,
|
||||
totalTokens: (usage?.total_tokens as number) ?? 0,
|
||||
reasoningTokens: (usage?.completion_tokens_details as Record<string, unknown>)?.reasoning_tokens as number | undefined,
|
||||
cacheHitTokens: usage?.prompt_cache_hit_tokens as number | undefined,
|
||||
// DeepSeek: prompt_cache_hit_tokens / MiMo: prompt_tokens_details.cached_tokens
|
||||
cacheHitTokens: (usage?.prompt_cache_hit_tokens as number | undefined)
|
||||
?? (usage?.prompt_tokens_details as Record<string, unknown> | undefined)?.cached_tokens as number | undefined,
|
||||
cacheMissTokens: usage?.prompt_cache_miss_tokens as number | undefined,
|
||||
},
|
||||
};
|
||||
@@ -264,6 +269,8 @@ function mapOpenAIFinishReason(reason: string): string {
|
||||
case 'length': return 'length';
|
||||
case 'tool_calls': return 'tool_calls';
|
||||
case 'content_filter': return 'content_filter';
|
||||
// MiMo 特有:检测到复读截断
|
||||
case 'repetition_truncation': return 'stop';
|
||||
default: return 'stop';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user