File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import {
28
28
GenerationConfig ,
29
29
GenerativeModel ,
30
30
GoogleGenerativeAI ,
31
+ GoogleSearchRetrievalTool ,
31
32
InlineDataPart ,
32
33
RequestOptions ,
33
34
Schema ,
@@ -132,6 +133,12 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({
132
133
"'gemini-2.0-flash-exp' model at present."
133
134
)
134
135
. optional ( ) ,
136
+ googleSearchRetrieval : z
137
+ . union ( [ z . boolean ( ) , z . object ( { } ) . passthrough ( ) ] )
138
+ . describe (
139
+ 'Retrieve public web data for grounding, powered by Google Search.'
140
+ )
141
+ . optional ( ) ,
135
142
} ) . passthrough ( ) ;
136
143
export type GeminiConfig = z . infer < typeof GeminiConfigSchema > ;
137
144
@@ -916,6 +923,7 @@ export function defineGoogleAIModel({
916
923
codeExecution : codeExecutionFromConfig ,
917
924
version : versionFromConfig ,
918
925
functionCallingConfig,
926
+ googleSearchRetrieval,
919
927
...restOfConfigOptions
920
928
} = requestConfig ;
921
929
@@ -928,6 +936,13 @@ export function defineGoogleAIModel({
928
936
} ) ;
929
937
}
930
938
939
+ if ( googleSearchRetrieval ) {
940
+ tools . push ( {
941
+ googleSearch :
942
+ googleSearchRetrieval === true ? { } : googleSearchRetrieval ,
943
+ } as GoogleSearchRetrievalTool ) ;
944
+ }
945
+
931
946
let toolConfig : ToolConfig | undefined ;
932
947
if ( functionCallingConfig ) {
933
948
toolConfig = {
You can’t perform that action at this time.
0 commit comments