Reputation: 11
I am currently using the @azure/openai npm package for Node.js to interact with the GPT-4 model. I have noticed that the toolCalls in the response are empty, even though I have included tools in my request.
Code:
const getCurrentWeather = {
name: 'get_current_weather',
description: 'Get the current weather in a given location',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'The city and state, e.g. San Francisco, CA',
},
unit: {
type: 'string',
enum: ['celsius', 'fahrenheit'],
},
},
required: ['location'],
},
};
const messages = [{ role: 'user', content: 'What is the weather like in Glasgow Scotland?' }];
const options = {
tools: [
{
type: 'function',
function: getCurrentWeather,
},
],
};
client.getChatCompletions(deploymentIdBest, messages, options).then((res) => console.log(res));
Expected Behavior: Ofcourse we expect something like this in the response:
{'role': 'assistant',
'content': None,
'tool_calls': [{'id': 'call_o7uyztQLeVIoRdjcDkDJY3ni',
'type': 'function',
'function': {'name': 'get_current_weather',
'arguments': '{\n "location": "Glasgow, Scotland",\n "format": "celsius"\n}'}}]}
Actual Behavior: This is the full response from the azure/openai client (tried both gpt-4-turbo and gpt-35-turbo):
{
"id": "chatcmpl-8fr5PAthe2uTIHVjd8mcy7pOMkrx5",
"object": "chat.completion",
"model": "gpt-4",
"usage": {
"promptTokens": 172,
"completionTokens": 22,
"totalTokens": 194
},
"created": "1970-01-20T17:36:26.203Z",
"promptFilterResults": [
{
"promptIndex": 0,
"contentFilterResults": {}
}
],
"choices": [
{
"index": 0,
"finishReason": "tool_calls",
"contentFilterResult": {
"error": {
"code": "content_filter_error",
"message": "The contents are not filtered"
}
},
"message": {
"role": "assistant",
"toolCalls": []
},
"contentFilterResults": {}
}
]
}
@azure/openai versions in question: 1.0.0-beta.10 and 1.0.0-alpha.20240104.1
Upvotes: 0
Views: 449
Reputation: 11740
This is an issue with the OpenAI service rather than the nodejs OpenAI SDK. I've checked, and the REST interface has the same issue. It is a recent change, I have positive memories of this working 2-3 weeks ago.
Someone already reported this to the Azure team here: https://github.com/Azure/azure-sdk-for-js/issues/28343
UPDATE: This has been fixed now, the issue was related with just a few service regions.
Upvotes: 0