@firebase/ai 2.2.1 → 2.3.0-canary.cb3bdd812

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.d.ts CHANGED
@@ -366,13 +366,13 @@ export declare class ChatSession {
366
366
  }
367
367
 
368
368
  /**
369
- * <b>(EXPERIMENTAL)</b> Defines an inference "backend" that uses Chrome's on-device model,
369
+ * Defines an inference "backend" that uses Chrome's on-device model,
370
370
  * and encapsulates logic for detecting when on-device inference is
371
371
  * possible.
372
372
  *
373
373
  * These methods should not be called directly by the user.
374
374
  *
375
- * @public
375
+ * @beta
376
376
  */
377
377
  export declare interface ChromeAdapter {
378
378
  /**
@@ -436,6 +436,56 @@ export declare interface CitationMetadata {
436
436
  citations: Citation[];
437
437
  }
438
438
 
439
+ /**
440
+ * The results of code execution run by the model.
441
+ *
442
+ * @public
443
+ */
444
+ export declare interface CodeExecutionResult {
445
+ /**
446
+ * The result of the code execution.
447
+ */
448
+ outcome?: Outcome;
449
+ /**
450
+ * The output from the code execution, or an error message
451
+ * if it failed.
452
+ */
453
+ output?: string;
454
+ }
455
+
456
+ /**
457
+ * Represents the code execution result from the model.
458
+ *
459
+ * @public
460
+ */
461
+ export declare interface CodeExecutionResultPart {
462
+ text?: never;
463
+ inlineData?: never;
464
+ functionCall?: never;
465
+ functionResponse?: never;
466
+ fileData: never;
467
+ thought?: never;
468
+ /**
469
+ * @internal
470
+ */
471
+ thoughtSignature?: never;
472
+ executableCode?: never;
473
+ codeExecutionResult?: CodeExecutionResult;
474
+ }
475
+
476
+ /**
477
+ * A tool that enables the model to use code execution.
478
+ *
479
+ * @public
480
+ */
481
+ export declare interface CodeExecutionTool {
482
+ /**
483
+ * Specifies the Google Search configuration.
484
+ * Currently, this is an empty object, but it's reserved for future configuration options.
485
+ */
486
+ codeExecution: {};
487
+ }
488
+
439
489
  /**
440
490
  * Content type for both prompts and response candidates.
441
491
  * @public
@@ -573,6 +623,42 @@ export declare interface ErrorDetails {
573
623
  [key: string]: unknown;
574
624
  }
575
625
 
626
+ /**
627
+ * An interface for executable code returned by the model.
628
+ *
629
+ * @public
630
+ */
631
+ export declare interface ExecutableCode {
632
+ /**
633
+ * The programming language of the code.
634
+ */
635
+ language?: Language;
636
+ /**
637
+ * The source code to be executed.
638
+ */
639
+ code?: string;
640
+ }
641
+
642
+ /**
643
+ * Represents the code that is executed by the model.
644
+ *
645
+ * @public
646
+ */
647
+ export declare interface ExecutableCodePart {
648
+ text?: never;
649
+ inlineData?: never;
650
+ functionCall?: never;
651
+ functionResponse?: never;
652
+ fileData: never;
653
+ thought?: never;
654
+ /**
655
+ * @internal
656
+ */
657
+ thoughtSignature?: never;
658
+ executableCode?: ExecutableCode;
659
+ codeExecutionResult?: never;
660
+ }
661
+
576
662
  /**
577
663
  * Data pointing to a file uploaded on Google Cloud Storage.
578
664
  * @public
@@ -597,6 +683,8 @@ export declare interface FileDataPart {
597
683
  * @internal
598
684
  */
599
685
  thoughtSignature?: never;
686
+ executableCode?: never;
687
+ codeExecutionResult?: never;
600
688
  }
601
689
 
602
690
  /**
@@ -718,6 +806,8 @@ export declare interface FunctionCallPart {
718
806
  * @internal
719
807
  */
720
808
  thoughtSignature?: never;
809
+ executableCode?: never;
810
+ codeExecutionResult?: never;
721
811
  }
722
812
 
723
813
  /**
@@ -805,6 +895,8 @@ export declare interface FunctionResponsePart {
805
895
  * @internal
806
896
  */
807
897
  thoughtSignature?: never;
898
+ executableCode?: never;
899
+ codeExecutionResult?: never;
808
900
  }
809
901
 
