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

gemini-2.0 does not recognize google_search_retrieval tool #667

Closed
Kvit opened this issue Feb 1, 2025 · 7 comments
Closed

gemini-2.0 does not recognize google_search_retrieval tool #667

Kvit opened this issue Feb 1, 2025 · 7 comments
Assignees
Labels
component:python sdk Issue/PR related to Python SDK status:awaiting user response Awaiting a response from the author type:bug Something isn't working

Comments

@Kvit
Copy link

Kvit commented Feb 1, 2025

Description of the bug:

While switching model from gemini-1.5-pro to gemini-2.0-flash-exp google_search_retrieval tool is no longer recognized

Actual vs expected behavior:

Using "gemini-2.0-flash-exp"

model = genai.GenerativeModel(
    model_name="gemini-2.0-flash-exp",
    tools='google_search_retrieval')

response = model.generate_content("Search latest news")
print(response.text)

InvalidArgument: 400 Unable to submit request because Please use google_search field instead of google_search_retrieval field.. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini

Expected:
Here's a summary of the latest news as of February 1, 2025...

Any other information you'd like to share?

Package Version

Name: google-generativeai
Version: 0.8.4
Summary: Google Generative AI High level API client library and tools.
Home-page: https://github.com/google/generative-ai-python
@Kvit
Copy link
Author

Kvit commented Feb 1, 2025

Code with search tool generated by Google AI Studio https://aistudio.google.com/ for model gemini-2.0-flash-exp also does not work

@gmKeshari gmKeshari added type:bug Something isn't working status:triaged Issue/PR triaged to the corresponding sub-team component:python sdk Issue/PR related to Python SDK labels Feb 2, 2025
@gmKeshari gmKeshari self-assigned this Feb 2, 2025
@gmKeshari
Copy link

Hi @Kvit,

My hunch is search grounding with 2.0 models only work with the new SDK. Have you tried with new SDK?? Here is the gist. You can also follow the quickstart colab notebook for grounding using search tool.

I checked with the AI Studio code, it's not working. I will escalate this to our internal team to update this.

Thanks.

@gmKeshari gmKeshari added status:awaiting user response Awaiting a response from the author and removed status:triaged Issue/PR triaged to the corresponding sub-team labels Feb 5, 2025
@Kvit
Copy link
Author

Kvit commented Feb 5, 2025

@gmKeshari I think I figured out the issue: Gemini 2.0 API structure is different from the previous version. I suppose AI Studio code generator should be updated. Otherwise, it is confusing.

https://ai.google.dev/gemini-api/docs/models/gemini-v2

@Kvit Kvit closed this as completed Feb 5, 2025
@tqdo
Copy link

tqdo commented Feb 7, 2025

@Kvit so how did you get it to work? I am having the same error

@gmKeshari
Copy link

Hi @tqdo,

Please use this doc which uses new SDK.

Thanks.

@Wazbat
Copy link

Wazbat commented Mar 9, 2025

I've arrived here while struggling to figure out how to enable grounding when using langchain. It seems like the documentation is a little all over the place, including the docs on the GCP page itself for grounding

@meher-gajula
Copy link

https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/grounding#ground-on-public-data

I just tried the example on Google Docs and I get the same error.

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 status:awaiting user response Awaiting a response from the author type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants