@firebase/ai 2.1.0-canary.44d8d742f → 2.1.0-firebase-studio-sdk-integration.f7536090e
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/ai",
|
|
3
|
-
"version": "2.1.0-
|
|
3
|
+
"version": "2.1.0-firebase-studio-sdk-integration.f7536090e",
|
|
4
4
|
"description": "The Firebase AI SDK",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"engines": {
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@firebase/app": "0.14.1-
|
|
49
|
-
"@firebase/app-types": "0.9.3-
|
|
48
|
+
"@firebase/app": "0.14.1-firebase-studio-sdk-integration.f7536090e",
|
|
49
|
+
"@firebase/app-types": "0.9.3-firebase-studio-sdk-integration.f7536090e"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@firebase/app-check-interop-types": "0.3.3-
|
|
53
|
-
"@firebase/component": "0.7.0-
|
|
54
|
-
"@firebase/logger": "0.5.0-
|
|
55
|
-
"@firebase/util": "1.13.0-
|
|
52
|
+
"@firebase/app-check-interop-types": "0.3.3-firebase-studio-sdk-integration.f7536090e",
|
|
53
|
+
"@firebase/component": "0.7.0-firebase-studio-sdk-integration.f7536090e",
|
|
54
|
+
"@firebase/logger": "0.5.0-firebase-studio-sdk-integration.f7536090e",
|
|
55
|
+
"@firebase/util": "1.13.0-firebase-studio-sdk-integration.f7536090e",
|
|
56
56
|
"tslib": "^2.1.0"
|
|
57
57
|
},
|
|
58
58
|
"license": "Apache-2.0",
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@firebase/app": "0.14.1-
|
|
60
|
+
"@firebase/app": "0.14.1-firebase-studio-sdk-integration.f7536090e",
|
|
61
61
|
"@rollup/plugin-json": "6.1.0",
|
|
62
62
|
"rollup": "2.79.2",
|
|
63
63
|
"rollup-plugin-replace": "2.2.0",
|