Azure OpenAI function call error: Missing parameter 'name': messages with role 'function' must have a 'name'.

Ulysses Wu 10 Reputation points
2023-09-12T07:52:48.3133333+00:00

The following request works on OpenAI API, but fails on Azure OpenAI with this error:

data: {"code":500,"message":"stream error: (error, status code: 400, message: Missing parameter 'name': messages with role 'function' must have a 'name'.)","model":"","choices":null}

    {        
        "model": "gpt-4-0613",
        "messages": [
            {
                "role": "system",
                "content": ""
            },
            {
                "role": "user",
                "content": "What is the weather like in Boston?"
            },
            {
                "role": "assistant",
                "content": "What is the weather like in Boston?",
                "function_call":{"name":"get_current_weather","arguments":"{\n  \u0022location\u0022: \u0022Boston, MA\u0022\n}"}
            },
            {
                "name": "get_current_weather",
                "role": "function",
                "content": "20 C"
            }
        ],
        "temperature": 0.001,
        "top_p": 1,
        "n": 1,
        "stream": true,
        "max_tokens": null,
        "presence_penalty": 0,
        "frequency_penalty": 0,
        "functions": [
     {
       "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"]
       }
     }
   ],
        "function_call": "auto"
    }
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,131 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Saurabh Sharma 23,821 Reputation points Microsoft Employee
    2023-09-26T21:25:12.14+00:00

    @Ulysses Wu

    I am getting results as you are expecting from Azure Open AI. I have tried this with GPT-35-Turbo and GPT-4 models. (See screenshots below)

    User's image

    If you are still getting this error then, I suggest you to please open an Azure Support ticket so that an engineer could look into your environment. Please let me know in case you have any limitations opening a support case.

    Thank you,

    Saurabh

    0 comments No comments

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.