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
192 stars 41 forks source link

Add system instruction support and beta API configuration #42

Closed gregpriday closed 1 month ago

gregpriday commented 1 month ago

This PR introduces system instruction support and adds the ability to easily configure the client to use the beta API endpoint (required for system instructions).

Changes

  1. System Instruction Support:

    • Added withSystemInstruction method to the GenerativeModel class
    • Updated GenerateContentRequest and related components to include system instructions in API requests
    • Modified Client and GenerativeModelContract to support system instructions
    • Added tests to verify system instruction functionality
  2. Beta API Support:

    • Introduced useBetaApi() method in the Factory class to easily set the base URL to the beta API endpoint
    • Added tests to cover the new beta API configuration

Usage Example

Gemini::factory()
    ->useBetaApi()
    ->withApiKey('my-api-key')
    ->make();

Please review and let me know if any further changes are needed.

gregpriday commented 1 month ago

I see this will actually need a few fixes and changes, but I'll wait to see if you want to add support for this first.

aydinfatih commented 1 month ago

Hello @gregpriday , First of all, thank you for your contribution.

I think it is not right to have beta and stable versions on the same branch.

Because most things change, such as parameters, returned answers, etc. Stable channel users will try and get errors when they see the beta features. Or it can be the other way around. For this, I created a new beta branch last week.

Those who want to use the beta features can add this branch as a dependency to their project.

https://packagist.org/packages/google-gemini-php/client#1.0.1-beta https://github.com/google-gemini-php/client/tree/beta