response.text quick accessor bug #318
Labels
component:python sdk
Issue/PR related to Python SDK
status:triaged
Issue/PR triaged to the corresponding sub-team
type:bug
Something isn't working
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,
safety_settings=self.safety_settings
)
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
The text was updated successfully, but these errors were encountered: