Skip to content

Commit

Permalink
fix: Gemini: reporting safety error properly (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik authored Nov 15, 2024
1 parent 106448e commit 9d3d351
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions aidial_adapter_vertexai/chat/gemini/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,13 @@ def to_openai_finish_reason(


def _get_candidate_text_safe(candidate: Candidate) -> str | None:
# The text content of a candidate may be missing when function is called
# The text content of a candidate may be missing when function is called or
# when the generation was terminated with SAFETY finish reason.
try:
return candidate.text
except ValueError:
if candidate.function_calls:
return None
else:
raise
except ValueError as e:
log.debug(f"The Candidate doesn't have text: {e}")
return None


T = TypeVar("T")
Expand Down

0 comments on commit 9d3d351

Please sign in to comment.