Make error of function json parsing more descriptive

This commit is contained in:
Wroclaw 2023-07-30 01:21:19 +02:00
parent 67d4361c26
commit 56869a2dc2

View file

@ -61,10 +61,15 @@ export default class FunctionManager {
}
public handleFunction(request: ChatCompletionRequestMessageFunctionCall) {
try {
const parsedArguments = JSON.parse(request.arguments ?? "");
return this.store.get(request.name ?? "")?.execute(parsedArguments);
}
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});
}
}
}
// buildins