@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.
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
  /**
@@ -819,6 +911,7 @@ export declare interface GenerateContentCandidate {
819
911
  safetyRatings?: SafetyRating[];
820
912
  citationMetadata?: CitationMetadata;
821
913
  groundingMetadata?: GroundingMetadata;
914
+ urlContextMetadata?: URLContextMetadata;
822
915
  }
823
916
 
824
917
  /**
@@ -1074,6 +1167,7 @@ export declare interface GoogleAIGenerateContentCandidate {
1074
1167
  safetyRatings?: SafetyRating[];
1075
1168
  citationMetadata?: GoogleAICitationMetadata;
1076
1169
  groundingMetadata?: GroundingMetadata;
1170
+ urlContextMetadata?: URLContextMetadata;
1077
1171
  }
1078
1172
 
1079
1173
  /**
@@ -1110,8 +1204,6 @@ export declare interface GoogleSearchTool {
1110
1204
  /**
1111
1205
  * Specifies the Google Search configuration.
1112
1206
  * 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
1207
  *
1116
1208
  * When using this feature, you are required to comply with the "Grounding with Google Search"
1117
1209
  * usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
@@ -1335,9 +1427,8 @@ export declare const HarmSeverity: {
1335
1427
  export declare type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
1336
1428
 
1337
1429
  /**
1338
- * <b>(EXPERIMENTAL)</b>
1339
1430
  * Configures hybrid inference.
1340
- * @public
1431
+ * @beta
1341
1432
  */
