Skip to content

Commit

Permalink
Handle scenario where a streaming chunk has both content and tool_calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevenic committed Dec 2, 2024
1 parent 0de2562 commit 0b10ad8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions js/packages/teams-ai/src/planners/LLMClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,15 @@ export class LLMClient<TContent = any> {
return;
}

// Ignore tool calls
// - see the tool call note below to understand why we're ignoring them.
if ((chunk.delta as any)?.tool_calls || chunk.delta?.action_calls) {
// Ignore calls without content
// - This is typically because the chunk represents a tool call.
// - See the note below for why we're handling tool calls this way.
if (!chunk.delta?.content) {
return;
}

// Send chunk to client
const text = chunk.delta?.content ?? '';
// Send text chunk to client
const text = chunk.delta?.content;
const citations = chunk.delta?.context?.citations ?? undefined;

if (text.length > 0) {
Expand Down

0 comments on commit 0b10ad8

Please sign in to comment.