generative-ai-dart
generative-ai-dart copied to clipboard
Is it possible to add mandatory JSON format response
i see in google docs an example for CURL
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=$API_KEY
-H 'Content-Type: application/json'
-X POST
-d '{ "contents":[{
"parts":[{"text": "List 5 popular cookie recipes using this JSON schema: { "type": "object", "properties": { "recipe_name": { "type": "string" },}}"}] }],
"generationConfig": {
"response_mime_type": "application/json",
} }'
so is it possible to add "response_mime_type": "application/json", to generationConfig ?
The current way to enforce JSON format response is to use function calling. The 0.3.1
release supports the tool config argument which can force the model to reply with a function call, and the function call can specify the JSON schema for the argument.
Support for JSON schemas without function calling is under consideration.
The mimeType
field is supported. Handled by https://github.com/google-gemini/generative-ai-dart/pull/156