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

response.text quick accessor bug #318

Open
mkdemkov opened this issue May 4, 2024 · 1 comment
Open

response.text quick accessor bug #318

mkdemkov opened this issue May 4, 2024 · 1 comment
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

Comments

@mkdemkov
Copy link

mkdemkov commented May 4, 2024

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
)

    try:
        response = await model.generate_content_async(self.history)
        print(response.text)

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 ..."

Any other information you'd like to share?

No response

@mkdemkov mkdemkov added component:python sdk Issue/PR related to Python SDK type:bug Something isn't working labels May 4, 2024
@singhniraj08
Copy link

@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!

@singhniraj08 singhniraj08 added the status:triaged Issue/PR triaged to the corresponding sub-team label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants