Merge pull request #6312 from continuedev/dallin/handle-empty-space-args
Handle empty string json args
This commit is contained in:
commit
fbcd6b25db
3 changed files with 7 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ export function safeParseToolCallArgs(
|
|||
toolCall: ToolCallDelta,
|
||||
): Record<string, any> {
|
||||
try {
|
||||
return JSON.parse(toolCall.function?.arguments ?? "{}");
|
||||
return JSON.parse(toolCall.function?.arguments?.trim() || "{}");
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Failed to parse tool call arguments:\nTool call: ${toolCall.function?.name + " " + toolCall.id}\nArgs:${toolCall.function?.arguments}\n`,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ const ResultGroup = memo(function ResultGroup({ group }: ResultGroupProps) {
|
|||
return (
|
||||
<>
|
||||
{group.map((result, i) => (
|
||||
<Result key={i} result={result} prevResult={group[i - 1]}></Result>
|
||||
<Result
|
||||
key={`${result.timestamp}-${i}`}
|
||||
result={result}
|
||||
prevResult={group[i - 1]}
|
||||
></Result>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export function safeParseArgs(
|
|||
errorId?: string,
|
||||
): Record<string, any> {
|
||||
try {
|
||||
return JSON.parse(args ?? "{}");
|
||||
return JSON.parse(args?.trim() || "{}");
|
||||
} catch (e) {
|
||||
const identifier = errorId ? `Call: ${errorId}\nArgs:${args}\n` : "";
|
||||
console.error(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue