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