Interesting comment in the OpenAI Node.JS Library:
The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
This is from the schema definition for the return value for a function_call:
/**
* The name and arguments of a function that should be called, as generated by the model.
* @export
* @interface ChatCompletionRequestMessageFunctionCall
*/
export interface ChatCompletionRequestMessageFunctionCall {
/**
* The name of the function to call.
* @type {string}
* @memberof ChatCompletionRequestMessageFunctionCall
*/
'name'?: string;
/**
* The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
* @type {string}
* @memberof ChatCompletionRequestMessageFunctionCall
*/
'arguments'?: string;
}
I know I keep plugging Alpha Wave on this site but that’s just because it takes care of details like this.
I also find it interesting that they marked name
as optional. That would imply that you shouldn’t even trust that you’re going to get an actual function name back, let alone a valid one.