From e5e06e40780a76bcc736d39cabcf8d79277ee1d3 Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Tue, 17 Dec 2024 03:40:13 -0800 Subject: [PATCH] fix: toolResultStream should support JSONSchema params (#1253) --- packages/react/CHANGELOG.md | 6 ++ packages/react/package.json | 2 +- .../runtimes/edge/streams/toolResultStream.ts | 60 +++++++++---------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index aefb6fce5..f304ebfde 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,11 @@ # @assistant-ui/react +## 0.7.15 + +### Patch Changes + +- fix: toolResultStream should support JSONSchema params + ## 0.7.14 ### Patch Changes diff --git a/packages/react/package.json b/packages/react/package.json index e1c44974b..f30a007de 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -29,7 +29,7 @@ "conversational-ui", "conversational-ai" ], - "version": "0.7.14", + "version": "0.7.15", "license": "MIT", "exports": { ".": { diff --git a/packages/react/src/runtimes/edge/streams/toolResultStream.ts b/packages/react/src/runtimes/edge/streams/toolResultStream.ts index 58e14c938..158448b07 100644 --- a/packages/react/src/runtimes/edge/streams/toolResultStream.ts +++ b/packages/react/src/runtimes/edge/streams/toolResultStream.ts @@ -64,38 +64,38 @@ export function toolResultStream( isError: true, }); return; - } else { - toolCallExecutions.set( - toolCallId, - (async () => { - if (!tool.execute) return; - - try { - const result = await tool.execute(args, { abortSignal }); - - controller.enqueue({ - type: "tool-result", - toolCallType, - toolCallId, - toolName, - result, - }); - } catch (error) { - controller.enqueue({ - type: "tool-result", - toolCallType, - toolCallId, - toolName, - result: "Error: " + error, - isError: true, - }); - } finally { - toolCallExecutions.delete(toolCallId); - } - })(), - ); } } + + toolCallExecutions.set( + toolCallId, + (async () => { + if (!tool.execute) return; + + try { + const result = await tool.execute(args, { abortSignal }); + + controller.enqueue({ + type: "tool-result", + toolCallType, + toolCallId, + toolName, + result, + }); + } catch (error) { + controller.enqueue({ + type: "tool-result", + toolCallType, + toolCallId, + toolName, + result: "Error: " + error, + isError: true, + }); + } finally { + toolCallExecutions.delete(toolCallId); + } + })(), + ); break; }