Skip to content

Commit c178cba

Browse files
authored
Merge pull request #1443 from Portkey-AI/feature/gemini-thought-message
thought messages support for gemini 3 pro
2 parents 8266e4d + fa63fd6 commit c178cba

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/providers/google-vertex-ai/chatComplete.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ export const VertexGoogleChatCompleteConfig: ProviderConfig = {
9191
functionCall: {
9292
name: tool_call.function.name,
9393
args: JSON.parse(tool_call.function.arguments),
94+
...(tool_call.function.thought_signature && {
95+
thought_signature: tool_call.function.thought_signature,
96+
}),
9497
},
9598
});
9699
});
@@ -467,6 +470,10 @@ export const GoogleChatCompleteResponseTransform: (
467470
function: {
468471
name: part.functionCall.name,
469472
arguments: JSON.stringify(part.functionCall.args),
473+
...(!strictOpenAiCompliance &&
474+
part.thoughtSignature && {
475+
thought_signature: part.thoughtSignature,
476+
}),
470477
},
471478
});
472479
} else if (part.text) {
@@ -698,6 +705,10 @@ export const GoogleChatCompleteStreamChunkTransform: (
698705
function: {
699706
name: part.functionCall.name,
700707
arguments: JSON.stringify(part.functionCall.args),
708+
...(!strictOpenAiCompliance &&
709+
part.thoughtSignature && {
710+
thought_signature: part.thoughtSignature,
711+
}),
701712
},
702713
};
703714
}

src/providers/google-vertex-ai/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface GoogleResponseCandidate {
2424
mimeType: string;
2525
data: string;
2626
};
27+
thoughtSignature?: string;
2728
}[];
2829
};
2930
logprobsResult?: {

src/providers/google/chatComplete.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ export const GoogleChatCompleteConfig: ProviderConfig = {
219219
functionCall: {
220220
name: tool_call.function.name,
221221
args: JSON.parse(tool_call.function.arguments),
222+
...(tool_call.function.thought_signature && {
223+
thought_signature: tool_call.function.thought_signature,
224+
}),
222225
},
223226
});
224227
});
@@ -472,6 +475,7 @@ export interface GoogleResponseCandidate {
472475
mimeType: string;
473476
data: string;
474477
};
478+
thoughtSignature?: string;
475479
}[];
476480
};
477481
logprobsResult?: {
@@ -603,6 +607,10 @@ export const GoogleChatCompleteResponseTransform: (
603607
function: {
604608
name: part.functionCall.name,
605609
arguments: JSON.stringify(part.functionCall.args),
610+
...(!strictOpenAiCompliance &&
611+
part.thoughtSignature && {
612+
thought_signature: part.thoughtSignature,
613+
}),
606614
},
607615
});
608616
} else if (part.text) {
@@ -785,6 +793,10 @@ export const GoogleChatCompleteStreamChunkTransform: (
785793
function: {
786794
name: part.functionCall.name,
787795
arguments: JSON.stringify(part.functionCall.args),
796+
...(!strictOpenAiCompliance &&
797+
part.thoughtSignature && {
798+
thought_signature: part.thoughtSignature,
799+
}),
788800
},
789801
};
790802
}

src/types/requestBody.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ export interface ToolCall {
265265
name: string;
266266
arguments: string;
267267
description?: string;
268+
thought_signature?: string;
268269
};
269270
}
270271

0 commit comments

Comments
 (0)