fix: Fix error messages with malformed gemini call (#3865)
This commit is contained in:
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user