@firebase/ai 2.7.0-canary.65a553baf → 2.7.0-canary.691a506ec
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 +1 -0
- package/dist/ai.d.ts +1 -0
- package/dist/esm/index.esm.js +16 -4
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/constants.d.ts +1 -0
- package/dist/esm/src/types/internal.d.ts +2 -0
- package/dist/index.cjs.js +16 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +16 -4
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +16 -4
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/types/internal.d.ts +2 -0
- package/package.json +8 -8
|
@@ -21,6 +21,7 @@ export declare const STAGING_URL = "https://staging-firebasevertexai.sandbox.goo
|
|
|
21
21
|
export declare const DEFAULT_API_VERSION = "v1beta";
|
|
22
22
|
export declare const PACKAGE_VERSION: string;
|
|
23
23
|
export declare const LANGUAGE_TAG = "gl-js";
|
|
24
|
+
export declare const HYBRID_TAG = "hybrid";
|
|
24
25
|
export declare const DEFAULT_FETCH_TIMEOUT_MS: number;
|
|
25
26
|
/**
|
|
26
27
|
* Defines the name of the default in-cloud model to use for hybrid inference.
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
|
|
18
18
|
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
19
19
|
import { Backend } from '../backend';
|
|
20
|
+
import { InferenceMode } from './enums';
|
|
20
21
|
export * from './imagen/internal';
|
|
21
22
|
export interface ApiSettings {
|
|
22
23
|
apiKey: string;
|
|
@@ -30,4 +31,5 @@ export interface ApiSettings {
|
|
|
30
31
|
backend: Backend;
|
|
31
32
|
getAuthToken?: () => Promise<FirebaseAuthTokenData | null>;
|
|
32
33
|
getAppCheckToken?: () => Promise<AppCheckTokenResult>;
|
|
34
|
+
inferenceMode?: InferenceMode;
|
|
33
35
|
}
|
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.7.0-canary.
|
|
11
|
+
var version = "2.7.0-canary.691a506ec";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -32,6 +32,7 @@ const DEFAULT_DOMAIN = 'firebasevertexai.googleapis.com';
|
|
|
32
32
|
const DEFAULT_API_VERSION = 'v1beta';
|
|
33
33
|
const PACKAGE_VERSION = version;
|
|
34
34
|
const LANGUAGE_TAG = 'gl-js';
|
|
35
|
+
const HYBRID_TAG = 'hybrid';
|
|
35
36
|
const DEFAULT_FETCH_TIMEOUT_MS = 180 * 1000;
|
|
36
37
|
/**
|
|
37
38
|
* Defines the name of the default in-cloud model to use for hybrid inference.
|
|
@@ -1516,16 +1517,25 @@ class WebSocketUrl {
|
|
|
1516
1517
|
/**
|
|
1517
1518
|
* Log language and "fire/version" to x-goog-api-client
|
|
1518
1519
|
*/
|
|
1519
|
-
function getClientHeaders() {
|
|
1520
|
+
function getClientHeaders(url) {
|
|
1520
1521
|
const loggingTags = [];
|
|
1521
1522
|
loggingTags.push(`${LANGUAGE_TAG}/${PACKAGE_VERSION}`);
|
|
1522
1523
|
loggingTags.push(`fire/${PACKAGE_VERSION}`);
|
|
1524
|
+
/**
|
|
1525
|
+
* No call would be made if ONLY_ON_DEVICE.
|
|
1526
|
+
* ONLY_IN_CLOUD does not indicate an intention to use hybrid.
|
|
1527
|
+
*/
|
|
1528
|
+
if (url.params.apiSettings.inferenceMode === InferenceMode.PREFER_ON_DEVICE ||
|
|
1529
|
+
url.params.apiSettings.inferenceMode === InferenceMode.PREFER_IN_CLOUD) {
|
|
1530
|
+
// No version
|
|
1531
|
+
loggingTags.push(HYBRID_TAG);
|
|
1532
|
+
}
|
|
1523
1533
|
return loggingTags.join(' ');
|
|
1524
1534
|
}
|
|
1525
1535
|
async function getHeaders(url) {
|
|
1526
1536
|
const headers = new Headers();
|
|
1527
1537
|
headers.append('Content-Type', 'application/json');
|
|
1528
|
-
headers.append('x-goog-api-client', getClientHeaders());
|
|
1538
|
+
headers.append('x-goog-api-client', getClientHeaders(url));
|
|
1529
1539
|
headers.append('x-goog-api-key', url.params.apiSettings.apiKey);
|
|
1530
1540
|
if (url.params.apiSettings.automaticDataCollectionEnabled) {
|
|
1531
1541
|
headers.append('X-Firebase-Appid', url.params.apiSettings.appId);
|
|
@@ -4467,7 +4477,9 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
|
|
|
4467
4477
|
* chromeAdapterFactory() method.
|
|
4468
4478
|
*/
|
|
4469
4479
|
const chromeAdapter = ai.chromeAdapterFactory?.(hybridParams.mode, typeof window === 'undefined' ? undefined : window, hybridParams.onDeviceParams);
|
|
4470
|
-
|
|
4480
|
+
const generativeModel = new GenerativeModel(ai, inCloudParams, requestOptions, chromeAdapter);
|
|
4481
|
+
generativeModel._apiSettings.inferenceMode = hybridParams.mode;
|
|
4482
|
+
return generativeModel;
|
|
4471
4483
|
}
|
|
4472
4484
|
/**
|
|
4473
4485
|
* Returns an {@link ImagenModel} class with methods for using Imagen.
|