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

Search grounding is not working - Error: use google_search field instead of google_search_retrieval field #330

Open
thenameless7741 opened this issue Jan 28, 2025 · 1 comment
Assignees
Labels
component:js sdk Issue/PR related to JavaScript SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working

Comments

@thenameless7741
Copy link

thenameless7741 commented Jan 28, 2025

Description of the bug:

I implemented the search grounding feature by following the sample code and it seems to be broken at the moment:

  const modelParams: ModelParams = {
    model: 'gemini-2.0-flash-exp',
    tools: [
      {
        googleSearchRetrieval: {
          dynamicRetrievalConfig: {
            mode: DynamicRetrievalMode.MODE_DYNAMIC,
            dynamicThreshold: 0.7, // default
          },
        },
      },
    ],
  };

Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent: [400 Bad Request] Unable to submit request because Please use google_search field instead of google_search_retrieval field..

A temporary workaround is to replace googleSearchRetrieval with an empty googleSearch:

  const modelParams: ModelParams = {
    model: 'gemini-2.0-flash-exp',
    tools: [
      { googleSearch: {} },
    ],
  };

Simply replacing the field name would result in this error:

Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent: [400 Bad Request] Invalid JSON payload received. Unknown name "dynamicRetrievalConfig" at 'tools[0].google_search': Cannot find field.

[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"tools[0].google_search","description":"Invalid JSON payload received. Unknown name "dynamicRetrievalConfig" at 'tools[0].google_search': Cannot find field."}]}]

Actual vs expected behavior:

Expected behavior: the documentation, sample code, and type definition should be updated to use googleSearch field.

Thank you.

@Leask
Copy link

Leask commented Jan 30, 2025

The issue is fixed, but no one has merged it: #318

@Gunand3043 Gunand3043 added type:bug Something isn't working status:triaged Issue/PR triaged to the corresponding sub-team component:js sdk Issue/PR related to JavaScript SDK labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:js sdk Issue/PR related to JavaScript SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants