@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.
- package/dist/ai-public.d.ts +28 -19
- package/dist/ai.d.ts +28 -19
- package/dist/esm/index.esm.js +31 -12
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/api.d.ts +1 -1
- package/dist/esm/src/methods/live-session-helpers.d.ts +2 -2
- package/dist/esm/src/methods/live-session.d.ts +10 -1
- package/dist/esm/src/models/imagen-model.d.ts +2 -2
- package/dist/esm/src/requests/imagen-image-format.d.ts +3 -3
- package/dist/esm/src/types/imagen/requests.d.ts +9 -9
- package/dist/esm/src/types/imagen/responses.d.ts +3 -3
- package/dist/esm/src/types/live-responses.d.ts +9 -1
- package/dist/index.cjs.js +31 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +31 -12
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +31 -12
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/api.d.ts +1 -1
- package/dist/src/methods/live-session-helpers.d.ts +2 -2
- package/dist/src/methods/live-session.d.ts +10 -1
- package/dist/src/models/imagen-model.d.ts +2 -2
- package/dist/src/requests/imagen-image-format.d.ts +3 -3
- package/dist/src/types/imagen/requests.d.ts +9 -9
- package/dist/src/types/imagen/responses.d.ts +3 -3
- package/dist/src/types/live-responses.d.ts +9 -1
- package/package.json +8 -8
package/dist/index.node.mjs
CHANGED
|
@@ -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.
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
|
3526
|
+
const functionResponse = await this.options.functionCallingHandler(message.functionCalls);
|
|
3508
3527
|
if (!this.isStopped) {
|
|
3509
|
-
void this.liveSession.
|
|
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
|
-
* @
|
|
3748
|
+
* @public
|
|
3730
3749
|
*/
|
|
3731
3750
|
function getImagenModel(ai, modelParams, requestOptions) {
|
|
3732
3751
|
if (!modelParams.model) {
|