You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
current definiiton (5.1.0) accepts Map<String, String> for responseFormat. This is incompatible when you are using json_schema.
MRE:
final responseFormatDef = {
"type":"json_schema",
"json_schema":jsonEncode({
"name":"story_generation",
"schema": {
"type":"object",
"properties": {
"title": {
"type":"string",
"description":"The title of the story."
},
"genre": {
"type":"string",
"description":"The genre of the story, as provided by the user. If user asks for any, make one yourself."
},
"language": {
"type":"string",
"description":"The language in which the story is written, as requested by the user."
},
"content": {
"type":"string",
"description":"The main body of the story."
}
},
"required": ["title", "genre", "language", "content"],
"additionalProperties":false
},
"strict":true
})
};
OpenAIChatCompletionModel completion =awaitOpenAI.instance.chat.create(
model:'gpt-4o',
responseFormat: responseFormatDef,
messages: [sysMsg, usrMsg]);
Here, I used jsonEncode to convert the json_schema field into a string. This consequently causes .create() to fail.
Once I change the type definition to Map<String, dynamic> and get rid of jsonEncode, it works fine (changing value type to dynamic makes it more versatile too).
The text was updated successfully, but these errors were encountered:
current definiiton (5.1.0) accepts Map<String, String> for responseFormat. This is incompatible when you are using json_schema.
MRE:
Here, I used
jsonEncode
to convert the json_schema field into a string. This consequently causes.create()
to fail.Once I change the type definition to
Map<String, dynamic>
and get rid ofjsonEncode
, it works fine (changing value type to dynamic makes it more versatile too).The text was updated successfully, but these errors were encountered: