feat: usageMetadata in GenerateContentResponse
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:
- Number of response tokens used
- Number of tokens in the prompt
- Total number of tokens.
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.
@aydinfatih and/or @bradleybernard if you could check this out when you get the time that'd be great 👍
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