@firebase/ai 2.3.0 → 2.4.0-canary.261508183

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.
Files changed (37) hide show
  1. package/dist/ai-public.d.ts +156 -29
  2. package/dist/ai.d.ts +157 -29
  3. package/dist/esm/index.esm.js +108 -34
  4. package/dist/esm/index.esm.js.map +1 -1
  5. package/dist/esm/src/api.d.ts +1 -1
  6. package/dist/esm/src/methods/live-session-helpers.d.ts +2 -2
  7. package/dist/esm/src/methods/live-session.d.ts +10 -1
  8. package/dist/esm/src/models/imagen-model.d.ts +2 -2
  9. package/dist/esm/src/requests/imagen-image-format.d.ts +3 -3
  10. package/dist/esm/src/types/content.d.ts +4 -4
  11. package/dist/esm/src/types/enums.d.ts +4 -4
  12. package/dist/esm/src/types/googleai.d.ts +2 -1
  13. package/dist/esm/src/types/imagen/requests.d.ts +9 -9
  14. package/dist/esm/src/types/imagen/responses.d.ts +3 -3
  15. package/dist/esm/src/types/live-responses.d.ts +9 -1
  16. package/dist/esm/src/types/requests.d.ts +22 -2
  17. package/dist/esm/src/types/responses.d.ts +92 -0
  18. package/dist/index.cjs.js +108 -33
  19. package/dist/index.cjs.js.map +1 -1
  20. package/dist/index.node.cjs.js +108 -33
  21. package/dist/index.node.cjs.js.map +1 -1
  22. package/dist/index.node.mjs +108 -34
  23. package/dist/index.node.mjs.map +1 -1
  24. package/dist/src/api.d.ts +1 -1
  25. package/dist/src/methods/live-session-helpers.d.ts +2 -2
  26. package/dist/src/methods/live-session.d.ts +10 -1
  27. package/dist/src/models/imagen-model.d.ts +2 -2
  28. package/dist/src/requests/imagen-image-format.d.ts +3 -3
  29. package/dist/src/types/content.d.ts +4 -4
  30. package/dist/src/types/enums.d.ts +4 -4
  31. package/dist/src/types/googleai.d.ts +2 -1
  32. package/dist/src/types/imagen/requests.d.ts +9 -9
  33. package/dist/src/types/imagen/responses.d.ts +3 -3
  34. package/dist/src/types/live-responses.d.ts +9 -1
  35. package/dist/src/types/requests.d.ts +22 -2
  36. package/dist/src/types/responses.d.ts +92 -0
  37. package/package.json +8 -8
