google-gemini-php / client

⚡️ Gemini PHP is a community-maintained PHP API client that allows you to interact with the Gemini AI API.
MIT License
169 stars 19 forks source link

support new JSON response mode for Gemini 1.5 Pro #19

Closed dmaicher closed 2 months ago

dmaicher commented 2 months ago

Fixes #18

This allows doing

$client
    ->generativeModel('models/gemini-1.5-pro-latest')
    ->withGenerationConfig(new GenerationConfig(responseMimeType: 'application/json'))

and the response will be JSON then.

aydinfatih commented 2 months ago

Hello, First of all, thank you for your feedback. This feature is currently in beta. Including it in the package might be a problem at the moment.

https://github.com/google-gemini-php/client/issues/14

dmaicher commented 2 months ago

Yeah I see. Maybe allowing GenerationConfig|Arrayable might be a solution? being constrained for the allowed config by this lib seems not so ideal. Whenever new config options are available this would require an update/release as we see with this issue.

aydinfatih commented 2 months ago

The package is currently not sending requests to the beta api. Therefore the stable api will not recognize this feature. I plan to create a separate branch for this and other beta features, so that those who want to use beta features can access them through this branch.

https://github.com/google-gemini-php/client/blob/06536196184cb6b29f096e29705a175b7b7350af/src/Factory.php#L33

dmaicher commented 2 months ago

The package is currently not sending requests to the beta api

yeah not by default but its easily possible with

Gemini::factory()->withBaseUrl('https://generativelanguage.googleapis.com/v1beta/')

Thanks for looking into it :+1:

aydinfatih commented 2 months ago

Yes, this is possible, but anyone using the package will need to be aware that this parameter only works in beta. As I said, I'm planning to open a separate branch for the beta to add these features, I'll let you know when that's done.

beliven-daniele-sarnari commented 1 month ago

Hello @aydinfatih do you have any update regarding the beta branch? Thanks

pionl commented 3 weeks ago

Hi @aydinfatih maybe instead of separate branch BetaGenerationConfig could be provided ?

avengerweb commented 1 day ago

I also think that the decision to exclude beta APIs is like putting the package on the shelf. Most generative AI providers release or mark their first revisions as beta or preview versions. Since this is a relatively new area, most users are really looking to use the latest versions.