It seems that you are having trouble specifying the schema for your JSON output when using Azure OpenAI. According to the documentation, the response_format
parameter has been deprecated in favor of the tools
parameter. You can specify your function and its parameters using the tools
parameter, and then call the function using the tool_choice
parameter. Here's an example of how you can modify your code to use the tools
and tool_choice
parameters:
const completion = await client.getChatCompletions(deploymentId, [
{
role: "system",
content: advanced_context
},
{
role: "user",
content: input
},
],
{
temperature: 0,
tools: [
{
name: "food_items",
parameters: schema,
}
],
tool_choice: {
name: "food_items"
}
});
You can define your function and its parameters in the tools
array, and then call the function using the tool_choice
parameter. Note that the tools
and tool_choice
parameters are passed as an object, not as separate parameters.
I hope this helps! Let me know if you have any further questions.
References: