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.
This commit is contained in:
Wroclaw 2023-07-30 01:43:41 +02:00
parent 124ac5cbf0
commit 000641bcfc

View file

@ -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);
}
}