diff --git a/google/generativeai/types/generation_types.py b/google/generativeai/types/generation_types.py index ff2ce1441..04627755b 100644 --- a/google/generativeai/types/generation_types.py +++ b/google/generativeai/types/generation_types.py @@ -324,14 +324,13 @@ def text(self): ValueError: If the candidate list or parts list does not contain exactly one entry. """ parts = self.parts - if len(parts) > 1 or "text" not in parts[0]: + if len(parts) != 1 or "text" not in parts[0]: raise ValueError( "The `response.text` quick accessor only works for " - "simple (single-`Part`) text responses. This response " - "contains multiple `Parts`. Use the `result.parts` " - "accessor or the full " + "simple (single-`Part`) text responses. This response is not simple text." + "Use the `result.parts` accessor or the full " "`result.candidates[index].content.parts` lookup " - "instead" + "instead." ) return parts[0].text