@firebase/ai 2.4.0-20251007135320 → 2.4.0-canary.44d9891f9

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.
@@ -25,11 +25,11 @@ import { LanguageModel } from '../types/language-model';
25
25
  export declare class ChromeAdapterImpl implements ChromeAdapter {
26
26
  languageModelProvider: LanguageModel;
27
27
  mode: InferenceMode;
28
- onDeviceParams: OnDeviceParams;
29
28
  static SUPPORTED_MIME_TYPES: string[];
30
29
  private isDownloading;
31
30
  private downloadPromise;
32
31
  private oldSession;
32
+ onDeviceParams: OnDeviceParams;
33
33
  constructor(languageModelProvider: LanguageModel, mode: InferenceMode, onDeviceParams?: OnDeviceParams);
34
34
  /**
35
35
  * Checks if a given request can be made on-device.
@@ -14,7 +14,11 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { GenerateContentRequest, ChromeAdapter } from '../types';
17
+ import { GenerateContentRequest, ChromeAdapter, InferenceSource } from '../types';
18
+ interface CallResult<Response> {
19
+ response: Response;
20
+ inferenceSource: InferenceSource;
21
+ }
18
22
  /**
19
23
  * Dispatches a request to the appropriate backend (on-device or in-cloud)
20
24
  * based on the inference mode.
@@ -25,4 +29,5 @@ import { GenerateContentRequest, ChromeAdapter } from '../types';
25
29
  * @param inCloudCall - The function to call for in-cloud inference.
26
30
  * @returns The response from the backend.
27
31
  */
28
- export declare function callCloudOrDevice<Response>(request: GenerateContentRequest, chromeAdapter: ChromeAdapter | undefined, onDeviceCall: () => Promise<Response>, inCloudCall: () => Promise<Response>): Promise<Response>;
32
+ export declare function callCloudOrDevice<Response>(request: GenerateContentRequest, chromeAdapter: ChromeAdapter | undefined, onDeviceCall: () => Promise<Response>, inCloudCall: () => Promise<Response>): Promise<CallResult<Response>>;
33
+ export {};
@@ -14,12 +14,12 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { EnhancedGenerateContentResponse, FunctionCall, GenerateContentResponse, ImagenGCSImage, ImagenInlineImage, InlineDataPart, Part } from '../types';
17
+ import { EnhancedGenerateContentResponse, FunctionCall, GenerateContentResponse, ImagenGCSImage, ImagenInlineImage, InlineDataPart, Part, InferenceSource } from '../types';
18
18
  /**
19
19
  * Creates an EnhancedGenerateContentResponse object that has helper functions and
20
20
  * other modifications that improve usability.
21
21
  */
22
- export declare function createEnhancedContentResponse(response: GenerateContentResponse): EnhancedGenerateContentResponse;
22
+ export declare function createEnhancedContentResponse(response: GenerateContentResponse, inferenceSource?: InferenceSource): EnhancedGenerateContentResponse;
23
23
  /**
24
24
  * Adds convenience helper methods to a response object, including stream
25
25
  * chunks (as long as each chunk is a complete GenerateContentResponse JSON).
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { GenerateContentResponse, GenerateContentStreamResult } from '../types';
18
18
  import { ApiSettings } from '../types/internal';
19
+ import { InferenceSource } from '../public-types';
19
20
  /**
20
21
  * Process a response.body stream from the backend and return an
21
22
  * iterator that provides one complete GenerateContentResponse at a time
@@ -24,7 +25,7 @@ import { ApiSettings } from '../types/internal';
24
25
  *
25
26
  * @param response - Response from a fetch call
26
27
  */
27
- export declare function processStream(response: Response, apiSettings: ApiSettings): GenerateContentStreamResult;
28
+ export declare function processStream(response: Response, apiSettings: ApiSettings, inferenceSource?: InferenceSource): GenerateContentStreamResult;
28
29
  /**
29
30
  * Reads a raw stream from the fetch response and join incomplete
30
31
  * chunks, returning a new stream that provides a single complete
@@ -349,6 +349,21 @@ export declare const InferenceMode: {
349
349
  * @beta
350
350
  */
351
351
  export type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
352
+ /**
353
+ * Indicates whether inference happened on-device or in-cloud.
354
+ *
355
+ * @beta
356
+ */
357
+ export declare const InferenceSource: {
358
+ readonly ON_DEVICE: "on_device";
359
+ readonly IN_CLOUD: "in_cloud";
360
+ };
361
+ /**
362
+ * Indicates whether inference happened on-device or in-cloud.
363
+ *
364
+ * @beta
365
+ */
366
+ export type InferenceSource = (typeof InferenceSource)[keyof typeof InferenceSource];
352
367
  /**
353
368
  * Represents the result of the code execution.
354
369
  *
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { Content, FunctionCall, InlineDataPart } from './content';
18
- import { BlockReason, FinishReason, HarmCategory, HarmProbability, HarmSeverity, Modality } from './enums';
18
+ import { BlockReason, FinishReason, HarmCategory, HarmProbability, HarmSeverity, InferenceSource, Modality } from './enums';
19
19
  /**
20
20
  * Result object returned from {@link GenerativeModel.generateContent} call.
21
21
  *
@@ -76,6 +76,12 @@ export interface EnhancedGenerateContentResponse extends GenerateContentResponse
76
76
  * set to `true`.
77
77
  */
78
78
  thoughtSummary: () => string | undefined;
79
+ /**
80
+ * Indicates whether inference happened on-device or in-cloud.
81
+ *
82
+ * @beta
83
+ */
84
+ inferenceSource?: InferenceSource;
79
85
  }
80
86
  /**
81
87
  * Individual response from {@link GenerativeModel.generateContent} and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/ai",
3
- "version": "2.4.0-20251007135320",
3
+ "version": "2.4.0-canary.44d9891f9",
4
4
  "description": "The Firebase AI SDK",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "engines": {
@@ -48,19 +48,19 @@
48
48
  "trusted-type-check": "tsec -p tsconfig.json --noEmit"
49
49
  },
50
50
  "peerDependencies": {
51
- "@firebase/app": "0.x",
52
- "@firebase/app-types": "0.x"
51
+ "@firebase/app": "0.14.4-canary.44d9891f9",
52
+ "@firebase/app-types": "0.9.3-canary.44d9891f9"
53
53
  },
54
54
  "dependencies": {
55
- "@firebase/app-check-interop-types": "0.3.3",
56
- "@firebase/component": "0.7.0",
57
- "@firebase/logger": "0.5.0",
58
- "@firebase/util": "1.13.0",
55
+ "@firebase/app-check-interop-types": "0.3.3-canary.44d9891f9",
56
+ "@firebase/component": "0.7.0-canary.44d9891f9",
57
+ "@firebase/logger": "0.5.0-canary.44d9891f9",
58
+ "@firebase/util": "1.13.0-canary.44d9891f9",
59
59
  "tslib": "^2.1.0"
60
60
  },
61
61
  "license": "Apache-2.0",
62
62
  "devDependencies": {
63
- "@firebase/app": "0.14.3",
63
+ "@firebase/app": "0.14.4-canary.44d9891f9",
64
64
  "@rollup/plugin-json": "6.1.0",
65
65
  "rollup": "2.79.2",
66
66
  "rollup-plugin-replace": "2.2.0",