16
16
*/
17
17
18
18
import { Content , FunctionCall , InlineDataPart } from './content' ;
19
- import { BlockReason , FinishReason , HarmCategory , HarmProbability , HarmSeverity } from './enums' ;
19
+ import {
20
+ BlockReason ,
21
+ FinishReason ,
22
+ HarmCategory ,
23
+ HarmProbability ,
24
+ HarmSeverity ,
25
+ Modality ,
26
+ } from './enums' ;
20
27
21
28
/**
22
29
* Result object returned from {@link GenerativeModel.generateContent} call.
@@ -77,14 +84,28 @@ export interface GenerateContentResponse {
77
84
}
78
85
79
86
/**
80
- * Usage metadata about a <code> {@link GenerateContentResponse}</code> .
87
+ * Usage metadata about a {@link GenerateContentResponse}.
81
88
*
82
89
* @public
83
90
*/
84
91
export interface UsageMetadata {
85
92
promptTokenCount : number ;
86
93
candidatesTokenCount : number ;
87
94
totalTokenCount : number ;
95
+ promptTokensDetails ?: ModalityTokenCount [ ] ;
96
+ candidatesTokensDetails ?: ModalityTokenCount [ ] ;
97
+ }
98
+
99
+ /**
100
+ * Represents token counting info for a single modality.
101
+ *
102
+ * @public
103
+ */
104
+ export interface ModalityTokenCount {
105
+ /** The modality associated with this token count. */
106
+ modality : Modality ;
107
+ /** The number of tokens counted. */
108
+ tokenCount : number ;
88
109
}
89
110
90
111
/**
@@ -95,11 +116,16 @@ export interface UsageMetadata {
95
116
export interface PromptFeedback {
96
117
blockReason ?: BlockReason ;
97
118
safetyRatings : SafetyRating [ ] ;
119
+ /**
120
+ * A human-readable description of the `blockReason`.
121
+ *
122
+ * This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
123
+ */
98
124
blockReasonMessage ?: string ;
99
125
}
100
126
101
127
/**
102
- * A candidate returned as part of a <code> {@link GenerateContentResponse}</code> .
128
+ * A candidate returned as part of a {@link GenerateContentResponse}.
103
129
* @public
104
130
*/
105
131
export interface GenerateContentCandidate {
@@ -113,7 +139,7 @@ export interface GenerateContentCandidate {
113
139
}
114
140
115
141
/**
116
- * Citation metadata that may be found on a <code> {@link GenerateContentCandidate}</code> .
142
+ * Citation metadata that may be found on a {@link GenerateContentCandidate}.
117
143
* @public
118
144
*/
119
145
export interface CitationMetadata {
@@ -129,7 +155,17 @@ export interface Citation {
129
155
endIndex ?: number ;
130
156
uri ?: string ;
131
157
license ?: string ;
158
+ /**
159
+ * The title of the cited source, if available.
160
+ *
161
+ * This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
162
+ */
132
163
title ?: string ;
164
+ /**
165
+ * The publication date of the cited source, if available.
166
+ *
167
+ * This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
168
+ */
133
169
publicationDate ?: Date ;
134
170
}
135
171
@@ -140,10 +176,14 @@ export interface Citation {
140
176
export interface GroundingMetadata {
141
177
webSearchQueries ?: string [ ] ;
142
178
retrievalQueries ?: string [ ] ;
179
+ /**
180
+ * @deprecated
181
+ */
143
182
groundingAttributions : GroundingAttribution [ ] ;
144
183
}
145
184
146
185
/**
186
+ * @deprecated
147
187
* @public
148
188
*/
149
189
export interface GroundingAttribution {
@@ -189,14 +229,32 @@ export interface Date {
189
229
}
190
230
191
231
/**
192
- * A safety rating associated with a <code> {@link GenerateContentCandidate}</code>
232
+ * A safety rating associated with a {@link GenerateContentCandidate}
193
233
* @public
194
234
*/
195
235
export interface SafetyRating {
196
236
category : HarmCategory ;
197
237
probability : HarmProbability ;
238
+ /**
239
+ * The harm severity level.
240
+ *
241
+ * This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
242
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to `HarmSeverity.UNSUPPORTED`.
243
+ */
198
244
severity : HarmSeverity ;
245
+ /**
246
+ * The probability score of the harm category.
247
+ *
248
+ * This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
249
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
250
+ */
199
251
probabilityScore : number ;
252
+ /**
253
+ * The severity score of the harm category.
254
+ *
255
+ * This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
256
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
257
+ */
200
258
severityScore : number ;
201
259
blocked : boolean ;
202
260
}
@@ -213,6 +271,13 @@ export interface CountTokensResponse {
213
271
/**
214
272
* The total number of billable characters counted across all instances
215
273
* from the request.
274
+ *
275
+ * This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
276
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
216
277
*/
217
278
totalBillableCharacters ?: number ;
279
+ /**
280
+ * The breakdown, by modality, of how many tokens are consumed by the prompt.
281
+ */
282
+ promptTokensDetails ?: ModalityTokenCount [ ] ;
218
283
}
0 commit comments