mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 22:39:36 +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) {
|
if ('index' in toolCall) {
|
||||||
const { id, index, function: fun } = toolCall
|
const { id, index, function: fun } = toolCall
|
||||||
if (fun?.name) {
|
if (fun?.name) {
|
||||||
toolCalls[index] = {
|
const toolCallObject = {
|
||||||
id: id || '',
|
id: id || '',
|
||||||
function: {
|
function: {
|
||||||
name: fun.name,
|
name: fun.name,
|
||||||
arguments: fun.arguments || ''
|
arguments: fun.arguments || ''
|
||||||
},
|
},
|
||||||
type: 'function'
|
type: 'function' as const
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index === -1) {
|
||||||
|
toolCalls.push(toolCallObject)
|
||||||
|
} else {
|
||||||
|
toolCalls[index] = toolCallObject
|
||||||
}
|
}
|
||||||
} else if (fun?.arguments) {
|
} else if (fun?.arguments) {
|
||||||
if (toolCalls[index] && toolCalls[index].type === 'function' && 'function' in toolCalls[index]) {
|
if (toolCalls[index] && toolCalls[index].type === 'function' && 'function' in toolCalls[index]) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user