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

feat: usageMetadata in GenerateContentResponse #27

Closed xavierandueza closed 1 month ago

xavierandueza commented 3 months ago

Context

Google's GenerateContentResponse includes a "usageMetadata".

The above has reference to 4 attributes of the usageMetadata, however the actual returned response currently only includes the 3 listed here in their API Reference. The raw response was checked and tested to ensure this.

This contains useful information about the:

Changes

This involved the creation of the UsageMetadata class, and modifications to the GenerateContentResponse class.

UsageMetadata Creation

This class implements the UsageMetadata (1.4.1) response as per the Gemini API.

GenerateContentResponse Changes

Integrated the new UsageMetadata class to include these.

xavierandueza commented 3 months ago

@aydinfatih and/or @bradleybernard if you could check this out when you get the time that'd be great 👍

aydinfatih commented 1 month ago

First of all, thank you very much for your contribution.

I didn't see the tests in this PR. I just did a general update to the package and included this feature, so I'm closing this PR.

https://github.com/google-gemini-php/client/pull/32