@firebase/ai 2.3.0-canary.ea8512812 → 2.4.0-20251007135320

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.
@@ -4,7 +4,7 @@ import { FirebaseError, Deferred, getModularInstance } from '@firebase/util';
4
4
  import { Logger } from '@firebase/logger';
5
5
 
6
6
  var name = "@firebase/ai";
7
- var version = "2.3.0-canary.ea8512812";
7
+ var version = "2.4.0-20251007135320";
8
8
 
9
9
  /**
10
10
  * @license
@@ -525,7 +525,7 @@ const SchemaType = {
525
525
  * and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
526
526
  * for more details.
527
527
  *
528
- * @beta
528
+ * @public
529
529
  */
530
530
  const ImagenSafetyFilterLevel = {
531
531
  /**
@@ -554,7 +554,7 @@ const ImagenSafetyFilterLevel = {
554
554
  * See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
555
555
  * documentation for more details.
556
556
  *
557
- * @beta
557
+ * @public
558
558
  */
559
559
  const ImagenPersonFilterLevel = {
560
560
  /**
@@ -587,7 +587,7 @@ const ImagenPersonFilterLevel = {
587
587
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
588
588
  * for more details and examples of the supported aspect ratios.
589
589
  *
590
- * @beta
590
+ * @public
591
591
  */
592
592
  const ImagenAspectRatio = {
593
593
  /**
@@ -2523,6 +2523,25 @@ class LiveSession {
2523
2523
  this.webSocketHandler.send(JSON.stringify(message));
2524
2524
  });
2525
2525
  }
2526
+ /**
2527
+ * Sends function responses to the server.
2528
+ *
2529
+ * @param functionResponses - The function responses to send.
2530
+ * @throws If this session has been closed.
2531
+ *
2532
+ * @beta
2533
+ */
2534
+ async sendFunctionResponses(functionResponses) {
2535
+ if (this.isClosed) {
2536
+ throw new AIError(AIErrorCode.REQUEST_ERROR, 'This LiveSession has been closed and cannot be used.');
2537
+ }
2538
+ const message = {
2539
+ toolResponse: {
2540
+ functionResponses
2541
+ }
2542
+ };
2543
+ this.webSocketHandler.send(JSON.stringify(message));
2544
+ }
2526
2545
  /**
2527
2546
  * Sends a stream of {@link GenerativeContentBlob}.
2528
2547
  *
@@ -2737,7 +2756,7 @@ class LiveGenerativeModel extends AIModel {
2737
2756
  * }
2738
2757
  * ```
2739
2758
  *
2740
- * @beta
2759
+ * @public
2741
2760
  */
2742
2761
  class ImagenModel extends AIModel {
2743
2762
  /**
@@ -2773,7 +2792,7 @@ class ImagenModel extends AIModel {
2773
2792
  * returned object will have a `filteredReason` property.
2774
2793
  * If all images are filtered, the `images` array will be empty.
2775
2794
  *
2776
- * @beta
2795
+ * @public
2777
2796
  */
2778
2797
  async generateImages(prompt) {
2779
2798
  const body = createPredictRequestBody(prompt, {
@@ -3236,7 +3255,7 @@ class AnyOfSchema extends Schema {
3236
3255
  * }
3237
3256
  * ```
3238
3257
  *
3239
- * @beta
3258
+ * @public
3240
3259
  */
3241
3260
  class ImagenImageFormat {
3242
3261
  constructor() {
@@ -3248,7 +3267,7 @@ class ImagenImageFormat {
3248
3267
  * @param compressionQuality - The level of compression (a number between 0 and 100).
3249
3268
  * @returns An {@link ImagenImageFormat} object for a JPEG image.
3250
3269
  *
3251
- * @beta
3270
+ * @public
3252
3271
  */
3253
3272
  static jpeg(compressionQuality) {
3254
3273
  if (compressionQuality &&
@@ -3262,7 +3281,7 @@ class ImagenImageFormat {
3262
3281
  *
3263
3282
  * @returns An {@link ImagenImageFormat} object for a PNG image.
3264
3283
  *
3265
- * @beta
3284
+ * @public
3266
3285
  */
3267
3286
  static png() {
3268
3287
  return { mimeType: 'image/png' };
@@ -3504,9 +3523,9 @@ class AudioConversationRunner {
3504
3523
  }
3505
3524
  else {
3506
3525
  try {
3507
- const resultPart = await this.options.functionCallingHandler(message.functionCalls);
3526
+ const functionResponse = await this.options.functionCallingHandler(message.functionCalls);
3508
3527
  if (!this.isStopped) {
3509
- void this.liveSession.send([resultPart]);
3528
+ void this.liveSession.sendFunctionResponses([functionResponse]);
3510
3529
  }
3511
3530
  }
3512
3531
  catch (e) {
@@ -3726,7 +3745,7 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
3726
3745
  * @throws If the `apiKey` or `projectId` fields are missing in your
3727
3746
  * Firebase config.
3728
3747
  *
3729
- * @beta
3748
+ * @public
3730
3749
  */
3731
3750
  function getImagenModel(ai, modelParams, requestOptions) {
3732
3751
  if (!modelParams.model) {