-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
response.text
is no longer directly accessible - TypeError: argument of type 'Part' is not iterable
#288
Comments
TypeError: argument of type 'Part' is not iterable
- response.text
is no longer directly accessible response.text
is no longer directly accessible - TypeError: argument of type 'Part' is not iterable
Any update on this pls. Does this break all the python examples? |
The public python examples are okay, this is a google-internal problem. @mitchspano I've added you to an email thread titled "Checking for oneof field presence in UPB proto messages", where we're discussing the cause of this. |
Thanks @MarkDaoust .. I am getting below error using langchain aswell as google-cloud-aiplatform. Am i missing something. |
Interesting. Thanks for the update. Reopened. Internally it has something to do with switching to upb protos, IDK if it's the same problem here. https://github.com/protocolbuffers/upb?tab=readme-ov-file proto-plus (used by these libraries)depends on an older version of protobuf (<5, when latest is 5.26.1), but upgrading to 5.26 doesn't cause this error. Can ou post a "pip freeze | grep proto"? |
Just with the python versions, using this SDK I can't reproduce that. Can you reproduce the error in Colab, for example, so we can replicate it and share with the owners? |
Used below to create my environment where i see the issue.name: python-test
|
The issue happens when parts is a protobuf object and not a dict - the check needs to be replaced with: if len(parts) != 1 or not hasattr(parts[0], "text"): Instead of: if len(parts) != 1 or "text" not in parts[0]: I am not sure if it will resolve all issues or if it needs to be a more comprehensive check, but it was causing issues for me and I ended up using parts[0].text directly to avoid similar issues.
|
For some reason - I was getting this error consistently yesterday, but can't reproduce today!!! |
@sakher, you do have a point, |
You guys know better, I haven't dug deep into it - but when the error happens (sporadically) from some debugging, the type of However, in some cases, the error doesn't happen, and the type of parts seems to be different in such cases: |
(@MarkDaoust see me inside corp as parrt) I'm also seeing this with anaconda and mac os (Sonoma 14.5) on apple silicon via
Snippet:
Oddly however, the response object does appear to have the appropriate elements:
For example the following evaluates fine:
Info:
My environment was old so I whacked anaconda and reinstalled everything. I get the same problem still.
|
I think this is the fix we need: |
Description of the bug:
Accessing the property
response.text
no longer works.As a workaround, I can get the detail with
response.candidates[0].content.parts[0].text
, but this seems like it might be a breaking change?Actual vs expected behavior:
I should be able to reference
response.text
directly.Any other information you'd like to share?
NOTE: I am using the internal Google3 version of this SDK - see go/generative-ai-python-sdk-response-type-issue for the exact line internally. There seems to be a discrepancy between Google3 and GitHub - this is the line in the GitHub repo.
Feel free to reach out to me internally - mitchspano@
The text was updated successfully, but these errors were encountered: