Make error of function json parsing more descriptive
This commit is contained in:
parent
67d4361c26
commit
56869a2dc2
1 changed files with 8 additions and 3 deletions
|
@ -61,9 +61,14 @@ export default class FunctionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleFunction(request: ChatCompletionRequestMessageFunctionCall) {
|
public handleFunction(request: ChatCompletionRequestMessageFunctionCall) {
|
||||||
|
try {
|
||||||
const parsedArguments = JSON.parse(request.arguments ?? "");
|
const parsedArguments = JSON.parse(request.arguments ?? "");
|
||||||
return this.store.get(request.name ?? "")?.execute(parsedArguments);
|
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});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue