Skip to content

Commit

Permalink
Fix issue of ignoring multiple tool calls
Browse files Browse the repository at this point in the history
This issue is described here: #431 (comment)
  • Loading branch information
castortech authored Jul 20, 2024
1 parent 0b0f5fd commit 93370d8
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions packages/core/src/model/nodes/ChatNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -910,37 +910,25 @@ export class ChatNodeImpl extends NodeImpl<ChatNode> {
}

if (functionCalls.length > 0) {
if (isMultiResponse) {
output['function-call' as PortId] = {
type: 'object[]',
value: functionCalls.map((functionCalls) => ({
name: functionCalls[0]?.name,
arguments: functionCalls[0]?.lastParsedArguments,
id: functionCalls[0]?.id,
})),
};
} else {
if (this.data.parallelFunctionCalling) {
console.dir({ functionCalls });
output['function-calls' as PortId] = {
type: 'object[]',
value: functionCalls[0]!.map((functionCall) => ({
name: functionCall.name,
arguments: functionCall.lastParsedArguments,
id: functionCall.id,
})),
};
} else {
output['function-call' as PortId] = {
type: 'object',
value: {
name: functionCalls[0]![0]?.name,
arguments: functionCalls[0]![0]?.lastParsedArguments,
id: functionCalls[0]![0]?.id,
} as Record<string, unknown>,
};
}
}
if (isMultiResponse) {
output['function-call' as PortId] = {
type: 'object[]',
value: functionCalls.flat().map((functionCall) => ({
name: functionCall.name,
arguments: functionCall.lastParsedArguments,
id: functionCall.id,
})),
}
} else {
output['function-call' as PortId] = {
type: 'object[]',
value: functionCalls[0]!.map((functionCall) => ({
name: functionCall.name,
arguments: functionCall.lastParsedArguments,
id: functionCall.id,
})),
}
}
}

context.onPartialOutputs?.(output);
Expand Down

0 comments on commit 93370d8

Please sign in to comment.