From 000641bcfcd49d694d44aa6750f63e69f220120f Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Sun, 30 Jul 2023 01:43:41 +0200 Subject: [PATCH] Do not catch function execution error when catching errors of json parsing. Errors from model function calling should propagate up instead of being catched there. --- src/funcitonManager.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/funcitonManager.ts b/src/funcitonManager.ts index 008c14e..d351c15 100644 --- a/src/funcitonManager.ts +++ b/src/funcitonManager.ts @@ -61,14 +61,16 @@ export default class FunctionManager { } public handleFunction(request: ChatCompletionRequestMessageFunctionCall) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let parsedArguments: any; try { - const parsedArguments = JSON.parse(request.arguments ?? ""); - return this.store.get(request.name ?? "")?.execute(parsedArguments); + parsedArguments = JSON.parse(request.arguments ?? ""); } catch (e) { console.error("Function arguments raw: " + request.arguments); throw new Error(`Failed to parse the function JSON arguments when running function [${request.name}]`, {cause: e}); } + return this.store.get(request.name ?? "")?.execute(parsedArguments); } }