ValueError: The response.text quick accessor only works when the response contains a valid Part, but none was returned. Check the candidate.safety_ratings to see if the response was blocked.
Actual vs expected behavior:
Actual: raises an exception
Expected: some text response like "Sorry, I can't answer your question due to ..."
@mkdemkov, Similar feature request #282 is already in progress. Requesting you to close this issue and please follow and +1 similar thread for updates. Thank you!
Description of the bug:
Here is the code snippet that sometimes falls with the ValueError exception despite the fact that I disabled all the safety settings:
genai.configure(api_key=self.api_key) model = genai.GenerativeModel( model_name="gemini-pro",
generation_config=self.generation_config,
ValueError: The
response.text
quick accessor only works when the response contains a validPart
, but none was returned. Check thecandidate.safety_ratings
to see if the response was blocked.Actual vs expected behavior:
Actual: raises an exception Expected: some text response like "Sorry, I can't answer your question due to ..."
Any other information you'd like to share?
No response