Skip to content

Commit 356b843

Browse files
MarkDaoustcopybara-github
authored andcommitted
fix: Don't generate warnings from response.text property because of thought_signature.
PiperOrigin-RevId: 830699329
1 parent 8937903 commit 356b843

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,6 +2597,7 @@ export class GenerateContentResponse {
25972597
if (
25982598
fieldName !== 'text' &&
25992599
fieldName !== 'thought' &&
2600+
fieldName !== 'thoughtSignature' &&
26002601
(fieldValue !== null || fieldValue !== undefined)
26012602
) {
26022603
nonTextParts.push(fieldName);

test/unit/types_test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,39 @@ describe('GenerateContentResponse.text', () => {
117117
},
118118
} as Candidate,
119119
];
120+
120121
expect(response.text).toBe('Hello ');
121122
});
123+
124+
it('should not warn when thought_signature is present', () => {
125+
const response = new GenerateContentResponse();
126+
response.candidates = [
127+
{
128+
content: {
129+
parts: [{text: 'Hello '}, {thoughtSignature: 'thought'}],
130+
},
131+
} as Candidate,
132+
];
133+
spyOn(console, 'warn');
134+
135+
expect(response.text).toEqual('Hello ');
136+
expect(console.warn).not.toHaveBeenCalled();
137+
});
138+
139+
it('should not warn when thought_signature is present in a text part', () => {
140+
const response = new GenerateContentResponse();
141+
response.candidates = [
142+
{
143+
content: {
144+
parts: [{text: 'Hello ', thoughtSignature: 'thought'}],
145+
},
146+
} as Candidate,
147+
];
148+
spyOn(console, 'warn');
149+
150+
expect(response.text).toEqual('Hello ');
151+
expect(console.warn).not.toHaveBeenCalled();
152+
});
122153
});
123154

124155
describe('GenerateContentResponse.data', () => {

0 commit comments

Comments
 (0)