From b0167d6480dc740385a6474716c58a58e67bd728 Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Tue, 24 Dec 2024 15:17:27 +0530 Subject: [PATCH] #837 delete unsupported fields in gemini models tool definitions --- src/providers/google-vertex-ai/chatComplete.ts | 4 ++++ src/providers/google/chatComplete.ts | 4 ++++ src/types/requestBody.ts | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/providers/google-vertex-ai/chatComplete.ts b/src/providers/google-vertex-ai/chatComplete.ts index c428e4bd6..49d6da853 100644 --- a/src/providers/google-vertex-ai/chatComplete.ts +++ b/src/providers/google-vertex-ai/chatComplete.ts @@ -269,6 +269,10 @@ export const VertexGoogleChatCompleteConfig: ProviderConfig = { const tools: any = []; params.tools?.forEach((tool) => { if (tool.type === 'function') { + // these are not supported by google + delete tool.function?.parameters?.properties?.additional_properties; + delete tool.function?.strict; + if (tool.function.name === 'googleSearchRetrieval') { tools.push(buildGoogleSearchRetrievalTool(tool)); } else { diff --git a/src/providers/google/chatComplete.ts b/src/providers/google/chatComplete.ts index 44937db3f..1b50311dd 100644 --- a/src/providers/google/chatComplete.ts +++ b/src/providers/google/chatComplete.ts @@ -329,6 +329,10 @@ export const GoogleChatCompleteConfig: ProviderConfig = { const tools: any = []; params.tools?.forEach((tool) => { if (tool.type === 'function') { + // these are not supported by google + delete tool.function?.parameters?.properties?.additional_properties; + delete tool.function?.strict; + if (tool.function.name === 'googleSearchRetrieval') { tools.push(buildGoogleSearchRetrievalTool(tool)); } else { diff --git a/src/types/requestBody.ts b/src/types/requestBody.ts index 272a7b3aa..17fca4df0 100644 --- a/src/types/requestBody.ts +++ b/src/types/requestBody.ts @@ -279,6 +279,8 @@ export interface Function { description?: string; /** The parameters for the function. */ parameters?: JsonSchema; + /** Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true */ + strict?: boolean; } export interface ToolChoiceObject {