Issue with @azure/openai npm package - Empty toolCalls in response

Mohamed Ali Trabelsi 30 Reputation points
2024-01-11T15:47:01.5633333+00:00
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: 
```javascript
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


Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,081 questions
{count} votes

Accepted answer
  1. Saurabh Sharma 23,846 Reputation points Microsoft Employee Moderator
    2024-02-02T05:50:46.8866667+00:00

    Hi @Mohamed Ali Trabelsi ,

    I have received confirmation from the products team that this issue has been resolved and you should be able to get the results now. Please check the below screenshot for reference: User's image

    Please let me know if you see any issue.

    Thanks

    Saurabh

    ---Please 'Accept as answer' and Upvote if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.