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

Support "Grounding with Google Search" in Google provider #3553

Open
wong2 opened this issue Nov 8, 2024 · 7 comments
Open

Support "Grounding with Google Search" in Google provider #3553

wong2 opened this issue Nov 8, 2024 · 7 comments
Assignees
Labels
ai/provider enhancement New feature or request

Comments

@wong2
Copy link
Contributor

wong2 commented Nov 8, 2024

Feature Description

The Gemini API has a new feature where you can ground results with Google search which reduces hallucinations and provides references to content:
https://ai.google.dev/gemini-api/docs/grounding

@wong2 wong2 changed the title Support Grounding with Google Search in Google provider Support "Grounding with Google Search" in Google provider Nov 8, 2024
@wong2 wong2 changed the title Support "Grounding with Google Search" in Google provider Support _Grounding with Google Search_ in Google provider Nov 8, 2024
@wong2 wong2 changed the title Support _Grounding with Google Search_ in Google provider Support "Grounding with Google Search" in Google provider Nov 8, 2024
@adolphnov
Copy link

I have tried vertex is valid, it will report an error in Google AI Studio, which does not support this parameter. And note that when used in the vertex, no tools can be included, otherwise an error will also be reported.
I hope this is helpful to you.

@lgrammel lgrammel added enhancement New feature or request ai/provider labels Nov 11, 2024
@lgrammel
Copy link
Collaborator

lgrammel commented Dec 9, 2024

@shaper do we support this with the latest provider versions?

@shaper
Copy link
Contributor

shaper commented Dec 9, 2024

We do support grounding with the Google Vertex 2.0+ google-vertex provider if you pass useSearchGrounding: true in the provider settings. It is still early support, we would value your input on how you need or would like to use it.

I also observed that grounding and tool use are mutually exclusive -- if you specify grounding you cannot specify additional tools with a Google-API-side restriction error. I believe the Vertex provider will ignore other tools if you specify grounding.

Notes on the current implementation:

  • we don't currently parse and include the grounding metadata in the response yet with the references to content (we should do this of course)
  • the configuration allowing you to specify a threshold looks new and we don't support this yet:
"dynamicRetrievalConfig": {
  "mode": "MODE_DYNAMIC",
  "dynamicThreshold": DYNAMIC_THRESHOLD
}
  • per the above the GenAI API (google provider) may now support grounding, we'd need to validate/add support for that, at the time of implementation I believe it was Vertex-only and so it is not present in google
  • there is add'l support possible in Vertex to allow grounding vs your own enterprise data which would require further work

@shaper
Copy link
Contributor

shaper commented Dec 12, 2024

The above changes were just published to the package versions in #4081

This enables search grounding support in the Google Generative AI google package, similar to what we've had in Google Vertex.

We plan to add support for customizing the dynamic retrieval config soon. At that time I would consider this issue complete. If there is interest in the enterprise data support mentioned above please file that as a separate issue.

@wottpal
Copy link

wottpal commented Dec 17, 2024

Hey there, dope addition! Just played with it a bit and got it to work pretty well.

Some observations though:

  1. It doesn't seem to work with generateObject, only generateText. At least I was not able to force the model to actually DO search when generating object output. Is that related to mutual exclusiveness with tool calls, you're mentioning above, @shaper? If yes, it should probably be mentioned in the docs.
  2. Being able to set the dynamic retrieval threshold is crucial for a lot of use cases IMO. Because in my observations the model sometimes tends to NOT google even though I nudge it towards it in my prompt a lot. Would be amazing to see this soon.

Lmk whether I should open separate issues for those if you want to close this one.

@shaper
Copy link
Contributor

shaper commented Dec 22, 2024

Hey there, dope addition! Just played with it a bit and got it to work pretty well.

Some observations though:

  1. It doesn't seem to work with generateObject, only generateText. At least I was not able to force the model to actually DO search when generating object output. Is that related to mutual exclusiveness with tool calls, you're mentioning above, @shaper? If yes, it should probably be mentioned in the docs.

Yes, probably -- I will check this and update docs if needed.

  1. Being able to set the dynamic retrieval threshold is crucial for a lot of use cases IMO. Because in my observations the model sometimes tends to NOT google even though I nudge it towards it in my prompt a lot. Would be amazing to see this soon.

It is on my radar, will try to get to it soon.

Lmk whether I should open separate issues for those if you want to close this one.

No need, let's keep this one for now.

@sroze
Copy link

sroze commented Dec 30, 2024

I just created another issue (and a proposed implementation plan) for the "enterprise" feature of grounding in your own data:
#4230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/provider enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants