File tree Expand file tree Collapse file tree 5 files changed +53
-4
lines changed Expand file tree Collapse file tree 5 files changed +53
-4
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,8 @@ export interface EnhancedGenerateContentResponse extends GenerateContentResponse
208
208
functionCalls: () => FunctionCall [] | undefined ;
209
209
inlineDataParts: () => InlineDataPart [] | undefined ;
210
210
text: () => string ;
211
+ // (undocumented)
212
+ thoughtSummary: () => string | undefined ;
211
213
}
212
214
213
215
// @public
@@ -240,6 +242,10 @@ export interface FileDataPart {
240
242
inlineData? : never ;
241
243
// (undocumented)
242
244
text? : never ;
245
+ // (undocumented)
246
+ thought? : boolean ;
247
+ // (undocumented)
248
+ thoughtSignature? : string ;
243
249
}
244
250
245
251
// @public
@@ -294,6 +300,10 @@ export interface FunctionCallPart {
294
300
inlineData? : never ;
295
301
// (undocumented)
296
302
text? : never ;
303
+ // (undocumented)
304
+ thought? : boolean ;
305
+ // (undocumented)
306
+ thoughtSignature? : string ;
297
307
}
298
308
299
309
// @public
@@ -326,6 +336,10 @@ export interface FunctionResponsePart {
326
336
inlineData? : never ;
327
337
// (undocumented)
328
338
text? : never ;
339
+ // (undocumented)
340
+ thought? : boolean ;
341
+ // (undocumented)
342
+ thoughtSignature? : string ;
329
343
}
330
344
331
345
// @public
@@ -691,6 +705,10 @@ export interface InlineDataPart {
691
705
inlineData: GenerativeContentBlob ;
692
706
// (undocumented)
693
707
text? : never ;
708
+ // (undocumented)
709
+ thought? : boolean ;
710
+ // (undocumented)
711
+ thoughtSignature? : string ;
694
712
videoMetadata? : VideoMetadata ;
695
713
}
696
714
@@ -957,10 +975,15 @@ export interface TextPart {
957
975
inlineData? : never ;
958
976
// (undocumented)
959
977
text: string ;
978
+ // (undocumented)
979
+ thought? : boolean ;
980
+ // (undocumented)
981
+ thoughtSignature? : string ;
960
982
}
961
983
962
984
// @public
963
985
export interface ThinkingConfig {
986
+ includeThoughts? : boolean ;
964
987
thinkingBudget? : number ;
965
988
}
966
989
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export function addHelpers(
78
78
}
79
79
) ;
80
80
}
81
- return getText ( response ) ;
81
+ return getText ( response , false ) ;
82
82
} else if ( response . promptFeedback ) {
83
83
throw new AIError (
84
84
AIErrorCode . RESPONSE_ERROR ,
@@ -160,13 +160,19 @@ export function addHelpers(
160
160
}
161
161
162
162
/**
163
- * Returns all text found in all parts of first candidate.
163
+ * Returns all text from the first candidate's parts, filtering by whether they
164
+ * are part of the model's 'thought' process.
165
+ *
166
+ * @param response - The {@link GenerateContentResponse} from which to extract text.
167
+ * @param isThought - If `true`, extracts text from `thought` parts of the response,
168
+ * which represent the model's internal reasoning. If `false`, extracts text from
169
+ * regular response parts.
164
170
*/
165
- export function getText ( response : GenerateContentResponse ) : string {
171
+ export function getText ( response : GenerateContentResponse , isThought : boolean ) : string {
166
172
const textStrings = [ ] ;
167
173
if ( response . candidates ?. [ 0 ] . content ?. parts ) {
168
174
for ( const part of response . candidates ?. [ 0 ] . content ?. parts ) {
169
- if ( part . text ) {
175
+ if ( part . text && ( part . thought ?? false ) === isThought ) {
170
176
textStrings . push ( part . text ) ;
171
177
}
172
178
}
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ export interface TextPart {
47
47
inlineData ?: never ;
48
48
functionCall ?: never ;
49
49
functionResponse ?: never ;
50
+ thought ?: boolean ;
51
+ thoughtSignature ?: string ;
50
52
}
51
53
52
54
/**
@@ -62,6 +64,8 @@ export interface InlineDataPart {
62
64
* Applicable if `inlineData` is a video.
63
65
*/
64
66
videoMetadata ?: VideoMetadata ;
67
+ thought ?: boolean ;
68
+ thoughtSignature ?: string ;
65
69
}
66
70
67
71
/**
@@ -90,6 +94,8 @@ export interface FunctionCallPart {
90
94
inlineData ?: never ;
91
95
functionCall : FunctionCall ;
92
96
functionResponse ?: never ;
97
+ thought ?: boolean ;
98
+ thoughtSignature ?: string ;
93
99
}
94
100
95
101
/**
@@ -101,6 +107,8 @@ export interface FunctionResponsePart {
101
107
inlineData ?: never ;
102
108
functionCall ?: never ;
103
109
functionResponse : FunctionResponse ;
110
+ thought ?: boolean ;
111
+ thoughtSignature ?: string ;
104
112
}
105
113
106
114
/**
@@ -113,6 +121,8 @@ export interface FileDataPart {
113
121
functionCall ?: never ;
114
122
functionResponse ?: never ;
115
123
fileData : FileData ;
124
+ thought ?: boolean ;
125
+ thoughtSignature ?: string ;
116
126
}
117
127
118
128
/**
Original file line number Diff line number Diff line change @@ -294,4 +294,13 @@ export interface ThinkingConfig {
294
294
* feature or if the specified budget is not within the model's supported range.
295
295
*/
296
296
thinkingBudget ?: number ;
297
+
298
+ /**
299
+ * Whether to include "thought summaries" in the model's response.
300
+ *
301
+ * Thought summaries provide a brief overview of the model's internal thinking process,
302
+ * offering insight into how it arrived at the final answer. This can be useful for
303
+ * debugging, understanding the model's reasoning, and verifying its accuracy.
304
+ */
305
+ includeThoughts ?: boolean ;
297
306
}
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export interface EnhancedGenerateContentResponse
69
69
*/
70
70
inlineDataParts : ( ) => InlineDataPart [ ] | undefined ;
71
71
functionCalls : ( ) => FunctionCall [ ] | undefined ;
72
+ thoughtSummary : ( ) => string | undefined ;
72
73
}
73
74
74
75
/**
You can’t perform that action at this time.
0 commit comments