@firebase/ai 2.1.0-20250806231852 → 2.1.0-canary.02280d747
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 +43 -5
- package/dist/ai.d.ts +43 -6
- package/dist/esm/index.esm.js +58 -38
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/index.d.ts +3 -0
- package/dist/esm/src/methods/chrome-adapter.d.ts +23 -21
- package/dist/esm/src/models/ai-model.d.ts +1 -1
- package/dist/esm/src/public-types.d.ts +10 -1
- package/dist/esm/src/service.d.ts +4 -1
- 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 +58 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +45 -26
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +45 -26
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/methods/chrome-adapter.d.ts +23 -21
- package/dist/src/models/ai-model.d.ts +1 -1
- package/dist/src/public-types.d.ts +10 -1
- package/dist/src/service.d.ts +4 -1
- 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/src/index.d.ts
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
+
import { AIService } from './service';
|
|
7
|
+
import { ComponentContainer, InstanceFactoryOptions } from '@firebase/component';
|
|
6
8
|
declare global {
|
|
7
9
|
interface Window {
|
|
8
10
|
[key: string]: unknown;
|
|
9
11
|
}
|
|
10
12
|
}
|
|
13
|
+
export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
|
|
11
14
|
export * from './api';
|
|
12
15
|
export * from './public-types';
|
|
@@ -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
|
/**
|
|
@@ -35,6 +35,10 @@ export interface AI {
|
|
|
35
35
|
* Vertex AI Gemini API (using {@link VertexAIBackend}).
|
|
36
36
|
*/
|
|
37
37
|
backend: Backend;
|
|
38
|
+
/**
|
|
39
|
+
* Options applied to this {@link AI} instance.
|
|
40
|
+
*/
|
|
41
|
+
options?: AIOptions;
|
|
38
42
|
/**
|
|
39
43
|
* @deprecated use `AI.backend.location` instead.
|
|
40
44
|
*
|
|
@@ -83,6 +87,11 @@ export type BackendType = (typeof BackendType)[keyof typeof BackendType];
|
|
|
83
87
|
export interface AIOptions {
|
|
84
88
|
/**
|
|
85
89
|
* The backend configuration to use for the AI service instance.
|
|
90
|
+
* Defaults to the Gemini Developer API backend ({@link GoogleAIBackend}).
|
|
86
91
|
*/
|
|
87
|
-
backend
|
|
92
|
+
backend?: Backend;
|
|
93
|
+
/**
|
|
94
|
+
* Whether to use App Check limited use tokens. Defaults to false.
|
|
95
|
+
*/
|
|
96
|
+
useLimitedUseAppCheckTokens?: boolean;
|
|
88
97
|
}
|
package/dist/src/service.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { FirebaseApp, _FirebaseService } from '@firebase/app';
|
|
18
|
-
import { AI } from './public-types';
|
|
18
|
+
import { AI, AIOptions } from './public-types';
|
|
19
19
|
import { AppCheckInternalComponentName, FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
|
|
20
20
|
import { Provider } from '@firebase/component';
|
|
21
21
|
import { FirebaseAuthInternal, FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
@@ -25,7 +25,10 @@ export declare class AIService implements AI, _FirebaseService {
|
|
|
25
25
|
backend: Backend;
|
|
26
26
|
auth: FirebaseAuthInternal | null;
|
|
27
27
|
appCheck: FirebaseAppCheckInternal | null;
|
|
28
|
+
_options?: Omit<AIOptions, 'backend'>;
|
|
28
29
|
location: string;
|
|
29
30
|
constructor(app: FirebaseApp, backend: Backend, authProvider?: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>);
|
|
30
31
|
_delete(): Promise<void>;
|
|
32
|
+
set options(optionsToSet: AIOptions);
|
|
33
|
+
get options(): AIOptions | undefined;
|
|
31
34
|
}
|
|
@@ -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-canary.02280d747",
|
|
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.
|
|
49
|
-
"@firebase/app-types": "0.
|
|
48
|
+
"@firebase/app": "0.14.1-canary.02280d747",
|
|
49
|
+
"@firebase/app-types": "0.9.3-canary.02280d747"
|
|
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-canary.02280d747",
|
|
53
|
+
"@firebase/component": "0.7.0-canary.02280d747",
|
|
54
|
+
"@firebase/logger": "0.5.0-canary.02280d747",
|
|
55
|
+
"@firebase/util": "1.13.0-canary.02280d747",
|
|
56
56
|
"tslib": "^2.1.0"
|
|
57
57
|
},
|
|
58
58
|
"license": "Apache-2.0",
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@firebase/app": "0.14.
|
|
60
|
+
"@firebase/app": "0.14.1-canary.02280d747",
|
|
61
61
|
"@rollup/plugin-json": "6.1.0",
|
|
62
62
|
"rollup": "2.79.2",
|
|
63
63
|
"rollup-plugin-replace": "2.2.0",
|