From e1354dce869f6044958b1c18354f435fd9f703c3 Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Tue, 31 Dec 2024 08:08:56 +0530 Subject: [PATCH] delete additional_parameters in google tools and response format --- src/providers/google/chatComplete.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/providers/google/chatComplete.ts b/src/providers/google/chatComplete.ts index 695bc3b9..2e53d52a 100644 --- a/src/providers/google/chatComplete.ts +++ b/src/providers/google/chatComplete.ts @@ -8,7 +8,11 @@ import { ToolChoice, } from '../../types/requestBody'; import { buildGoogleSearchRetrievalTool } from '../google-vertex-ai/chatComplete'; -import { derefer, getMimeType } from '../google-vertex-ai/utils'; +import { + derefer, + getMimeType, + recursivelyDeleteUnsupportedParameters, +} from '../google-vertex-ai/utils'; import { ChatCompletionResponse, ErrorResponse, @@ -44,6 +48,9 @@ const transformGenerationConfig = (params: Params) => { } if (params?.response_format?.type === 'json_schema') { generationConfig['responseMimeType'] = 'application/json'; + recursivelyDeleteUnsupportedParameters( + params?.response_format?.json_schema?.schema + ); let schema = params?.response_format?.json_schema?.schema ?? params?.response_format?.json_schema; @@ -330,10 +337,7 @@ export const GoogleChatCompleteConfig: ProviderConfig = { params.tools?.forEach((tool) => { if (tool.type === 'function') { // these are not supported by google - delete tool.function?.parameters?.additional_properties; - delete tool.function?.parameters?.additionalProperties; - delete tool.function?.parameters?.properties?.additional_properties; - delete tool.function?.parameters?.properties?.additionalProperties; + recursivelyDeleteUnsupportedParameters(tool.function?.parameters); delete tool.function?.strict; if (tool.function.name === 'googleSearchRetrieval') {