Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get finishReason value #68

Open
GeekTNT opened this issue Feb 18, 2025 · 0 comments
Open

How to get finishReason value #68

GeekTNT opened this issue Feb 18, 2025 · 0 comments

Comments

@GeekTNT
Copy link

GeekTNT commented Feb 18, 2025

Hello,

I'm using

$input  = "Do something";
$client->geminiFlash()->generateContent($input);

And sometimes it fails with the following output (finishReason RECITATION):

It happens for eg. when I want to translate a text, that's copyrighted.

object(Gemini\Responses\GenerativeModel\GenerateContentResponse)#30 (3) {
  ["candidates"]=>
  array(1) {
    [0]=>
    object(Gemini\Data\Candidate)#25 (7) {
      ["content"]=>
      object(Gemini\Data\Content)#16 (2) {
        ["parts"]=>
        array(0) {
        }
        ["role"]=>
        enum(Gemini\Enums\Role::MODEL)
      }
      ["finishReason"]=>
      enum(Gemini\Enums\FinishReason::RECITATION)
      ["safetyRatings"]=>
      array(0) {
      }
      ["citationMetadata"]=>
      object(Gemini\Data\CitationMetadata)#31 (1) {
        ["citationSources"]=>
        array(4) {
...

More on the finishReason respones
https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest/vertexai.generative_models.FinishReason

Is there a way to check the finishReason value.
Or even better, can you make it so if the finishReason is not STOP to return the exception.

I can provide the content I used for the testing if needed.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant