@firebase/ai 1.4.0 → 1.4.1-canary.2b5731292

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/index.cjs.js CHANGED
@@ -9,7 +9,7 @@ var logger$1 = require('@firebase/logger');
9
9
  var tslib = require('tslib');
10
10
 
11
11
  var name = "@firebase/ai";
12
- var version = "1.4.0";
12
+ var version = "1.4.1-canary.2b5731292";
13
13
 
14
14
  /**
15
15
  * @license
@@ -60,230 +60,221 @@ const POSSIBLE_ROLES = ['user', 'model', 'function', 'system'];
60
60
  * Harm categories that would cause prompts or candidates to be blocked.
61
61
  * @public
62
62
  */
63
- exports.HarmCategory = void 0;
64
- (function (HarmCategory) {
65
- HarmCategory["HARM_CATEGORY_HATE_SPEECH"] = "HARM_CATEGORY_HATE_SPEECH";
66
- HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
67
- HarmCategory["HARM_CATEGORY_HARASSMENT"] = "HARM_CATEGORY_HARASSMENT";
68
- HarmCategory["HARM_CATEGORY_DANGEROUS_CONTENT"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
69
- })(exports.HarmCategory || (exports.HarmCategory = {}));
63
+ const HarmCategory = {
64
+ HARM_CATEGORY_HATE_SPEECH: 'HARM_CATEGORY_HATE_SPEECH',
65
+ HARM_CATEGORY_SEXUALLY_EXPLICIT: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
66
+ HARM_CATEGORY_HARASSMENT: 'HARM_CATEGORY_HARASSMENT',
67
+ HARM_CATEGORY_DANGEROUS_CONTENT: 'HARM_CATEGORY_DANGEROUS_CONTENT'
68
+ };
70
69
  /**
71
70
  * Threshold above which a prompt or candidate will be blocked.
72
71
  * @public
73
72
  */
74
- exports.HarmBlockThreshold = void 0;
75
- (function (HarmBlockThreshold) {
73
+ const HarmBlockThreshold = {
76
74
  /**
77
75
  * Content with `NEGLIGIBLE` will be allowed.
78
76
  */
79
- HarmBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
77
+ BLOCK_LOW_AND_ABOVE: 'BLOCK_LOW_AND_ABOVE',
80
78
  /**
81
79
  * Content with `NEGLIGIBLE` and `LOW` will be allowed.
82
80
  */
83
- HarmBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
81
+ BLOCK_MEDIUM_AND_ABOVE: 'BLOCK_MEDIUM_AND_ABOVE',
84
82
  /**
85
83
  * Content with `NEGLIGIBLE`, `LOW`, and `MEDIUM` will be allowed.
86
84
  */
87
- HarmBlockThreshold["BLOCK_ONLY_HIGH"] = "BLOCK_ONLY_HIGH";
85
+ BLOCK_ONLY_HIGH: 'BLOCK_ONLY_HIGH',
88
86
  /**
89
87
  * All content will be allowed.
90
88
  */
91
- HarmBlockThreshold["BLOCK_NONE"] = "BLOCK_NONE";
89
+ BLOCK_NONE: 'BLOCK_NONE',
92
90
  /**
93
91
  * All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
94
92
  * to the {@link HarmCategory} will not be present in the response.
95
93
  */
96
- HarmBlockThreshold["OFF"] = "OFF";
97
- })(exports.HarmBlockThreshold || (exports.HarmBlockThreshold = {}));
94
+ OFF: 'OFF'
95
+ };
98
96
  /**
99
97
  * This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
100
98
  *
101
99
  * @public
102
100
  */
103
- exports.HarmBlockMethod = void 0;
104
- (function (HarmBlockMethod) {
101
+ const HarmBlockMethod = {
105
102
  /**
106
103
  * The harm block method uses both probability and severity scores.
107
104
  */
108
- HarmBlockMethod["SEVERITY"] = "SEVERITY";
105
+ SEVERITY: 'SEVERITY',
109
106
  /**
110
107
  * The harm block method uses the probability score.
111
108
  */
112
- HarmBlockMethod["PROBABILITY"] = "PROBABILITY";
113
- })(exports.HarmBlockMethod || (exports.HarmBlockMethod = {}));
109
+ PROBABILITY: 'PROBABILITY'
110
+ };
114
111
  /**
115
112
  * Probability that a prompt or candidate matches a harm category.
116
113
  * @public
117
114
  */
118
- exports.HarmProbability = void 0;
119
- (function (HarmProbability) {
115
+ const HarmProbability = {
120
116
  /**
121
117
  * Content has a negligible chance of being unsafe.
122
118
  */
123
- HarmProbability["NEGLIGIBLE"] = "NEGLIGIBLE";
119
+ NEGLIGIBLE: 'NEGLIGIBLE',
124
120
  /**
125
121
  * Content has a low chance of being unsafe.
126
122
  */
127
- HarmProbability["LOW"] = "LOW";
123
+ LOW: 'LOW',
128
124
  /**
129
125
  * Content has a medium chance of being unsafe.
130
126
  */
131
- HarmProbability["MEDIUM"] = "MEDIUM";
127
+ MEDIUM: 'MEDIUM',
132
128
  /**
133
129
  * Content has a high chance of being unsafe.
134
130
  */
135
- HarmProbability["HIGH"] = "HIGH";
136
- })(exports.HarmProbability || (exports.HarmProbability = {}));
131
+ HIGH: 'HIGH'
132
+ };
137
133
  /**
138
134
  * Harm severity levels.
139
135
  * @public
140
136
  */
141
- exports.HarmSeverity = void 0;
142
- (function (HarmSeverity) {
137
+ const HarmSeverity = {
143
138
  /**
144
139
  * Negligible level of harm severity.
145
140
  */
146
- HarmSeverity["HARM_SEVERITY_NEGLIGIBLE"] = "HARM_SEVERITY_NEGLIGIBLE";
141
+ HARM_SEVERITY_NEGLIGIBLE: 'HARM_SEVERITY_NEGLIGIBLE',
147
142
  /**
148
143
  * Low level of harm severity.
149
144
  */
150
- HarmSeverity["HARM_SEVERITY_LOW"] = "HARM_SEVERITY_LOW";
145
+ HARM_SEVERITY_LOW: 'HARM_SEVERITY_LOW',
151
146
  /**
152
147
  * Medium level of harm severity.
153
148
  */
154
- HarmSeverity["HARM_SEVERITY_MEDIUM"] = "HARM_SEVERITY_MEDIUM";
149
+ HARM_SEVERITY_MEDIUM: 'HARM_SEVERITY_MEDIUM',
155
150
  /**
156
151
  * High level of harm severity.
157
152
  */
158
- HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
153
+ HARM_SEVERITY_HIGH: 'HARM_SEVERITY_HIGH',
159
154
  /**
160
155
  * Harm severity is not supported.
161
156
  *
162
157
  * @remarks
163
158
  * The GoogleAI backend does not support `HarmSeverity`, so this value is used as a fallback.
164
159
  */
165
- HarmSeverity["HARM_SEVERITY_UNSUPPORTED"] = "HARM_SEVERITY_UNSUPPORTED";
166
- })(exports.HarmSeverity || (exports.HarmSeverity = {}));
160
+ HARM_SEVERITY_UNSUPPORTED: 'HARM_SEVERITY_UNSUPPORTED'
161
+ };
167
162
  /**
168
163
  * Reason that a prompt was blocked.
169
164
  * @public
170
165
  */
171
- exports.BlockReason = void 0;
172
- (function (BlockReason) {
166
+ const BlockReason = {
173
167
  /**
174
168
  * Content was blocked by safety settings.
175
169
  */
176
- BlockReason["SAFETY"] = "SAFETY";
170
+ SAFETY: 'SAFETY',
177
171
  /**
178
172
  * Content was blocked, but the reason is uncategorized.
179
173
  */
180
- BlockReason["OTHER"] = "OTHER";
174
+ OTHER: 'OTHER',
181
175
  /**
182
176
  * Content was blocked because it contained terms from the terminology blocklist.
183
177
  */
184
- BlockReason["BLOCKLIST"] = "BLOCKLIST";
178
+ BLOCKLIST: 'BLOCKLIST',
185
179
  /**
186
180
  * Content was blocked due to prohibited content.
187
181
  */
188
- BlockReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
189
- })(exports.BlockReason || (exports.BlockReason = {}));
182
+ PROHIBITED_CONTENT: 'PROHIBITED_CONTENT'
183
+ };
190
184
  /**
191
185
  * Reason that a candidate finished.
192
186
  * @public
193
187
  */
194
- exports.FinishReason = void 0;
195
- (function (FinishReason) {
188
+ const FinishReason = {
196
189
  /**
197
190
  * Natural stop point of the model or provided stop sequence.
198
191
  */
199
- FinishReason["STOP"] = "STOP";
192
+ STOP: 'STOP',
200
193
  /**
201
194
  * The maximum number of tokens as specified in the request was reached.
202
195
  */
203
- FinishReason["MAX_TOKENS"] = "MAX_TOKENS";
196
+ MAX_TOKENS: 'MAX_TOKENS',
204
197
  /**
205
198
  * The candidate content was flagged for safety reasons.
206
199
  */
207
- FinishReason["SAFETY"] = "SAFETY";
200
+ SAFETY: 'SAFETY',
208
201
  /**
209
202
  * The candidate content was flagged for recitation reasons.
210
203
  */
211
- FinishReason["RECITATION"] = "RECITATION";
204
+ RECITATION: 'RECITATION',
212
205
  /**
213
206
  * Unknown reason.
214
207
  */
215
- FinishReason["OTHER"] = "OTHER";
208
+ OTHER: 'OTHER',
216
209
  /**
217
210
  * The candidate content contained forbidden terms.
218
211
  */
219
- FinishReason["BLOCKLIST"] = "BLOCKLIST";
212
+ BLOCKLIST: 'BLOCKLIST',
220
213
  /**
221
214
  * The candidate content potentially contained prohibited content.
222
215
  */
223
- FinishReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
216
+ PROHIBITED_CONTENT: 'PROHIBITED_CONTENT',
224
217
  /**
225
218
  * The candidate content potentially contained Sensitive Personally Identifiable Information (SPII).
226
219
  */
227
- FinishReason["SPII"] = "SPII";
220
+ SPII: 'SPII',
228
221
  /**
229
222
  * The function call generated by the model was invalid.
230
223
  */
231
- FinishReason["MALFORMED_FUNCTION_CALL"] = "MALFORMED_FUNCTION_CALL";
232
- })(exports.FinishReason || (exports.FinishReason = {}));
224
+ MALFORMED_FUNCTION_CALL: 'MALFORMED_FUNCTION_CALL'
225
+ };
233
226
  /**
234
227
  * @public
235
228
  */
236
- exports.FunctionCallingMode = void 0;
237
- (function (FunctionCallingMode) {
229
+ const FunctionCallingMode = {
238
230
  /**
239
231
  * Default model behavior; model decides to predict either a function call
240
232
  * or a natural language response.
241
233
  */
242
- FunctionCallingMode["AUTO"] = "AUTO";
234
+ AUTO: 'AUTO',
243
235
  /**
244
236
  * Model is constrained to always predicting a function call only.
245
237
  * If `allowed_function_names` is set, the predicted function call will be
246
238
  * limited to any one of `allowed_function_names`, else the predicted
247
239
  * function call will be any one of the provided `function_declarations`.
248
240
  */
249
- FunctionCallingMode["ANY"] = "ANY";
241
+ ANY: 'ANY',
250
242
  /**
251
243
  * Model will not predict any function call. Model behavior is same as when
252
244
  * not passing any function declarations.
253
245
  */
254
- FunctionCallingMode["NONE"] = "NONE";
255
- })(exports.FunctionCallingMode || (exports.FunctionCallingMode = {}));
246
+ NONE: 'NONE'
247
+ };
256
248
  /**
257
249
  * Content part modality.
258
250
  * @public
259
251
  */
260
- exports.Modality = void 0;
261
- (function (Modality) {
252
+ const Modality = {
262
253
  /**
263
254
  * Unspecified modality.
264
255
  */
265
- Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
256
+ MODALITY_UNSPECIFIED: 'MODALITY_UNSPECIFIED',
266
257
  /**
267
258
  * Plain text.
268
259
  */
269
- Modality["TEXT"] = "TEXT";
260
+ TEXT: 'TEXT',
270
261
  /**
271
262
  * Image.
272
263
  */
273
- Modality["IMAGE"] = "IMAGE";
264
+ IMAGE: 'IMAGE',
274
265
  /**
275
266
  * Video.
276
267
  */
277
- Modality["VIDEO"] = "VIDEO";
268
+ VIDEO: 'VIDEO',
278
269
  /**
279
270
  * Audio.
280
271
  */
281
- Modality["AUDIO"] = "AUDIO";
272
+ AUDIO: 'AUDIO',
282
273
  /**
283
274
  * Document (for example, PDF).
284
275
  */
285
- Modality["DOCUMENT"] = "DOCUMENT";
286
- })(exports.Modality || (exports.Modality = {}));
276
+ DOCUMENT: 'DOCUMENT'
277
+ };
287
278
  /**
288
279
  * Generation modalities to be returned in generation responses.
289
280
  *
@@ -302,6 +293,56 @@ const ResponseModality = {
302
293
  IMAGE: 'IMAGE'
303
294
  };
304
295
 
296
+ /**
297
+ * @license
298
+ * Copyright 2024 Google LLC
299
+ *
300
+ * Licensed under the Apache License, Version 2.0 (the "License");
301
+ * you may not use this file except in compliance with the License.
302
+ * You may obtain a copy of the License at
303
+ *
304
+ * http://www.apache.org/licenses/LICENSE-2.0
305
+ *
306
+ * Unless required by applicable law or agreed to in writing, software
307
+ * distributed under the License is distributed on an "AS IS" BASIS,
308
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
309
+ * See the License for the specific language governing permissions and
310
+ * limitations under the License.
311
+ */
312
+ /**
313
+ * Standardized error codes that {@link AIError} can have.
314
+ *
315
+ * @public
316
+ */
317
+ const AIErrorCode = {
318
+ /** A generic error occurred. */
319
+ ERROR: 'error',
320
+ /** An error occurred in a request. */
321
+ REQUEST_ERROR: 'request-error',
322
+ /** An error occurred in a response. */
323
+ RESPONSE_ERROR: 'response-error',
324
+ /** An error occurred while performing a fetch. */
325
+ FETCH_ERROR: 'fetch-error',
326
+ /** An error associated with a Content object. */
327
+ INVALID_CONTENT: 'invalid-content',
328
+ /** An error due to the Firebase API not being enabled in the Console. */
329
+ API_NOT_ENABLED: 'api-not-enabled',
330
+ /** An error due to invalid Schema input. */
331
+ INVALID_SCHEMA: 'invalid-schema',
332
+ /** An error occurred due to a missing Firebase API key. */
333
+ NO_API_KEY: 'no-api-key',
334
+ /** An error occurred due to a missing Firebase app ID. */
335
+ NO_APP_ID: 'no-app-id',
336
+ /** An error occurred due to a model name not being specified during initialization. */
337
+ NO_MODEL: 'no-model',
338
+ /** An error occurred due to a missing project ID. */
339
+ NO_PROJECT_ID: 'no-project-id',
340
+ /** An error occurred while parsing. */
341
+ PARSE_FAILED: 'parse-failed',
342
+ /** An error occurred due an attempt to use an unsupported feature. */
343
+ UNSUPPORTED: 'unsupported'
344
+ };
345
+
305
346
  /**
306
347
  * @license
307
348
  * Copyright 2024 Google LLC
@@ -324,21 +365,20 @@ const ResponseModality = {
324
365
  * {@link https://swagger.io/docs/specification/data-models/data-types/ | OpenAPI specification}
325
366
  * @public
326
367
  */
327
- exports.SchemaType = void 0;
328
- (function (SchemaType) {
368
+ const SchemaType = {
329
369
  /** String type. */
330
- SchemaType["STRING"] = "string";
370
+ STRING: 'string',
331
371
  /** Number type. */
332
- SchemaType["NUMBER"] = "number";
372
+ NUMBER: 'number',
333
373
  /** Integer type. */
334
- SchemaType["INTEGER"] = "integer";
374
+ INTEGER: 'integer',
335
375
  /** Boolean type. */
336
- SchemaType["BOOLEAN"] = "boolean";
376
+ BOOLEAN: 'boolean',
337
377
  /** Array type. */
338
- SchemaType["ARRAY"] = "array";
378
+ ARRAY: 'array',
339
379
  /** Object type. */
340
- SchemaType["OBJECT"] = "object";
341
- })(exports.SchemaType || (exports.SchemaType = {}));
380
+ OBJECT: 'object'
381
+ };
342
382
 
343
383
  /**
344
384
  * @license
@@ -368,28 +408,27 @@ exports.SchemaType = void 0;
368
408
  *
369
409
  * @beta
370
410
  */
371
- exports.ImagenSafetyFilterLevel = void 0;
372
- (function (ImagenSafetyFilterLevel) {
411
+ const ImagenSafetyFilterLevel = {
373
412
  /**
374
413
  * The most aggressive filtering level; most strict blocking.
375
414
  */
376
- ImagenSafetyFilterLevel["BLOCK_LOW_AND_ABOVE"] = "block_low_and_above";
415
+ BLOCK_LOW_AND_ABOVE: 'block_low_and_above',
377
416
  /**
378
417
  * Blocks some sensitive prompts and responses.
379
418
  */
380
- ImagenSafetyFilterLevel["BLOCK_MEDIUM_AND_ABOVE"] = "block_medium_and_above";
419
+ BLOCK_MEDIUM_AND_ABOVE: 'block_medium_and_above',
381
420
  /**
382
421
  * Blocks few sensitive prompts and responses.
383
422
  */
384
- ImagenSafetyFilterLevel["BLOCK_ONLY_HIGH"] = "block_only_high";
423
+ BLOCK_ONLY_HIGH: 'block_only_high',
385
424
  /**
386
425
  * The least aggressive filtering level; blocks very few sensitive prompts and responses.
387
426
  *
388
427
  * Access to this feature is restricted and may require your case to be reviewed and approved by
389
428
  * Cloud support.
390
429
  */
391
- ImagenSafetyFilterLevel["BLOCK_NONE"] = "block_none";
392
- })(exports.ImagenSafetyFilterLevel || (exports.ImagenSafetyFilterLevel = {}));
430
+ BLOCK_NONE: 'block_none'
431
+ };
393
432
  /**
394
433
  * A filter level controlling whether generation of images containing people or faces is allowed.
395
434
  *
@@ -398,12 +437,11 @@ exports.ImagenSafetyFilterLevel = void 0;
398
437
  *
399
438
  * @beta
400
439
  */
401
- exports.ImagenPersonFilterLevel = void 0;
402
- (function (ImagenPersonFilterLevel) {
440
+ const ImagenPersonFilterLevel = {
403
441
  /**
404
442
  * Disallow generation of images containing people or faces; images of people are filtered out.
405
443
  */
406
- ImagenPersonFilterLevel["BLOCK_ALL"] = "dont_allow";
444
+ BLOCK_ALL: 'dont_allow',
407
445
  /**
408
446
  * Allow generation of images containing adults only; images of children are filtered out.
409
447
  *
@@ -411,7 +449,7 @@ exports.ImagenPersonFilterLevel = void 0;
411
449
  * 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}
412
450
  * for more details.
413
451
  */
414
- ImagenPersonFilterLevel["ALLOW_ADULT"] = "allow_adult";
452
+ ALLOW_ADULT: 'allow_adult',
415
453
  /**
416
454
  * Allow generation of images containing adults only; images of children are filtered out.
417
455
  *
@@ -419,8 +457,8 @@ exports.ImagenPersonFilterLevel = void 0;
419
457
  * 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}
420
458
  * for more details.
421
459
  */
422
- ImagenPersonFilterLevel["ALLOW_ALL"] = "allow_all";
423
- })(exports.ImagenPersonFilterLevel || (exports.ImagenPersonFilterLevel = {}));
460
+ ALLOW_ALL: 'allow_all'
461
+ };
424
462
  /**
425
463
  * Aspect ratios for Imagen images.
426
464
  *
@@ -432,29 +470,28 @@ exports.ImagenPersonFilterLevel = void 0;
432
470
  *
433
471
  * @beta
434
472
  */
435
- exports.ImagenAspectRatio = void 0;
436
- (function (ImagenAspectRatio) {
473
+ const ImagenAspectRatio = {
437
474
  /**
438
475
  * Square (1:1) aspect ratio.
439
476
  */
440
- ImagenAspectRatio["SQUARE"] = "1:1";
477
+ 'SQUARE': '1:1',
441
478
  /**
442
479
  * Landscape (3:4) aspect ratio.
443
480
  */
444
- ImagenAspectRatio["LANDSCAPE_3x4"] = "3:4";
481
+ 'LANDSCAPE_3x4': '3:4',
445
482
  /**
446
483
  * Portrait (4:3) aspect ratio.
447
484
  */
448
- ImagenAspectRatio["PORTRAIT_4x3"] = "4:3";
485
+ 'PORTRAIT_4x3': '4:3',
449
486
  /**
450
487
  * Landscape (16:9) aspect ratio.
451
488
  */
452
- ImagenAspectRatio["LANDSCAPE_16x9"] = "16:9";
489
+ 'LANDSCAPE_16x9': '16:9',
453
490
  /**
454
491
  * Portrait (9:16) aspect ratio.
455
492
  */
456
- ImagenAspectRatio["PORTRAIT_9x16"] = "9:16";
457
- })(exports.ImagenAspectRatio || (exports.ImagenAspectRatio = {}));
493
+ 'PORTRAIT_9x16': '9:16'
494
+ };
458
495
 
459
496
  /**
460
497
  * @license
@@ -634,7 +671,7 @@ class AIError extends util.FirebaseError {
634
671
  /**
635
672
  * Constructs a new instance of the `AIError` class.
636
673
  *
637
- * @param code - The error code from {@link AIErrorCode}.
674
+ * @param code - The error code from {@link (AIErrorCode:type)}.
638
675
  * @param message - A human-readable message describing the error.
639
676
  * @param customErrorData - Optional error data.
640
677
  */
@@ -695,7 +732,7 @@ function encodeInstanceIdentifier(backend) {
695
732
  return `${AI_TYPE}/vertexai/${backend.location}`;
696
733
  }
697
734
  else {
698
- throw new AIError("error" /* AIErrorCode.ERROR */, `Invalid backend: ${JSON.stringify(backend.backendType)}`);
735
+ throw new AIError(AIErrorCode.ERROR, `Invalid backend: ${JSON.stringify(backend.backendType)}`);
699
736
  }
700
737
  }
