Closed YiLuo59 closed 4 days ago
@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!
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