Skip to content

Commit

Permalink
delete additional_parameters in google tools and response format
Browse files Browse the repository at this point in the history
  • Loading branch information
narengogi committed Dec 31, 2024
1 parent 70524ae commit e1354dc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/providers/google/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit e1354dc

Please sign in to comment.