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

Invalid operation: The response.text quick accessor requires the response to contain a valid Part, but none were returned. Please check the candidate.safety_ratings to determine if the response was blocked. #461

Closed
YiLuo59 opened this issue Jun 18, 2024 · 2 comments
Labels
component:support How to do xyz? status:awaiting user response Awaiting a response from the author type:bug Something isn't working

Comments

@YiLuo59
Copy link

YiLuo59 commented Jun 18, 2024

Description of the bug:

My code is as following:

def model_generate(query, model):
response = model.generate_content(query,
generation_config=genai.types.GenerationConfig(
max_output_tokens=3000,
temperature=0.7),
safety_settings={
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
})
return response

response = model_generate(input, model)

Then I got error: Invalid operation: The response.text quick accessor requires the response to contain a valid Part, but none were returned. Please check the candidate.safety_ratings to determine if the response was blocked.

image

How can I deal with that?

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

@YiLuo59 YiLuo59 added the type:bug Something isn't working label Jun 18, 2024
@singhniraj08
Copy link
Contributor

@YiLuo59, Thank you reporting this issue. Similar issue is already filed in python SDK repo (#python/373)
This repository is for issues related to website(https://ai.google.dev/) like documentation bugs or improvements. Requesting you to close this issue, follow and +1 similar thread for updates. Thank you!

@singhniraj08 singhniraj08 added status:awaiting user response Awaiting a response from the author component:support How to do xyz? labels Jun 20, 2024
@YiLuo59 YiLuo59 closed this as completed Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:support How to do xyz? status:awaiting user response Awaiting a response from the author type:bug Something isn't working
3 participants