continue-custom/core/tools/parseArgs.ts

14 lines
419 B
TypeScript

import { ToolCallDelta } from "..";
export function safeParseToolCallArgs(
toolCall: ToolCallDelta,
): Record<string, any> {
try {
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`,
//);
return {};
}
}