1342
1433
  export declare interface HybridParams {
1343
1434
  /**
@@ -1820,20 +1911,37 @@ export declare interface ImagenSafetySettings {
1820
1911
  }
1821
1912
 
1822
1913
  /**
1823
- * <b>(EXPERIMENTAL)</b>
1824
1914
  * Determines whether inference happens on-device or in-cloud.
1825
- * @public
1915
+ *
1916
+ * @remarks
1917
+ * <b>PREFER_ON_DEVICE:</b> Attempt to make inference calls using an
1918
+ * on-device model. If on-device inference is not available, the SDK
1919
+ * will fall back to using a cloud-hosted model.
1920
+ * <br/>
1921
+ * <b>ONLY_ON_DEVICE:</b> Only attempt to make inference calls using an
1922
+ * on-device model. The SDK will not fall back to a cloud-hosted model.
1923
+ * If on-device inference is not available, inference methods will throw.
1924
+ * <br/>
1925
+ * <b>ONLY_IN_CLOUD:</b> Only attempt to make inference calls using a
1926
+ * cloud-hosted model. The SDK will not fall back to an on-device model.
1927
+ * <br/>
1928
+ * <b>PREFER_IN_CLOUD:</b> Attempt to make inference calls to a
1929
+ * cloud-hosted model. If not available, the SDK will fall back to an
1930
+ * on-device model.
1931
+ *
1932
+ * @beta
1826
1933
  */
1827
1934
  export declare const InferenceMode: {
1828
1935
  readonly PREFER_ON_DEVICE: "prefer_on_device";
1829
1936
  readonly ONLY_ON_DEVICE: "only_on_device";
1830
1937
  readonly ONLY_IN_CLOUD: "only_in_cloud";
1938
+ readonly PREFER_IN_CLOUD: "prefer_in_cloud";
1831
1939
  };
1832
1940
 
1833
1941
  /**
1834
- * <b>(EXPERIMENTAL)</b>
1835
1942
  * Determines whether inference happens on-device or in-cloud.
1836
- * @public
1943
+ *
1944
+ * @beta
1837
1945
  */
1838
1946
  export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
1839
1947
 
@@ -1855,6 +1963,8 @@ export declare interface InlineDataPart {
1855
1963
  * @internal
1856
1964
  */
1857
1965
  thoughtSignature?: never;
1966
+ executableCode?: never;
1967
+ codeExecutionResult?: never;
1858
1968
  }
1859
1969
 
1860
1970
  /**
@@ -1866,10 +1976,26 @@ export declare class IntegerSchema extends Schema {
1866
1976
  }
1867
1977
 
1868
1978
  /**
1869
- * <b>(EXPERIMENTAL)</b>
1870
- * Configures the creation of an on-device language model session.
1979
+ * The programming language of the code.
1980
+ *
1871
1981
  * @public
1872
1982
  */
1983
+ export declare const Language: {
1984
+ UNSPECIFIED: string;
1985
+ PYTHON: string;
1986
+ };
1987
+
1988
+ /**
1989
+ * The programming language of the code.
1990
+ *
1991
+ * @public
1992
+ */
1993
+ export declare type Language = (typeof Language)[keyof typeof Language];
1994
+
1995
+ /**
1996
+ * Configures the creation of an on-device language model session.
1997
+ * @beta
1998
+ */
1873
1999
  export declare interface LanguageModelCreateCoreOptions {
1874
2000
  topK?: number;
1875
2001
  temperature?: number;
@@ -1877,9 +2003,8 @@ export declare interface LanguageModelCreateCoreOptions {
1877
2003
  }
1878
2004
 
1879
2005
  /**
1880
- * <b>(EXPERIMENTAL)</b>
1881
2006
  * Configures the creation of an on-device language model session.
1882
- * @public
2007
+ * @beta
1883
2008
  */
1884
2009
  export declare interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
1885
2010
  signal?: AbortSignal;
@@ -1887,18 +2012,16 @@ export declare interface LanguageModelCreateOptions extends LanguageModelCreateC
1887
2012
  }
1888
2013
 
1889
2014
  /**
1890
- * <b>(EXPERIMENTAL)</b>
1891
2015
  * Options for the expected inputs for an on-device language model.
1892
- * @public
2016
+ * @beta
1893
2017
  */ export declare interface LanguageModelExpected {
1894
2018
  type: LanguageModelMessageType;
1895
2019
  languages?: string[];
1896
2020
  }
1897
2021
 
1898
2022
  /**
1899
- * <b>(EXPERIMENTAL)</b>
1900
2023
  * An on-device language model message.
1901
- * @public
2024
+ * @beta
1902
2025
  */
1903
2026
  export declare interface LanguageModelMessage {
1904
2027
  role: LanguageModelMessageRole;
@@ -1906,9 +2029,8 @@ export declare interface LanguageModelMessage {
1906
2029
  }
1907
2030
 
1908
2031
  /**
1909
- * <b>(EXPERIMENTAL)</b>
1910
2032
  * An on-device language model content object.
1911
- * @public
2033
+ * @beta
1912
2034
  */
1913
2035
  export declare interface LanguageModelMessageContent {
1914
2036
  type: LanguageModelMessageType;
@@ -1916,30 +2038,26 @@ export declare interface LanguageModelMessageContent {
1916
2038
  }
1917
2039
 
1918
2040
  /**
1919
- * <b>(EXPERIMENTAL)</b>
1920
2041
  * Content formats that can be provided as on-device message content.
1921
- * @public
2042
+ * @beta
1922
2043
  */
1923
2044
  export declare type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
1924
2045
 
1925
2046
  /**
1926
- * <b>(EXPERIMENTAL)</b>
1927
2047
  * Allowable roles for on-device language model usage.
1928
- * @public
2048
+ * @beta
1929
2049
  */
1930
2050
  export declare type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
1931
2051
 
1932
2052
  /**
1933
- * <b>(EXPERIMENTAL)</b>
1934
2053
  * Allowable types for on-device language model messages.
1935
- * @public
2054
+ * @beta
1936
2055
  */
1937
2056
  export declare type LanguageModelMessageType = 'text' | 'image' | 'audio';
1938
2057
 
1939
2058
  /**
1940
- * <b>(EXPERIMENTAL)</b>
1941
2059
  * Options for an on-device language model prompt.
1942
- * @public
2060
+ * @beta
1943
2061
  */
1944
2062
  export declare interface LanguageModelPromptOptions {
1945
2063
  responseConstraint?: object;
@@ -2291,22 +2409,40 @@ export declare interface ObjectSchemaRequest extends SchemaRequest {
2291
2409
  }
2292
2410
 
2293
2411
  /**
2294
- * <b>(EXPERIMENTAL)</b>
2295
2412
  * Encapsulates configuration for on-device inference.
2296
2413
  *
2297
- * @public
2414
+ * @beta
2298
2415
  */
2299
2416
  export declare interface OnDeviceParams {
2300
2417
  createOptions?: LanguageModelCreateOptions;
2301
2418
  promptOptions?: LanguageModelPromptOptions;
2302
2419
  }
2303
2420
 
2421
+ /**
2422
+ * Represents the result of the code execution.
2423
+ *
2424
+ * @public
2425
+ */
2426
+ export declare const Outcome: {
2427
+ UNSPECIFIED: string;
2428
+ OK: string;
2429
+ FAILED: string;
2430
+ DEADLINE_EXCEEDED: string;
2431
+ };
2432
+
2433
+ /**
2434
+ * Represents the result of the code execution.
2435
+ *
2436
+ * @public
2437
+ */
2438
+ export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
2439
+
2304
2440
  /**
2305
2441
  * Content part - includes text, image/video, or function call/response
2306
2442
  * part types.
2307
2443
  * @public
2308
2444
  */
2309
- export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
2445
+ export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
2310
2446
 
2311
2447
  /**
2312
2448
  * Possible roles.
@@ -2819,6 +2955,8 @@ export declare interface TextPart {
2819
2955
  * @internal
2820
2956
  */
2821
2957
  thoughtSignature?: string;
2958
+ executableCode?: never;
2959
+ codeExecutionResult?: never;
2822
2960
  }
2823
2961
 
2824
2962
  /**
@@ -2859,7 +2997,7 @@ export declare interface ThinkingConfig {
2859
2997
  * Defines a tool that model can call to access external knowledge.
2860
2998
  * @public
2861
2999
  */
2862
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
3000
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
2863
3001
 
2864
3002
  /**
2865
3003
  * Tool config. This config is shared for all tools provided in the request.
@@ -2875,6 +3013,115 @@ export declare interface ToolConfig {
2875
3013
  */
2876
3014
  export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
2877
3015
 
3016
+ /**
3017
+ * Specifies the URL Context configuration.
3018
+ *
3019
+ * @beta
3020
+ */
3021
+ export declare interface URLContext {
3022
+ }
3023
+
3024
+ /**
3025
+ * Metadata related to {@link URLContextTool}.
3026
+ *
3027
+ * @beta
3028
+ */
3029
+ export declare interface URLContextMetadata {
3030
+ /**
3031
+ * List of URL metadata used to provide context to the Gemini model.
3032
+ */
3033
+ urlMetadata: URLMetadata[];
3034
+ }
3035
+
3036
+ /**
3037
+ * A tool that allows you to provide additional context to the models in the form of public web
3038
+ * URLs. By including URLs in your request, the Gemini model will access the content from those
3039
+ * pages to inform and enhance its response.
3040
+ *
3041
+ * @beta
3042
+ */
3043
+ export declare interface URLContextTool {
3044
+ /**
3045
+ * Specifies the URL Context configuration.
3046
+ */
3047
+ urlContext: URLContext;
3048
+ }
3049
+
3050
+ /**
3051
+ * Metadata for a single URL retrieved by the {@link URLContextTool} tool.
3052
+ *
3053
+ * @beta
3054
+ */
3055
+ export declare interface URLMetadata {
3056
+ /**
3057
+ * The retrieved URL.
3058
+ */
3059
+ retrievedUrl?: string;
3060
+ /**
3061
+ * The status of the URL retrieval.
3062
+ */
3063
+ urlRetrievalStatus?: URLRetrievalStatus;
3064
+ }
3065
+
3066
+ /**
3067
+ * The status of a URL retrieval.
3068
+ *
3069
+ * @remarks
3070
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
3071
+ * <br/>
3072
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
3073
+ * <br/>
3074
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
3075
+ * <br/>
3076
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
3077
+ * <br/>
3078
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
3079
+ * <br/>
3080
+ *
3081
+ * @beta
3082
+ */
3083
+ export declare const URLRetrievalStatus: {
3084
+ /**
3085
+ * Unspecified retrieval status.
3086
+ */
3087
+ URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
3088
+ /**
3089
+ * The URL retrieval was successful.
3090
+ */
3091
+ URL_RETRIEVAL_STATUS_SUCCESS: string;
3092
+ /**
3093
+ * The URL retrieval failed.
3094
+ */
3095
+ URL_RETRIEVAL_STATUS_ERROR: string;
3096
+ /**
3097
+ * The URL retrieval failed because the content is behind a paywall.
3098
+ */
3099
+ URL_RETRIEVAL_STATUS_PAYWALL: string;
3100
+ /**
3101
+ * The URL retrieval failed because the content is unsafe.
3102
+ */
3103
+ URL_RETRIEVAL_STATUS_UNSAFE: string;
3104
+ };
3105
+
3106
+ /**
3107
+ * The status of a URL retrieval.
3108
+ *
3109
+ * @remarks
3110
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
3111
+ * <br/>
3112
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
3113
+ * <br/>
3114
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
3115
+ * <br/>
3116
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
3117
+ * <br/>
3118
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
3119
+ * <br/>
3120
+ *
3121
+ * @beta
3122
+ */
3123
+ export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
3124
+
2878
3125
  /**
2879
3126
  * Usage metadata about a {@link GenerateContentResponse}.
2880
3127
  *
@@ -2888,8 +3135,16 @@ export declare interface UsageMetadata {
2888
3135
  */
2889
3136
  thoughtsTokenCount?: number;
2890
3137
  totalTokenCount: number;
3138
+ /**
3139
+ * The number of tokens used by tools.
3140
+ */
3141
+ toolUsePromptTokenCount?: number;
2891
3142
  promptTokensDetails?: ModalityTokenCount[];
2892
3143
  candidatesTokensDetails?: ModalityTokenCount[];
3144
+ /**
3145
+ * A list of tokens used by tools, broken down by modality.
3146
+ */
3147
+ toolUsePromptTokensDetails?: ModalityTokenCount[];
2893
3148
  }
2894
3149
 
2895
3150
  /**