From 9696cbfec3864aa56ca00d023d10f0c3a7f6394c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Tranta?= Date: Thu, 19 Sep 2024 10:57:33 +0200 Subject: [PATCH] add original delta to the created temporary message --- src/react/useChatStream.test.ts | 2 ++ src/react/useChatStream.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/react/useChatStream.test.ts b/src/react/useChatStream.test.ts index dc4ade7..1b94f97 100644 --- a/src/react/useChatStream.test.ts +++ b/src/react/useChatStream.test.ts @@ -1090,7 +1090,9 @@ describe("useAIStream", () => { This is the joke: Why do Czechs always carry a pencil and paper? In case they need to draw a red line somewhere!`, + "handled_tool_result": true, "role": "tool", + "tool_call_id": "call_uTSra7MsEkzrL8VffnRtHsdW", }, { role: 'assistant', content: "End of assistant message!" } ]) diff --git a/src/react/useChatStream.ts b/src/react/useChatStream.ts index ee7d7ae..2b2d19d 100644 --- a/src/react/useChatStream.ts +++ b/src/react/useChatStream.ts @@ -97,7 +97,9 @@ export function combineAIMessageChunkWithCompleteMessages( finish_reason: 'length' as const, index: choice.index, logprobs: null, + delta: choice.delta, message: { + ...choice.delta, content: choice.delta.content ?? "", // @ts-expect-error - mantain the original role here role: choice.delta.role ?? "assistant" as const,