Skip to content

Commit

Permalink
#837 delete unsupported fields in gemini models tool definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
narengogi committed Dec 24, 2024
1 parent 82df813 commit b0167d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/providers/google-vertex-ai/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/providers/google/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/types/requestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b0167d6

Please sign in to comment.