701
738
  /**
@@ -706,20 +743,20 @@ function encodeInstanceIdentifier(backend) {
706
743
  function decodeInstanceIdentifier(instanceIdentifier) {
707
744
  const identifierParts = instanceIdentifier.split('/');
708
745
  if (identifierParts[0] !== AI_TYPE) {
709
- throw new AIError("error" /* AIErrorCode.ERROR */, `Invalid instance identifier, unknown prefix '${identifierParts[0]}'`);
746
+ throw new AIError(AIErrorCode.ERROR, `Invalid instance identifier, unknown prefix '${identifierParts[0]}'`);
710
747
  }
711
748
  const backendType = identifierParts[1];
712
749
  switch (backendType) {
713
750
  case 'vertexai':
714
751
  const location = identifierParts[2];
715
752
  if (!location) {
716
- throw new AIError("error" /* AIErrorCode.ERROR */, `Invalid instance identifier, unknown location '${instanceIdentifier}'`);
753
+ throw new AIError(AIErrorCode.ERROR, `Invalid instance identifier, unknown location '${instanceIdentifier}'`);
717
754
  }
718
755
  return new VertexAIBackend(location);
719
756
  case 'googleai':
720
757
  return new GoogleAIBackend();
721
758
  default:
722
- throw new AIError("error" /* AIErrorCode.ERROR */, `Invalid instance identifier string: '${instanceIdentifier}'`);
759
+ throw new AIError(AIErrorCode.ERROR, `Invalid instance identifier string: '${instanceIdentifier}'`);
723
760
  }
