fix
This commit is contained in:
Binary file not shown.
@@ -105,9 +105,21 @@ class GoogleAdapter:
|
|||||||
|
|
||||||
if response.usage_metadata:
|
if response.usage_metadata:
|
||||||
token_usage = response.usage_metadata.total_token_count
|
token_usage = response.usage_metadata.total_token_count
|
||||||
|
|
||||||
if response.parts is None and response.candidates[0].finish_reason is not None:
|
# Check prompt-level block (e.g. PROHIBITED_CONTENT) — no candidates in this case
|
||||||
raise GoogleGenerationException(f"Generation blocked in cause of {response.candidates[0].finish_reason.value}")
|
if response.prompt_feedback and response.prompt_feedback.block_reason:
|
||||||
|
raise GoogleGenerationException(
|
||||||
|
f"Generation blocked at prompt level: {response.prompt_feedback.block_reason.value}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check candidate-level block
|
||||||
|
if response.parts is None:
|
||||||
|
response_reason = (
|
||||||
|
response.candidates[0].finish_reason
|
||||||
|
if response.candidates and len(response.candidates) > 0
|
||||||
|
else "Unknown"
|
||||||
|
)
|
||||||
|
raise GoogleGenerationException(f"Generation blocked: {response_reason}")
|
||||||
|
|
||||||
generated_images = []
|
generated_images = []
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user