@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.
@@ -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.58ddd6e54";
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.
@@ -1208,16 +1209,25 @@ class WebSocketUrl {
1208
1209
  /**
1209
1210
  * Log language and "fire/version" to x-goog-api-client
1210
1211
  */
1211
- function getClientHeaders() {
1212
+ function getClientHeaders(url) {
1212
1213
  const loggingTags = [];
1213
1214
  loggingTags.push(`${LANGUAGE_TAG}/${PACKAGE_VERSION}`);
1214
1215
  loggingTags.push(`fire/${PACKAGE_VERSION}`);
1216
+ /**
1217
+ * No call would be made if ONLY_ON_DEVICE.
1218
+ * ONLY_IN_CLOUD does not indicate an intention to use hybrid.
1219
+ */
1220
+ if (url.params.apiSettings.inferenceMode === InferenceMode.PREFER_ON_DEVICE ||
1221
+ url.params.apiSettings.inferenceMode === InferenceMode.PREFER_IN_CLOUD) {
1222
+ // No version
1223
+ loggingTags.push(HYBRID_TAG);
1224
+ }
1215
1225
  return loggingTags.join(' ');
1216
1226
  }
1217
1227
  async function getHeaders(url) {
1218
1228
  const headers = new Headers();
1219
1229
  headers.append('Content-Type', 'application/json');
1220
- headers.append('x-goog-api-client', getClientHeaders());
1230
+ headers.append('x-goog-api-client', getClientHeaders(url));
1221
1231
  headers.append('x-goog-api-key', url.params.apiSettings.apiKey);
1222
1232
  if (url.params.apiSettings.automaticDataCollectionEnabled) {
1223
1233
  headers.append('X-Firebase-Appid', url.params.apiSettings.appId);
@@ -4159,7 +4169,9 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
4159
4169
  * chromeAdapterFactory() method.
4160
4170
  */
4161
4171
  const chromeAdapter = ai.chromeAdapterFactory?.(hybridParams.mode, typeof window === 'undefined' ? undefined : window, hybridParams.onDeviceParams);
4162
- return new GenerativeModel(ai, inCloudParams, requestOptions, chromeAdapter);
4172
+ const generativeModel = new GenerativeModel(ai, inCloudParams, requestOptions, chromeAdapter);
4173
+ generativeModel._apiSettings.inferenceMode = hybridParams.mode;
4174
+ return generativeModel;
4163
4175
  }
4164
4176
  /**
4165
4177
  * Returns an {@link ImagenModel} class with methods for using Imagen.