@firebase/ai 2.7.0-canary.58ddd6e54 → 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 +13 -0
- package/dist/ai.d.ts +13 -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/esm/src/types/responses.d.ts +12 -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/dist/src/types/responses.d.ts +12 -0
- package/package.json +8 -8
package/dist/ai-public.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ declare interface ApiSettings {
|
|
|
165
165
|
backend: Backend;
|
|
166
166
|
getAuthToken?: () => Promise<FirebaseAuthTokenData | null>;
|
|
167
167
|
getAppCheckToken?: () => Promise<AppCheckTokenResult>;
|
|
168
|
+
inferenceMode?: InferenceMode;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
/**
|
|
@@ -3329,6 +3330,18 @@ export declare interface UsageMetadata {
|
|
|
3329
3330
|
* A list of tokens used by tools, broken down by modality.
|
|
3330
3331
|
*/
|
|
3331
3332
|
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
3333
|
+
/**
|
|
3334
|
+
* The number of tokens in the prompt that were served from the cache.
|
|
3335
|
+
* If implicit caching is not active or no content was cached,
|
|
3336
|
+
* this will be 0.
|
|
3337
|
+
*/
|
|
3338
|
+
cachedContentTokenCount?: number;
|
|
3339
|
+
/**
|
|
3340
|
+
* Detailed breakdown of the cached tokens by modality (for example, text or
|
|
3341
|
+
* image). This list provides granular insight into which parts of
|
|
3342
|
+
* the content were cached.
|
|
3343
|
+
*/
|
|
3344
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
3332
3345
|
}
|
|
3333
3346
|
|
|
3334
3347
|
/**
|
package/dist/ai.d.ts
CHANGED
|
@@ -202,6 +202,7 @@ declare interface ApiSettings {
|
|
|
202
202
|
backend: Backend;
|
|
203
203
|
getAuthToken?: () => Promise<FirebaseAuthTokenData | null>;
|
|
204
204
|
getAppCheckToken?: () => Promise<AppCheckTokenResult>;
|
|
205
|
+
inferenceMode?: InferenceMode;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
/**
|
|
@@ -3492,6 +3493,18 @@ export declare interface UsageMetadata {
|
|
|
3492
3493
|
* A list of tokens used by tools, broken down by modality.
|
|
3493
3494
|
*/
|
|
3494
3495
|
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
3496
|
+
/**
|
|
3497
|
+
* The number of tokens in the prompt that were served from the cache.
|
|
3498
|
+
* If implicit caching is not active or no content was cached,
|
|
3499
|
+
* this will be 0.
|
|
3500
|
+
*/
|
|
3501
|
+
cachedContentTokenCount?: number;
|
|
3502
|
+
/**
|
|
3503
|
+
* Detailed breakdown of the cached tokens by modality (for example, text or
|
|
3504
|
+
* image). This list provides granular insight into which parts of
|
|
3505
|
+
* the content were cached.
|
|
3506
|
+
*/
|
|
3507
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
3495
3508
|
}
|
|
3496
3509
|
|
|
3497
3510
|
/**
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FirebaseError, Deferred, getModularInstance } from '@firebase/util';
|
|
|
4
4
|
import { Logger } from '@firebase/logger';
|
|
5
5
|
|
|
6
6
|
var name = "@firebase/ai";
|
|
7
|
-
var version = "2.7.0-canary.
|
|
7
|
+
var version = "2.7.0-canary.691a506ec";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -28,6 +28,7 @@ const DEFAULT_DOMAIN = 'firebasevertexai.googleapis.com';
|
|
|
28
28
|
const DEFAULT_API_VERSION = 'v1beta';
|
|
29
29
|
const PACKAGE_VERSION = version;
|
|
30
30
|
const LANGUAGE_TAG = 'gl-js';
|
|
31
|
+
const HYBRID_TAG = 'hybrid';
|
|
31
32
|
const DEFAULT_FETCH_TIMEOUT_MS = 180 * 1000;
|
|
32
33
|
/**
|
|
33
34
|
* Defines the name of the default in-cloud model to use for hybrid inference.
|
|
@@ -1512,16 +1513,25 @@ class WebSocketUrl {
|
|
|
1512
1513
|
/**
|
|
1513
1514
|
* Log language and "fire/version" to x-goog-api-client
|
|
1514
1515
|
*/
|
|
1515
|
-
function getClientHeaders() {
|
|
1516
|
+
function getClientHeaders(url) {
|
|
1516
1517
|
const loggingTags = [];
|
|
1517
1518
|
loggingTags.push(`${LANGUAGE_TAG}/${PACKAGE_VERSION}`);
|
|
1518
1519
|
loggingTags.push(`fire/${PACKAGE_VERSION}`);
|
|
1520
|
+
/**
|
|
1521
|
+
* No call would be made if ONLY_ON_DEVICE.
|
|
1522
|
+
* ONLY_IN_CLOUD does not indicate an intention to use hybrid.
|
|
1523
|
+
*/
|
|
1524
|
+
if (url.params.apiSettings.inferenceMode === InferenceMode.PREFER_ON_DEVICE ||
|
|
1525
|
+
url.params.apiSettings.inferenceMode === InferenceMode.PREFER_IN_CLOUD) {
|
|
1526
|
+
// No version
|
|
1527
|
+
loggingTags.push(HYBRID_TAG);
|
|
1528
|
+
}
|
|
1519
1529
|
return loggingTags.join(' ');
|
|
1520
1530
|
}
|
|
1521
1531
|
async function getHeaders(url) {
|
|
1522
1532
|
const headers = new Headers();
|
|
1523
1533
|
headers.append('Content-Type', 'application/json');
|
|
1524
|
-
headers.append('x-goog-api-client', getClientHeaders());
|
|
1534
|
+
headers.append('x-goog-api-client', getClientHeaders(url));
|
|
1525
1535
|
headers.append('x-goog-api-key', url.params.apiSettings.apiKey);
|
|
1526
1536
|
if (url.params.apiSettings.automaticDataCollectionEnabled) {
|
|
1527
1537
|
headers.append('X-Firebase-Appid', url.params.apiSettings.appId);
|
|
@@ -4463,7 +4473,9 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
|
|
|
4463
4473
|
* chromeAdapterFactory() method.
|
|
4464
4474
|
*/
|
|
4465
4475
|
const chromeAdapter = ai.chromeAdapterFactory?.(hybridParams.mode, typeof window === 'undefined' ? undefined : window, hybridParams.onDeviceParams);
|
|
4466
|
-
|
|
4476
|
+
const generativeModel = new GenerativeModel(ai, inCloudParams, requestOptions, chromeAdapter);
|
|
4477
|
+
generativeModel._apiSettings.inferenceMode = hybridParams.mode;
|
|
4478
|
+
return generativeModel;
|
|
4467
4479
|
}
|
|
4468
4480
|
/**
|
|
4469
4481
|
* Returns an {@link ImagenModel} class with methods for using Imagen.
|