Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.49k stars 4.81k forks source link

[BUG] 'json_object' is not of type 'object' - 'response_format' #40632

Closed PooSham closed 11 months ago

PooSham commented 11 months ago

Library name and version

Azure.AI.OpenAI 1.0.0-beta.10

Describe the bug

Setting ResponseFormat = ChatCompletionsResponseFormat.JsonObject throws an exception when calling GetChatCompletions against a model that should support JSON mode.

I've tried it against deployments of the gpt-35-turbo model with version 1106, as well as the gpt-4 model with version 1106-preview. None of which worked.

Expected behavior

To not get this error for gpt-35-turbo 1106 and gpt-4 1106-preview, since they should be supported according to the CHANGELOG

Actual behavior

An Azure.RequestFailedException is thrown, with the following message:

'json_object' is not of type 'object' - 'response_format'
Status: 400 (model_error)

Content:
{
  "error": {
    "message": "'json_object' is not of type 'object' - 'response_format'",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

Headers:
<Here comes a list of headers I don't want to share on github>

Reproduction Steps

Set up a deployment in Azure OpenAI Studio with model gpt-35-turbo or gpt-4 with version 1106 or 1106-preview respectively.

Run the following code:

var chatCompletionsOptions = new ChatCompletionsOptions("my-gpt-4-deployment", new List<ChatRequestUserMessage>() { new ChatRequestUserMessage("test content") })
{
    ResponseFormat = ChatCompletionsResponseFormat.JsonObject
};

var openAIClient = new OpenAIClient(new Uri("Azure AI URI"), new Azure.AzureKeyCredential("Azure AI Key"));
openAIClient.GetChatCompletions(chatCompletionsOptions);

Environment

OS: Windows 11 .NET runtime: .NET Framework 4.8 Language: VB.NET (I wrote the reproduction steps in C#, but the code that ran this for me was VB.NET) IDE: Visual Studio 16.11.29

PooSham commented 11 months ago

I'm not sure if the problem lies in the SDK or Azure OpenAI Studio.

github-actions[bot] commented 11 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.

github-actions[bot] commented 11 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.