package/dist/ai.d.ts CHANGED
@@ -439,7 +439,7 @@ export declare interface CitationMetadata {
439
439
  /**
440
440
  * The results of code execution run by the model.
441
441
  *
442
- * @public
442
+ * @beta
443
443
  */
444
444
  export declare interface CodeExecutionResult {
445
445
  /**
@@ -456,7 +456,7 @@ export declare interface CodeExecutionResult {
456
456
  /**
457
457
  * Represents the code execution result from the model.
458
458
  *
459
- * @public
459
+ * @beta
460
460
  */
461
461
  export declare interface CodeExecutionResultPart {
462
462
  text?: never;
@@ -476,7 +476,7 @@ export declare interface CodeExecutionResultPart {
476
476
  /**
477
477
  * A tool that enables the model to use code execution.
478
478
  *
479
- * @public
479
+ * @beta
480
480
  */
481
481
  export declare interface CodeExecutionTool {
482
482
  /**
@@ -626,7 +626,7 @@ export declare interface ErrorDetails {
626
626
  /**
627
627
  * An interface for executable code returned by the model.
628
628
  *
629
- * @public
629
+ * @beta
630
630
  */
631
631
  export declare interface ExecutableCode {
632
632
  /**
@@ -642,7 +642,7 @@ export declare interface ExecutableCode {
642
642
  /**
643
643
  * Represents the code that is executed by the model.
644
644
  *
645
- * @public
645
+ * @beta
646
646
  */
647
647
  export declare interface ExecutableCodePart {
648
648
  text?: never;
@@ -911,6 +911,7 @@ export declare interface GenerateContentCandidate {
911
911
  safetyRatings?: SafetyRating[];
912
912
  citationMetadata?: CitationMetadata;
913
913
  groundingMetadata?: GroundingMetadata;
914
+ urlContextMetadata?: URLContextMetadata;
914
915
  }
915
916
 
916
917
  /**
@@ -1102,7 +1103,7 @@ export declare function getGenerativeModel(ai: AI, modelParams: ModelParams | Hy
1102
1103
  * @throws If the `apiKey` or `projectId` fields are missing in your
1103
1104
  * Firebase config.
1104
1105
  *
1105
- * @beta
1106
+ * @public
1106
1107
  */
1107
1108
  export declare function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
1108
1109
 
@@ -1166,6 +1167,7 @@ export declare interface GoogleAIGenerateContentCandidate {
1166
1167
  safetyRatings?: SafetyRating[];
1167
1168
  citationMetadata?: GoogleAICitationMetadata;
1168
1169
  groundingMetadata?: GroundingMetadata;
1170
+ urlContextMetadata?: URLContextMetadata;
1169
1171
  }
1170
1172
 
1171
1173
  /**
@@ -1452,7 +1454,7 @@ export declare interface HybridParams {
1452
1454
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
1453
1455
  * for more details and examples of the supported aspect ratios.
1454
1456
  *
1455
- * @beta
1457
+ * @public
1456
1458
  */
1457
1459
  export declare const ImagenAspectRatio: {
1458
1460
  /**
@@ -1486,7 +1488,7 @@ export declare const ImagenAspectRatio: {
1486
1488
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
1487
1489
  * for more details and examples of the supported aspect ratios.
1488
1490
  *
1489
- * @beta
1491
+ * @public
1490
1492
  */
1491
1493
  export declare type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof ImagenAspectRatio];
1492
1494
 
@@ -1494,7 +1496,7 @@ export declare type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof
1494
1496
  * An image generated by Imagen, stored in a Cloud Storage for Firebase bucket.
1495
1497
  *
1496
1498
  * This feature is not available yet.
1497
- * @beta
1499
+ * @public
1498
1500
  */
1499
1501
  export declare interface ImagenGCSImage {
1500
1502
  /**
@@ -1517,7 +1519,7 @@ export declare interface ImagenGCSImage {
1517
1519
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images-imagen | documentation} for
1518
1520
  * more details.
1519
1521
  *
1520
- * @beta
1522
+ * @public
1521
1523
  */
1522
1524
  export declare interface ImagenGenerationConfig {
1523
1525
  /**
@@ -1569,7 +1571,7 @@ export declare interface ImagenGenerationConfig {
1569
1571
  /**
1570
1572
  * The response from a request to generate images with Imagen.
1571
1573
  *
1572
- * @beta
1574
+ * @public
1573
1575
  */
1574
1576
  export declare interface ImagenGenerationResponse<T extends ImagenInlineImage | ImagenGCSImage> {
1575
1577
  /**
@@ -1624,7 +1626,7 @@ export declare interface ImagenGenerationResponse<T extends ImagenInlineImage |
1624
1626
  * }
1625
1627
  * ```
1626
1628
  *
1627
- * @beta
1629
+ * @public
1628
1630
  */
1629
1631
  export declare class ImagenImageFormat {
1630
1632
  /**
@@ -1642,7 +1644,7 @@ export declare class ImagenImageFormat {
1642
1644
  * @param compressionQuality - The level of compression (a number between 0 and 100).
1643
1645
  * @returns An {@link ImagenImageFormat} object for a JPEG image.
1644
1646
  *
1645
- * @beta
1647
+ * @public
1646
1648
  */
1647
1649
  static jpeg(compressionQuality?: number): ImagenImageFormat;
1648
1650
  /**
@@ -1650,7 +1652,7 @@ export declare class ImagenImageFormat {
1650
1652
  *
1651
1653
  * @returns An {@link ImagenImageFormat} object for a PNG image.
1652
1654
  *
1653
- * @beta
1655
+ * @public
1654
1656
  */
1655
1657
  static png(): ImagenImageFormat;
1656
1658
  }
@@ -1674,7 +1676,7 @@ export declare class ImagenImageFormat {
1674
1676
  /**
1675
1677
  * An image generated by Imagen, represented as inline data.
1676
1678
  *
1677
- * @beta
1679
+ * @public
1678
1680
  */
1679
1681
  export declare interface ImagenInlineImage {
1680
1682
  /**
@@ -1709,7 +1711,7 @@ export declare interface ImagenInlineImage {
1709
1711
  * }
1710
1712
  * ```
1711
1713
  *
1712
- * @beta
1714
+ * @public
1713
1715
  */
1714
1716
  export declare class ImagenModel extends AIModel {
1715
1717
  requestOptions?: RequestOptions | undefined;
@@ -1748,7 +1750,7 @@ export declare class ImagenModel extends AIModel {
1748
1750
  * returned object will have a `filteredReason` property.
1749
1751
  * If all images are filtered, the `images` array will be empty.
1750
1752
  *
1751
- * @beta
1753
+ * @public
1752
1754
  */
1753
1755
  generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
1754
1756
  /**
@@ -1776,7 +1778,7 @@ export declare class ImagenModel extends AIModel {
1776
1778
  /**
1777
1779
  * Parameters for configuring an {@link ImagenModel}.
1778
1780
  *
1779
- * @beta
1781
+ * @public
1780
1782
  */
1781
1783
  export declare interface ImagenModelParams {
1782
1784
  /**
@@ -1805,7 +1807,7 @@ export declare interface ImagenModelParams {
1805
1807
  * See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
1806
1808
  * documentation for more details.
1807
1809
  *
1808
- * @beta
1810
+ * @public
1809
1811
  */
1810
1812
  export declare const ImagenPersonFilterLevel: {
1811
1813
  /**
@@ -1836,7 +1838,7 @@ export declare const ImagenPersonFilterLevel: {
1836
1838
  * See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
1837
1839
  * documentation for more details.
1838
1840
  *
1839
- * @beta
1841
+ * @public
1840
1842
  */
1841
1843
  export declare type ImagenPersonFilterLevel = (typeof ImagenPersonFilterLevel)[keyof typeof ImagenPersonFilterLevel];
1842
1844
 
@@ -1850,7 +1852,7 @@ export declare type ImagenPersonFilterLevel = (typeof ImagenPersonFilterLevel)[k
1850
1852
  * and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
1851
1853
  * for more details.
1852
1854
  *
1853
- * @beta
1855
+ * @public
1854
1856
  */
1855
1857
  export declare const ImagenSafetyFilterLevel: {
1856
1858
  /**
@@ -1884,7 +1886,7 @@ export declare const ImagenSafetyFilterLevel: {
1884
1886
  * and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
1885
1887
  * for more details.
1886
1888
  *
1887
- * @beta
1889
+ * @public
1888
1890
  */
1889
1891
  export declare type ImagenSafetyFilterLevel = (typeof ImagenSafetyFilterLevel)[keyof typeof ImagenSafetyFilterLevel];
1890
1892
 
@@ -1894,7 +1896,7 @@ export declare type ImagenSafetyFilterLevel = (typeof ImagenSafetyFilterLevel)[k
1894
1896
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
1895
1897
  * for more details.
1896
1898
  *
1897
- * @beta
1899
+ * @public
1898
1900
  */
1899
1901
  export declare interface ImagenSafetySettings {
1900
1902
  /**
@@ -1976,7 +1978,7 @@ export declare class IntegerSchema extends Schema {
1976
1978
  /**
1977
1979
  * The programming language of the code.
1978
1980
  *
1979
- * @public
1981
+ * @beta
1980
1982
  */
1981
1983
  export declare const Language: {
1982
1984
  UNSPECIFIED: string;
@@ -1986,7 +1988,7 @@ export declare const Language: {
1986
1988
  /**
1987
1989
  * The programming language of the code.
1988
1990
  *
1989
- * @public
1991
+ * @beta
1990
1992
  */
1991
1993
  export declare type Language = (typeof Language)[keyof typeof Language];
1992
1994
 
@@ -2274,6 +2276,15 @@ export declare class LiveSession {
2274
2276
  * @beta
2275
2277
  */
2276
2278
  sendMediaChunks(mediaChunks: GenerativeContentBlob[]): Promise<void>;
2279
+ /**
2280
+ * Sends function responses to the server.
2281
+ *
2282
+ * @param functionResponses - The function responses to send.
2283
+ * @throws If this session has been closed.
2284
+ *
2285
+ * @beta
2286
+ */
2287
+ sendFunctionResponses(functionResponses: FunctionResponse[]): Promise<void>;
2277
2288
  /**
2278
2289
  * Sends a stream of {@link GenerativeContentBlob}.
2279
2290
  *
@@ -2419,7 +2430,7 @@ export declare interface OnDeviceParams {
2419
2430
  /**
2420
2431
  * Represents the result of the code execution.
2421
2432
  *
2422
- * @public
2433
+ * @beta
2423
2434
  */
2424
2435
  export declare const Outcome: {
2425
2436
  UNSPECIFIED: string;
@@ -2431,7 +2442,7 @@ export declare const Outcome: {
2431
2442
  /**
2432
2443
  * Represents the result of the code execution.
2433
2444
  *
2434
- * @public
2445
+ * @beta
2435
2446
  */
2436
2447
  export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
2437
2448
 
@@ -2911,7 +2922,7 @@ export declare interface StartAudioConversationOptions {
2911
2922
  * The handler should perform the function call and return the result as a `Part`,
2912
2923
  * which will then be sent back to the model.
2913
2924
  */
2914
- functionCallingHandler?: (functionCalls: LiveServerToolCall['functionCalls']) => Promise<Part>;
2925
+ functionCallingHandler?: (functionCalls: FunctionCall[]) => Promise<FunctionResponse>;
2915
2926
  }
2916
2927
 
2917
2928
  /**
@@ -2995,7 +3006,7 @@ export declare interface ThinkingConfig {
2995
3006
  * Defines a tool that model can call to access external knowledge.
2996
3007
  * @public
2997
3008
  */
2998
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
3009
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
2999
3010
 
3000
3011
  /**
3001
3012
  * Tool config. This config is shared for all tools provided in the request.
@@ -3011,6 +3022,115 @@ export declare interface ToolConfig {
3011
3022
  */
3012
3023
  export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
3013
3024
 
3025
+ /**
3026
+ * Specifies the URL Context configuration.
3027
+ *
3028
+ * @beta
3029
+ */
3030
+ export declare interface URLContext {
3031
+ }
3032
+
3033
+ /**
3034
+ * Metadata related to {@link URLContextTool}.
3035
+ *
3036
+ * @beta
3037
+ */
3038
+ export declare interface URLContextMetadata {
3039
+ /**
3040
+ * List of URL metadata used to provide context to the Gemini model.
3041
+ */
3042
+ urlMetadata: URLMetadata[];
3043
+ }
3044
+
3045
+ /**
3046
+ * A tool that allows you to provide additional context to the models in the form of public web
3047
+ * URLs. By including URLs in your request, the Gemini model will access the content from those
3048
+ * pages to inform and enhance its response.
3049
+ *
3050
+ * @beta
3051
+ */
3052
+ export declare interface URLContextTool {
3053
+ /**
3054
+ * Specifies the URL Context configuration.
3055
+ */
3056
+ urlContext: URLContext;
3057
+ }
3058
+
3059
+ /**
3060
+ * Metadata for a single URL retrieved by the {@link URLContextTool} tool.
3061
+ *
3062
+ * @beta
3063
+ */
3064
+ export declare interface URLMetadata {
3065
+ /**
3066
+ * The retrieved URL.
3067
+ */
3068
+ retrievedUrl?: string;
3069
+ /**
3070
+ * The status of the URL retrieval.
3071
+ */
3072
+ urlRetrievalStatus?: URLRetrievalStatus;
3073
+ }
3074
+
3075
+ /**
3076
+ * The status of a URL retrieval.
3077
+ *
3078
+ * @remarks
3079
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
3080
+ * <br/>
3081
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
3082
+ * <br/>
3083
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
3084
+ * <br/>
3085
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
3086
+ * <br/>
3087
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
3088
+ * <br/>
3089
+ *
3090
+ * @beta
3091
+ */
3092
+ export declare const URLRetrievalStatus: {
3093
+ /**
3094
+ * Unspecified retrieval status.
3095
+ */
3096
+ URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
3097
+ /**
3098
+ * The URL retrieval was successful.
3099
+ */
3100
+ URL_RETRIEVAL_STATUS_SUCCESS: string;
3101
+ /**
3102
+ * The URL retrieval failed.
3103
+ */
3104
+ URL_RETRIEVAL_STATUS_ERROR: string;
3105
+ /**
3106
+ * The URL retrieval failed because the content is behind a paywall.
3107
+ */
3108
+ URL_RETRIEVAL_STATUS_PAYWALL: string;
3109
+ /**
3110
+ * The URL retrieval failed because the content is unsafe.
3111
+ */
3112
+ URL_RETRIEVAL_STATUS_UNSAFE: string;
3113
+ };
3114
+
3115
+ /**
3116
+ * The status of a URL retrieval.
3117
+ *
3118
+ * @remarks
3119
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
3120
+ * <br/>
3121
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
3122
+ * <br/>
3123
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
3124
+ * <br/>
3125
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
3126
+ * <br/>
3127
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
3128
+ * <br/>
3129
+ *
3130
+ * @beta
3131
+ */
3132
+ export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
3133
+
3014
3134
  /**
3015
3135
  * Usage metadata about a {@link GenerateContentResponse}.
3016
3136
  *
@@ -3024,8 +3144,16 @@ export declare interface UsageMetadata {
3024
3144
  */
3025
3145
  thoughtsTokenCount?: number;
3026
3146
  totalTokenCount: number;
3147
+ /**
3148
+ * The number of tokens used by tools.
3149
+ */
3150
+ toolUsePromptTokenCount?: number;
3027
3151
  promptTokensDetails?: ModalityTokenCount[];
3028
3152
  candidatesTokensDetails?: ModalityTokenCount[];
3153
+ /**
3154
+ * A list of tokens used by tools, broken down by modality.
3155
+ */
3156
+ toolUsePromptTokensDetails?: ModalityTokenCount[];
3029
3157
  }
3030
3158
 
3031
3159
  /**