Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions google/generativeai/types/generation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down