fix: Fix error messages with malformed gemini call (#3865)

This commit is contained in:
Matthew Zhou
2025-08-11 16:59:19 -07:00
committed by GitHub
parent 639641137d
commit 5772365285

View File

@@ -303,11 +303,11 @@ class GoogleVertexClient(LLMClientBase):
for candidate in response.candidates:
content = candidate.content
if content.role is None or content.parts is None:
if content is None or content.role is None or content.parts is None:
# This means the response is malformed like MALFORMED_FUNCTION_CALL
# NOTE: must be a ValueError to trigger a retry
if candidate.finish_reason == "MALFORMED_FUNCTION_CALL":
raise ValueError(f"Error in response data from LLM: {candidate.finish_message[:350]}...")
raise ValueError(f"Error in response data from LLM: {candidate.finish_reason}...")
else:
raise ValueError(f"Error in response data from LLM: {response_data}")