-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(google-common): Grounding with Google Search and Vertex AI Search #7280
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, and sorry for the delayed review!
See one comment but looks fine otherwise
tools.forEach((tool) => { | ||
if ( | ||
"functionDeclarations" in tool && | ||
Array.isArray(tool.functionDeclarations) | ||
) { | ||
const funcs: GeminiFunctionDeclaration[] = tool.functionDeclarations; | ||
geminiTools[0].functionDeclarations?.push(...funcs); | ||
geminiTools.push({ functionDeclarations: [...funcs] }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vaguely remember this not working due to Google rejecting it - can you add a test using multiple traditional tools? And maybe one using search grounding alongside several tools as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @afirstenberg and @jacoblee93,
Thank you for the review! We’re glad to hear that you appreciate our code contribution. We’ll make sure to add the additional test cases as requested. Please note that libs/langchain-google-vertexai/src/tests/chat_models.int.test.ts already includes test cases for grounding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are some known bugs on Google's side about having multiple tools at once - but Google considers this a bug on their end. It should be possible to submit multiple tools at once and mixing functions and other tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this breaks multiple functions, will revert partially
CC @afirstenberg for a peek as well! |
@@ -309,6 +309,8 @@ export interface GeminiContent { | |||
|
|||
export interface GeminiTool { | |||
functionDeclarations?: GeminiFunctionDeclaration[]; | |||
googleSearchRetrieval?: object; | |||
retrieval?: object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have like to see these as actual types or classes rather than as object
, but I don't think this should hold off on merging.
Generally looks good and I'm sorry I missed this two weeks ago. I do suggest making actual types for the possible attributes for LGTM |
…texAIRetrieval for grounding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much!
It's not supported yet from the look of it |
We’ve implemented grounding with Google Search and Vertex AI Search. To use this feature, simply call
.bindTools([searchRetrievalTool])
on the model and pass in the appropriatesearchRetrievalTool
object, as defined in the Google Cloud documentation on grounding, depending on the type of grounding you want to use.Here are the implementation details:
googleSearchRetrieval
andretrieval
parameters toGeminiTool
.convertToGeminiTools
andformatTools
previously supported only one tool type (functionDeclarations
), but we’ve refactored them to handle these two new tools.structuredToolsToGeminiTools
function has been removed; its logic is now consolidated withinformatTools
.We've also added test cases and documentation changes.
Twitter handle: @renathossain
Fixes #5073