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
Labels
component:support
How to do xyz?
status:awaiting user response
Awaiting a response from the author
type:bug
Something isn't working
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 validPart
, but none were returned. Please check thecandidate.safety_ratings
to determine if the response was blocked.How can I deal with that?
Actual vs expected behavior:
No response
Any other information you'd like to share?
No response
The text was updated successfully, but these errors were encountered: