Claude: Improve error handling and reporting for tool use
This commit is contained in:
parent
8256807697
commit
d4f632e76c
@ -412,8 +412,8 @@
|
||||
// Delay at most 3 times
|
||||
if(delayCount < 3)
|
||||
{
|
||||
// TODO: Defensive check, validate and remove
|
||||
debugger;
|
||||
// TODO: Defensive message, validate and remove
|
||||
console.warn("Identical screenshot, rate limiting");
|
||||
delayCount++;
|
||||
// Wait some time and retry
|
||||
await new Promise(function(f, r) { setTimeout(f, 5000); });
|
||||
@ -557,11 +557,12 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
debugger;
|
||||
return new Error("Error: Invalid action");
|
||||
}
|
||||
else
|
||||
{
|
||||
debugger;
|
||||
// We can get there due to model hallucinations
|
||||
return new Error("Error: Invalid tool syntax");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -63,13 +63,24 @@ async function sendMessages(handleTool)
|
||||
var commandResponse = await handleTool(c.input);
|
||||
var responseObj = {type: "tool_result", tool_use_id: c.id };
|
||||
if(commandResponse != null)
|
||||
responseObj.content = commandResponse;
|
||||
{
|
||||
if(commandResponse instanceof Error)
|
||||
{
|
||||
console.warn(`Tool error: ${commandResponse.message}`);
|
||||
responseObj.content = commandResponse.message;
|
||||
responseObj.is_error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
responseObj.content = commandResponse;
|
||||
}
|
||||
}
|
||||
addMessageInternal("user", [responseObj]);
|
||||
sendMessages(handleTool);
|
||||
}
|
||||
else
|
||||
{
|
||||
debugger;
|
||||
console.warn(`Invalid response type: ${c.type}`);
|
||||
}
|
||||
}
|
||||
if(response.stop_reason == "end_turn")
|
||||
|
Loading…
x
Reference in New Issue
Block a user