@firebase/ai 2.2.1 → 2.3.0-canary.0ffcb26af

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.
@@ -326,13 +326,13 @@ export declare class ChatSession {
326
326
  }
327
327
 
328
328
  /**
329
- * <b>(EXPERIMENTAL)</b> Defines an inference "backend" that uses Chrome's on-device model,
329
+ * Defines an inference "backend" that uses Chrome's on-device model,
330
330
  * and encapsulates logic for detecting when on-device inference is
331
331
  * possible.
332
332
  *
333
333
  * These methods should not be called directly by the user.
334
334
  *
335
- * @public
335
+ * @beta
336
336
  */
337
337
  export declare interface ChromeAdapter {
338
338
  /**
@@ -393,6 +393,53 @@ export declare interface CitationMetadata {
393
393
  citations: Citation[];
394
394
  }
395
395
 
396
+ /**
397
+ * The results of code execution run by the model.
398
+ *
399
+ * @public
400
+ */
401
+ export declare interface CodeExecutionResult {
402
+ /**
403
+ * The result of the code execution.
404
+ */
405
+ outcome?: Outcome;
406
+ /**
407
+ * The output from the code execution, or an error message
408
+ * if it failed.
409
+ */
410
+ output?: string;
411
+ }
412
+
413
+ /**
414
+ * Represents the code execution result from the model.
415
+ *
416
+ * @public
417
+ */
418
+ export declare interface CodeExecutionResultPart {
419
+ text?: never;
420
+ inlineData?: never;
421
+ functionCall?: never;
422
+ functionResponse?: never;
423
+ fileData: never;
424
+ thought?: never;
425
+ /* Excluded from this release type: thoughtSignature */
426
+ executableCode?: never;
427
+ codeExecutionResult?: CodeExecutionResult;
428
+ }
429
+
430
+ /**
431
+ * A tool that enables the model to use code execution.
432
+ *
433
+ * @public
434
+ */
435
+ export declare interface CodeExecutionTool {
436
+ /**
437
+ * Specifies the Google Search configuration.
438
+ * Currently, this is an empty object, but it's reserved for future configuration options.
439
+ */
440
+ codeExecution: {};
441
+ }
442
+
396
443
  /**
397
444
  * Content type for both prompts and response candidates.
398
445
  * @public
@@ -530,6 +577,39 @@ export declare interface ErrorDetails {
530
577
  [key: string]: unknown;
531
578
  }
532
579
 
580
+ /**
581
+ * An interface for executable code returned by the model.
582
+ *
583
+ * @public
584
+ */
585
+ export declare interface ExecutableCode {
586
+ /**
587
+ * The programming language of the code.
588
+ */
589
+ language?: Language;
590
+ /**
591
+ * The source code to be executed.
592
+ */
593
+ code?: string;
594
+ }
595
+
596
+ /**
597
+ * Represents the code that is executed by the model.
598
+ *
599
+ * @public
600
+ */
601
+ export declare interface ExecutableCodePart {
602
+ text?: never;
603
+ inlineData?: never;
604
+ functionCall?: never;
605
+ functionResponse?: never;
606
+ fileData: never;
607
+ thought?: never;
608
+ /* Excluded from this release type: thoughtSignature */
609
+ executableCode?: ExecutableCode;
610
+ codeExecutionResult?: never;
611
+ }
612
+
533
613
  /**
534
614
  * Data pointing to a file uploaded on Google Cloud Storage.
535
615
  * @public
@@ -551,6 +631,8 @@ export declare interface FileDataPart {
551
631
  fileData: FileData;
552
632
  thought?: boolean;
553
633
  /* Excluded from this release type: thoughtSignature */
634
+ executableCode?: never;
635
+ codeExecutionResult?: never;
554
636
  }
555
637
 
556
638
  /**
@@ -669,6 +751,8 @@ export declare interface FunctionCallPart {
669
751
  functionResponse?: never;
670
752
  thought?: boolean;
671
753
  /* Excluded from this release type: thoughtSignature */
754
+ executableCode?: never;
755
+ codeExecutionResult?: never;
672
756
  }
673
757
 
674
758
  /**
@@ -753,6 +837,8 @@ export declare interface FunctionResponsePart {
753
837
  functionResponse: FunctionResponse;
754
838
  thought?: boolean;
755
839
  /* Excluded from this release type: thoughtSignature */
840
+ executableCode?: never;
841
+ codeExecutionResult?: never;
756
842
  }
757
843
 
