Skip to content

Commit

Permalink
fix: stop error when tool has no instructions (#493)
Browse files Browse the repository at this point in the history
Previously, if a tool had no instructions, then the SDK would report an
error because there would have been no output. That has been changed in
the SDK.

Now, in these changes, if a blank message is received when running a
tool, a special "no response received" message will be displayed to the
user.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams authored Sep 11, 2024
1 parent 18eaca7 commit ceefbf8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
7 changes: 5 additions & 2 deletions components/chat/useChatSocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ const useChatSocket = () => {
let content = isMainContent
? callFrame.output[callFrame.output.length - 1].content || ''
: '';
if (!content) continue;
setGenerating(true);
if (
content === 'Waiting for model response...' &&
Expand All @@ -157,13 +156,17 @@ const useChatSocket = () => {
latestAgentMessageRef.current.message = content;

if (isMainContent && callFrame.type === 'callFinish') {
if (!latestAgentMessageRef.current.message) {
latestAgentMessageRef.current.message =
"The message received from the assistant was empty, this happens if the tool doesn't have any instructions.";
}
setMessages([
...messagesRef.current,
{ ...latestAgentMessageRef.current },
]);
setLatestAgentMessage({} as Message);
setGenerating(false);
} else {
} else if (latestAgentMessageRef.current.message) {
setLatestAgentMessage({ ...latestAgentMessageRef.current });
}
}
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"main": "electron/main.mjs",
"dependencies": {
"@gptscript-ai/gptscript": "^0.9.5-rc5",
"@gptscript-ai/gptscript": "github:gptscript-ai/node-gptscript#1cf71a66d0ca7cffe98343bf672f54a6a84d9ed0",
"@monaco-editor/react": "^4.6.0",
"@nextui-org/button": "2.0.32",
"@nextui-org/code": "2.0.28",
Expand Down

0 comments on commit ceefbf8

Please sign in to comment.