@firebase/ai 1.4.0 → 1.4.1-canary.25b60fdaa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-public.d.ts +462 -213
- package/dist/ai.d.ts +465 -213
- package/dist/esm/{index.esm2017.js → index.esm.js} +349 -276
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/src/api.d.ts +2 -38
- package/dist/esm/src/errors.d.ts +1 -1
- package/dist/esm/src/public-types.d.ts +0 -18
- package/dist/esm/src/requests/schema-builder.d.ts +25 -6
- package/dist/esm/src/types/enums.d.ts +102 -60
- package/dist/esm/src/types/error.d.ts +21 -15
- package/dist/esm/src/types/imagen/requests.d.ts +53 -19
- package/dist/esm/src/types/imagen/responses.d.ts +2 -2
- package/dist/esm/src/types/requests.d.ts +69 -7
- package/dist/esm/src/types/responses.d.ts +135 -12
- package/dist/esm/src/types/schema.d.ts +41 -20
- package/dist/index.cjs.js +364 -279
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +364 -279
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +348 -275
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/api.d.ts +2 -38
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/public-types.d.ts +0 -18
- package/dist/src/requests/schema-builder.d.ts +25 -6
- package/dist/src/types/enums.d.ts +102 -60
- package/dist/src/types/error.d.ts +21 -15
- package/dist/src/types/imagen/requests.d.ts +53 -19
- package/dist/src/types/imagen/responses.d.ts +2 -2
- package/dist/src/types/requests.d.ts +69 -7
- package/dist/src/types/responses.d.ts +135 -12
- package/dist/src/types/schema.d.ts +41 -20
- package/package.json +14 -13
- package/dist/esm/index.esm2017.js.map +0 -1
|
@@ -28,221 +28,263 @@ export declare const POSSIBLE_ROLES: readonly ["user", "model", "function", "sys
|
|
|
28
28
|
* Harm categories that would cause prompts or candidates to be blocked.
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
export declare
|
|
32
|
-
HARM_CATEGORY_HATE_SPEECH
|
|
33
|
-
HARM_CATEGORY_SEXUALLY_EXPLICIT
|
|
34
|
-
HARM_CATEGORY_HARASSMENT
|
|
35
|
-
HARM_CATEGORY_DANGEROUS_CONTENT
|
|
36
|
-
}
|
|
31
|
+
export declare const HarmCategory: {
|
|
32
|
+
readonly HARM_CATEGORY_HATE_SPEECH: "HARM_CATEGORY_HATE_SPEECH";
|
|
33
|
+
readonly HARM_CATEGORY_SEXUALLY_EXPLICIT: "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
34
|
+
readonly HARM_CATEGORY_HARASSMENT: "HARM_CATEGORY_HARASSMENT";
|
|
35
|
+
readonly HARM_CATEGORY_DANGEROUS_CONTENT: "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Harm categories that would cause prompts or candidates to be blocked.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export type HarmCategory = (typeof HarmCategory)[keyof typeof HarmCategory];
|
|
37
42
|
/**
|
|
38
43
|
* Threshold above which a prompt or candidate will be blocked.
|
|
39
44
|
* @public
|
|
40
45
|
*/
|
|
41
|
-
export declare
|
|
46
|
+
export declare const HarmBlockThreshold: {
|
|
42
47
|
/**
|
|
43
48
|
* Content with `NEGLIGIBLE` will be allowed.
|
|
44
49
|
*/
|
|
45
|
-
BLOCK_LOW_AND_ABOVE
|
|
50
|
+
readonly BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
|
|
46
51
|
/**
|
|
47
52
|
* Content with `NEGLIGIBLE` and `LOW` will be allowed.
|
|
48
53
|
*/
|
|
49
|
-
BLOCK_MEDIUM_AND_ABOVE
|
|
54
|
+
readonly BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
|
|
50
55
|
/**
|
|
51
56
|
* Content with `NEGLIGIBLE`, `LOW`, and `MEDIUM` will be allowed.
|
|
52
57
|
*/
|
|
53
|
-
BLOCK_ONLY_HIGH
|
|
58
|
+
readonly BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
|
|
54
59
|
/**
|
|
55
60
|
* All content will be allowed.
|
|
56
61
|
*/
|
|
57
|
-
BLOCK_NONE
|
|
62
|
+
readonly BLOCK_NONE: "BLOCK_NONE";
|
|
58
63
|
/**
|
|
59
64
|
* All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
|
|
60
65
|
* to the {@link HarmCategory} will not be present in the response.
|
|
61
66
|
*/
|
|
62
|
-
OFF
|
|
63
|
-
}
|
|
67
|
+
readonly OFF: "OFF";
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Threshold above which a prompt or candidate will be blocked.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export type HarmBlockThreshold = (typeof HarmBlockThreshold)[keyof typeof HarmBlockThreshold];
|
|
64
74
|
/**
|
|
65
75
|
* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
|
|
66
76
|
*
|
|
67
77
|
* @public
|
|
68
78
|
*/
|
|
69
|
-
export declare
|
|
79
|
+
export declare const HarmBlockMethod: {
|
|
70
80
|
/**
|
|
71
81
|
* The harm block method uses both probability and severity scores.
|
|
72
82
|
*/
|
|
73
|
-
SEVERITY
|
|
83
|
+
readonly SEVERITY: "SEVERITY";
|
|
74
84
|
/**
|
|
75
85
|
* The harm block method uses the probability score.
|
|
76
86
|
*/
|
|
77
|
-
PROBABILITY
|
|
78
|
-
}
|
|
87
|
+
readonly PROBABILITY: "PROBABILITY";
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export type HarmBlockMethod = (typeof HarmBlockMethod)[keyof typeof HarmBlockMethod];
|
|
79
95
|
/**
|
|
80
96
|
* Probability that a prompt or candidate matches a harm category.
|
|
81
97
|
* @public
|
|
82
98
|
*/
|
|
83
|
-
export declare
|
|
99
|
+
export declare const HarmProbability: {
|
|
84
100
|
/**
|
|
85
101
|
* Content has a negligible chance of being unsafe.
|
|
86
102
|
*/
|
|
87
|
-
NEGLIGIBLE
|
|
103
|
+
readonly NEGLIGIBLE: "NEGLIGIBLE";
|
|
88
104
|
/**
|
|
89
105
|
* Content has a low chance of being unsafe.
|
|
90
106
|
*/
|
|
91
|
-
LOW
|
|
107
|
+
readonly LOW: "LOW";
|
|
92
108
|
/**
|
|
93
109
|
* Content has a medium chance of being unsafe.
|
|
94
110
|
*/
|
|
95
|
-
MEDIUM
|
|
111
|
+
readonly MEDIUM: "MEDIUM";
|
|
96
112
|
/**
|
|
97
113
|
* Content has a high chance of being unsafe.
|
|
98
114
|
*/
|
|
99
|
-
HIGH
|
|
100
|
-
}
|
|
115
|
+
readonly HIGH: "HIGH";
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Probability that a prompt or candidate matches a harm category.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
export type HarmProbability = (typeof HarmProbability)[keyof typeof HarmProbability];
|
|
101
122
|
/**
|
|
102
123
|
* Harm severity levels.
|
|
103
124
|
* @public
|
|
104
125
|
*/
|
|
105
|
-
export declare
|
|
126
|
+
export declare const HarmSeverity: {
|
|
106
127
|
/**
|
|
107
128
|
* Negligible level of harm severity.
|
|
108
129
|
*/
|
|
109
|
-
HARM_SEVERITY_NEGLIGIBLE
|
|
130
|
+
readonly HARM_SEVERITY_NEGLIGIBLE: "HARM_SEVERITY_NEGLIGIBLE";
|
|
110
131
|
/**
|
|
111
132
|
* Low level of harm severity.
|
|
112
133
|
*/
|
|
113
|
-
HARM_SEVERITY_LOW
|
|
134
|
+
readonly HARM_SEVERITY_LOW: "HARM_SEVERITY_LOW";
|
|
114
135
|
/**
|
|
115
136
|
* Medium level of harm severity.
|
|
116
137
|
*/
|
|
117
|
-
HARM_SEVERITY_MEDIUM
|
|
138
|
+
readonly HARM_SEVERITY_MEDIUM: "HARM_SEVERITY_MEDIUM";
|
|
118
139
|
/**
|
|
119
140
|
* High level of harm severity.
|
|
120
141
|
*/
|
|
121
|
-
HARM_SEVERITY_HIGH
|
|
142
|
+
readonly HARM_SEVERITY_HIGH: "HARM_SEVERITY_HIGH";
|
|
122
143
|
/**
|
|
123
144
|
* Harm severity is not supported.
|
|
124
145
|
*
|
|
125
146
|
* @remarks
|
|
126
147
|
* The GoogleAI backend does not support `HarmSeverity`, so this value is used as a fallback.
|
|
127
148
|
*/
|
|
128
|
-
HARM_SEVERITY_UNSUPPORTED
|
|
129
|
-
}
|
|
149
|
+
readonly HARM_SEVERITY_UNSUPPORTED: "HARM_SEVERITY_UNSUPPORTED";
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Harm severity levels.
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
export type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
|
|
130
156
|
/**
|
|
131
157
|
* Reason that a prompt was blocked.
|
|
132
158
|
* @public
|
|
133
159
|
*/
|
|
134
|
-
export declare
|
|
160
|
+
export declare const BlockReason: {
|
|
135
161
|
/**
|
|
136
162
|
* Content was blocked by safety settings.
|
|
137
163
|
*/
|
|
138
|
-
SAFETY
|
|
164
|
+
readonly SAFETY: "SAFETY";
|
|
139
165
|
/**
|
|
140
166
|
* Content was blocked, but the reason is uncategorized.
|
|
141
167
|
*/
|
|
142
|
-
OTHER
|
|
168
|
+
readonly OTHER: "OTHER";
|
|
143
169
|
/**
|
|
144
170
|
* Content was blocked because it contained terms from the terminology blocklist.
|
|
145
171
|
*/
|
|
146
|
-
BLOCKLIST
|
|
172
|
+
readonly BLOCKLIST: "BLOCKLIST";
|
|
147
173
|
/**
|
|
148
174
|
* Content was blocked due to prohibited content.
|
|
149
175
|
*/
|
|
150
|
-
PROHIBITED_CONTENT
|
|
151
|
-
}
|
|
176
|
+
readonly PROHIBITED_CONTENT: "PROHIBITED_CONTENT";
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Reason that a prompt was blocked.
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
export type BlockReason = (typeof BlockReason)[keyof typeof BlockReason];
|
|
152
183
|
/**
|
|
153
184
|
* Reason that a candidate finished.
|
|
154
185
|
* @public
|
|
155
186
|
*/
|
|
156
|
-
export declare
|
|
187
|
+
export declare const FinishReason: {
|
|
157
188
|
/**
|
|
158
189
|
* Natural stop point of the model or provided stop sequence.
|
|
159
190
|
*/
|
|
160
|
-
STOP
|
|
191
|
+
readonly STOP: "STOP";
|
|
161
192
|
/**
|
|
162
193
|
* The maximum number of tokens as specified in the request was reached.
|
|
163
194
|
*/
|
|
164
|
-
MAX_TOKENS
|
|
195
|
+
readonly MAX_TOKENS: "MAX_TOKENS";
|
|
165
196
|
/**
|
|
166
197
|
* The candidate content was flagged for safety reasons.
|
|
167
198
|
*/
|
|
168
|
-
SAFETY
|
|
199
|
+
readonly SAFETY: "SAFETY";
|
|
169
200
|
/**
|
|
170
201
|
* The candidate content was flagged for recitation reasons.
|
|
171
202
|
*/
|
|
172
|
-
RECITATION
|
|
203
|
+
readonly RECITATION: "RECITATION";
|
|
173
204
|
/**
|
|
174
205
|
* Unknown reason.
|
|
175
206
|
*/
|
|
176
|
-
OTHER
|
|
207
|
+
readonly OTHER: "OTHER";
|
|
177
208
|
/**
|
|
178
209
|
* The candidate content contained forbidden terms.
|
|
179
210
|
*/
|
|
180
|
-
BLOCKLIST
|
|
211
|
+
readonly BLOCKLIST: "BLOCKLIST";
|
|
181
212
|
/**
|
|
182
213
|
* The candidate content potentially contained prohibited content.
|
|
183
214
|
*/
|
|
184
|
-
PROHIBITED_CONTENT
|
|
215
|
+
readonly PROHIBITED_CONTENT: "PROHIBITED_CONTENT";
|
|
185
216
|
/**
|
|
186
217
|
* The candidate content potentially contained Sensitive Personally Identifiable Information (SPII).
|
|
187
218
|
*/
|
|
188
|
-
SPII
|
|
219
|
+
readonly SPII: "SPII";
|
|
189
220
|
/**
|
|
190
221
|
* The function call generated by the model was invalid.
|
|
191
222
|
*/
|
|
192
|
-
MALFORMED_FUNCTION_CALL
|
|
193
|
-
}
|
|
223
|
+
readonly MALFORMED_FUNCTION_CALL: "MALFORMED_FUNCTION_CALL";
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Reason that a candidate finished.
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
export type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
|
|
194
230
|
/**
|
|
195
231
|
* @public
|
|
196
232
|
*/
|
|
197
|
-
export declare
|
|
233
|
+
export declare const FunctionCallingMode: {
|
|
198
234
|
/**
|
|
199
235
|
* Default model behavior; model decides to predict either a function call
|
|
200
236
|
* or a natural language response.
|
|
201
237
|
*/
|
|
202
|
-
AUTO
|
|
238
|
+
readonly AUTO: "AUTO";
|
|
203
239
|
/**
|
|
204
240
|
* Model is constrained to always predicting a function call only.
|
|
205
241
|
* If `allowed_function_names` is set, the predicted function call will be
|
|
206
242
|
* limited to any one of `allowed_function_names`, else the predicted
|
|
207
243
|
* function call will be any one of the provided `function_declarations`.
|
|
208
244
|
*/
|
|
209
|
-
ANY
|
|
245
|
+
readonly ANY: "ANY";
|
|
210
246
|
/**
|
|
211
247
|
* Model will not predict any function call. Model behavior is same as when
|
|
212
248
|
* not passing any function declarations.
|
|
213
249
|
*/
|
|
214
|
-
NONE
|
|
215
|
-
}
|
|
250
|
+
readonly NONE: "NONE";
|
|
251
|
+
};
|
|
252
|
+
export type FunctionCallingMode = (typeof FunctionCallingMode)[keyof typeof FunctionCallingMode];
|
|
216
253
|
/**
|
|
217
254
|
* Content part modality.
|
|
218
255
|
* @public
|
|
219
256
|
*/
|
|
220
|
-
export declare
|
|
257
|
+
export declare const Modality: {
|
|
221
258
|
/**
|
|
222
259
|
* Unspecified modality.
|
|
223
260
|
*/
|
|
224
|
-
MODALITY_UNSPECIFIED
|
|
261
|
+
readonly MODALITY_UNSPECIFIED: "MODALITY_UNSPECIFIED";
|
|
225
262
|
/**
|
|
226
263
|
* Plain text.
|
|
227
264
|
*/
|
|
228
|
-
TEXT
|
|
265
|
+
readonly TEXT: "TEXT";
|
|
229
266
|
/**
|
|
230
267
|
* Image.
|
|
231
268
|
*/
|
|
232
|
-
IMAGE
|
|
269
|
+
readonly IMAGE: "IMAGE";
|
|
233
270
|
/**
|
|
234
271
|
* Video.
|
|
235
272
|
*/
|
|
236
|
-
VIDEO
|
|
273
|
+
readonly VIDEO: "VIDEO";
|
|
237
274
|
/**
|
|
238
275
|
* Audio.
|
|
239
276
|
*/
|
|
240
|
-
AUDIO
|
|
277
|
+
readonly AUDIO: "AUDIO";
|
|
241
278
|
/**
|
|
242
279
|
* Document (for example, PDF).
|
|
243
280
|
*/
|
|
244
|
-
DOCUMENT
|
|
245
|
-
}
|
|
281
|
+
readonly DOCUMENT: "DOCUMENT";
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Content part modality.
|
|
285
|
+
* @public
|
|
286
|
+
*/
|
|
287
|
+
export type Modality = (typeof Modality)[keyof typeof Modality];
|
|
246
288
|
/**
|
|
247
289
|
* Generation modalities to be returned in generation responses.
|
|
248
290
|
*
|
|
@@ -51,31 +51,37 @@ export interface CustomErrorData {
|
|
|
51
51
|
*
|
|
52
52
|
* @public
|
|
53
53
|
*/
|
|
54
|
-
export declare const
|
|
54
|
+
export declare const AIErrorCode: {
|
|
55
55
|
/** A generic error occurred. */
|
|
56
|
-
ERROR
|
|
56
|
+
readonly ERROR: "error";
|
|
57
57
|
/** An error occurred in a request. */
|
|
58
|
-
REQUEST_ERROR
|
|
58
|
+
readonly REQUEST_ERROR: "request-error";
|
|
59
59
|
/** An error occurred in a response. */
|
|
60
|
-
RESPONSE_ERROR
|
|
60
|
+
readonly RESPONSE_ERROR: "response-error";
|
|
61
61
|
/** An error occurred while performing a fetch. */
|
|
62
|
-
FETCH_ERROR
|
|
62
|
+
readonly FETCH_ERROR: "fetch-error";
|
|
63
63
|
/** An error associated with a Content object. */
|
|
64
|
-
INVALID_CONTENT
|
|
64
|
+
readonly INVALID_CONTENT: "invalid-content";
|
|
65
65
|
/** An error due to the Firebase API not being enabled in the Console. */
|
|
66
|
-
API_NOT_ENABLED
|
|
66
|
+
readonly API_NOT_ENABLED: "api-not-enabled";
|
|
67
67
|
/** An error due to invalid Schema input. */
|
|
68
|
-
INVALID_SCHEMA
|
|
68
|
+
readonly INVALID_SCHEMA: "invalid-schema";
|
|
69
69
|
/** An error occurred due to a missing Firebase API key. */
|
|
70
|
-
NO_API_KEY
|
|
70
|
+
readonly NO_API_KEY: "no-api-key";
|
|
71
71
|
/** An error occurred due to a missing Firebase app ID. */
|
|
72
|
-
NO_APP_ID
|
|
72
|
+
readonly NO_APP_ID: "no-app-id";
|
|
73
73
|
/** An error occurred due to a model name not being specified during initialization. */
|
|
74
|
-
NO_MODEL
|
|
74
|
+
readonly NO_MODEL: "no-model";
|
|
75
75
|
/** An error occurred due to a missing project ID. */
|
|
76
|
-
NO_PROJECT_ID
|
|
76
|
+
readonly NO_PROJECT_ID: "no-project-id";
|
|
77
77
|
/** An error occurred while parsing. */
|
|
78
|
-
PARSE_FAILED
|
|
78
|
+
readonly PARSE_FAILED: "parse-failed";
|
|
79
79
|
/** An error occurred due an attempt to use an unsupported feature. */
|
|
80
|
-
UNSUPPORTED
|
|
81
|
-
}
|
|
80
|
+
readonly UNSUPPORTED: "unsupported";
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Standardized error codes that {@link AIError} can have.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export type AIErrorCode = (typeof AIErrorCode)[keyof typeof AIErrorCode];
|
|
@@ -70,7 +70,7 @@ export interface ImagenGenerationConfig {
|
|
|
70
70
|
numberOfImages?: number;
|
|
71
71
|
/**
|
|
72
72
|
* The aspect ratio of the generated images. The default value is square 1:1.
|
|
73
|
-
* Supported aspect ratios depend on the Imagen model, see {@link ImagenAspectRatio}
|
|
73
|
+
* Supported aspect ratios depend on the Imagen model, see {@link (ImagenAspectRatio:type)}
|
|
74
74
|
* for more details.
|
|
75
75
|
*/
|
|
76
76
|
aspectRatio?: ImagenAspectRatio;
|
|
@@ -106,27 +106,40 @@ export interface ImagenGenerationConfig {
|
|
|
106
106
|
*
|
|
107
107
|
* @beta
|
|
108
108
|
*/
|
|
109
|
-
export declare
|
|
109
|
+
export declare const ImagenSafetyFilterLevel: {
|
|
110
110
|
/**
|
|
111
111
|
* The most aggressive filtering level; most strict blocking.
|
|
112
112
|
*/
|
|
113
|
-
BLOCK_LOW_AND_ABOVE
|
|
113
|
+
readonly BLOCK_LOW_AND_ABOVE: "block_low_and_above";
|
|
114
114
|
/**
|
|
115
115
|
* Blocks some sensitive prompts and responses.
|
|
116
116
|
*/
|
|
117
|
-
BLOCK_MEDIUM_AND_ABOVE
|
|
117
|
+
readonly BLOCK_MEDIUM_AND_ABOVE: "block_medium_and_above";
|
|
118
118
|
/**
|
|
119
119
|
* Blocks few sensitive prompts and responses.
|
|
120
120
|
*/
|
|
121
|
-
BLOCK_ONLY_HIGH
|
|
121
|
+
readonly BLOCK_ONLY_HIGH: "block_only_high";
|
|
122
122
|
/**
|
|
123
123
|
* The least aggressive filtering level; blocks very few sensitive prompts and responses.
|
|
124
124
|
*
|
|
125
125
|
* Access to this feature is restricted and may require your case to be reviewed and approved by
|
|
126
126
|
* Cloud support.
|
|
127
127
|
*/
|
|
128
|
-
BLOCK_NONE
|
|
129
|
-
}
|
|
128
|
+
readonly BLOCK_NONE: "block_none";
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* A filter level controlling how aggressively to filter sensitive content.
|
|
132
|
+
*
|
|
133
|
+
* Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AI
|
|
134
|
+
* are assessed against a list of safety filters, which include 'harmful categories' (for example,
|
|
135
|
+
* `violence`, `sexual`, `derogatory`, and `toxic`). This filter level controls how aggressively to
|
|
136
|
+
* filter out potentially harmful content from responses. See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
137
|
+
* and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
|
|
138
|
+
* for more details.
|
|
139
|
+
*
|
|
140
|
+
* @beta
|
|
141
|
+
*/
|
|
142
|
+
export type ImagenSafetyFilterLevel = (typeof ImagenSafetyFilterLevel)[keyof typeof ImagenSafetyFilterLevel];
|
|
130
143
|
/**
|
|
131
144
|
* A filter level controlling whether generation of images containing people or faces is allowed.
|
|
132
145
|
*
|
|
@@ -135,11 +148,11 @@ export declare enum ImagenSafetyFilterLevel {
|
|
|
135
148
|
*
|
|
136
149
|
* @beta
|
|
137
150
|
*/
|
|
138
|
-
export declare
|
|
151
|
+
export declare const ImagenPersonFilterLevel: {
|
|
139
152
|
/**
|
|
140
153
|
* Disallow generation of images containing people or faces; images of people are filtered out.
|
|
141
154
|
*/
|
|
142
|
-
BLOCK_ALL
|
|
155
|
+
readonly BLOCK_ALL: "dont_allow";
|
|
143
156
|
/**
|
|
144
157
|
* Allow generation of images containing adults only; images of children are filtered out.
|
|
145
158
|
*
|
|
@@ -147,7 +160,7 @@ export declare enum ImagenPersonFilterLevel {
|
|
|
147
160
|
* reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
|
|
148
161
|
* for more details.
|
|
149
162
|
*/
|
|
150
|
-
ALLOW_ADULT
|
|
163
|
+
readonly ALLOW_ADULT: "allow_adult";
|
|
151
164
|
/**
|
|
152
165
|
* Allow generation of images containing adults only; images of children are filtered out.
|
|
153
166
|
*
|
|
@@ -155,8 +168,17 @@ export declare enum ImagenPersonFilterLevel {
|
|
|
155
168
|
* reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
|
|
156
169
|
* for more details.
|
|
157
170
|
*/
|
|
158
|
-
ALLOW_ALL
|
|
159
|
-
}
|
|
171
|
+
readonly ALLOW_ALL: "allow_all";
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* A filter level controlling whether generation of images containing people or faces is allowed.
|
|
175
|
+
*
|
|
176
|
+
* See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
|
|
177
|
+
* documentation for more details.
|
|
178
|
+
*
|
|
179
|
+
* @beta
|
|
180
|
+
*/
|
|
181
|
+
export type ImagenPersonFilterLevel = (typeof ImagenPersonFilterLevel)[keyof typeof ImagenPersonFilterLevel];
|
|
160
182
|
/**
|
|
161
183
|
* Settings for controlling the aggressiveness of filtering out sensitive content.
|
|
162
184
|
*
|
|
@@ -187,25 +209,37 @@ export interface ImagenSafetySettings {
|
|
|
187
209
|
*
|
|
188
210
|
* @beta
|
|
189
211
|
*/
|
|
190
|
-
export declare
|
|
212
|
+
export declare const ImagenAspectRatio: {
|
|
191
213
|
/**
|
|
192
214
|
* Square (1:1) aspect ratio.
|
|
193
215
|
*/
|
|
194
|
-
SQUARE
|
|
216
|
+
readonly SQUARE: "1:1";
|
|
195
217
|
/**
|
|
196
218
|
* Landscape (3:4) aspect ratio.
|
|
197
219
|
*/
|
|
198
|
-
LANDSCAPE_3x4
|
|
220
|
+
readonly LANDSCAPE_3x4: "3:4";
|
|
199
221
|
/**
|
|
200
222
|
* Portrait (4:3) aspect ratio.
|
|
201
223
|
*/
|
|
202
|
-
PORTRAIT_4x3
|
|
224
|
+
readonly PORTRAIT_4x3: "4:3";
|
|
203
225
|
/**
|
|
204
226
|
* Landscape (16:9) aspect ratio.
|
|
205
227
|
*/
|
|
206
|
-
LANDSCAPE_16x9
|
|
228
|
+
readonly LANDSCAPE_16x9: "16:9";
|
|
207
229
|
/**
|
|
208
230
|
* Portrait (9:16) aspect ratio.
|
|
209
231
|
*/
|
|
210
|
-
PORTRAIT_9x16
|
|
211
|
-
}
|
|
232
|
+
readonly PORTRAIT_9x16: "9:16";
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Aspect ratios for Imagen images.
|
|
236
|
+
*
|
|
237
|
+
* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
|
|
238
|
+
* {@link ImagenGenerationConfig}.
|
|
239
|
+
*
|
|
240
|
+
* See the the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
241
|
+
* for more details and examples of the supported aspect ratios.
|
|
242
|
+
*
|
|
243
|
+
* @beta
|
|
244
|
+
*/
|
|
245
|
+
export type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof ImagenAspectRatio];
|
|
@@ -67,8 +67,8 @@ export interface ImagenGenerationResponse<T extends ImagenInlineImage | ImagenGC
|
|
|
67
67
|
* The reason that images were filtered out. This property will only be defined if one
|
|
68
68
|
* or more images were filtered.
|
|
69
69
|
*
|
|
70
|
-
* Images may be filtered out due to the {@link ImagenSafetyFilterLevel},
|
|
71
|
-
* {@link ImagenPersonFilterLevel}, or filtering included in the model.
|
|
70
|
+
* Images may be filtered out due to the {@link (ImagenSafetyFilterLevel:type)},
|
|
71
|
+
* {@link (ImagenPersonFilterLevel:type)}, or filtering included in the model.
|
|
72
72
|
* The filter levels may be adjusted in your {@link ImagenSafetySettings}.
|
|
73
73
|
*
|
|
74
74
|
* See the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen | Responsible AI and usage guidelines for Imagen}
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { TypedSchema } from '../requests/schema-builder';
|
|
17
|
+
import { ObjectSchema, TypedSchema } from '../requests/schema-builder';
|
|
18
18
|
import { Content, Part } from './content';
|
|
19
19
|
import { FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, HarmCategory, ResponseModality } from './enums';
|
|
20
|
-
import {
|
|
20
|
+
import { ObjectSchemaRequest, SchemaRequest } from './schema';
|
|
21
21
|
/**
|
|
22
22
|
* Base parameters for a number of methods.
|
|
23
23
|
* @public
|
|
@@ -87,7 +87,7 @@ export interface GenerationConfig {
|
|
|
87
87
|
* value can be a class generated with a {@link Schema} static method
|
|
88
88
|
* like `Schema.string()` or `Schema.object()` or it can be a plain
|
|
89
89
|
* JS object matching the {@link SchemaRequest} interface.
|
|
90
|
-
* <br/>Note: This only applies when the specified `
|
|
90
|
+
* <br/>Note: This only applies when the specified `responseMimeType` supports a schema; currently
|
|
91
91
|
* this is limited to `application/json` and `text/x.enum`.
|
|
92
92
|
*/
|
|
93
93
|
responseSchema?: TypedSchema | SchemaRequest;
|
|
@@ -101,6 +101,10 @@ export interface GenerationConfig {
|
|
|
101
101
|
* @beta
|
|
102
102
|
*/
|
|
103
103
|
responseModalities?: ResponseModality[];
|
|
104
|
+
/**
|
|
105
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
106
|
+
*/
|
|
107
|
+
thinkingConfig?: ThinkingConfig;
|
|
104
108
|
}
|
|
105
109
|
/**
|
|
106
110
|
* Params for {@link GenerativeModel.startChat}.
|
|
@@ -149,7 +153,7 @@ export interface RequestOptions {
|
|
|
149
153
|
* Defines a tool that model can call to access external knowledge.
|
|
150
154
|
* @public
|
|
151
155
|
*/
|
|
152
|
-
export
|
|
156
|
+
export type Tool = FunctionDeclarationsTool | GoogleSearchTool;
|
|
153
157
|
/**
|
|
154
158
|
* Structured representation of a function declaration as defined by the
|
|
155
159
|
* {@link https://spec.openapis.org/oas/v3.0.3 | OpenAPI 3.0 specification}.
|
|
@@ -159,7 +163,7 @@ export declare type Tool = FunctionDeclarationsTool;
|
|
|
159
163
|
* as a Tool by the model and executed by the client.
|
|
160
164
|
* @public
|
|
161
165
|
*/
|
|
162
|
-
export
|
|
166
|
+
export interface FunctionDeclaration {
|
|
163
167
|
/**
|
|
164
168
|
* The name of the function to call. Must start with a letter or an
|
|
165
169
|
* underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with
|
|
@@ -176,7 +180,41 @@ export declare interface FunctionDeclaration {
|
|
|
176
180
|
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
|
|
177
181
|
* case-sensitive. For a function with no parameters, this can be left unset.
|
|
178
182
|
*/
|
|
179
|
-
parameters?:
|
|
183
|
+
parameters?: ObjectSchema | ObjectSchemaRequest;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A tool that allows a Gemini model to connect to Google Search to access and incorporate
|
|
187
|
+
* up-to-date information from the web into its responses.
|
|
188
|
+
*
|
|
189
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
190
|
+
* "Grounding with Google Search" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
191
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
192
|
+
* section within the Service Specific Terms).
|
|
193
|
+
*
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
export interface GoogleSearchTool {
|
|
197
|
+
/**
|
|
198
|
+
* Specifies the Google Search configuration.
|
|
199
|
+
* Currently, this is an empty object, but it's reserved for future configuration options.
|
|
200
|
+
* Specifies the Google Search configuration. Currently, this is an empty object, but it's
|
|
201
|
+
* reserved for future configuration options.
|
|
202
|
+
*
|
|
203
|
+
* When using this feature, you are required to comply with the "Grounding with Google Search"
|
|
204
|
+
* usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
205
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
206
|
+
* section within the Service Specific Terms).
|
|
207
|
+
*/
|
|
208
|
+
googleSearch: GoogleSearch;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Specifies the Google Search configuration.
|
|
212
|
+
*
|
|
213
|
+
* @remarks Currently, this is an empty object, but it's reserved for future configuration options.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
export interface GoogleSearch {
|
|
180
218
|
}
|
|
181
219
|
/**
|
|
182
220
|
* A `FunctionDeclarationsTool` is a piece of code that enables the system to
|
|
@@ -184,7 +222,7 @@ export declare interface FunctionDeclaration {
|
|
|
184
222
|
* outside of knowledge and scope of the model.
|
|
185
223
|
* @public
|
|
186
224
|
*/
|
|
187
|
-
export
|
|
225
|
+
export interface FunctionDeclarationsTool {
|
|
188
226
|
/**
|
|
189
227
|
* Optional. One or more function declarations
|
|
190
228
|
* to be passed to the model along with the current user query. Model may
|
|
@@ -211,3 +249,27 @@ export interface FunctionCallingConfig {
|
|
|
211
249
|
mode?: FunctionCallingMode;
|
|
212
250
|
allowedFunctionNames?: string[];
|
|
213
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
254
|
+
*
|
|
255
|
+
* Certain models utilize a thinking process before generating a response. This allows them to
|
|
256
|
+
* reason through complex problems and plan a more coherent and accurate answer.
|
|
257
|
+
*
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
export interface ThinkingConfig {
|
|
261
|
+
/**
|
|
262
|
+
* The thinking budget, in tokens.
|
|
263
|
+
*
|
|
264
|
+
* This parameter sets an upper limit on the number of tokens the model can use for its internal
|
|
265
|
+
* "thinking" process. A higher budget may result in higher quality responses for complex tasks
|
|
266
|
+
* but can also increase latency and cost.
|
|
267
|
+
*
|
|
268
|
+
* If you don't specify a budget, the model will determine the appropriate amount
|
|
269
|
+
* of thinking based on the complexity of the prompt.
|
|
270
|
+
*
|
|
271
|
+
* An error will be thrown if you set a thinking budget for a model that does not support this
|
|
272
|
+
* feature or if the specified budget is not within the model's supported range.
|
|
273
|
+
*/
|
|
274
|
+
thinkingBudget?: number;
|
|
275
|
+
}
|