810
902
  /**
@@ -1110,8 +1202,6 @@ export declare interface GoogleSearchTool {
1110
1202
  /**
1111
1203
  * Specifies the Google Search configuration.
1112
1204
  * Currently, this is an empty object, but it's reserved for future configuration options.
1113
- * Specifies the Google Search configuration. Currently, this is an empty object, but it's
1114
- * reserved for future configuration options.
1115
1205
  *
1116
1206
  * When using this feature, you are required to comply with the "Grounding with Google Search"
1117
1207
  * usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
@@ -1335,9 +1425,8 @@ export declare const HarmSeverity: {
1335
1425
  export declare type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
1336
1426
 
1337
1427
  /**
1338
- * <b>(EXPERIMENTAL)</b>
1339
1428
  * Configures hybrid inference.
1340
- * @public
1429
+ * @beta
1341
1430
  */
1342
1431
  export declare interface HybridParams {
1343
1432
  /**
@@ -1820,20 +1909,37 @@ export declare interface ImagenSafetySettings {
1820
1909
  }
1821
1910
 
1822
1911
  /**
1823
- * <b>(EXPERIMENTAL)</b>
1824
1912
  * Determines whether inference happens on-device or in-cloud.
1825
- * @public
1913
+ *
1914
+ * @remarks
1915
+ * <b>PREFER_ON_DEVICE:</b> Attempt to make inference calls using an
1916
+ * on-device model. If on-device inference is not available, the SDK
1917
+ * will fall back to using a cloud-hosted model.
1918
+ * <br/>
1919
+ * <b>ONLY_ON_DEVICE:</b> Only attempt to make inference calls using an
1920
+ * on-device model. The SDK will not fall back to a cloud-hosted model.
1921
+ * If on-device inference is not available, inference methods will throw.
1922
+ * <br/>
1923
+ * <b>ONLY_IN_CLOUD:</b> Only attempt to make inference calls using a
1924
+ * cloud-hosted model. The SDK will not fall back to an on-device model.
1925
+ * <br/>
1926
+ * <b>PREFER_IN_CLOUD:</b> Attempt to make inference calls to a
1927
+ * cloud-hosted model. If not available, the SDK will fall back to an
1928
+ * on-device model.
1929
+ *
1930
+ * @beta
1826
1931
  */
1827
1932
  export declare const InferenceMode: {
1828
1933
  readonly PREFER_ON_DEVICE: "prefer_on_device";
1829
1934
  readonly ONLY_ON_DEVICE: "only_on_device";
1830
1935
  readonly ONLY_IN_CLOUD: "only_in_cloud";
1936
+ readonly PREFER_IN_CLOUD: "prefer_in_cloud";
1831
1937
  };
1832
1938
 
1833
1939
  /**
1834
- * <b>(EXPERIMENTAL)</b>
1835
1940
  * Determines whether inference happens on-device or in-cloud.
1836
- * @public
1941
+ *
1942
+ * @beta
1837
1943
  */
1838
1944
  export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
1839
1945
 
@@ -1855,6 +1961,8 @@ export declare interface InlineDataPart {
1855
1961
  * @internal
1856
1962
  */
1857
1963
  thoughtSignature?: never;
1964
+ executableCode?: never;
1965
+ codeExecutionResult?: never;
1858
1966
  }
1859
1967
 
1860
1968
  /**
@@ -1866,10 +1974,26 @@ export declare class IntegerSchema extends Schema {
1866
1974
  }
1867
1975
 
1868
1976
  /**
1869
- * <b>(EXPERIMENTAL)</b>
1870
- * Configures the creation of an on-device language model session.
1977
+ * The programming language of the code.
1978
+ *
1979
+ * @public
1980
+ */
1981
+ export declare const Language: {
1982
+ UNSPECIFIED: string;
1983
+ PYTHON: string;
1984
+ };
1985
+
1986
+ /**
1987
+ * The programming language of the code.
1988
+ *
1871
1989
  * @public
1872
1990
  */
1991
+ export declare type Language = (typeof Language)[keyof typeof Language];
1992
+
1993
+ /**
1994
+ * Configures the creation of an on-device language model session.
1995
+ * @beta
1996
+ */
1873
1997
  export declare interface LanguageModelCreateCoreOptions {
1874
1998
  topK?: number;
1875
1999
  temperature?: number;
@@ -1877,9 +2001,8 @@ export declare interface LanguageModelCreateCoreOptions {
1877
2001
  }
1878
2002
 
1879
2003
  /**
1880
- * <b>(EXPERIMENTAL)</b>
1881
2004
  * Configures the creation of an on-device language model session.
1882
- * @public
2005
+ * @beta
1883
2006
  */
1884
2007
  export declare interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
1885
2008
  signal?: AbortSignal;
@@ -1887,18 +2010,16 @@ export declare interface LanguageModelCreateOptions extends LanguageModelCreateC
1887
2010
  }
1888
2011
 
1889
2012
  /**
1890
- * <b>(EXPERIMENTAL)</b>
1891
2013
  * Options for the expected inputs for an on-device language model.
1892
- * @public
2014
+ * @beta
1893
2015
  */ export declare interface LanguageModelExpected {
1894
2016
  type: LanguageModelMessageType;
1895
2017
  languages?: string[];
1896
2018
  }
1897
2019
 
1898
2020
  /**
1899
- * <b>(EXPERIMENTAL)</b>
1900
2021
  * An on-device language model message.
1901
- * @public
2022
+ * @beta
1902
2023
  */
1903
2024
  export declare interface LanguageModelMessage {
1904
2025
  role: LanguageModelMessageRole;
@@ -1906,9 +2027,8 @@ export declare interface LanguageModelMessage {
1906
2027
  }
1907
2028
 
1908
2029
  /**
1909
- * <b>(EXPERIMENTAL)</b>
1910
2030
  * An on-device language model content object.
1911
- * @public
2031
+ * @beta
1912
2032
  */
1913
2033
  export declare interface LanguageModelMessageContent {
1914
2034
  type: LanguageModelMessageType;
@@ -1916,30 +2036,26 @@ export declare interface LanguageModelMessageContent {
1916
2036
  }
1917
2037
 
1918
2038
  /**
1919
- * <b>(EXPERIMENTAL)</b>
1920
2039
  * Content formats that can be provided as on-device message content.
1921
- * @public
2040
+ * @beta
1922
2041
  */
1923
2042
  export declare type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
1924
2043
 
1925
2044
  /**
1926
- * <b>(EXPERIMENTAL)</b>
1927
2045
  * Allowable roles for on-device language model usage.
1928
- * @public
2046
+ * @beta
1929
2047
  */
1930
2048
  export declare type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
1931
2049
 
1932
2050
  /**
1933
- * <b>(EXPERIMENTAL)</b>
1934
2051
  * Allowable types for on-device language model messages.
1935
- * @public
2052
+ * @beta
1936
2053
  */
1937
2054
  export declare type LanguageModelMessageType = 'text' | 'image' | 'audio';
1938
2055
 
1939
2056
  /**
1940
- * <b>(EXPERIMENTAL)</b>
1941
2057
  * Options for an on-device language model prompt.
1942
- * @public
2058
+ * @beta
1943
2059
  */
1944
2060
  export declare interface LanguageModelPromptOptions {
1945
2061
  responseConstraint?: object;
@@ -2291,22 +2407,40 @@ export declare interface ObjectSchemaRequest extends SchemaRequest {
2291
2407
  }
2292
2408
 
2293
2409
  /**
2294
- * <b>(EXPERIMENTAL)</b>
2295
2410
  * Encapsulates configuration for on-device inference.
2296
2411
  *
2297
- * @public
2412
+ * @beta
2298
2413
  */
2299
2414
  export declare interface OnDeviceParams {
2300
2415
  createOptions?: LanguageModelCreateOptions;
2301
2416
  promptOptions?: LanguageModelPromptOptions;
2302
2417
  }
2303
2418
 
2419
+ /**
2420
+ * Represents the result of the code execution.
2421
+ *
2422
+ * @public
2423
+ */
2424
+ export declare const Outcome: {
2425
+ UNSPECIFIED: string;
2426
+ OK: string;
2427
+ FAILED: string;
2428
+ DEADLINE_EXCEEDED: string;
2429
+ };
2430
+
2431
+ /**
2432
+ * Represents the result of the code execution.
2433
+ *
2434
+ * @public
2435
+ */
2436
+ export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
2437
+
2304
2438
  /**
2305
2439
  * Content part - includes text, image/video, or function call/response
2306
2440
  * part types.
2307
2441
  * @public
2308
2442
  */
2309
- export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
2443
+ export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
2310
2444
 
2311
2445
  /**
2312
2446
  * Possible roles.
@@ -2819,6 +2953,8 @@ export declare interface TextPart {
2819
2953
  * @internal
2820
2954
  */
2821
2955
  thoughtSignature?: string;
2956
+ executableCode?: never;
2957
+ codeExecutionResult?: never;
2822
2958
  }
2823
2959
 
2824
2960
  /**
@@ -2859,7 +2995,7 @@ export declare interface ThinkingConfig {
2859
2995
  * Defines a tool that model can call to access external knowledge.
2860
2996
  * @public
2861
2997
  */
2862
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
2998
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
2863
2999
 
2864
3000
  /**
2865
3001
  * Tool config. This config is shared for all tools provided in the request.