Skip to content

Commit

Permalink
fix: raise AttributeError for accessing non-existent fields of a proto.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 614668287
  • Loading branch information
Yeesian Ng authored and Copybara-Service committed Mar 11, 2024
1 parent f90c9cc commit b91edf5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vertexai/generative_models/_generative_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ def text(self) -> str:
if len(self.parts) > 1:
raise ValueError("Multiple content parts are not supported.")
if not self.parts:
raise ValueError("Content has no parts.")
raise AttributeError("Content has no parts.")
return self.parts[0].text


Expand Down Expand Up @@ -1612,7 +1612,7 @@ def to_dict(self) -> Dict[str, Any]:
@property
def text(self) -> str:
if "text" not in self._raw_part:
raise ValueError("Part has no text.")
raise AttributeError("Part has no text.")
return self._raw_part.text

@property
Expand Down

0 comments on commit b91edf5

Please sign in to comment.