fix(OpenAIApiClient): 适配glm 4.5 toolcall (#9516)

* fix(OpenAIApiClient): update toolCalls handling to support dynamic index assignment

* refactor(OpenAIApiClient): streamline toolCalls management with reusable object structure
This commit is contained in:
SuYao 2025-08-25 19:49:52 +08:00 committed by GitHub
parent 1764be8a30
commit 57702f545d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -924,13 +924,19 @@ export class OpenAIAPIClient extends OpenAIBaseClient<
if ('index' in toolCall) {
const { id, index, function: fun } = toolCall
if (fun?.name) {
toolCalls[index] = {
const toolCallObject = {
id: id || '',
function: {
name: fun.name,
arguments: fun.arguments || ''
},
type: 'function'
type: 'function' as const
}
if (index === -1) {
toolCalls.push(toolCallObject)
} else {
toolCalls[index] = toolCallObject
}
} else if (fun?.arguments) {
if (toolCalls[index] && toolCalls[index].type === 'function' && 'function' in toolCalls[index]) {