Skip to content

Commit 42abe42

Browse files
russellwheatleymikehardy
authored andcommitted
enums.ts
1 parent f284271 commit 42abe42

File tree

1 file changed

+164
-39
lines changed

1 file changed

+164
-39
lines changed

packages/ai/lib/types/enums.ts

Lines changed: 164 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,42 @@ export enum HarmCategory {
4343
* @public
4444
*/
4545
export enum HarmBlockThreshold {
46-
// Content with NEGLIGIBLE will be allowed.
46+
/**
47+
* Content with `NEGLIGIBLE` will be allowed.
48+
*/
4749
BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE',
48-
// Content with NEGLIGIBLE and LOW will be allowed.
50+
/**
51+
* Content with `NEGLIGIBLE` and `LOW` will be allowed.
52+
*/
4953
BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE',
50-
// Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.
54+
/**
55+
* Content with `NEGLIGIBLE`, `LOW`, and `MEDIUM` will be allowed.
56+
*/
5157
BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH',
52-
// All content will be allowed.
58+
/**
59+
* All content will be allowed.
60+
*/
5361
BLOCK_NONE = 'BLOCK_NONE',
62+
/**
63+
* All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
64+
* to the {@link HarmCategory} will not be present in the response.
65+
*/
66+
OFF = 'OFF',
5467
}
5568

5669
/**
70+
* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
71+
*
5772
* @public
5873
*/
5974
export enum HarmBlockMethod {
60-
// The harm block method uses both probability and severity scores.
75+
/**
76+
* The harm block method uses both probability and severity scores.
77+
*/
6178
SEVERITY = 'SEVERITY',
62-
// The harm block method uses the probability score.
79+
/**
80+
* The harm block method uses the probability score.
81+
*/
6382
PROBABILITY = 'PROBABILITY',
6483
}
6584

@@ -68,13 +87,21 @@ export enum HarmBlockMethod {
6887
* @public
6988
*/
7089
export enum HarmProbability {
71-
// Content has a negligible chance of being unsafe.
90+
/**
91+
* Content has a negligible chance of being unsafe.
92+
*/
7293
NEGLIGIBLE = 'NEGLIGIBLE',
73-
// Content has a low chance of being unsafe.
94+
/**
95+
* Content has a low chance of being unsafe.
96+
*/
7497
LOW = 'LOW',
75-
// Content has a medium chance of being unsafe.
98+
/**
99+
* Content has a medium chance of being unsafe.
100+
*/
76101
MEDIUM = 'MEDIUM',
77-
// Content has a high chance of being unsafe.
102+
/**
103+
* Content has a high chance of being unsafe.
104+
*/
78105
HIGH = 'HIGH',
79106
}
80107

@@ -83,13 +110,21 @@ export enum HarmProbability {
83110
* @public
84111
*/
85112
export enum HarmSeverity {
86-
// Negligible level of harm severity.
113+
/**
114+
* Negligible level of harm severity.
115+
*/
87116
HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE',
88-
// Low level of harm severity.
117+
/**
118+
* Low level of harm severity.
119+
*/
89120
HARM_SEVERITY_LOW = 'HARM_SEVERITY_LOW',
90-
// Medium level of harm severity.
121+
/**
122+
* Medium level of harm severity.
123+
*/
91124
HARM_SEVERITY_MEDIUM = 'HARM_SEVERITY_MEDIUM',
92-
// High level of harm severity.
125+
/**
126+
* High level of harm severity.
127+
*/
93128
HARM_SEVERITY_HIGH = 'HARM_SEVERITY_HIGH',
94129
/**
95130
* Harm severity is not supported.
@@ -105,52 +140,142 @@ export enum HarmSeverity {
105140
* @public
106141
*/
107142
export enum BlockReason {
108-
// The prompt was blocked because it contained terms from the terminology blocklist.
109-
BLOCKLIST = 'BLOCKLIST',
110-
// The prompt was blocked due to prohibited content.
111-
PROHIBITED_CONTENT = 'PROHIBITED_CONTENT',
112-
// Content was blocked by safety settings.
143+
/**
144+
* Content was blocked by safety settings.
145+
*/
113146
SAFETY = 'SAFETY',
114-
// Content was blocked, but the reason is uncategorized.
147+
/**
148+
* Content was blocked, but the reason is uncategorized.
149+
*/
115150
OTHER = 'OTHER',
151+
/**
152+
* Content was blocked because it contained terms from the terminology blocklist.
153+
*/
154+
BLOCKLIST = 'BLOCKLIST',
155+
/**
156+
* Content was blocked due to prohibited content.
157+
*/
158+
PROHIBITED_CONTENT = 'PROHIBITED_CONTENT',
116159
}
117160

118161
/**
119162
* Reason that a candidate finished.
120163
* @public
121164
*/
122165
export enum FinishReason {
123-
// Token generation was stopped because the response contained forbidden terms.
124-
BLOCKLIST = 'BLOCKLIST',
125-
// Token generation was stopped because the response contained potentially prohibited content.
126-
PROHIBITED_CONTENT = 'PROHIBITED_CONTENT',
127-
// Token generation was stopped because of Sensitive Personally Identifiable Information (SPII).
128-
SPII = 'SPII',
129-
// Natural stop point of the model or provided stop sequence.
166+
/**
167+
* Natural stop point of the model or provided stop sequence.
168+
*/
130169
STOP = 'STOP',
131-
// The maximum number of tokens as specified in the request was reached.
170+
/**
171+
* The maximum number of tokens as specified in the request was reached.
172+
*/
132173
MAX_TOKENS = 'MAX_TOKENS',
133-
// The candidate content was flagged for safety reasons.
174+
/**
175+
* The candidate content was flagged for safety reasons.
176+
*/
134177
SAFETY = 'SAFETY',
135-
// The candidate content was flagged for recitation reasons.
178+
/**
179+
* The candidate content was flagged for recitation reasons.
180+
*/
136181
RECITATION = 'RECITATION',
137-
// Unknown reason.
182+
/**
183+
* Unknown reason.
184+
*/
138185
OTHER = 'OTHER',
186+
/**
187+
* The candidate content contained forbidden terms.
188+
*/
189+
BLOCKLIST = 'BLOCKLIST',
190+
/**
191+
* The candidate content potentially contained prohibited content.
192+
*/
193+
PROHIBITED_CONTENT = 'PROHIBITED_CONTENT',
194+
/**
195+
* The candidate content potentially contained Sensitive Personally Identifiable Information (SPII).
196+
*/
197+
SPII = 'SPII',
198+
/**
199+
* The function call generated by the model was invalid.
200+
*/
201+
MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL',
139202
}
140203

141204
/**
142205
* @public
143206
*/
144207
export enum FunctionCallingMode {
145-
// Default model behavior, model decides to predict either a function call
146-
// or a natural language response.
208+
/**
209+
* Default model behavior; model decides to predict either a function call
210+
* or a natural language response.
211+
*/
147212
AUTO = 'AUTO',
148-
// Model is constrained to always predicting a function call only.
149-
// If "allowed_function_names" is set, the predicted function call will be
150-
// limited to any one of "allowed_function_names", else the predicted
151-
// function call will be any one of the provided "function_declarations".
213+
/**
214+
* Model is constrained to always predicting a function call only.
215+
* If `allowed_function_names` is set, the predicted function call will be
216+
* limited to any one of `allowed_function_names`, else the predicted
217+
* function call will be any one of the provided `function_declarations`.
218+
*/
152219
ANY = 'ANY',
153-
// Model will not predict any function call. Model behavior is same as when
154-
// not passing any function declarations.
220+
/**
221+
* Model will not predict any function call. Model behavior is same as when
222+
* not passing any function declarations.
223+
*/
155224
NONE = 'NONE',
156225
}
226+
227+
/**
228+
* Content part modality.
229+
* @public
230+
*/
231+
export enum Modality {
232+
/**
233+
* Unspecified modality.
234+
*/
235+
MODALITY_UNSPECIFIED = 'MODALITY_UNSPECIFIED',
236+
/**
237+
* Plain text.
238+
*/
239+
TEXT = 'TEXT',
240+
/**
241+
* Image.
242+
*/
243+
IMAGE = 'IMAGE',
244+
/**
245+
* Video.
246+
*/
247+
VIDEO = 'VIDEO',
248+
/**
249+
* Audio.
250+
*/
251+
AUDIO = 'AUDIO',
252+
/**
253+
* Document (for example, PDF).
254+
*/
255+
DOCUMENT = 'DOCUMENT',
256+
}
257+
258+
/**
259+
* Generation modalities to be returned in generation responses.
260+
*
261+
* @beta
262+
*/
263+
export const ResponseModality = {
264+
/**
265+
* Text.
266+
* @beta
267+
*/
268+
TEXT: 'TEXT',
269+
/**
270+
* Image.
271+
* @beta
272+
*/
273+
IMAGE: 'IMAGE',
274+
} as const;
275+
276+
/**
277+
* Generation modalities to be returned in generation responses.
278+
*
279+
* @beta
280+
*/
281+
export type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseModality];

0 commit comments

Comments
 (0)