@firebase/ai 2.2.0 → 2.2.1-canary.06ab5c4f9
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 +19 -138
- package/dist/ai.d.ts +19 -175
- package/dist/esm/index.esm.js +604 -515
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/factory-browser.d.ts +19 -0
- package/dist/esm/src/index.d.ts +0 -3
- package/dist/esm/src/requests/hybrid-helpers.d.ts +28 -0
- package/dist/esm/src/types/enums.d.ts +19 -0
- package/dist/index.cjs.js +603 -515
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +90 -18
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +90 -18
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/factory-browser.d.ts +19 -0
- package/dist/src/index.d.ts +0 -3
- package/dist/src/requests/hybrid-helpers.d.ts +28 -0
- package/dist/src/types/enums.d.ts +19 -0
- package/package.json +10 -9
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { ComponentContainer, InstanceFactoryOptions } from '@firebase/component';
|
|
18
|
+
import { AIService } from './service';
|
|
19
|
+
export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import { AIService } from './service';
|
|
7
|
-
import { ComponentContainer, InstanceFactoryOptions } from '@firebase/component';
|
|
8
6
|
import { LanguageModel } from './types/language-model';
|
|
9
7
|
declare global {
|
|
10
8
|
interface Window {
|
|
11
9
|
LanguageModel: LanguageModel;
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
|
-
export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
|
|
15
12
|
export * from './api';
|
|
16
13
|
export * from './public-types';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { GenerateContentRequest, ChromeAdapter } from '../types';
|
|
18
|
+
/**
|
|
19
|
+
* Dispatches a request to the appropriate backend (on-device or in-cloud)
|
|
20
|
+
* based on the inference mode.
|
|
21
|
+
*
|
|
22
|
+
* @param request - The request to be sent.
|
|
23
|
+
* @param chromeAdapter - The on-device model adapter.
|
|
24
|
+
* @param onDeviceCall - The function to call for on-device inference.
|
|
25
|
+
* @param inCloudCall - The function to call for in-cloud inference.
|
|
26
|
+
* @returns The response from the backend.
|
|
27
|
+
*/
|
|
28
|
+
export declare function callCloudOrDevice<Response>(request: GenerateContentRequest, chromeAdapter: ChromeAdapter | undefined, onDeviceCall: () => Promise<Response>, inCloudCall: () => Promise<Response>): Promise<Response>;
|
|
@@ -319,16 +319,35 @@ export type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseMo
|
|
|
319
319
|
/**
|
|
320
320
|
* <b>(EXPERIMENTAL)</b>
|
|
321
321
|
* Determines whether inference happens on-device or in-cloud.
|
|
322
|
+
*
|
|
323
|
+
* @remarks
|
|
324
|
+
* <b>PREFER_ON_DEVICE:</b> Attempt to make inference calls using an
|
|
325
|
+
* on-device model. If on-device inference is not available, the SDK
|
|
326
|
+
* will fall back to using a cloud-hosted model.
|
|
327
|
+
* <br/>
|
|
328
|
+
* <b>ONLY_ON_DEVICE:</b> Only attempt to make inference calls using an
|
|
329
|
+
* on-device model. The SDK will not fall back to a cloud-hosted model.
|
|
330
|
+
* If on-device inference is not available, inference methods will throw.
|
|
331
|
+
* <br/>
|
|
332
|
+
* <b>ONLY_IN_CLOUD:</b> Only attempt to make inference calls using a
|
|
333
|
+
* cloud-hosted model. The SDK will not fall back to an on-device model.
|
|
334
|
+
* <br/>
|
|
335
|
+
* <b>PREFER_IN_CLOUD:</b> Attempt to make inference calls to a
|
|
336
|
+
* cloud-hosted model. If not available, the SDK will fall back to an
|
|
337
|
+
* on-device model.
|
|
338
|
+
*
|
|
322
339
|
* @public
|
|
323
340
|
*/
|
|
324
341
|
export declare const InferenceMode: {
|
|
325
342
|
readonly PREFER_ON_DEVICE: "prefer_on_device";
|
|
326
343
|
readonly ONLY_ON_DEVICE: "only_on_device";
|
|
327
344
|
readonly ONLY_IN_CLOUD: "only_in_cloud";
|
|
345
|
+
readonly PREFER_IN_CLOUD: "prefer_in_cloud";
|
|
328
346
|
};
|
|
329
347
|
/**
|
|
330
348
|
* <b>(EXPERIMENTAL)</b>
|
|
331
349
|
* Determines whether inference happens on-device or in-cloud.
|
|
350
|
+
*
|
|
332
351
|
* @public
|
|
333
352
|
*/
|
|
334
353
|
export type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/ai",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1-canary.06ab5c4f9",
|
|
4
4
|
"description": "The Firebase AI SDK",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"engines": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dev": "rollup -c -w",
|
|
36
36
|
"update-responses": "../../scripts/update_vertexai_responses.sh",
|
|
37
37
|
"testsetup": "yarn update-responses && yarn ts-node ./test-utils/convert-mocks.ts",
|
|
38
|
-
"test": "run-p --npm-path npm lint test:browser",
|
|
38
|
+
"test": "run-p --npm-path npm lint type-check test:browser",
|
|
39
39
|
"test:ci": "yarn testsetup && node ../../scripts/run_tests_in_ci.js -s test",
|
|
40
40
|
"test:skip-clone": "karma start",
|
|
41
41
|
"test:browser": "yarn testsetup && karma start",
|
|
@@ -44,22 +44,23 @@
|
|
|
44
44
|
"test:integration:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha integration/**/*.test.ts --config ../../config/mocharc.node.js",
|
|
45
45
|
"api-report": "api-extractor run --local --verbose",
|
|
46
46
|
"typings:public": "node ../../scripts/build/use_typings.js ./dist/ai-public.d.ts",
|
|
47
|
+
"type-check": "yarn tsc --noEmit",
|
|
47
48
|
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
|
-
"@firebase/app": "0.
|
|
51
|
-
"@firebase/app-types": "0.
|
|
51
|
+
"@firebase/app": "0.14.2-canary.06ab5c4f9",
|
|
52
|
+
"@firebase/app-types": "0.9.3-canary.06ab5c4f9"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@firebase/app-check-interop-types": "0.3.3",
|
|
55
|
-
"@firebase/component": "0.7.0",
|
|
56
|
-
"@firebase/logger": "0.5.0",
|
|
57
|
-
"@firebase/util": "1.13.0",
|
|
55
|
+
"@firebase/app-check-interop-types": "0.3.3-canary.06ab5c4f9",
|
|
56
|
+
"@firebase/component": "0.7.0-canary.06ab5c4f9",
|
|
57
|
+
"@firebase/logger": "0.5.0-canary.06ab5c4f9",
|
|
58
|
+
"@firebase/util": "1.13.0-canary.06ab5c4f9",
|
|
58
59
|
"tslib": "^2.1.0"
|
|
59
60
|
},
|
|
60
61
|
"license": "Apache-2.0",
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@firebase/app": "0.14.2",
|
|
63
|
+
"@firebase/app": "0.14.2-canary.06ab5c4f9",
|
|
63
64
|
"@rollup/plugin-json": "6.1.0",
|
|
64
65
|
"rollup": "2.79.2",
|
|
65
66
|
"rollup-plugin-replace": "2.2.0",
|