724
761
  }
725
762
 
@@ -768,13 +805,13 @@ class AIModel {
768
805
  constructor(ai, modelName) {
769
806
  var _a, _b, _c, _d, _e, _f;
770
807
  if (!((_b = (_a = ai.app) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.apiKey)) {
771
- throw new AIError("no-api-key" /* AIErrorCode.NO_API_KEY */, `The "apiKey" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid API key.`);
808
+ throw new AIError(AIErrorCode.NO_API_KEY, `The "apiKey" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid API key.`);
772
809
  }
773
810
  else if (!((_d = (_c = ai.app) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.projectId)) {
774
- throw new AIError("no-project-id" /* AIErrorCode.NO_PROJECT_ID */, `The "projectId" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid project ID.`);
811
+ throw new AIError(AIErrorCode.NO_PROJECT_ID, `The "projectId" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid project ID.`);
775
812
  }
776
813
  else if (!((_f = (_e = ai.app) === null || _e === void 0 ? void 0 : _e.options) === null || _f === void 0 ? void 0 : _f.appId)) {
777
- throw new AIError("no-app-id" /* AIErrorCode.NO_APP_ID */, `The "appId" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid app ID.`);
814
+ throw new AIError(AIErrorCode.NO_APP_ID, `The "appId" field is empty in the local Firebase config. Firebase AI requires this field to contain a valid app ID.`);
778
815
  }
779
816
  else {
780
817
  this._apiSettings = {
@@ -915,7 +952,7 @@ class RequestUrl {
915
952
  return `projects/${this.apiSettings.project}/locations/${this.apiSettings.backend.location}/${this.model}`;
916
953
  }
917
954
  else {
918
- throw new AIError("error" /* AIErrorCode.ERROR */, `Invalid backend: ${JSON.stringify(this.apiSettings.backend)}`);
955
+ throw new AIError(AIErrorCode.ERROR, `Invalid backend: ${JSON.stringify(this.apiSettings.backend)}`);
919
956
  }
920
957
  }
921
958
  get queryParams() {
@@ -1000,12 +1037,13 @@ async function makeRequest(model, task, apiSettings, stream, body, requestOption
1000
1037
  // ignored
1001
1038
  }
1002
1039
  if (response.status === 403 &&
1040
+ errorDetails &&
1003
1041
  errorDetails.some((detail) => detail.reason === 'SERVICE_DISABLED') &&
1004
1042
  errorDetails.some((detail) => {
1005
1043
  var _a, _b;
1006
1044
  return (_b = (_a = detail.links) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.description.includes('Google developers console API activation');
1007
1045
  })) {
1008
- throw new AIError("api-not-enabled" /* AIErrorCode.API_NOT_ENABLED */, `The Firebase AI SDK requires the Firebase AI ` +
1046
+ throw new AIError(AIErrorCode.API_NOT_ENABLED, `The Firebase AI SDK requires the Firebase AI ` +
1009
1047
  `API ('firebasevertexai.googleapis.com') to be enabled in your ` +
1010
1048
  `Firebase project. Enable this API by visiting the Firebase Console ` +
1011
1049
  `at https://console.firebase.google.com/project/${url.apiSettings.project}/genai/ ` +
@@ -1017,7 +1055,7 @@ async function makeRequest(model, task, apiSettings, stream, body, requestOption
1017
1055
  errorDetails
1018
1056
  });
1019
1057
  }
1020
- throw new AIError("fetch-error" /* AIErrorCode.FETCH_ERROR */, `Error fetching from ${url}: [${response.status} ${response.statusText}] ${message}`, {
1058
+ throw new AIError(AIErrorCode.FETCH_ERROR, `Error fetching from ${url}: [${response.status} ${response.statusText}] ${message}`, {
1021
1059
  status: response.status,
1022
1060
  statusText: response.statusText,
1023
1061
  errorDetails
@@ -1026,10 +1064,10 @@ async function makeRequest(model, task, apiSettings, stream, body, requestOption
1026
1064
  }
1027
1065
  catch (e) {
1028
1066
  let err = e;
1029
- if (e.code !== "fetch-error" /* AIErrorCode.FETCH_ERROR */ &&
1030
- e.code !== "api-not-enabled" /* AIErrorCode.API_NOT_ENABLED */ &&
1067
+ if (e.code !== AIErrorCode.FETCH_ERROR &&
1068
+ e.code !== AIErrorCode.API_NOT_ENABLED &&
1031
1069
  e instanceof Error) {
1032
- err = new AIError("error" /* AIErrorCode.ERROR */, `Error fetching from ${url.toString()}: ${e.message}`);
1070
+ err = new AIError(AIErrorCode.ERROR, `Error fetching from ${url.toString()}: ${e.message}`);
1033
1071
  err.stack = e.stack;
1034
1072
  }
1035
1073
  throw err;
@@ -1088,14 +1126,14 @@ function addHelpers(response) {
1088
1126
  `Access response.candidates directly to use the other candidates.`);
1089
1127
  }
1090
1128
  if (hadBadFinishReason(response.candidates[0])) {
1091
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, {
1129
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, {
1092
1130
  response
1093
1131
  });
1094
1132
  }
1095
1133
  return getText(response);
1096
1134
  }
1097
1135
  else if (response.promptFeedback) {
1098
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, `Text not available. ${formatBlockErrorMessage(response)}`, {
1136
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, `Text not available. ${formatBlockErrorMessage(response)}`, {
1099
1137
  response
1100
1138
  });
1101
1139
  }
@@ -1109,14 +1147,14 @@ function addHelpers(response) {
1109
1147
  `Access response.candidates directly to use the other candidates.`);
1110
1148
  }
1111
1149
  if (hadBadFinishReason(response.candidates[0])) {
1112
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, {
1150
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, {
1113
1151
  response
1114
1152
  });
1115
1153
  }
1116
1154
  return getInlineDataParts(response);
1117
1155
  }
1118
1156
  else if (response.promptFeedback) {
1119
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, `Data not available. ${formatBlockErrorMessage(response)}`, {
1157
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, `Data not available. ${formatBlockErrorMessage(response)}`, {
1120
1158
  response
1121
1159
  });
1122
1160
  }
@@ -1130,14 +1168,14 @@ function addHelpers(response) {
1130
1168
  `Access response.candidates directly to use the other candidates.`);
1131
1169
  }
1132
1170
  if (hadBadFinishReason(response.candidates[0])) {
1133
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, {
1171
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, `Response error: ${formatBlockErrorMessage(response)}. Response body stored in error.response`, {
1134
1172
  response
1135
1173
  });
1136
1174
  }
1137
1175
  return getFunctionCalls(response);
1138
1176
  }
1139
1177
  else if (response.promptFeedback) {
1140
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, `Function call not available. ${formatBlockErrorMessage(response)}`, {
1178
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, `Function call not available. ${formatBlockErrorMessage(response)}`, {
1141
1179
  response
1142
1180
  });
1143
1181
  }
@@ -1207,10 +1245,10 @@ function getInlineDataParts(response) {
1207
1245
  return undefined;
1208
1246
  }
1209
1247
  }
1210
- const badFinishReasons = [exports.FinishReason.RECITATION, exports.FinishReason.SAFETY];
1248
+ const badFinishReasons = [FinishReason.RECITATION, FinishReason.SAFETY];
1211
1249
  function hadBadFinishReason(candidate) {
1212
1250
  return (!!candidate.finishReason &&
1213
- badFinishReasons.includes(candidate.finishReason));
1251
+ badFinishReasons.some(reason => reason === candidate.finishReason));
1214
1252
  }
1215
1253
  function formatBlockErrorMessage(response) {
1216
1254
  var _a, _b, _c;
@@ -1250,7 +1288,7 @@ async function handlePredictResponse(response) {
1250
1288
  let filteredReason = undefined;
1251
1289
  // The backend should always send a non-empty array of predictions if the response was successful.
1252
1290
  if (!responseJson.predictions || ((_a = responseJson.predictions) === null || _a === void 0 ? void 0 : _a.length) === 0) {
1253
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, 'No predictions or filtered reason received from Vertex AI. Please report this issue with the full error details at https://github.com/firebase/firebase-js-sdk/issues.');
1291
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, 'No predictions or filtered reason received from Vertex AI. Please report this issue with the full error details at https://github.com/firebase/firebase-js-sdk/issues.');
1254
1292
  }
1255
1293
  for (const prediction of responseJson.predictions) {
1256
1294
  if (prediction.raiFilteredReason) {
@@ -1269,7 +1307,7 @@ async function handlePredictResponse(response) {
1269
1307
  });
1270
1308
  }
1271
1309
  else {
1272
- throw new AIError("response-error" /* AIErrorCode.RESPONSE_ERROR */, `Predictions array in response has missing properties. Response: ${JSON.stringify(responseJson)}`);
1310
+ throw new AIError(AIErrorCode.RESPONSE_ERROR, `Predictions array in response has missing properties. Response: ${JSON.stringify(responseJson)}`);
1273
1311
  }
1274
1312
  }
1275
1313
  return { images, filteredReason };
@@ -1316,7 +1354,7 @@ function mapGenerateContentRequest(generateContentRequest) {
1316
1354
  var _a, _b;
1317
1355
  (_a = generateContentRequest.safetySettings) === null || _a === void 0 ? void 0 : _a.forEach(safetySetting => {
1318
1356
  if (safetySetting.method) {
1319
- throw new AIError("unsupported" /* AIErrorCode.UNSUPPORTED */, 'SafetySetting.method is not supported in the the Gemini Developer API. Please remove this property.');
1357
+ throw new AIError(AIErrorCode.UNSUPPORTED, 'SafetySetting.method is not supported in the the Gemini Developer API. Please remove this property.');
1320
1358
  }
1321
1359
  });
1322
1360
  if ((_b = generateContentRequest.generationConfig) === null || _b === void 0 ? void 0 : _b.topK) {
@@ -1392,14 +1430,14 @@ function mapGenerateContentCandidates(candidates) {
1392
1430
  if (candidate.safetyRatings) {
1393
1431
  mappedSafetyRatings = candidate.safetyRatings.map(safetyRating => {
1394
1432
  var _a, _b, _c;
1395
- return Object.assign(Object.assign({}, safetyRating), { severity: (_a = safetyRating.severity) !== null && _a !== void 0 ? _a : exports.HarmSeverity.HARM_SEVERITY_UNSUPPORTED, probabilityScore: (_b = safetyRating.probabilityScore) !== null && _b !== void 0 ? _b : 0, severityScore: (_c = safetyRating.severityScore) !== null && _c !== void 0 ? _c : 0 });
1433
+ return Object.assign(Object.assign({}, safetyRating), { severity: (_a = safetyRating.severity) !== null && _a !== void 0 ? _a : HarmSeverity.HARM_SEVERITY_UNSUPPORTED, probabilityScore: (_b = safetyRating.probabilityScore) !== null && _b !== void 0 ? _b : 0, severityScore: (_c = safetyRating.severityScore) !== null && _c !== void 0 ? _c : 0 });
1396
1434
  });
1397
1435
  }
1398
1436
  // videoMetadata is not supported.
1399
1437
  // Throw early since developers may send a long video as input and only expect to pay
1400
1438
  // for inference on a small portion of the video.
1401
1439
  if ((_a = candidate.content) === null || _a === void 0 ? void 0 : _a.parts.some(part => part === null || part === void 0 ? void 0 : part.videoMetadata)) {
1402
- throw new AIError("unsupported" /* AIErrorCode.UNSUPPORTED */, 'Part.videoMetadata is not supported in the Gemini Developer API. Please remove this property.');
1440
+ throw new AIError(AIErrorCode.UNSUPPORTED, 'Part.videoMetadata is not supported in the Gemini Developer API. Please remove this property.');
1403
1441
  }
1404
1442
  const mappedCandidate = {
1405
1443
  index: candidate.index,
@@ -1423,7 +1461,7 @@ function mapPromptFeedback(promptFeedback) {
1423
1461
  mappedSafetyRatings.push({
1424
1462
  category: safetyRating.category,
1425
1463
  probability: safetyRating.probability,
1426
- severity: (_a = safetyRating.severity) !== null && _a !== void 0 ? _a : exports.HarmSeverity.HARM_SEVERITY_UNSUPPORTED,
1464
+ severity: (_a = safetyRating.severity) !== null && _a !== void 0 ? _a : HarmSeverity.HARM_SEVERITY_UNSUPPORTED,
1427
1465
  probabilityScore: (_b = safetyRating.probabilityScore) !== null && _b !== void 0 ? _b : 0,
1428
1466
  severityScore: (_c = safetyRating.severityScore) !== null && _c !== void 0 ? _c : 0,
1429
1467
  blocked: safetyRating.blocked
@@ -1520,7 +1558,7 @@ function getResponseStream(inputStream) {
1520
1558
  return reader.read().then(({ value, done }) => {
1521
1559
  if (done) {
1522
1560
  if (currentText.trim()) {
1523
- controller.error(new AIError("parse-failed" /* AIErrorCode.PARSE_FAILED */, 'Failed to parse stream'));
1561
+ controller.error(new AIError(AIErrorCode.PARSE_FAILED, 'Failed to parse stream'));
1524
1562
  return;
1525
1563
  }
1526
1564
  controller.close();
@@ -1534,7 +1572,7 @@ function getResponseStream(inputStream) {
1534
1572
  parsedResponse = JSON.parse(match[1]);
1535
1573
  }
1536
1574
  catch (e) {
1537
- controller.error(new AIError("parse-failed" /* AIErrorCode.PARSE_FAILED */, `Error parsing JSON response: "${match[1]}`));
1575
+ controller.error(new AIError(AIErrorCode.PARSE_FAILED, `Error parsing JSON response: "${match[1]}`));
1538
1576
  return;
1539
1577
  }
1540
1578
  controller.enqueue(parsedResponse);
@@ -1579,6 +1617,8 @@ function aggregateResponses(responses) {
1579
1617
  candidate.finishMessage;
1580
1618
  aggregatedResponse.candidates[i].safetyRatings =
1581
1619
  candidate.safetyRatings;
1620
+ aggregatedResponse.candidates[i].groundingMetadata =
1621
+ candidate.groundingMetadata;
1582
1622
  /**
1583
1623
  * Candidates should always have content and parts, but this handles
1584
1624
  * possible malformed responses.
@@ -1605,7 +1645,7 @@ function aggregateResponses(responses) {
1605
1645
  newPart.functionCall = part.functionCall;
1606
1646
  }
1607
1647
  if (Object.keys(newPart).length === 0) {
1608
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, 'Part should have at least one property, but there are none. This is likely caused ' +
1648
+ throw new AIError(AIErrorCode.INVALID_CONTENT, 'Part should have at least one property, but there are none. This is likely caused ' +
1609
1649
  'by a malformed response from the backend.');
1610
1650
  }
1611
1651
  aggregatedResponse.candidates[i].content.parts.push(newPart);
@@ -1740,10 +1780,10 @@ function assignRoleToPartsAndValidateSendMessageRequest(parts) {
1740
1780
  }
1741
1781
  }
1742
1782
  if (hasUserContent && hasFunctionContent) {
1743
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, 'Within a single message, FunctionResponse cannot be mixed with other type of Part in the request for sending chat message.');
1783
+ throw new AIError(AIErrorCode.INVALID_CONTENT, 'Within a single message, FunctionResponse cannot be mixed with other type of Part in the request for sending chat message.');
1744
1784
  }
1745
1785
  if (!hasUserContent && !hasFunctionContent) {
1746
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, 'No Content is provided for sending chat message.');
1786
+ throw new AIError(AIErrorCode.INVALID_CONTENT, 'No Content is provided for sending chat message.');
1747
1787
  }
1748
1788
  if (hasUserContent) {
1749
1789
  return userContent;
@@ -1836,16 +1876,16 @@ function validateChatHistory(history) {
1836
1876
  for (const currContent of history) {
1837
1877
  const { role, parts } = currContent;
1838
1878
  if (!prevContent && role !== 'user') {
1839
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, `First Content should be with role 'user', got ${role}`);
1879
+ throw new AIError(AIErrorCode.INVALID_CONTENT, `First Content should be with role 'user', got ${role}`);
1840
1880
  }
1841
1881
  if (!POSSIBLE_ROLES.includes(role)) {
1842
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, `Each item should include role field. Got ${role} but valid roles are: ${JSON.stringify(POSSIBLE_ROLES)}`);
1882
+ throw new AIError(AIErrorCode.INVALID_CONTENT, `Each item should include role field. Got ${role} but valid roles are: ${JSON.stringify(POSSIBLE_ROLES)}`);
1843
1883
  }
1844
1884
  if (!Array.isArray(parts)) {
1845
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, `Content should have 'parts' but property with an array of Parts`);
1885
+ throw new AIError(AIErrorCode.INVALID_CONTENT, `Content should have 'parts' but property with an array of Parts`);
1846
1886
  }
1847
1887
  if (parts.length === 0) {
1848
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, `Each Content should have at least one part`);
1888
+ throw new AIError(AIErrorCode.INVALID_CONTENT, `Each Content should have at least one part`);
1849
1889
  }
1850
1890
  const countFields = {
1851
1891
  text: 0,
@@ -1863,13 +1903,13 @@ function validateChatHistory(history) {
1863
1903
  const validParts = VALID_PARTS_PER_ROLE[role];
1864
1904
  for (const key of VALID_PART_FIELDS) {
1865
1905
  if (!validParts.includes(key) && countFields[key] > 0) {
1866
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, `Content with role '${role}' can't contain '${key}' part`);
1906
+ throw new AIError(AIErrorCode.INVALID_CONTENT, `Content with role '${role}' can't contain '${key}' part`);
1867
1907
  }
1868
1908
  }
1869
1909
  if (prevContent) {
1870
1910
  const validPreviousContentRoles = VALID_PREVIOUS_CONTENT_ROLES[role];
1871
1911
  if (!validPreviousContentRoles.includes(prevContent.role)) {
1872
- throw new AIError("invalid-content" /* AIErrorCode.INVALID_CONTENT */, `Content with role '${role}' can't follow '${prevContent.role}'. Valid previous roles: ${JSON.stringify(VALID_PREVIOUS_CONTENT_ROLES)}`);
1912
+ throw new AIError(AIErrorCode.INVALID_CONTENT, `Content with role '${role}' can't follow '${prevContent.role}'. Valid previous roles: ${JSON.stringify(VALID_PREVIOUS_CONTENT_ROLES)}`);
1873
1913
  }
1874
1914
  }
1875
1915
  prevContent = currContent;
@@ -2271,7 +2311,7 @@ class Schema {
2271
2311
  };
2272
2312
  for (const prop in this) {
2273
2313
  if (this.hasOwnProperty(prop) && this[prop] !== undefined) {
2274
- if (prop !== 'required' || this.type === exports.SchemaType.OBJECT) {
2314
+ if (prop !== 'required' || this.type === SchemaType.OBJECT) {
2275
2315
  obj[prop] = this[prop];
2276
2316
  }
2277
2317
  }
@@ -2309,7 +2349,7 @@ class Schema {
2309
2349
  */
2310
2350
  class IntegerSchema extends Schema {
2311
2351
  constructor(schemaParams) {
2312
- super(Object.assign({ type: exports.SchemaType.INTEGER }, schemaParams));
2352
+ super(Object.assign({ type: SchemaType.INTEGER }, schemaParams));
2313
2353
  }
2314
2354
  }
2315
2355
  /**
@@ -2318,7 +2358,7 @@ class IntegerSchema extends Schema {
2318
2358
  */
2319
2359
  class NumberSchema extends Schema {
2320
2360
  constructor(schemaParams) {
2321
- super(Object.assign({ type: exports.SchemaType.NUMBER }, schemaParams));
2361
+ super(Object.assign({ type: SchemaType.NUMBER }, schemaParams));
2322
2362
  }
2323
2363
  }
2324
2364
  /**
@@ -2327,7 +2367,7 @@ class NumberSchema extends Schema {
2327
2367
  */
2328
2368
  class BooleanSchema extends Schema {
2329
2369
  constructor(schemaParams) {
2330
- super(Object.assign({ type: exports.SchemaType.BOOLEAN }, schemaParams));
2370
+ super(Object.assign({ type: SchemaType.BOOLEAN }, schemaParams));
2331
2371
  }
2332
2372
  }
2333
2373
  /**
@@ -2337,7 +2377,7 @@ class BooleanSchema extends Schema {
2337
2377
  */
2338
2378
  class StringSchema extends Schema {
2339
2379
  constructor(schemaParams, enumValues) {
2340
- super(Object.assign({ type: exports.SchemaType.STRING }, schemaParams));
2380
+ super(Object.assign({ type: SchemaType.STRING }, schemaParams));
2341
2381
  this.enum = enumValues;
2342
2382
  }
2343
2383
  /**
@@ -2359,7 +2399,7 @@ class StringSchema extends Schema {
2359
2399
  */
2360
2400
  class ArraySchema extends Schema {
2361
2401
  constructor(schemaParams, items) {
2362
- super(Object.assign({ type: exports.SchemaType.ARRAY }, schemaParams));
2402
+ super(Object.assign({ type: SchemaType.ARRAY }, schemaParams));
2363
2403
  this.items = items;
2364
2404
  }
2365
2405
  /**
@@ -2378,7 +2418,7 @@ class ArraySchema extends Schema {
2378
2418
  */
2379
2419
  class ObjectSchema extends Schema {
2380
2420
  constructor(schemaParams, properties, optionalProperties = []) {
2381
- super(Object.assign({ type: exports.SchemaType.OBJECT }, schemaParams));
2421
+ super(Object.assign({ type: SchemaType.OBJECT }, schemaParams));
2382
2422
  this.properties = properties;
2383
2423
  this.optionalProperties = optionalProperties;
2384
2424
  }
@@ -2392,7 +2432,7 @@ class ObjectSchema extends Schema {
2392
2432
  if (this.optionalProperties) {
2393
2433
  for (const propertyKey of this.optionalProperties) {
2394
2434
  if (!this.properties.hasOwnProperty(propertyKey)) {
2395
- throw new AIError("invalid-schema" /* AIErrorCode.INVALID_SCHEMA */, `Property "${propertyKey}" specified in "optionalProperties" does not exist.`);
2435
+ throw new AIError(AIErrorCode.INVALID_SCHEMA, `Property "${propertyKey}" specified in "optionalProperties" does not exist.`);
2396
2436
  }
2397
2437
  }
2398
2438
  }
@@ -2492,50 +2532,6 @@ class ImagenImageFormat {
2492
2532
  * See the License for the specific language governing permissions and
2493
2533
  * limitations under the License.
2494
2534
  */
2495
- /**
2496
- * @deprecated Use the new {@link AIModel} instead. The Vertex AI in Firebase SDK has been
2497
- * replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
2498
- * services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
2499
- *
2500
- * Base class for Firebase AI model APIs.
2501
- *
2502
- * @public
2503
- */
2504
- const VertexAIModel = AIModel;
2505
- /**
2506
- * @deprecated Use the new {@link AIError} instead. The Vertex AI in Firebase SDK has been
2507
- * replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
2508
- * services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
2509
- *
2510
- * Error class for the Firebase AI SDK.
2511
- *
2512
- * @public
2513
- */
2514
- const VertexAIError = AIError;
2515
- /**
2516
- * @deprecated Use the new {@link getAI | getAI()} instead. The Vertex AI in Firebase SDK has been
2517
- * replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
2518
- * services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
2519
- *
2520
- * Returns a {@link VertexAI} instance for the given app, configured to use the
2521
- * Vertex AI Gemini API. This instance will be
2522
- * configured to use the Vertex AI Gemini API.
2523
- *
2524
- * @param app - The {@link @firebase/app#FirebaseApp} to use.
2525
- * @param options - Options to configure the Vertex AI instance, including the location.
2526
- *
2527
- * @public
2528
- */
2529
- function getVertexAI(app$1 = app.getApp(), options) {
2530
- app$1 = util.getModularInstance(app$1);
2531
- // Dependencies
2532
- const AIProvider = app._getProvider(app$1, AI_TYPE);
2533
- const backend = new VertexAIBackend(options === null || options === void 0 ? void 0 : options.location);
2534
- const identifier = encodeInstanceIdentifier(backend);
2535
- return AIProvider.getImmediate({
2536
- identifier
2537
- });
2538
- }
2539
2535
  /**
2540
2536
  * Returns the default {@link AI} instance that is associated with the provided
2541
2537
  * {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new instance with the
@@ -2581,7 +2577,7 @@ function getAI(app$1 = app.getApp(), options = { backend: new GoogleAIBackend()
2581
2577
  */
2582
2578
  function getGenerativeModel(ai, modelParams, requestOptions) {
2583
2579
  if (!modelParams.model) {
2584
- throw new AIError("no-model" /* AIErrorCode.NO_MODEL */, `Must provide a model name. Example: getGenerativeModel({ model: 'my-model-name' })`);
2580
+ throw new AIError(AIErrorCode.NO_MODEL, `Must provide a model name. Example: getGenerativeModel({ model: 'my-model-name' })`);
2585
2581
  }
2586
2582
  return new GenerativeModel(ai, modelParams, requestOptions);
2587
2583
  }
@@ -2601,7 +2597,7 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
2601
2597
  */
2602
2598
  function getImagenModel(ai, modelParams, requestOptions) {
2603
2599
  if (!modelParams.model) {
2604
- throw new AIError("no-model" /* AIErrorCode.NO_MODEL */, `Must provide a model name. Example: getImagenModel({ model: 'my-model-name' })`);
2600
+ throw new AIError(AIErrorCode.NO_MODEL, `Must provide a model name. Example: getImagenModel({ model: 'my-model-name' })`);
2605
2601
  }
2606
2602
  return new ImagenModel(ai, modelParams, requestOptions);
2607
2603
  }
@@ -2614,7 +2610,7 @@ function getImagenModel(ai, modelParams, requestOptions) {
2614
2610
  function registerAI() {
2615
2611
  app._registerComponent(new component.Component(AI_TYPE, (container, { instanceIdentifier }) => {
2616
2612
  if (!instanceIdentifier) {
2617
- throw new AIError("error" /* AIErrorCode.ERROR */, 'AIService instance identifier is undefined.');
2613
+ throw new AIError(AIErrorCode.ERROR, 'AIService instance identifier is undefined.');
2618
2614
  }
2619
2615
  const backend = decodeInstanceIdentifier(instanceIdentifier);
2620
2616
  // getImmediate for FirebaseApp will always succeed
@@ -2630,28 +2626,39 @@ function registerAI() {
2630
2626
  registerAI();
2631
2627
 
2632
2628
  exports.AIError = AIError;
2629
+ exports.AIErrorCode = AIErrorCode;
2633
2630
  exports.AIModel = AIModel;
2634
2631
  exports.ArraySchema = ArraySchema;
2635
2632
  exports.Backend = Backend;
2636
2633
  exports.BackendType = BackendType;
2634
+ exports.BlockReason = BlockReason;
2637
2635
  exports.BooleanSchema = BooleanSchema;
2638
2636
  exports.ChatSession = ChatSession;
2637
+ exports.FinishReason = FinishReason;
2638
+ exports.FunctionCallingMode = FunctionCallingMode;
2639
2639
  exports.GenerativeModel = GenerativeModel;
2640
2640
  exports.GoogleAIBackend = GoogleAIBackend;
2641
+ exports.HarmBlockMethod = HarmBlockMethod;
2642
+ exports.HarmBlockThreshold = HarmBlockThreshold;
2643
+ exports.HarmCategory = HarmCategory;
2644
+ exports.HarmProbability = HarmProbability;
2645
+ exports.HarmSeverity = HarmSeverity;
2646
+ exports.ImagenAspectRatio = ImagenAspectRatio;
2641
2647
  exports.ImagenImageFormat = ImagenImageFormat;
2642
2648
  exports.ImagenModel = ImagenModel;
2649
+ exports.ImagenPersonFilterLevel = ImagenPersonFilterLevel;
2650
+ exports.ImagenSafetyFilterLevel = ImagenSafetyFilterLevel;
2643
2651
  exports.IntegerSchema = IntegerSchema;
2652
+ exports.Modality = Modality;
2644
2653
  exports.NumberSchema = NumberSchema;
2645
2654
  exports.ObjectSchema = ObjectSchema;
2646
2655
  exports.POSSIBLE_ROLES = POSSIBLE_ROLES;
2647
2656
  exports.ResponseModality = ResponseModality;
2648
2657
  exports.Schema = Schema;
2658
+ exports.SchemaType = SchemaType;
2649
2659
  exports.StringSchema = StringSchema;
2650
2660
  exports.VertexAIBackend = VertexAIBackend;
2651
- exports.VertexAIError = VertexAIError;
2652
- exports.VertexAIModel = VertexAIModel;
2653
2661
  exports.getAI = getAI;
2654
2662
  exports.getGenerativeModel = getGenerativeModel;
2655
2663
  exports.getImagenModel = getImagenModel;
2656
- exports.getVertexAI = getVertexAI;
2657
2664
  //# sourceMappingURL=index.cjs.js.map