diff --git a/js/plugins/google-genai/src/googleai/gemini.ts b/js/plugins/google-genai/src/googleai/gemini.ts index 9d7195b3f0..d4df65aa01 100644 --- a/js/plugins/google-genai/src/googleai/gemini.ts +++ b/js/plugins/google-genai/src/googleai/gemini.ts @@ -64,21 +64,23 @@ import { /** * See https://ai.google.dev/gemini-api/docs/safety-settings#safety-filters. */ -const SafetySettingsSchema = z.object({ - category: z.enum([ - 'HARM_CATEGORY_UNSPECIFIED', - 'HARM_CATEGORY_HATE_SPEECH', - 'HARM_CATEGORY_SEXUALLY_EXPLICIT', - 'HARM_CATEGORY_HARASSMENT', - 'HARM_CATEGORY_DANGEROUS_CONTENT', - ]), - threshold: z.enum([ - 'BLOCK_LOW_AND_ABOVE', - 'BLOCK_MEDIUM_AND_ABOVE', - 'BLOCK_ONLY_HIGH', - 'BLOCK_NONE', - ]), -}); +const SafetySettingsSchema = z + .object({ + category: z.enum([ + 'HARM_CATEGORY_UNSPECIFIED', + 'HARM_CATEGORY_HATE_SPEECH', + 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + 'HARM_CATEGORY_HARASSMENT', + 'HARM_CATEGORY_DANGEROUS_CONTENT', + ]), + threshold: z.enum([ + 'BLOCK_LOW_AND_ABOVE', + 'BLOCK_MEDIUM_AND_ABOVE', + 'BLOCK_ONLY_HIGH', + 'BLOCK_NONE', + ]), + }) + .passthrough(); const VoiceConfigSchema = z .object({ @@ -169,6 +171,7 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ 'predict a function call and guarantee function schema adherence. ' + 'With NONE, the model is prohibited from making function calls.' ) + .passthrough() .optional(), responseModalities: z .array(z.enum(['TEXT', 'IMAGE', 'AUDIO'])) @@ -225,6 +228,7 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ ) .optional(), }) + .passthrough() .optional(), }).passthrough(); export type GeminiConfigSchemaType = typeof GeminiConfigSchema; diff --git a/js/plugins/google-genai/src/vertexai/gemini.ts b/js/plugins/google-genai/src/vertexai/gemini.ts index 383535f445..4f56d0388f 100644 --- a/js/plugins/google-genai/src/vertexai/gemini.ts +++ b/js/plugins/google-genai/src/vertexai/gemini.ts @@ -61,63 +61,70 @@ import { modelName, } from './utils.js'; -export const SafetySettingsSchema = z.object({ - category: z.enum([ - /** The harm category is unspecified. */ - 'HARM_CATEGORY_UNSPECIFIED', - /** The harm category is hate speech. */ - 'HARM_CATEGORY_HATE_SPEECH', - /** The harm category is dangerous content. */ - 'HARM_CATEGORY_DANGEROUS_CONTENT', - /** The harm category is harassment. */ - 'HARM_CATEGORY_HARASSMENT', - /** The harm category is sexually explicit content. */ - 'HARM_CATEGORY_SEXUALLY_EXPLICIT', - ]), - threshold: z.enum([ - 'BLOCK_LOW_AND_ABOVE', - 'BLOCK_MEDIUM_AND_ABOVE', - 'BLOCK_ONLY_HIGH', - 'BLOCK_NONE', - ]), -}); - -const VertexRetrievalSchema = z.object({ - datastore: z - .object({ - projectId: z.string().describe('Google Cloud Project ID.').optional(), - location: z - .string() - .describe('Google Cloud region e.g. us-central1.') - .optional(), - dataStoreId: z - .string() - .describe( - 'The data store id, when project id and location are provided as ' + - 'separate options. Alternatively, the full path to the data ' + - 'store should be provided in the form: "projects/{project}/' + - 'locations/{location}/collections/default_collection/dataStores/{data_store}".' - ), - }) - .describe('Vertex AI Search data store details'), - disableAttribution: z - .boolean() - .describe( - 'Disable using the search data in detecting grounding attribution. This ' + - 'does not affect how the result is given to the model for generation.' - ) - .optional(), -}); - -const GoogleSearchRetrievalSchema = z.object({ - disableAttribution: z - .boolean() - .describe( - 'Disable using the search data in detecting grounding attribution. This ' + - 'does not affect how the result is given to the model for generation.' - ) - .optional(), -}); +export const SafetySettingsSchema = z + .object({ + category: z.enum([ + /** The harm category is unspecified. */ + 'HARM_CATEGORY_UNSPECIFIED', + /** The harm category is hate speech. */ + 'HARM_CATEGORY_HATE_SPEECH', + /** The harm category is dangerous content. */ + 'HARM_CATEGORY_DANGEROUS_CONTENT', + /** The harm category is harassment. */ + 'HARM_CATEGORY_HARASSMENT', + /** The harm category is sexually explicit content. */ + 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + ]), + threshold: z.enum([ + 'BLOCK_LOW_AND_ABOVE', + 'BLOCK_MEDIUM_AND_ABOVE', + 'BLOCK_ONLY_HIGH', + 'BLOCK_NONE', + ]), + }) + .passthrough(); + +const VertexRetrievalSchema = z + .object({ + datastore: z + .object({ + projectId: z.string().describe('Google Cloud Project ID.').optional(), + location: z + .string() + .describe('Google Cloud region e.g. us-central1.') + .optional(), + dataStoreId: z + .string() + .describe( + 'The data store id, when project id and location are provided as ' + + 'separate options. Alternatively, the full path to the data ' + + 'store should be provided in the form: "projects/{project}/' + + 'locations/{location}/collections/default_collection/dataStores/{data_store}".' + ), + }) + .describe('Vertex AI Search data store details') + .passthrough(), + disableAttribution: z + .boolean() + .describe( + 'Disable using the search data in detecting grounding attribution. This ' + + 'does not affect how the result is given to the model for generation.' + ) + .optional(), + }) + .passthrough(); + +const GoogleSearchRetrievalSchema = z + .object({ + disableAttribution: z + .boolean() + .describe( + 'Disable using the search data in detecting grounding attribution. This ' + + 'does not affect how the result is given to the model for generation.' + ) + .optional(), + }) + .passthrough(); /** * Zod schema of Gemini model options. @@ -254,6 +261,7 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ 'predict a function call and guarantee function schema adherence. ' + 'With NONE, the model is prohibited from making function calls.' ) + .passthrough() .optional(), /** * Retrieval config for search grounding and maps grounding @@ -276,6 +284,7 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ */ languageCode: z.string().optional(), }) + .passthrough() .optional(), thinkingConfig: z .object({ @@ -302,6 +311,7 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ ) .optional(), }) + .passthrough() .optional(), }).passthrough(); export type GeminiConfigSchemaType = typeof GeminiConfigSchema; diff --git a/js/plugins/google-genai/src/vertexai/imagen.ts b/js/plugins/google-genai/src/vertexai/imagen.ts index 6e1c399096..5b4e893791 100644 --- a/js/plugins/google-genai/src/vertexai/imagen.ts +++ b/js/plugins/google-genai/src/vertexai/imagen.ts @@ -125,6 +125,7 @@ export const ImagenConfigSchema = GenerationCommonConfigSchema.extend({ 'needing to provide one. Consequently, when you provide ' + 'this parameter you can omit a mask object.' ) + .passthrough() .optional(), maskDilation: z .number() @@ -158,6 +159,7 @@ export const ImagenConfigSchema = GenerationCommonConfigSchema.extend({ .describe('The factor to upscale the image.'), }) .describe('Configuration for upscaling.') + .passthrough() .optional(), }).passthrough(); export type ImagenConfigSchemaType = typeof ImagenConfigSchema;