Skip to content

Commit

Permalink
fix(ai-sdk): DataStream interop without tool call streaming (#1039)
Browse files Browse the repository at this point in the history
Co-authored-by: Abdulaziz Alaboudi <[email protected]>
  • Loading branch information
Yonom and Alaboudi1 authored Oct 21, 2024
1 parent b38165d commit a1bfd26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/honest-monkeys-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@assistant-ui/react": patch
---

fix(ai-sdk): DataStream interop without tool call streaming
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function assistantDecoderStream() {
case AssistantStreamChunkType.ToolCallBegin: {
const { toolCallId: id, toolName: name } = value;
toolCallNames.set(id, name);

currentToolCall = { id, name, argsText: "" };

controller.enqueue({
Expand Down Expand Up @@ -96,6 +97,8 @@ export function assistantDecoderStream() {

case AssistantStreamChunkType.ToolCall: {
const { toolCallId, toolName, args } = value;
toolCallNames.set(toolCallId, toolName);

const argsText = JSON.stringify(args);
controller.enqueue({
type: "tool-call-delta",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const appendOrUpdateToolCall = (
argsTextDelta: string,
): ChatModelRunResult => {
let contentParts = message.content ?? [];
let contentPartIdx = contentParts.findIndex(
const contentPartIdx = contentParts.findIndex(
(c) => c.type === "tool-call" && c.toolCallId === toolCallId,
);
let contentPart =
Expand Down

0 comments on commit a1bfd26

Please sign in to comment.