@firebase/ai 2.1.0-canary.44d8d742f → 2.1.0-canary.cc605e728
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 +10 -5
- package/dist/ai.d.ts +10 -5
- package/dist/esm/index.esm.js +24 -22
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/methods/chrome-adapter.d.ts +23 -21
- package/dist/esm/src/types/chrome-adapter.d.ts +6 -4
- package/dist/esm/src/types/requests.d.ts +4 -1
- package/dist/index.cjs.js +24 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +24 -22
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +24 -22
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/methods/chrome-adapter.d.ts +23 -21
- package/dist/src/types/chrome-adapter.d.ts +6 -4
- package/dist/src/types/requests.d.ts +4 -1
- package/package.json +8 -8
package/dist/index.node.cjs.js
CHANGED
|
@@ -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.1.0-canary.
|
|
11
|
+
var version = "2.1.0-canary.cc605e728";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -2373,17 +2373,17 @@ class ChromeAdapterImpl {
|
|
|
2373
2373
|
/**
|
|
2374
2374
|
* Checks if a given request can be made on-device.
|
|
2375
2375
|
*
|
|
2376
|
-
*
|
|
2377
|
-
*
|
|
2378
|
-
*
|
|
2379
|
-
*
|
|
2380
|
-
*
|
|
2381
|
-
* </ol>
|
|
2376
|
+
* Encapsulates a few concerns:
|
|
2377
|
+
* the mode
|
|
2378
|
+
* API existence
|
|
2379
|
+
* prompt formatting
|
|
2380
|
+
* model availability, including triggering download if necessary
|
|
2382
2381
|
*
|
|
2383
|
-
*
|
|
2384
|
-
*
|
|
2382
|
+
*
|
|
2383
|
+
* Pros: callers needn't be concerned with details of on-device availability.</p>
|
|
2384
|
+
* Cons: this method spans a few concerns and splits request validation from usage.
|
|
2385
2385
|
* If instance variables weren't already part of the API, we could consider a better
|
|
2386
|
-
* separation of concerns
|
|
2386
|
+
* separation of concerns.
|
|
2387
2387
|
*/
|
|
2388
2388
|
async isAvailable(request) {
|
|
2389
2389
|
if (!this.mode) {
|
|
@@ -2424,8 +2424,9 @@ class ChromeAdapterImpl {
|
|
|
2424
2424
|
/**
|
|
2425
2425
|
* Generates content on device.
|
|
2426
2426
|
*
|
|
2427
|
-
*
|
|
2428
|
-
*
|
|
2427
|
+
* @remarks
|
|
2428
|
+
* This is comparable to {@link GenerativeModel.generateContent} for generating content in
|
|
2429
|
+
* Cloud.
|
|
2429
2430
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
2430
2431
|
* @returns {@link Response}, so we can reuse common response formatting.
|
|
2431
2432
|
*/
|
|
@@ -2438,8 +2439,9 @@ class ChromeAdapterImpl {
|
|
|
2438
2439
|
/**
|
|
2439
2440
|
* Generates content stream on device.
|
|
2440
2441
|
*
|
|
2441
|
-
*
|
|
2442
|
-
*
|
|
2442
|
+
* @remarks
|
|
2443
|
+
* This is comparable to {@link GenerativeModel.generateContentStream} for generating content in
|
|
2444
|
+
* Cloud.
|
|
2443
2445
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
2444
2446
|
* @returns {@link Response}, so we can reuse common response formatting.
|
|
2445
2447
|
*/
|
|
@@ -2490,11 +2492,11 @@ class ChromeAdapterImpl {
|
|
|
2490
2492
|
/**
|
|
2491
2493
|
* Triggers out-of-band download of an on-device model.
|
|
2492
2494
|
*
|
|
2493
|
-
*
|
|
2494
|
-
* LanguageModel.create
|
|
2495
|
+
* Chrome only downloads models as needed. Chrome knows a model is needed when code calls
|
|
2496
|
+
* LanguageModel.create.
|
|
2495
2497
|
*
|
|
2496
|
-
*
|
|
2497
|
-
* tracking if a download has previously been requested
|
|
2498
|
+
* Since Chrome manages the download, the SDK can only avoid redundant download requests by
|
|
2499
|
+
* tracking if a download has previously been requested.
|
|
2498
2500
|
*/
|
|
2499
2501
|
download() {
|
|
2500
2502
|
if (this.isDownloading) {
|
|
@@ -2548,12 +2550,12 @@ class ChromeAdapterImpl {
|
|
|
2548
2550
|
/**
|
|
2549
2551
|
* Abstracts Chrome session creation.
|
|
2550
2552
|
*
|
|
2551
|
-
*
|
|
2553
|
+
* Chrome uses a multi-turn session for all inference. Firebase AI uses single-turn for all
|
|
2552
2554
|
* inference. To map the Firebase AI API to Chrome's API, the SDK creates a new session for all
|
|
2553
|
-
* inference
|
|
2555
|
+
* inference.
|
|
2554
2556
|
*
|
|
2555
|
-
*
|
|
2556
|
-
* new session is created before an old session is destroyed
|
|
2557
|
+
* Chrome will remove a model from memory if it's no longer in use, so this method ensures a
|
|
2558
|
+
* new session is created before an old session is destroyed.
|
|
2557
2559
|
*/
|
|
2558
2560
|
async createSession() {
|
|
2559
2561
|
if (!this.languageModelProvider) {
|