cookbook
cookbook copied to clipboard
Returning a Fixed Json
trafficstars
Hi I am working on audio understanding and would like the script return me the output in a fixed output format. Something like this
{
"name": "set_output_json_format",
"parameters": {
"type": "object",
"properties": {
"count": {
"type": "string",
"description": "Represents the number of times the user has chanted correctly"
},
"mantra": {
"type": "string",
"description": "Represents the mantra chanted"
}
}
}
}
How can I do it in the Audio Script?
Hi, please see this tutorial:
https://ai.google.dev/tutorials/structured_data_extraction
We are working on adding a "json_schema" to the API in the next release, that will make this simpler.
The API supports this now. Check out the JSON mode recipe: https://github.com/google-gemini/cookbook/blob/main/quickstarts/JSON_mode.ipynb