Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Train P3: keep openai-chat.ts at 1,000 lines (#5793)

milind-soni2212339377ae
diff --git a/server/drivers/openai-chat.ts b/server/drivers/openai-chat.ts
index bbd3f5ff23..86c6e718ea 100644
--- a/server/drivers/openai-chat.ts
+++ b/server/drivers/openai-chat.ts
@@ -803,8 +803,7 @@ export function createOpenAIChatRuntime<Config>(options: RuntimeOptions<Config>)
let fatal: Error | undefined, title = call.function.name, skipRepeatCount = false;
try {
let args: unknown;
- const rawArguments = call.function.arguments.trim() ? call.function.arguments : "{}";
- try { args = JSON.parse(rawArguments); }
+ try { args = JSON.parse(call.function.arguments.trim() || "{}"); } // An empty argument string is a tool with no arguments.
catch { throw new ChatProtocolError("tool arguments are not complete JSON"); }
if (!object(args)) throw new ChatProtocolError("tool arguments must be a JSON object");
const inputPreview = preview(args);