758
844
  /**
@@ -767,6 +853,7 @@ export declare interface GenerateContentCandidate {
767
853
  safetyRatings?: SafetyRating[];
768
854
  citationMetadata?: CitationMetadata;
769
855
  groundingMetadata?: GroundingMetadata;
856
+ urlContextMetadata?: URLContextMetadata;
770
857
  }
771
858
 
772
859
  /**
@@ -1024,8 +1111,6 @@ export declare interface GoogleSearchTool {
1024
1111
  /**
1025
1112
  * Specifies the Google Search configuration.
1026
1113
  * Currently, this is an empty object, but it's reserved for future configuration options.
1027
- * Specifies the Google Search configuration. Currently, this is an empty object, but it's
1028
- * reserved for future configuration options.
1029
1114
  *
1030
1115
  * When using this feature, you are required to comply with the "Grounding with Google Search"
1031
1116
  * usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
@@ -1249,9 +1334,8 @@ export declare const HarmSeverity: {
1249
1334
  export declare type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
1250
1335
 
1251
1336
  /**
1252
- * <b>(EXPERIMENTAL)</b>
1253
1337
  * Configures hybrid inference.
1254
- * @public
1338
+ * @beta
1255
1339
  */
1256
1340
  export declare interface HybridParams {
1257
1341
  /**
@@ -1715,20 +1799,37 @@ export declare interface ImagenSafetySettings {
1715
1799
  }
1716
1800
 
1717
1801
  /**
1718
- * <b>(EXPERIMENTAL)</b>
1719
1802
  * Determines whether inference happens on-device or in-cloud.
1720
- * @public
1803
+ *
1804
+ * @remarks
1805
+ * <b>PREFER_ON_DEVICE:</b> Attempt to make inference calls using an
1806
+ * on-device model. If on-device inference is not available, the SDK
1807
+ * will fall back to using a cloud-hosted model.
1808
+ * <br/>
1809
+ * <b>ONLY_ON_DEVICE:</b> Only attempt to make inference calls using an
1810
+ * on-device model. The SDK will not fall back to a cloud-hosted model.
1811
+ * If on-device inference is not available, inference methods will throw.
1812
+ * <br/>
1813
+ * <b>ONLY_IN_CLOUD:</b> Only attempt to make inference calls using a
1814
+ * cloud-hosted model. The SDK will not fall back to an on-device model.
1815
+ * <br/>
1816
+ * <b>PREFER_IN_CLOUD:</b> Attempt to make inference calls to a
1817
+ * cloud-hosted model. If not available, the SDK will fall back to an
1818
+ * on-device model.
1819
+ *
1820
+ * @beta
1721
1821
  */
1722
1822
  export declare const InferenceMode: {
1723
1823
  readonly PREFER_ON_DEVICE: "prefer_on_device";
1724
1824
  readonly ONLY_ON_DEVICE: "only_on_device";
1725
1825
  readonly ONLY_IN_CLOUD: "only_in_cloud";
1826
+ readonly PREFER_IN_CLOUD: "prefer_in_cloud";
1726
1827
  };
1727
1828
 
1728
1829
  /**
1729
- * <b>(EXPERIMENTAL)</b>
1730
1830
  * Determines whether inference happens on-device or in-cloud.
1731
- * @public
1831
+ *
1832
+ * @beta
1732
1833
  */
1733
1834
  export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
1734
1835
 
@@ -1747,6 +1848,8 @@ export declare interface InlineDataPart {
1747
1848
  videoMetadata?: VideoMetadata;
1748
1849
  thought?: boolean;
1749
1850
  /* Excluded from this release type: thoughtSignature */
1851
+ executableCode?: never;
1852
+ codeExecutionResult?: never;
1750
1853
  }
1751
1854
 
1752
1855
  /**
@@ -1758,10 +1861,26 @@ export declare class IntegerSchema extends Schema {
1758
1861
  }
1759
1862
 
1760
1863
  /**
1761
- * <b>(EXPERIMENTAL)</b>
1762
- * Configures the creation of an on-device language model session.
1864
+ * The programming language of the code.
1865
+ *
1866
+ * @public
1867
+ */
1868
+ export declare const Language: {
1869
+ UNSPECIFIED: string;
1870
+ PYTHON: string;
1871
+ };
1872
+
1873
+ /**
1874
+ * The programming language of the code.
1875
+ *
1763
1876
  * @public
1764
1877
  */
1878
+ export declare type Language = (typeof Language)[keyof typeof Language];
1879
+
1880
+ /**
1881
+ * Configures the creation of an on-device language model session.
1882
+ * @beta
1883
+ */
1765
1884
  export declare interface LanguageModelCreateCoreOptions {
1766
1885
  topK?: number;
1767
1886
  temperature?: number;
@@ -1769,9 +1888,8 @@ export declare interface LanguageModelCreateCoreOptions {
1769
1888
  }
1770
1889
 
1771
1890
  /**
1772
- * <b>(EXPERIMENTAL)</b>
1773
1891
  * Configures the creation of an on-device language model session.
1774
- * @public
1892
+ * @beta
1775
1893
  */
1776
1894
  export declare interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
1777
1895
  signal?: AbortSignal;
@@ -1779,18 +1897,16 @@ export declare interface LanguageModelCreateOptions extends LanguageModelCreateC
1779
1897
  }
1780
1898
 
1781
1899
  /**
1782
- * <b>(EXPERIMENTAL)</b>
1783
1900
  * Options for the expected inputs for an on-device language model.
1784
- * @public
1901
+ * @beta
1785
1902
  */ export declare interface LanguageModelExpected {
1786
1903
  type: LanguageModelMessageType;
1787
1904
  languages?: string[];
1788
1905
  }
1789
1906
 
1790
1907
  /**
1791
- * <b>(EXPERIMENTAL)</b>
1792
1908
  * An on-device language model message.
1793
- * @public
1909
+ * @beta
1794
1910
  */
1795
1911
  export declare interface LanguageModelMessage {
1796
1912
  role: LanguageModelMessageRole;
@@ -1798,9 +1914,8 @@ export declare interface LanguageModelMessage {
1798
1914
  }
1799
1915
 
1800
1916
  /**
1801
- * <b>(EXPERIMENTAL)</b>
1802
1917
  * An on-device language model content object.
1803
- * @public
1918
+ * @beta
1804
1919
  */
1805
1920
  export declare interface LanguageModelMessageContent {
1806
1921
  type: LanguageModelMessageType;
@@ -1808,30 +1923,26 @@ export declare interface LanguageModelMessageContent {
1808
1923
  }
1809
1924
 
1810
1925
  /**
1811
- * <b>(EXPERIMENTAL)</b>
1812
1926
  * Content formats that can be provided as on-device message content.
1813
- * @public
1927
+ * @beta
1814
1928
  */
1815
1929
  export declare type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
1816
1930
 
1817
1931
  /**
1818
- * <b>(EXPERIMENTAL)</b>
1819
1932
  * Allowable roles for on-device language model usage.
1820
- * @public
1933
+ * @beta
1821
1934
  */
1822
1935
  export declare type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
1823
1936
 
1824
1937
  /**
1825
- * <b>(EXPERIMENTAL)</b>
1826
1938
  * Allowable types for on-device language model messages.
1827
- * @public
1939
+ * @beta
1828
1940
  */
1829
1941
  export declare type LanguageModelMessageType = 'text' | 'image' | 'audio';
1830
1942
 
1831
1943
  /**
1832
- * <b>(EXPERIMENTAL)</b>
1833
1944
  * Options for an on-device language model prompt.
1834
- * @public
1945
+ * @beta
1835
1946
  */
1836
1947
  export declare interface LanguageModelPromptOptions {
1837
1948
  responseConstraint?: object;
@@ -2167,22 +2278,40 @@ export declare interface ObjectSchemaRequest extends SchemaRequest {
2167
2278
  }
2168
2279
 
2169
2280
  /**
2170
- * <b>(EXPERIMENTAL)</b>
2171
2281
  * Encapsulates configuration for on-device inference.
2172
2282
  *
2173
- * @public
2283
+ * @beta
2174
2284
  */
2175
2285
  export declare interface OnDeviceParams {
2176
2286
  createOptions?: LanguageModelCreateOptions;
2177
2287
  promptOptions?: LanguageModelPromptOptions;
2178
2288
  }
2179
2289
 
2290
+ /**
2291
+ * Represents the result of the code execution.
2292
+ *
2293
+ * @public
2294
+ */
2295
+ export declare const Outcome: {
2296
+ UNSPECIFIED: string;
2297
+ OK: string;
2298
+ FAILED: string;
2299
+ DEADLINE_EXCEEDED: string;
2300
+ };
2301
+
2302
+ /**
2303
+ * Represents the result of the code execution.
2304
+ *
2305
+ * @public
2306
+ */
2307
+ export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
2308
+
2180
2309
  /**
2181
2310
  * Content part - includes text, image/video, or function call/response
2182
2311
  * part types.
2183
2312
  * @public
2184
2313
  */
2185
- export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
2314
+ export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
2186
2315
 
2187
2316
  /**
2188
2317
  * Possible roles.
@@ -2684,6 +2813,8 @@ export declare interface TextPart {
2684
2813
  functionResponse?: never;
2685
2814
  thought?: boolean;
2686
2815
  /* Excluded from this release type: thoughtSignature */
2816
+ executableCode?: never;
2817
+ codeExecutionResult?: never;
2687
2818
  }
2688
2819
 
2689
2820
  /**
@@ -2724,7 +2855,7 @@ export declare interface ThinkingConfig {
2724
2855
  * Defines a tool that model can call to access external knowledge.
2725
2856
  * @public
2726
2857
  */
2727
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
2858
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
2728
2859
 
2729
2860
  /**
2730
2861
  * Tool config. This config is shared for all tools provided in the request.
@@ -2740,6 +2871,115 @@ export declare interface ToolConfig {
2740
2871
  */
2741
2872
  export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
2742
2873
 
2874
+ /**
2875
+ * Specifies the URL Context configuration.
2876
+ *
2877
+ * @beta
2878
+ */
2879
+ export declare interface URLContext {
2880
+ }
2881
+
2882
+ /**
2883
+ * Metadata related to {@link URLContextTool}.
2884
+ *
2885
+ * @beta
2886
+ */
2887
+ export declare interface URLContextMetadata {
2888
+ /**
2889
+ * List of URL metadata used to provide context to the Gemini model.
2890
+ */
2891
+ urlMetadata: URLMetadata[];
2892
+ }
2893
+
2894
+ /**
2895
+ * A tool that allows you to provide additional context to the models in the form of public web
2896
+ * URLs. By including URLs in your request, the Gemini model will access the content from those
2897
+ * pages to inform and enhance its response.
2898
+ *
2899
+ * @beta
2900
+ */
2901
+ export declare interface URLContextTool {
2902
+ /**
2903
+ * Specifies the URL Context configuration.
2904
+ */
2905
+ urlContext: URLContext;
2906
+ }
2907
+
2908
+ /**
2909
+ * Metadata for a single URL retrieved by the {@link URLContextTool} tool.
2910
+ *
2911
+ * @beta
2912
+ */
2913
+ export declare interface URLMetadata {
2914
+ /**
2915
+ * The retrieved URL.
2916
+ */
2917
+ retrievedUrl?: string;
2918
+ /**
2919
+ * The status of the URL retrieval.
2920
+ */
2921
+ urlRetrievalStatus?: URLRetrievalStatus;
2922
+ }
2923
+
2924
+ /**
2925
+ * The status of a URL retrieval.
2926
+ *
2927
+ * @remarks
2928
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
2929
+ * <br/>
2930
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
2931
+ * <br/>
2932
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
2933
+ * <br/>
2934
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
2935
+ * <br/>
2936
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
2937
+ * <br/>
2938
+ *
2939
+ * @beta
2940
+ */
2941
+ export declare const URLRetrievalStatus: {
2942
+ /**
2943
+ * Unspecified retrieval status.
2944
+ */
2945
+ URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
2946
+ /**
2947
+ * The URL retrieval was successful.
2948
+ */
2949
+ URL_RETRIEVAL_STATUS_SUCCESS: string;
2950
+ /**
2951
+ * The URL retrieval failed.
2952
+ */
2953
+ URL_RETRIEVAL_STATUS_ERROR: string;
2954
+ /**
2955
+ * The URL retrieval failed because the content is behind a paywall.
2956
+ */
2957
+ URL_RETRIEVAL_STATUS_PAYWALL: string;
2958
+ /**
2959
+ * The URL retrieval failed because the content is unsafe.
2960
+ */
2961
+ URL_RETRIEVAL_STATUS_UNSAFE: string;
2962
+ };
2963
+
2964
+ /**
2965
+ * The status of a URL retrieval.
2966
+ *
2967
+ * @remarks
2968
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
2969
+ * <br/>
2970
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
2971
+ * <br/>
2972
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
2973
+ * <br/>
2974
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
2975
+ * <br/>
2976
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
2977
+ * <br/>
2978
+ *
2979
+ * @beta
2980
+ */
2981
+ export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
2982
+
2743
2983
  /**
2744
2984
  * Usage metadata about a {@link GenerateContentResponse}.
2745
2985
  *
@@ -2753,8 +2993,16 @@ export declare interface UsageMetadata {
2753
2993
  */
2754
2994
  thoughtsTokenCount?: number;
2755
2995
  totalTokenCount: number;
2996
+ /**
2997
+ * The number of tokens used by tools.
2998
+ */
2999
+ toolUsePromptTokenCount?: number;
2756
3000
  promptTokensDetails?: ModalityTokenCount[];
2757
3001
  candidatesTokensDetails?: ModalityTokenCount[];
3002
+ /**
3003
+ * A list of tokens used by tools, broken down by modality.
3004
+ */
3005
+ toolUsePromptTokensDetails?: ModalityTokenCount[];
2758
3006
  }
2759
3007
 
2760
3008
  /**