mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 05:11:24 +08:00
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:
parent
1764be8a30
commit
57702f545d
@ -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]) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user