Skip to content

Commit a330fb5

Browse files
authored
chore(js/plugins/googleai): added google search options to gemini config schema (#2938)
1 parent 38529ff commit a330fb5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

js/plugins/googleai/src/gemini.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
GenerationConfig,
2929
GenerativeModel,
3030
GoogleGenerativeAI,
31+
GoogleSearchRetrievalTool,
3132
InlineDataPart,
3233
RequestOptions,
3334
Schema,
@@ -132,6 +133,12 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({
132133
"'gemini-2.0-flash-exp' model at present."
133134
)
134135
.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(),
135142
}).passthrough();
136143
export type GeminiConfig = z.infer<typeof GeminiConfigSchema>;
137144

@@ -916,6 +923,7 @@ export function defineGoogleAIModel({
916923
codeExecution: codeExecutionFromConfig,
917924
version: versionFromConfig,
918925
functionCallingConfig,
926+
googleSearchRetrieval,
919927
...restOfConfigOptions
920928
} = requestConfig;
921929

@@ -928,6 +936,13 @@ export function defineGoogleAIModel({
928936
});
929937
}
930938

939+
if (googleSearchRetrieval) {
940+
tools.push({
941+
googleSearch:
942+
googleSearchRetrieval === true ? {} : googleSearchRetrieval,
943+
} as GoogleSearchRetrievalTool);
944+
}
945+
931946
let toolConfig: ToolConfig | undefined;
932947
if (functionCallingConfig) {
933948
toolConfig = {

0 commit comments

Comments
 (0)