feat: allow JSON mode
Resolve google-gemini-php/client#8
Use v1beta as default base URL to support the feature
With models/gemini-pro, API returns Json mode is not enabled for models/gemini-pro
Working on models/gemini-1.5-pro
Maybe add an example of use to use in ReadMe:
$generationConfig = new GenerationConfig(
1,
[],
null,
null,
null,
null,
'application/json',
[
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'product_name' => [
'type' => 'string'
]
]
]
],
);
$generativeModel = $client
->generativeModel('models/gemini-1.5-pro')
->withGenerationConfig($generationConfig)
->generateContent("Give me 5 names for my product, it's a bottle of tea");
Output :
[
{
"product_name": "SereniTea"
},
{
"product_name": "Tea'light"
},
{
"product_name": "The Daily Brew"
},
{
"product_name": "Zen Leaves"
},
{
"product_name": "Bottled Bliss"
}
]
This PR will make the library completely dependent on the beta. A separate branch can be created for beta and proceed from there. I am therefore closing this PR.
Hi @jnlin @camilleislasse This feature has been added to the beta version. You can use it by updating the version of the package in composer.json to the version I specified.
https://packagist.org/packages/google-gemini-php/client#1.0.0-beta