Would love to see support for the new structured outputs that ollama supports in a new format option to describe the json schema object we want to enforce.
curl -X POST http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{
"model": "llama3.1",
"messages": [{"role": "user", "content": "Tell me about Canada."}],
"stream": false,
"format": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"capital": {
"type": "string"
},
"languages": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"name",
"capital",
"languages"
]
}
}'
As far as the API for this, I'd think we could just add a new Object option to ResponseFormat, but not sure exactly what i'd expect for the actual schema definition offhand?
new ChatOptions<MyExpectedShape>()
{
ResponseFormat = ChatResponseFormat.Object,
Schema = typeof(MyExpectedShape)
}
// ...
new ChatOptions()
{
ResponseFormat = ChatResponseFormat.Object,
Schema = typeof(MyExpectedShape),
SchemaSerializerOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
}
}
regardless, this would greatly enhance the capabilities for json handling and would be a great value add!
Would love to see support for the new structured outputs that ollama supports in a new
formatoption to describe the json schema object we want to enforce.As far as the API for this, I'd think we could just add a new
Objectoption toResponseFormat, but not sure exactly what i'd expect for the actual schema definition offhand?regardless, this would greatly enhance the capabilities for json handling and would be a great value add!