@@ -31,229 +31,284 @@ export const POSSIBLE_ROLES = ['user', 'model', 'function', 'system'] as const;
31
31
* Harm categories that would cause prompts or candidates to be blocked.
32
32
* @public
33
33
*/
34
- export enum HarmCategory {
35
- HARM_CATEGORY_HATE_SPEECH = 'HARM_CATEGORY_HATE_SPEECH' ,
36
- HARM_CATEGORY_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_SEXUALLY_EXPLICIT' ,
37
- HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT' ,
38
- HARM_CATEGORY_DANGEROUS_CONTENT = 'HARM_CATEGORY_DANGEROUS_CONTENT'
39
- }
34
+ export const HarmCategory = {
35
+ HARM_CATEGORY_HATE_SPEECH : 'HARM_CATEGORY_HATE_SPEECH' ,
36
+ HARM_CATEGORY_SEXUALLY_EXPLICIT : 'HARM_CATEGORY_SEXUALLY_EXPLICIT' ,
37
+ HARM_CATEGORY_HARASSMENT : 'HARM_CATEGORY_HARASSMENT' ,
38
+ HARM_CATEGORY_DANGEROUS_CONTENT : 'HARM_CATEGORY_DANGEROUS_CONTENT'
39
+ } as const ;
40
+
41
+ /**
42
+ * Harm categories that would cause prompts or candidates to be blocked.
43
+ * @public
44
+ */
45
+ export type HarmCategory = ( typeof HarmCategory ) [ keyof typeof HarmCategory ] ;
40
46
41
47
/**
42
48
* Threshold above which a prompt or candidate will be blocked.
43
49
* @public
44
50
*/
45
- export enum HarmBlockThreshold {
51
+ export const HarmBlockThreshold = {
46
52
/**
47
53
* Content with `NEGLIGIBLE` will be allowed.
48
54
*/
49
- BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE' ,
55
+ BLOCK_LOW_AND_ABOVE : 'BLOCK_LOW_AND_ABOVE' ,
50
56
/**
51
57
* Content with `NEGLIGIBLE` and `LOW` will be allowed.
52
58
*/
53
- BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE' ,
59
+ BLOCK_MEDIUM_AND_ABOVE : 'BLOCK_MEDIUM_AND_ABOVE' ,
54
60
/**
55
61
* Content with `NEGLIGIBLE`, `LOW`, and `MEDIUM` will be allowed.
56
62
*/
57
- BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH' ,
63
+ BLOCK_ONLY_HIGH : 'BLOCK_ONLY_HIGH' ,
58
64
/**
59
65
* All content will be allowed.
60
66
*/
61
- BLOCK_NONE = 'BLOCK_NONE' ,
67
+ BLOCK_NONE : 'BLOCK_NONE' ,
62
68
/**
63
69
* All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
64
70
* to the {@link HarmCategory} will not be present in the response.
65
71
*/
66
- OFF = 'OFF'
67
- }
72
+ OFF : 'OFF'
73
+ } as const ;
74
+
75
+ /**
76
+ * Threshold above which a prompt or candidate will be blocked.
77
+ * @public
78
+ */
79
+ export type HarmBlockThreshold =
80
+ ( typeof HarmBlockThreshold ) [ keyof typeof HarmBlockThreshold ] ;
68
81
69
82
/**
70
83
* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
71
84
*
72
85
* @public
73
86
*/
74
- export enum HarmBlockMethod {
87
+ export const HarmBlockMethod = {
75
88
/**
76
89
* The harm block method uses both probability and severity scores.
77
90
*/
78
- SEVERITY = 'SEVERITY' ,
91
+ SEVERITY : 'SEVERITY' ,
79
92
/**
80
93
* The harm block method uses the probability score.
81
94
*/
82
- PROBABILITY = 'PROBABILITY'
83
- }
95
+ PROBABILITY : 'PROBABILITY'
96
+ } as const ;
97
+
98
+ /**
99
+ * This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
100
+ *
101
+ * @public
102
+ */
103
+ export type HarmBlockMethod =
104
+ ( typeof HarmBlockMethod ) [ keyof typeof HarmBlockMethod ] ;
84
105
85
106
/**
86
107
* Probability that a prompt or candidate matches a harm category.
87
108
* @public
88
109
*/
89
- export enum HarmProbability {
110
+ export const HarmProbability = {
90
111
/**
91
112
* Content has a negligible chance of being unsafe.
92
113
*/
93
- NEGLIGIBLE = 'NEGLIGIBLE' ,
114
+ NEGLIGIBLE : 'NEGLIGIBLE' ,
94
115
/**
95
116
* Content has a low chance of being unsafe.
96
117
*/
97
- LOW = 'LOW' ,
118
+ LOW : 'LOW' ,
98
119
/**
99
120
* Content has a medium chance of being unsafe.
100
121
*/
101
- MEDIUM = 'MEDIUM' ,
122
+ MEDIUM : 'MEDIUM' ,
102
123
/**
103
124
* Content has a high chance of being unsafe.
104
125
*/
105
- HIGH = 'HIGH'
106
- }
126
+ HIGH : 'HIGH'
127
+ } as const ;
128
+
129
+ /**
130
+ * Probability that a prompt or candidate matches a harm category.
131
+ * @public
132
+ */
133
+ export type HarmProbability =
134
+ ( typeof HarmProbability ) [ keyof typeof HarmProbability ] ;
107
135
108
136
/**
109
137
* Harm severity levels.
110
138
* @public
111
139
*/
112
- export enum HarmSeverity {
140
+ export const HarmSeverity = {
113
141
/**
114
142
* Negligible level of harm severity.
115
143
*/
116
- HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE' ,
144
+ HARM_SEVERITY_NEGLIGIBLE : 'HARM_SEVERITY_NEGLIGIBLE' ,
117
145
/**
118
146
* Low level of harm severity.
119
147
*/
120
- HARM_SEVERITY_LOW = 'HARM_SEVERITY_LOW' ,
148
+ HARM_SEVERITY_LOW : 'HARM_SEVERITY_LOW' ,
121
149
/**
122
150
* Medium level of harm severity.
123
151
*/
124
- HARM_SEVERITY_MEDIUM = 'HARM_SEVERITY_MEDIUM' ,
152
+ HARM_SEVERITY_MEDIUM : 'HARM_SEVERITY_MEDIUM' ,
125
153
/**
126
154
* High level of harm severity.
127
155
*/
128
- HARM_SEVERITY_HIGH = 'HARM_SEVERITY_HIGH' ,
156
+ HARM_SEVERITY_HIGH : 'HARM_SEVERITY_HIGH' ,
129
157
/**
130
158
* Harm severity is not supported.
131
159
*
132
160
* @remarks
133
161
* The GoogleAI backend does not support `HarmSeverity`, so this value is used as a fallback.
134
162
*/
135
- HARM_SEVERITY_UNSUPPORTED = 'HARM_SEVERITY_UNSUPPORTED'
136
- }
163
+ HARM_SEVERITY_UNSUPPORTED : 'HARM_SEVERITY_UNSUPPORTED'
164
+ } as const ;
165
+
166
+ /**
167
+ * Harm severity levels.
168
+ * @public
169
+ */
170
+ export type HarmSeverity = ( typeof HarmSeverity ) [ keyof typeof HarmSeverity ] ;
137
171
138
172
/**
139
173
* Reason that a prompt was blocked.
140
174
* @public
141
175
*/
142
- export enum BlockReason {
176
+ export const BlockReason = {
143
177
/**
144
178
* Content was blocked by safety settings.
145
179
*/
146
- SAFETY = 'SAFETY' ,
180
+ SAFETY : 'SAFETY' ,
147
181
/**
148
182
* Content was blocked, but the reason is uncategorized.
149
183
*/
150
- OTHER = 'OTHER' ,
184
+ OTHER : 'OTHER' ,
151
185
/**
152
186
* Content was blocked because it contained terms from the terminology blocklist.
153
187
*/
154
- BLOCKLIST = 'BLOCKLIST' ,
188
+ BLOCKLIST : 'BLOCKLIST' ,
155
189
/**
156
190
* Content was blocked due to prohibited content.
157
191
*/
158
- PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'
159
- }
192
+ PROHIBITED_CONTENT : 'PROHIBITED_CONTENT'
193
+ } as const ;
194
+
195
+ /**
196
+ * Reason that a prompt was blocked.
197
+ * @public
198
+ */
199
+ export type BlockReason = ( typeof BlockReason ) [ keyof typeof BlockReason ] ;
160
200
161
201
/**
162
202
* Reason that a candidate finished.
163
203
* @public
164
204
*/
165
- export enum FinishReason {
205
+ export const FinishReason = {
166
206
/**
167
207
* Natural stop point of the model or provided stop sequence.
168
208
*/
169
- STOP = 'STOP' ,
209
+ STOP : 'STOP' ,
170
210
/**
171
211
* The maximum number of tokens as specified in the request was reached.
172
212
*/
173
- MAX_TOKENS = 'MAX_TOKENS' ,
213
+ MAX_TOKENS : 'MAX_TOKENS' ,
174
214
/**
175
215
* The candidate content was flagged for safety reasons.
176
216
*/
177
- SAFETY = 'SAFETY' ,
217
+ SAFETY : 'SAFETY' ,
178
218
/**
179
219
* The candidate content was flagged for recitation reasons.
180
220
*/
181
- RECITATION = 'RECITATION' ,
221
+ RECITATION : 'RECITATION' ,
182
222
/**
183
223
* Unknown reason.
184
224
*/
185
- OTHER = 'OTHER' ,
225
+ OTHER : 'OTHER' ,
186
226
/**
187
227
* The candidate content contained forbidden terms.
188
228
*/
189
- BLOCKLIST = 'BLOCKLIST' ,
229
+ BLOCKLIST : 'BLOCKLIST' ,
190
230
/**
191
231
* The candidate content potentially contained prohibited content.
192
232
*/
193
- PROHIBITED_CONTENT = 'PROHIBITED_CONTENT' ,
233
+ PROHIBITED_CONTENT : 'PROHIBITED_CONTENT' ,
194
234
/**
195
235
* The candidate content potentially contained Sensitive Personally Identifiable Information (SPII).
196
236
*/
197
- SPII = 'SPII' ,
237
+ SPII : 'SPII' ,
198
238
/**
199
239
* The function call generated by the model was invalid.
200
240
*/
201
- MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL'
202
- }
241
+ MALFORMED_FUNCTION_CALL : 'MALFORMED_FUNCTION_CALL'
242
+ } as const ;
243
+
244
+ /**
245
+ * Reason that a candidate finished.
246
+ * @public
247
+ */
248
+ export type FinishReason = ( typeof FinishReason ) [ keyof typeof FinishReason ] ;
203
249
204
250
/**
205
251
* @public
206
252
*/
207
- export enum FunctionCallingMode {
253
+ export const FunctionCallingMode = {
208
254
/**
209
255
* Default model behavior; model decides to predict either a function call
210
256
* or a natural language response.
211
257
*/
212
- AUTO = 'AUTO' ,
258
+ AUTO : 'AUTO' ,
213
259
/**
214
260
* Model is constrained to always predicting a function call only.
215
261
* If `allowed_function_names` is set, the predicted function call will be
216
262
* limited to any one of `allowed_function_names`, else the predicted
217
263
* function call will be any one of the provided `function_declarations`.
218
264
*/
219
- ANY = 'ANY' ,
265
+ ANY : 'ANY' ,
220
266
/**
221
267
* Model will not predict any function call. Model behavior is same as when
222
268
* not passing any function declarations.
223
269
*/
224
- NONE = 'NONE'
225
- }
270
+ NONE : 'NONE'
271
+ } as const ;
272
+
273
+ export type FunctionCallingMode =
274
+ ( typeof FunctionCallingMode ) [ keyof typeof FunctionCallingMode ] ;
226
275
227
276
/**
228
277
* Content part modality.
229
278
* @public
230
279
*/
231
- export enum Modality {
280
+ export const Modality = {
232
281
/**
233
282
* Unspecified modality.
234
283
*/
235
- MODALITY_UNSPECIFIED = 'MODALITY_UNSPECIFIED' ,
284
+ MODALITY_UNSPECIFIED : 'MODALITY_UNSPECIFIED' ,
236
285
/**
237
286
* Plain text.
238
287
*/
239
- TEXT = 'TEXT' ,
288
+ TEXT : 'TEXT' ,
240
289
/**
241
290
* Image.
242
291
*/
243
- IMAGE = 'IMAGE' ,
292
+ IMAGE : 'IMAGE' ,
244
293
/**
245
294
* Video.
246
295
*/
247
- VIDEO = 'VIDEO' ,
296
+ VIDEO : 'VIDEO' ,
248
297
/**
249
298
* Audio.
250
299
*/
251
- AUDIO = 'AUDIO' ,
300
+ AUDIO : 'AUDIO' ,
252
301
/**
253
302
* Document (for example, PDF).
254
303
*/
255
- DOCUMENT = 'DOCUMENT'
256
- }
304
+ DOCUMENT : 'DOCUMENT'
305
+ } as const ;
306
+
307
+ /**
308
+ * Content part modality.
309
+ * @public
310
+ */
311
+ export type Modality = ( typeof Modality ) [ keyof typeof Modality ] ;
257
312
258
313
/**
259
314
* Generation modalities to be returned in generation responses.
0 commit comments