In this snippet, the SDK raises a ValueError when there is no accessible .text attribute. To be compatible with Python's hasattr this should raise an AttributeError.
Additionally, the Python docs make it quite clear this is not an intended use for ValueError:
exception ValueError
Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError.
Emphasis on receives, which does not describe a scenario in which a user may access a .text part but find it non-existent.
https://github.com/googleapis/python-aiplatform/blob/a9010aad6eaaa8cde335f5f8b25591a48a43b085/vertexai/generative_models/_generative_models.py#L1604-L1609
In this snippet, the SDK raises a
ValueError
when there is no accessible.text
attribute. To be compatible with Python'shasattr
this should raise anAttributeError
.Additionally, the Python docs make it quite clear this is not an intended use for
ValueError
:Emphasis on receives, which does not describe a scenario in which a user may access a
.text
part but find it non-existent.cc: @yeesian
Environment details
N/A
Steps to reproduce
N/A
Code example
N/A
Stack trace
N/A