@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.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { FirebaseError, getModularInstance } from '@firebase/util';
|
|
|
4
4
|
import { Logger } from '@firebase/logger';
|
|
5
5
|
|
|
6
6
|
var name = "@firebase/ai";
|
|
7
|
-
var version = "2.1.0-canary.
|
|
7
|
+
var version = "2.1.0-canary.cc605e728";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -2369,17 +2369,17 @@ class ChromeAdapterImpl {
|
|
|
2369
2369
|
/**
|
|
2370
2370
|
* Checks if a given request can be made on-device.
|
|
2371
2371
|
*
|
|
2372
|
-
*
|
|
2373
|
-
*
|
|
2374
|
-
*
|
|
2375
|
-
*
|
|
2376
|
-
*
|
|
2377
|
-
* </ol>
|
|
2372
|
+
* Encapsulates a few concerns:
|
|
2373
|
+
* the mode
|
|
2374
|
+
* API existence
|
|
2375
|
+
* prompt formatting
|
|
2376
|
+
* model availability, including triggering download if necessary
|
|
2378
2377
|
*
|
|
2379
|
-
*
|
|
2380
|
-
*
|
|
2378
|
+
*
|
|
2379
|
+
* Pros: callers needn't be concerned with details of on-device availability.</p>
|
|
2380
|
+
* Cons: this method spans a few concerns and splits request validation from usage.
|
|
2381
2381
|
* If instance variables weren't already part of the API, we could consider a better
|
|
2382
|
-
* separation of concerns
|
|
2382
|
+
* separation of concerns.
|
|
2383
2383
|
*/
|
|
2384
2384
|
async isAvailable(request) {
|
|
2385
2385
|
if (!this.mode) {
|
|
@@ -2420,8 +2420,9 @@ class ChromeAdapterImpl {
|
|
|
2420
2420
|
/**
|
|
2421
2421
|
* Generates content on device.
|
|
2422
2422
|
*
|
|
2423
|
-
*
|
|
2424
|
-
*
|
|
2423
|
+
* @remarks
|
|
2424
|
+
* This is comparable to {@link GenerativeModel.generateContent} for generating content in
|
|
2425
|
+
* Cloud.
|
|
2425
2426
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
2426
2427
|
* @returns {@link Response}, so we can reuse common response formatting.
|
|
2427
2428
|
*/
|
|
@@ -2434,8 +2435,9 @@ class ChromeAdapterImpl {
|
|
|
2434
2435
|
/**
|
|
2435
2436
|
* Generates content stream on device.
|
|
2436
2437
|
*
|
|
2437
|
-
*
|
|
2438
|
-
*
|
|
2438
|
+
* @remarks
|
|
2439
|
+
* This is comparable to {@link GenerativeModel.generateContentStream} for generating content in
|
|
2440
|
+
* Cloud.
|
|
2439
2441
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
2440
2442
|
* @returns {@link Response}, so we can reuse common response formatting.
|
|
2441
2443
|
*/
|
|
@@ -2486,11 +2488,11 @@ class ChromeAdapterImpl {
|
|
|
2486
2488
|
/**
|
|
2487
2489
|
* Triggers out-of-band download of an on-device model.
|
|
2488
2490
|
*
|
|
2489
|
-
*
|
|
2490
|
-
* LanguageModel.create
|
|
2491
|
+
* Chrome only downloads models as needed. Chrome knows a model is needed when code calls
|
|
2492
|
+
* LanguageModel.create.
|
|
2491
2493
|
*
|
|
2492
|
-
*
|
|
2493
|
-
* tracking if a download has previously been requested
|
|
2494
|
+
* Since Chrome manages the download, the SDK can only avoid redundant download requests by
|
|
2495
|
+
* tracking if a download has previously been requested.
|
|
2494
2496
|
*/
|
|
2495
2497
|
download() {
|
|
2496
2498
|
if (this.isDownloading) {
|
|
@@ -2544,12 +2546,12 @@ class ChromeAdapterImpl {
|
|
|
2544
2546
|
/**
|
|
2545
2547
|
* Abstracts Chrome session creation.
|
|
2546
2548
|
*
|
|
2547
|
-
*
|
|
2549
|
+
* Chrome uses a multi-turn session for all inference. Firebase AI uses single-turn for all
|
|
2548
2550
|
* inference. To map the Firebase AI API to Chrome's API, the SDK creates a new session for all
|
|
2549
|
-
* inference
|
|
2551
|
+
* inference.
|
|
2550
2552
|
*
|
|
2551
|
-
*
|
|
2552
|
-
* new session is created before an old session is destroyed
|
|
2553
|
+
* Chrome will remove a model from memory if it's no longer in use, so this method ensures a
|
|
2554
|
+
* new session is created before an old session is destroyed.
|
|
2553
2555
|
*/
|
|
2554
2556
|
async createSession() {
|
|
2555
2557
|
if (!this.languageModelProvider) {
|