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:
parent
124ac5cbf0
commit
000641bcfc
1 changed files with 4 additions and 2 deletions
|
@ -61,14 +61,16 @@ export default class FunctionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleFunction(request: ChatCompletionRequestMessageFunctionCall) {
|
public handleFunction(request: ChatCompletionRequestMessageFunctionCall) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
let parsedArguments: any;
|
||||||
try {
|
try {
|
||||||
const parsedArguments = JSON.parse(request.arguments ?? "");
|
parsedArguments = JSON.parse(request.arguments ?? "");
|
||||||
return this.store.get(request.name ?? "")?.execute(parsedArguments);
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error("Function arguments raw: " + request.arguments);
|
console.error("Function arguments raw: " + request.arguments);
|
||||||
throw new Error(`Failed to parse the function JSON arguments when running function [${request.name}]`, {cause: e});
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue