I think 'CreateJsonSchemaFormat()' is not working #183
Replies: 2 comments 1 reply
-
Hello, @helloSalmon ! Could you share a bit more of your code that includes the creation of the ChatResponseFormat format = ChatResponseFormat.CreateJsonSchemaFormat(
"Character_Sheet",
BinaryData.FromString("""
{
"type": "object",
"properties": {
},
"additionalProperties": false
}
"""),
"test description",
strictSchemaEnabled: true);
ChatCompletionOptions options = ModelReaderWriter.Read<ChatCompletionOptions>(BinaryData.FromString("""
{
"messages": [ { "role": "user", "content": "hello world" } ]
}
"""));
options.ResponseFormat = format;
Console.WriteLine(ModelReaderWriter.Write(options).ToString()); Outputs the expected (albeit unformatted) JSON: {"messages":[{"role":"user","content":"hello world"}],"model":null,"response_format":{"json_schema":{"description":"This is about json schema format","name":"Character_Sheet","schema":{
"type": "object",
"properties": {
},
"additionalProperties": false
},"strict":true},"type":"json_schema"}}
If you can share a bit more of the code context, we'd love to take a look! |
Beta Was this translation helpful? Give feedback.
-
Just to follow up, here's a link to the GitHub Issue where this was resolved: 🔗 #193 Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hello!
I know this should be in the bug issue. But before I try it there, I want to make sure I'm not doing something wrong.
When I try this code and check jsonOptions.ResponseFormat.ToString(), it only returns '{"type":"json_schema"}'.
Of course, I already check that 'data' variable has correct value.
If I try chatCompletion with that jsonOptions like,
it return HTTP 400 error that response_format.json_schema is missing.
Is there something that I missed?
Thank you for your time.
Beta Was this translation helpful? Give feedback.
All reactions