GoogleCloudPlatform / generative-ai

Sample code and notebooks for Generative AI on Google Cloud, with Gemini on Vertex AI
https://cloud.google.com/vertex-ai/docs/generative-ai/learn/overview
Apache License 2.0
7.34k stars 1.99k forks source link

[Bug]: function_call not handled in BaseGenerateContentResponse.text #1379

Closed neilp9 closed 10 hours ago

neilp9 commented 17 hours ago

File Name

google/generativeai/types/generation_types.py

What happened?

calling session.send_message returns a GenerateContentResponse object, and when this response includes a function call, response.text should still work. Also, there should ideally be a convenience accessor for response.function_call

Instead, response.text throws an error when a function call is present

Relevant log output

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

Code of Conduct

koverholt commented 10 hours ago

Thanks for the info. This repository is for Generative AI with Vertex AI on Google Cloud, not the Google AI Studio Gemini API. For issues with the Google AI Gemini API, you can report them in the appropriate repository in the google-gemini GitHub organization (https://github.com/google-gemini/generative-ai-python) or post a message on their developer forums (https://discuss.ai.google.dev/c/gemini-api/4).