Skip to content
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

Can't handle repeated Value field (from protobuf/struct.proto) #488

Open
MarkDaoust opened this issue Sep 16, 2024 · 1 comment
Open

Can't handle repeated Value field (from protobuf/struct.proto) #488

MarkDaoust opened this issue Sep 16, 2024 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@MarkDaoust
Copy link

MarkDaoust commented Sep 16, 2024

We're launching an instance of this prediction service:

google/ai/generativelanguage/v1main/prediction_service.proto;l=77

The PredictRequest has in instances field that is a repeated protobufs.struct.Value.

Screenshot 2024-09-17 at 9 03 34 AM

No matter what you pass as instances here, the result is "Value must be iterable".

Debugging found that if you pass a list/sequence it gets converted to a struct_pb2.ListValue but the field is a repeated struct._pb2.Value so that fails.

Steps to reproduce

https://colab.sandbox.google.com/drive/1grGEJgXiZyvrJCZKvsFmuLyEeXc65vai?resourcekey=0-lTxTMUz7WTDYmV-CS9UHOQ#scrollTo=f4HxrpopJQ-C

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@MarkDaoust MarkDaoust added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Sep 16, 2024
@MarkDaoust
Copy link
Author

Update:

I found a workaround, so I'm not blocked.

  1. I wrote my own to_value function:

https://github.com/google-gemini/generative-ai-python/blob/imagen/google/generativeai/vision_models/_vision_models.py#L55-L98

  1. And then when I need an instance containing a list of Values, I create an instance of the underlying raw proto (to bypass the failing logic):

https://github.com/google-gemini/generative-ai-python/blob/imagen/google/generativeai/vision_models/_vision_models.py#L351-L354

But it would be nice if this case was handled.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant