@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.
@@ -8,7 +8,7 @@ var util = require('@firebase/util');
8
8
  var logger$1 = require('@firebase/logger');
9
9
 
10
10
  var name = "@firebase/ai";
11
- var version = "2.3.0-canary.ea8512812";
11
+ var version = "2.4.0-20251007135320";
12
12
 
13
13
  /**
14
14
  * @license
@@ -529,7 +529,7 @@ const SchemaType = {
529
529
  * and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
530
530
  * for more details.
531
531
  *
532
- * @beta
532
+ * @public
533
533
  */
534
534
  const ImagenSafetyFilterLevel = {
535
535
  /**
@@ -558,7 +558,7 @@ const ImagenSafetyFilterLevel = {
558
558
  * See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
559
559
  * documentation for more details.
560
560
  *
561
- * @beta
561
+ * @public
562
562
  */
563
563
  const ImagenPersonFilterLevel = {
564
564
  /**
@@ -591,7 +591,7 @@ const ImagenPersonFilterLevel = {
591
591
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
592
592
  * for more details and examples of the supported aspect ratios.
593
593
  *
594
- * @beta
594
+ * @public
595
595
  */
596
596
  const ImagenAspectRatio = {
597
597
  /**
@@ -2527,6 +2527,25 @@ class LiveSession {
2527
2527
  this.webSocketHandler.send(JSON.stringify(message));
2528
2528
  });
2529
2529
  }
2530
+ /**
2531
+ * Sends function responses to the server.
2532
+ *
2533
+ * @param functionResponses - The function responses to send.
2534
+ * @throws If this session has been closed.
2535
+ *
2536
+ * @beta
2537
+ */
2538
+ async sendFunctionResponses(functionResponses) {
2539
+ if (this.isClosed) {
2540
+ throw new AIError(AIErrorCode.REQUEST_ERROR, 'This LiveSession has been closed and cannot be used.');
2541
+ }
2542
+ const message = {
2543
+ toolResponse: {
2544
+ functionResponses
2545
+ }
2546
+ };
2547
+ this.webSocketHandler.send(JSON.stringify(message));
2548
+ }
2530
2549
  /**
2531
2550
  * Sends a stream of {@link GenerativeContentBlob}.
2532
2551
  *
@@ -2741,7 +2760,7 @@ class LiveGenerativeModel extends AIModel {
2741
2760
  * }
2742
2761
  * ```
2743
2762
  *
2744
- * @beta
2763
+ * @public
2745
2764
  */
2746
2765
  class ImagenModel extends AIModel {
2747
2766
  /**
@@ -2777,7 +2796,7 @@ class ImagenModel extends AIModel {
2777
2796
  * returned object will have a `filteredReason` property.
2778
2797
  * If all images are filtered, the `images` array will be empty.
2779
2798
  *
2780
- * @beta
2799
+ * @public
2781
2800
  */
2782
2801
  async generateImages(prompt) {
2783
2802
  const body = createPredictRequestBody(prompt, {
@@ -3240,7 +3259,7 @@ class AnyOfSchema extends Schema {
3240
3259
  * }
3241
3260
  * ```
3242
3261
  *
3243
- * @beta
3262
+ * @public
3244
3263
  */
3245
3264
  class ImagenImageFormat {
3246
3265
  constructor() {
@@ -3252,7 +3271,7 @@ class ImagenImageFormat {
3252
3271
  * @param compressionQuality - The level of compression (a number between 0 and 100).
3253
3272
  * @returns An {@link ImagenImageFormat} object for a JPEG image.
3254
3273
  *
3255
- * @beta
3274
+ * @public
3256
3275
  */
3257
3276
  static jpeg(compressionQuality) {
3258
3277
  if (compressionQuality &&
@@ -3266,7 +3285,7 @@ class ImagenImageFormat {
3266
3285
  *
3267
3286
  * @returns An {@link ImagenImageFormat} object for a PNG image.
3268
3287
  *
3269
- * @beta
3288
+ * @public
3270
3289
  */
3271
3290
  static png() {
3272
3291
  return { mimeType: 'image/png' };
@@ -3508,9 +3527,9 @@ class AudioConversationRunner {
3508
3527
  }
3509
3528
  else {
3510
3529
  try {
3511
- const resultPart = await this.options.functionCallingHandler(message.functionCalls);
3530
+ const functionResponse = await this.options.functionCallingHandler(message.functionCalls);
3512
3531
  if (!this.isStopped) {
3513
- void this.liveSession.send([resultPart]);
3532
+ void this.liveSession.sendFunctionResponses([functionResponse]);
3514
3533
  }
3515
3534
  }
3516
3535
  catch (e) {
@@ -3730,7 +3749,7 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
3730
3749
  * @throws If the `apiKey` or `projectId` fields are missing in your
3731
3750
  * Firebase config.
3732
3751
  *
3733
- * @beta
3752
+ * @public
3734
3753
  */
3735
3754
  function getImagenModel(ai, modelParams, requestOptions) {
3736
3755
  if (!modelParams.model) {