修复推理字段删除逻辑:当reasoning设置为off时正确删除原始请求中的推理字段
- 修正request-openai.js中reasoning字段的处理逻辑 - 修正request-anthropic.js中thinking字段的处理逻辑 - 确保当模型配置reasoning为off时,原始请求中的推理相关字段被显式删除 - 与routes.js中的直接转发逻辑保持一致
This commit is contained in:
@@ -120,23 +120,10 @@ export function transformToAnthropic(openaiRequest) {
|
|||||||
type: 'enabled',
|
type: 'enabled',
|
||||||
budget_tokens: budgetTokens[reasoningLevel]
|
budget_tokens: budgetTokens[reasoningLevel]
|
||||||
};
|
};
|
||||||
}
|
} else {
|
||||||
// If request already has thinking field, respect the configuration rule
|
// If reasoning is off or invalid, explicitly remove thinking field
|
||||||
// Remove it if model config is off/invalid, otherwise override with config
|
// This ensures any thinking field from the original request is deleted
|
||||||
if (openaiRequest.thinking) {
|
delete anthropicRequest.thinking;
|
||||||
if (reasoningLevel) {
|
|
||||||
const budgetTokens = {
|
|
||||||
'low': 4096,
|
|
||||||
'medium': 12288,
|
|
||||||
'high': 24576
|
|
||||||
};
|
|
||||||
|
|
||||||
anthropicRequest.thinking = {
|
|
||||||
type: 'enabled',
|
|
||||||
budget_tokens: budgetTokens[reasoningLevel]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// If reasoningLevel is null (off/invalid), don't add thinking field
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass through other compatible parameters
|
// Pass through other compatible parameters
|
||||||
|
|||||||
@@ -91,21 +91,15 @@ export function transformToOpenAI(openaiRequest) {
|
|||||||
// Handle reasoning field based on model configuration
|
// Handle reasoning field based on model configuration
|
||||||
const reasoningLevel = getModelReasoning(openaiRequest.model);
|
const reasoningLevel = getModelReasoning(openaiRequest.model);
|
||||||
if (reasoningLevel) {
|
if (reasoningLevel) {
|
||||||
|
// Add reasoning field based on model configuration
|
||||||
targetRequest.reasoning = {
|
targetRequest.reasoning = {
|
||||||
effort: reasoningLevel,
|
effort: reasoningLevel,
|
||||||
summary: 'auto'
|
summary: 'auto'
|
||||||
};
|
};
|
||||||
}
|
} else {
|
||||||
// If request already has reasoning field, respect the configuration rule
|
// If reasoning is off or invalid, explicitly remove reasoning field
|
||||||
// Remove it if model config is off/invalid, otherwise override with config
|
// This ensures any reasoning field from the original request is deleted
|
||||||
if (openaiRequest.reasoning) {
|
delete targetRequest.reasoning;
|
||||||
if (reasoningLevel) {
|
|
||||||
targetRequest.reasoning = {
|
|
||||||
effort: reasoningLevel,
|
|
||||||
summary: 'auto'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// If reasoningLevel is null (off/invalid), don't add reasoning field
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass through other parameters
|
// Pass through other parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user