refactor: update tool content handling for GPT and Dashscope models in OpenAIProvider

This commit is contained in:
Vaayne 2025-03-18 09:40:58 +08:00 committed by 亢奋猫
parent 48a6c4d017
commit 1e4bc56780

View File

@ -534,24 +534,25 @@ export default class OpenAIProvider extends BaseProvider {
} }
} }
const provider = lastUserMessage?.model?.provider
const modelName = lastUserMessage?.model?.name
if ( if (
lastUserMessage?.model?.provider === 'doubao' || modelName?.toLocaleLowerCase().includes('gpt') ||
lastUserMessage?.model?.name.toLowerCase().includes('deepseek') (provider === 'dashscope' && modelName?.toLocaleLowerCase().includes('qwen'))
) { ) {
console.log('doubao or deepseek only support tool content in text')
reqMessages.push({
role: 'tool',
content: JSON.stringify(toolResponsContent),
tool_call_id: toolCall.id
} as ChatCompletionToolMessageParam)
} else {
reqMessages.push({ reqMessages.push({
role: 'tool', role: 'tool',
content: toolResponsContent, content: toolResponsContent,
tool_call_id: toolCall.id tool_call_id: toolCall.id
} as ChatCompletionToolMessageParam) } as ChatCompletionToolMessageParam)
} else {
reqMessages.push({
role: 'tool',
content: JSON.stringify(toolResponsContent),
tool_call_id: toolCall.id
} as ChatCompletionToolMessageParam)
} }
upsertMCPToolResponse( upsertMCPToolResponse(
toolResponses, toolResponses,
{ tool: mcpTool, status: 'done', response: toolCallResponse, id: toolCall.id }, { tool: mcpTool, status: 'done', response: toolCallResponse, id: toolCall.id },