-
Notifications
You must be signed in to change notification settings - Fork 327
Closed
Labels
bugCategory: Something isn't working and appears to be a defect in the client library.Category: Something isn't working and appears to be a defect in the client library.
Description
Confirm this is not an issue with the OpenAI Python Library
- This is not an issue with the OpenAI Python Library
Confirm this is not an issue with the underlying OpenAI API
- This is not an issue with the OpenAI API
Confirm this is not an issue with Azure OpenAI
- This is not an issue with Azure OpenAI
Describe the bug
I'm always getting the same error message as soon as I try to use any variation of ChatResponseFormat.CreateJsonSchemaFormat
Couldn't get response from ChatGPT: System.ClientModel.ClientResultException: HTTP 400 (invalid_request_error: missing_required_parameter)
Parameter: response_format.json_schema
Missing required parameter: 'response_format.json_schema'.
at OpenAI.ClientPipelineExtensions.ProcessMessageAsync (System.ClientModel.Primitives.ClientPipeline pipeline, System.ClientModel.Primitives.PipelineMessage message, System.ClientModel.Primitives.RequestOptions options) [0x0015e] in <92cde0f04c3a467caa9bf3e15fe4f0c8>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in <27124aa0e30a41659b903b822b959bc7>:0
at OpenAI.Chat.ChatClient.CompleteChatAsync (System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options) [0x000ad] in <92cde0f04c3a467caa9bf3e15fe4f0c8>:0
at OpenAI.Chat.ChatClient.CompleteChatAsync (System.Collections.Generic.IEnumerable`1[T] messages, OpenAI.Chat.ChatCompletionOptions options, System.Threading.CancellationToken cancellationToken) [0x00152] in <92cde0f04c3a467caa9bf3e15fe4f0c8>:0
In the code below, if I use chatOptions.ResponseFormat = ChatResponseFormat.JsonObject
, I don't get an error message, but then I of course don't get to specify the schema.
This user was also having issues in Unity, but the error message was unclear so it's hard to know if it's the same issue. Plus whatever fixed it should be documented.
To Reproduce
Run the code below in Unity 2022.3.22f1
Library installed using NuGet for Unity
Code snippets
var client = new OpenAI.Chat.ChatClient(model: model.Or(DEFAULT_CHAT_GPT_MODEL), apiKey);
var chatOptions = new ChatCompletionOptions();
chatOptions.ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(
name: "math_reasoning",
jsonSchema: BinaryData.FromString(
"{\n" +
" \"type\": \"object\",\n" +
" \"properties\": {\n" +
" \"steps\": {\n" +
" \"type\": \"array\",\n" +
" \"items\": {\n" +
" \"type\": \"object\",\n" +
" \"properties\": {\n" +
" \"explanation\": { \"type\": \"string\" },\n" +
" \"output\": { \"type\": \"string\" }\n" +
" },\n" +
" \"required\": [\"explanation\", \"output\"],\n" +
" \"additionalProperties\": false\n" +
" }\n" +
" },\n" +
" \"final_answer\": { \"type\": \"string\" }\n" +
" },\n" +
" \"required\": [\"steps\", \"final_answer\"],\n" +
" \"additionalProperties\": false\n" +
"}"),
strictSchemaEnabled: true);
var chatMessage = new UserChatMessage(query);
return client.CompleteChatAsync(new List<UserChatMessage> { chatMessage }, chatOptions)
OS
winOS
.NET version
.NET Standard 2.1
Library version
2.0.0-beta.10
Metadata
Metadata
Assignees
Labels
bugCategory: Something isn't working and appears to be a defect in the client library.Category: Something isn't working and appears to be a defect in the client library.