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

[Bug]: Several cells fail with Cannot get the Candidate text #962

Closed
1 task done
telpirion opened this issue Aug 20, 2024 · 1 comment
Closed
1 task done

[Bug]: Several cells fail with Cannot get the Candidate text #962

telpirion opened this issue Aug 20, 2024 · 1 comment
Assignees

Comments

@telpirion
Copy link

telpirion commented Aug 20, 2024

File Name

gemini/use-cases/multimodal_use_cases_workshop.ipynb

What happened?

  1. Install dependencies, restart kernel.
  2. Provide project ID and region (us-west1) in the pertinent cells.
  3. Run all following cells.

Expected:
All cells run successfully, no errors

Actual:
The Finding bugs in the code and Create a developer getting started guide both fail with a ValueError:

ValueError: Cannot get the Candidate text.
Response candidate content has no parts (and thus no text). The candidate is likely blocked by the safety filters.
Content:

Relevant log output

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~/.local/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py in text(self)
   1967         try:
-> 1968             return self.content.text
   1969         except (ValueError, AttributeError) as e:

4 frames
ValueError: Response candidate content has no parts (and thus no text). The candidate is likely blocked by the safety filters.
Content:
{}

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
ValueError: Cannot get the Candidate text.
Response candidate content has no parts (and thus no text). The candidate is likely blocked by the safety filters.
Content:
{}
Candidate:
{
  "finish_reason": "SAFETY",
  "safety_ratings": [
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "probability": "NEGLIGIBLE",
      "probability_score": 0.21777344,
      "severity": "HARM_SEVERITY_LOW",
      "severity_score": 0.33984375
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "probability": "MEDIUM",
      "blocked": true,
      "probability_score": 0.66015625,
      "severity": "HARM_SEVERITY_MEDIUM",
      "severity_score": 0.40625
    },
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "probability": "NEGLIGIBLE",
      "probability_score": 0.29296875,
      "severity": "HARM_SEVERITY_LOW",
      "severity_score": 0.203125
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "probability": "NEGLIGIBLE",
      "probability_score": 0.09423828,
      "severity": "HARM_SEVERITY_MEDIUM",
      "severity_score": 0.62109375
    }
  ]
}

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
~/.local/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py in text(self)
   1888             # Enrich the error message with the whole Response.
   1889             # The Candidate object does not have full information.
-> 1890             raise ValueError(
   1891                 "Cannot get the response text.\n"
   1892                 f"{e}\n"

ValueError: Cannot get the response text.
Cannot get the Candidate text.
Response candidate content has no parts (and thus no text). The candidate is likely blocked by the safety filters.
Content:
{}
Candidate:
{
  "finish_reason": "SAFETY",
  "safety_ratings": [
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "probability": "NEGLIGIBLE",
      "probability_score": 0.21777344,
      "severity": "HARM_SEVERITY_LOW",
      "severity_score": 0.33984375
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "probability": "MEDIUM",
      "blocked": true,
      "probability_score": 0.66015625,
      "severity": "HARM_SEVERITY_MEDIUM",
      "severity_score": 0.40625
    },
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "probability": "NEGLIGIBLE",
      "probability_score": 0.29296875,
      "severity": "HARM_SEVERITY_LOW",
      "severity_score": 0.203125
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "probability": "NEGLIGIBLE",
      "probability_score": 0.09423828,
      "severity": "HARM_SEVERITY_MEDIUM",
      "severity_score": 0.62109375
    }
  ]
}
Response:
{
  "candidates": [
    {
      "finish_reason": "SAFETY",
      "safety_ratings": [
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "probability": "NEGLIGIBLE",
          "probability_score": 0.21777344,
          "severity": "HARM_SEVERITY_LOW",
          "severity_score": 0.33984375
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "probability": "MEDIUM",
          "blocked": true,
          "probability_score": 0.66015625,
          "severity": "HARM_SEVERITY_MEDIUM",
          "severity_score": 0.40625
        },
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "probability": "NEGLIGIBLE",
          "probability_score": 0.29296875,
          "severity": "HARM_SEVERITY_LOW",
          "severity_score": 0.203125
        },
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "probability": "NEGLIGIBLE",
          "probability_score": 0.09423828,
          "severity": "HARM_SEVERITY_MEDIUM",
          "severity_score": 0.62109375
        }
      ]
    }
  ],
  "usage_metadata": {
    "prompt_token_count": 655873,
    "candidates_token_count": 1,
    "total_token_count": 655874
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@gericdong
Copy link
Contributor

Thanks for reporting this issue. There have been some changes made into the RAI and Safety Filters that were possible the source of this kind of issue. Closing this issue for now but please try and reopen this issue if needed. Thanks.

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

3 participants