0

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

1
  • It is something recent, and I am experiencing it myself in a solution that was working perfectly previously. In the result the toolCalls array is empty with the nodejs SDK. My hunch this is a wireformat mismatch with the ever evolving SDK + API. Trying to validate this now with a direct REST invoke. Commented Jan 17, 2024 at 15:14

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.