Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Dec 16, 2024
1 parent 042e813 commit 6ded610
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class InferenceConnector extends SubActionConnector<Config, Secrets> {
prev.choices[0].message.content += chunk.choices[0].message.content ?? '';

chunk.choices[0].message.tool_calls?.forEach((toolCall) => {
if (toolCall.index !== undefined && toolCall.id) {
if (toolCall.index !== undefined) {
const prevToolCallLength = prev.choices[0].message.tool_calls?.length ?? 0;
if (prevToolCallLength - 1 !== toolCall.index) {
if (!prev.choices[0].message.tool_calls) {
Expand All @@ -205,9 +205,18 @@ export class InferenceConnector extends SubActionConnector<Config, Secrets> {
}
const prevToolCall = prev.choices[0].message.tool_calls[toolCall.index];

prevToolCall.function.name += toolCall.function?.name;
prevToolCall.function.arguments += toolCall.function?.arguments;
prevToolCall.id += toolCall.id;
if (toolCall.function?.name) {
prevToolCall.function.name += toolCall.function?.name;
}
if (toolCall.function?.arguments) {
prevToolCall.function.arguments += toolCall.function?.arguments;
}
if (toolCall.id) {
prevToolCall.id += toolCall.id;
}
if (toolCall.type) {
prevToolCall.type = toolCall.type;
}
}
});
} else if (chunk.usage) {
Expand Down

0 comments on commit 6ded610

Please sign in to comment.