Open gabrielmdesidera opened 1 day ago
This is the partial response that was returned that triggered this bug:
GenerateContentResponse(
done=True,
iterator=None,
result=protos.GenerateContentResponse({
"candidates": [
{
"finish_reason": "SAFETY",
"index": 0,
"safety_ratings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "HIGH"
}
]
}
],
"usage_metadata": {
"prompt_token_count": 121385,
"candidates_token_count": 1,
"total_token_count": 121386
}
}),
)
It looks like the safety violation should have triggered an error with a finish message, but the finish_message attribute is not present in the candidate instance, thus leading to the AttributeError: Unknown field for Candidate: finish_message
bug
Description of the bug:
During regular use, some requests to Gemini are returning this error instead of the response (Python project running in Docker):
Actual vs expected behavior:
By reading the code from #527, I assume the expected behaviour would be to raise another error with the intended message
Any other information you'd like to share?
No response