@firebase/ai 2.1.0-canary.44d8d742f → 2.1.0-canary.5501791d0
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
|
@@ -34,24 +34,25 @@ export declare class ChromeAdapterImpl implements ChromeAdapter {
|
|
|
34
34
|
/**
|
|
35
35
|
* Checks if a given request can be made on-device.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* </ol>
|
|
37
|
+
* Encapsulates a few concerns:
|
|
38
|
+
* the mode
|
|
39
|
+
* API existence
|
|
40
|
+
* prompt formatting
|
|
41
|
+
* model availability, including triggering download if necessary
|
|
43
42
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
*
|
|
44
|
+
* Pros: callers needn't be concerned with details of on-device availability.</p>
|
|
45
|
+
* Cons: this method spans a few concerns and splits request validation from usage.
|
|
46
46
|
* If instance variables weren't already part of the API, we could consider a better
|
|
47
|
-
* separation of concerns
|
|
47
|
+
* separation of concerns.
|
|
48
48
|
*/
|
|
49
49
|
isAvailable(request: GenerateContentRequest): Promise<boolean>;
|
|
50
50
|
/**
|
|
51
51
|
* Generates content on device.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* This is comparable to {@link GenerativeModel.generateContent} for generating content in
|
|
55
|
+
* Cloud.
|
|
55
56
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
56
57
|
* @returns {@link Response}, so we can reuse common response formatting.
|
|
57
58
|
*/
|
|
@@ -59,8 +60,9 @@ export declare class ChromeAdapterImpl implements ChromeAdapter {
|
|
|
59
60
|
/**
|
|
60
61
|
* Generates content stream on device.
|
|
61
62
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* This is comparable to {@link GenerativeModel.generateContentStream} for generating content in
|
|
65
|
+
* Cloud.
|
|
64
66
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
65
67
|
* @returns {@link Response}, so we can reuse common response formatting.
|
|
66
68
|
*/
|
|
@@ -77,11 +79,11 @@ export declare class ChromeAdapterImpl implements ChromeAdapter {
|
|
|
77
79
|
/**
|
|
78
80
|
* Triggers out-of-band download of an on-device model.
|
|
79
81
|
*
|
|
80
|
-
*
|
|
81
|
-
* LanguageModel.create
|
|
82
|
+
* Chrome only downloads models as needed. Chrome knows a model is needed when code calls
|
|
83
|
+
* LanguageModel.create.
|
|
82
84
|
*
|
|
83
|
-
*
|
|
84
|
-
* tracking if a download has previously been requested
|
|
85
|
+
* Since Chrome manages the download, the SDK can only avoid redundant download requests by
|
|
86
|
+
* tracking if a download has previously been requested.
|
|
85
87
|
*/
|
|
86
88
|
private download;
|
|
87
89
|
/**
|
|
@@ -99,12 +101,12 @@ export declare class ChromeAdapterImpl implements ChromeAdapter {
|
|
|
99
101
|
/**
|
|
100
102
|
* Abstracts Chrome session creation.
|
|
101
103
|
*
|
|
102
|
-
*
|
|
104
|
+
* Chrome uses a multi-turn session for all inference. Firebase AI uses single-turn for all
|
|
103
105
|
* inference. To map the Firebase AI API to Chrome's API, the SDK creates a new session for all
|
|
104
|
-
* inference
|
|
106
|
+
* inference.
|
|
105
107
|
*
|
|
106
|
-
*
|
|
107
|
-
* new session is created before an old session is destroyed
|
|
108
|
+
* Chrome will remove a model from memory if it's no longer in use, so this method ensures a
|
|
109
|
+
* new session is created before an old session is destroyed.
|
|
108
110
|
*/
|
|
109
111
|
private createSession;
|
|
110
112
|
/**
|
|
@@ -34,16 +34,18 @@ export interface ChromeAdapter {
|
|
|
34
34
|
/**
|
|
35
35
|
* Generates content using on-device inference.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* This is comparable to {@link GenerativeModel.generateContent} for generating
|
|
39
|
+
* content using in-cloud inference.
|
|
39
40
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
40
41
|
*/
|
|
41
42
|
generateContent(request: GenerateContentRequest): Promise<Response>;
|
|
42
43
|
/**
|
|
43
44
|
* Generates a content stream using on-device inference.
|
|
44
45
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This is comparable to {@link GenerativeModel.generateContentStream} for generating
|
|
48
|
+
* a content stream using in-cloud inference.
|
|
47
49
|
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
48
50
|
*/
|
|
49
51
|
generateContentStream(request: GenerateContentRequest): Promise<Response>;
|
|
@@ -146,7 +146,10 @@ export interface RequestOptions {
|
|
|
146
146
|
*/
|
|
147
147
|
timeout?: number;
|
|
148
148
|
/**
|
|
149
|
-
* Base url for endpoint. Defaults to
|
|
149
|
+
* Base url for endpoint. Defaults to
|
|
150
|
+
* https://firebasevertexai.googleapis.com, which is the
|
|
151
|
+
* {@link https://console.cloud.google.com/apis/library/firebasevertexai.googleapis.com?project=_ | Firebase AI Logic API}
|
|
152
|
+
* (used regardless of your chosen Gemini API provider).
|
|
150
153
|
*/
|
|
151
154
|
baseUrl?: string;
|
|
152
155
|
}
|
package/dist/index.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.5501791d0";
|
|
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) {
|