Skip to content

function_call not handled in BaseGenerateContentResponse.text #620

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

Closed
neilp9 opened this issue Nov 8, 2024 · 1 comment
Closed

function_call not handled in BaseGenerateContentResponse.text #620

neilp9 opened this issue Nov 8, 2024 · 1 comment
Labels
component:python sdk Issue/PR related to Python SDK

Comments

@neilp9
Copy link

neilp9 commented Nov 8, 2024

Description of the bug:

calling session.send_message returns a GenerateContentResponse object, and when this response includes a function call, response.text raises the following error:

File ".../.virtualenvs/cai/lib/python3.11/site-packages/google/generativeai/types/generation_types.py", line 538, in text
    part_type = protos.Part.pb(part).whichOneof("data")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: whichOneof

Actual vs expected behavior:

response.text should return the text part of the response rather than throwing error. Related but separate of an issue, there should ideally be a convenience accessor for response.function_call

Any other information you'd like to share?

No response

@Gunand3043 Gunand3043 added status:triaged Issue/PR triaged to the corresponding sub-team component:python sdk Issue/PR related to Python SDK labels Nov 11, 2024
@MarkDaoust MarkDaoust mentioned this issue Nov 12, 2024
@MarkDaoust MarkDaoust mentioned this issue Feb 19, 2025
@MarkDaoust
Copy link
Collaborator

The WhichOneOf error is being fixed. But .text isn't meant to handle everything. For anything remotely complicated, users should iterate over the parts and decide what to do with each one.

@github-actions github-actions bot removed the status:triaged Issue/PR triaged to the corresponding sub-team label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants