fix: 对照 API 文档修复 3 个 Adapter 的 8 个实现差异
通过逐接口对比 DeepSeek/AgnesAI/Ollama 官方文档与实现代码,发现并修复:
DeepSeek (4 fix):
- temperature 默认值: 错误发送 0(API默认=1),改为 undefined 让 API 用默认值
- thinking 禁用: API 默认 enabled,不传=开启。改为显式发送 {type:disabled}
- reasoning_effort: 补充 xhigh→max 映射(文档规定)
- stream 请求: 补充 AbortSignal.timeout 超时控制
Agnes AI (2 fix):
- temperature 默认值: 同上
- 图片 image_url: 移除文档未提及的 detail 字段
Ollama (3 fix):
- temperature 默认值: 同上(Ollama默认≈0.8)
- tool_calls arguments: 从对象改为 JSON 字符串(REST API 要求)
- finishReason: 使用 done_reason 字段正确映射(之前始终返回 STOP)
This commit is contained in:
@@ -74,6 +74,7 @@ export class DeepSeekAdapter extends BaseAdapter {
|
||||
...this.config.headers,
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
signal: AbortSignal.timeout(this.config.timeoutMs ?? 300_000),
|
||||
});
|
||||
|
||||
if (!response.ok || !response.body) {
|
||||
@@ -150,7 +151,7 @@ export class DeepSeekAdapter extends BaseAdapter {
|
||||
const body: Record<string, unknown> = {
|
||||
model: this.config.defaultModel,
|
||||
messages,
|
||||
temperature: request.params.temperature ?? 0,
|
||||
temperature: request.params.temperature,
|
||||
max_tokens: request.params.maxTokens,
|
||||
stream,
|
||||
};
|
||||
@@ -164,10 +165,13 @@ export class DeepSeekAdapter extends BaseAdapter {
|
||||
}
|
||||
|
||||
// Thinking 模式
|
||||
if (request.params.thinkingEnabled) {
|
||||
// API 默认 thinking.type = "enabled",必须显式发送 disabled 才能关闭
|
||||
if (request.params.thinkingEnabled === false) {
|
||||
body.thinking = { type: 'disabled' };
|
||||
} else if (request.params.thinkingEnabled) {
|
||||
body.thinking = { type: 'enabled' };
|
||||
const effortMap: Record<string, string> = {
|
||||
low: 'high', medium: 'high', high: 'high', max: 'max',
|
||||
low: 'high', medium: 'high', high: 'high', xhigh: 'max', max: 'max',
|
||||
};
|
||||
body.reasoning_effort = effortMap[request.params.thinkingEffort ?? 'high'] ?? 'high';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user