@firebase/ai 2.3.0 → 2.4.0-canary.b7e18d0ff

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
@@ -396,7 +396,7 @@ export declare interface CitationMetadata {
396
396
  /**
397
397
  * The results of code execution run by the model.
398
398
  *
399
- * @public
399
+ * @beta
400
400
  */
401
401
  export declare interface CodeExecutionResult {
402
402
  /**
@@ -413,7 +413,7 @@ export declare interface CodeExecutionResult {
413
413
  /**
414
414
  * Represents the code execution result from the model.
415
415
  *
416
- * @public
416
+ * @beta
417
417
  */
418
418
  export declare interface CodeExecutionResultPart {
419
419
  text?: never;
@@ -430,7 +430,7 @@ export declare interface CodeExecutionResultPart {
430
430
  /**
431
431
  * A tool that enables the model to use code execution.
432
432
  *
433
- * @public
433
+ * @beta
434
434
  */
435
435
  export declare interface CodeExecutionTool {
436
436
  /**
@@ -580,7 +580,7 @@ export declare interface ErrorDetails {
580
580
  /**
581
581
  * An interface for executable code returned by the model.
582
582
  *
583
- * @public
583
+ * @beta
584
584
  */
585
585
  export declare interface ExecutableCode {
586
586
  /**
@@ -596,7 +596,7 @@ export declare interface ExecutableCode {
596
596
  /**
597
597
  * Represents the code that is executed by the model.
598
598
  *
599
- * @public
599
+ * @beta
600
600
  */
601
601
  export declare interface ExecutableCodePart {
602
602
  text?: never;
@@ -853,6 +853,7 @@ export declare interface GenerateContentCandidate {
853
853
  safetyRatings?: SafetyRating[];
854
854
  citationMetadata?: CitationMetadata;
855
855
  groundingMetadata?: GroundingMetadata;
856
+ urlContextMetadata?: URLContextMetadata;
856
857
  }
857
858
 
858
859
  /**
@@ -1044,7 +1045,7 @@ export declare function getGenerativeModel(ai: AI, modelParams: ModelParams | Hy
1044
1045
  * @throws If the `apiKey` or `projectId` fields are missing in your
1045
1046
  * Firebase config.
1046
1047
  *
1047
- * @beta
1048
+ * @public
1048
1049
  */
1049
1050
  export declare function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
1050
1051
 
@@ -1360,7 +1361,7 @@ export declare interface HybridParams {
1360
1361
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
1361
1362
  * for more details and examples of the supported aspect ratios.
1362
1363
  *
1363
- * @beta
1364
+ * @public
1364
1365
  */
1365
1366
  export declare const ImagenAspectRatio: {
1366
1367
  /**
@@ -1394,7 +1395,7 @@ export declare const ImagenAspectRatio: {
1394
1395
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
1395
1396
  * for more details and examples of the supported aspect ratios.
1396
1397
  *
1397
- * @beta
1398
+ * @public
1398
1399
  */
1399
1400
  export declare type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof ImagenAspectRatio];
1400
1401
 
@@ -1402,7 +1403,7 @@ export declare type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof
1402
1403
  * An image generated by Imagen, stored in a Cloud Storage for Firebase bucket.
1403
1404
  *
1404
1405
  * This feature is not available yet.
1405
- * @beta
1406
+ * @public
1406
1407
  */
1407
1408
  export declare interface ImagenGCSImage {
1408
1409
  /**
@@ -1425,7 +1426,7 @@ export declare interface ImagenGCSImage {
1425
1426
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images-imagen | documentation} for
1426
1427
  * more details.
1427
1428
  *
1428
- * @beta
1429
+ * @public
1429
1430
  */
1430
1431
  export declare interface ImagenGenerationConfig {
1431
1432
  /**
@@ -1477,7 +1478,7 @@ export declare interface ImagenGenerationConfig {
1477
1478
  /**
1478
1479
  * The response from a request to generate images with Imagen.
1479
1480
  *
1480
- * @beta
1481
+ * @public
1481
1482
  */
1482
1483
  export declare interface ImagenGenerationResponse<T extends ImagenInlineImage | ImagenGCSImage> {
1483
1484
  /**
@@ -1532,7 +1533,7 @@ export declare interface ImagenGenerationResponse<T extends ImagenInlineImage |
1532
1533
  * }
1533
1534
  * ```
1534
1535
  *
1535
- * @beta
1536
+ * @public
1536
1537
  */
1537
1538
  export declare class ImagenImageFormat {
1538
1539
  /**
@@ -1550,7 +1551,7 @@ export declare class ImagenImageFormat {
1550
1551
  * @param compressionQuality - The level of compression (a number between 0 and 100).
1551
1552
  * @returns An {@link ImagenImageFormat} object for a JPEG image.
1552
1553
  *
1553
- * @beta
1554
+ * @public
1554
1555
  */
1555
1556
  static jpeg(compressionQuality?: number): ImagenImageFormat;
1556
1557
  /**
@@ -1558,7 +1559,7 @@ export declare class ImagenImageFormat {
1558
1559
  *
1559
1560
  * @returns An {@link ImagenImageFormat} object for a PNG image.
1560
1561
  *
1561
- * @beta
1562
+ * @public
1562
1563
  */
1563
1564
  static png(): ImagenImageFormat;
1564
1565
  }
@@ -1582,7 +1583,7 @@ export declare class ImagenImageFormat {
1582
1583
  /**
1583
1584
  * An image generated by Imagen, represented as inline data.
1584
1585
  *
1585
- * @beta
1586
+ * @public
1586
1587
  */
1587
1588
  export declare interface ImagenInlineImage {
1588
1589
  /**
@@ -1617,7 +1618,7 @@ export declare interface ImagenInlineImage {
1617
1618
  * }
1618
1619
  * ```
1619
1620
  *
1620
- * @beta
1621
+ * @public
1621
1622
  */
1622
1623
  export declare class ImagenModel extends AIModel {
1623
1624
  requestOptions?: RequestOptions | undefined;
@@ -1656,7 +1657,7 @@ export declare class ImagenModel extends AIModel {
1656
1657
  * returned object will have a `filteredReason` property.
1657
1658
  * If all images are filtered, the `images` array will be empty.
1658
1659
  *
1659
- * @beta
1660
+ * @public
1660
1661
  */
1661
1662
  generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
1662
1663
  /* Excluded from this release type: generateImagesGCS */
@@ -1665,7 +1666,7 @@ export declare class ImagenModel extends AIModel {
1665
1666
  /**
1666
1667
  * Parameters for configuring an {@link ImagenModel}.
1667
1668
  *
1668
- * @beta
1669
+ * @public
1669
1670
  */
1670
1671
  export declare interface ImagenModelParams {
1671
1672
  /**
@@ -1694,7 +1695,7 @@ export declare interface ImagenModelParams {
1694
1695
  * See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
1695
1696
  * documentation for more details.
1696
1697
  *
1697
- * @beta
1698
+ * @public
1698
1699
  */
1699
1700
  export declare const ImagenPersonFilterLevel: {
1700
1701
  /**
@@ -1725,7 +1726,7 @@ export declare const ImagenPersonFilterLevel: {
1725
1726
  * See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
1726
1727
  * documentation for more details.
1727
1728
  *
1728
- * @beta
1729
+ * @public
1729
1730
  */
1730
1731
  export declare type ImagenPersonFilterLevel = (typeof ImagenPersonFilterLevel)[keyof typeof ImagenPersonFilterLevel];
1731
1732
 
@@ -1739,7 +1740,7 @@ export declare type ImagenPersonFilterLevel = (typeof ImagenPersonFilterLevel)[k
1739
1740
  * and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
1740
1741
  * for more details.
1741
1742
  *
1742
- * @beta
1743
+ * @public
1743
1744
  */
1744
1745
  export declare const ImagenSafetyFilterLevel: {
1745
1746
  /**
@@ -1773,7 +1774,7 @@ export declare const ImagenSafetyFilterLevel: {
1773
1774
  * and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
1774
1775
  * for more details.
1775
1776
  *
1776
- * @beta
1777
+ * @public
1777
1778
  */
1778
1779
  export declare type ImagenSafetyFilterLevel = (typeof ImagenSafetyFilterLevel)[keyof typeof ImagenSafetyFilterLevel];
1779
1780
 
@@ -1783,7 +1784,7 @@ export declare type ImagenSafetyFilterLevel = (typeof ImagenSafetyFilterLevel)[k
1783
1784
  * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
1784
1785
  * for more details.
1785
1786
  *
1786
- * @beta
1787
+ * @public
1787
1788
  */
1788
1789
  export declare interface ImagenSafetySettings {
1789
1790
  /**
@@ -1862,7 +1863,7 @@ export declare class IntegerSchema extends Schema {
1862
1863
  /**
1863
1864
  * The programming language of the code.
1864
1865
  *
1865
- * @public
1866
+ * @beta
1866
1867
  */
1867
1868
  export declare const Language: {
1868
1869
  UNSPECIFIED: string;
@@ -1872,7 +1873,7 @@ export declare const Language: {
1872
1873
  /**
1873
1874
  * The programming language of the code.
1874
1875
  *
1875
- * @public
1876
+ * @beta
1876
1877
  */
1877
1878
  export declare type Language = (typeof Language)[keyof typeof Language];
1878
1879
 
@@ -2147,6 +2148,15 @@ export declare class LiveSession {
2147
2148
  * @beta
2148
2149
  */
2149
2150
  sendMediaChunks(mediaChunks: GenerativeContentBlob[]): Promise<void>;
2151
+ /**
2152
+ * Sends function responses to the server.
2153
+ *
2154
+ * @param functionResponses - The function responses to send.
2155
+ * @throws If this session has been closed.
2156
+ *
2157
+ * @beta
2158
+ */
2159
+ sendFunctionResponses(functionResponses: FunctionResponse[]): Promise<void>;
2150
2160
  /**
2151
2161
  * Sends a stream of {@link GenerativeContentBlob}.
2152
2162
  *
@@ -2289,7 +2299,7 @@ export declare interface OnDeviceParams {
2289
2299
  /**
2290
2300
  * Represents the result of the code execution.
2291
2301
  *
2292
- * @public
2302
+ * @beta
2293
2303
  */
2294
2304
  export declare const Outcome: {
2295
2305
  UNSPECIFIED: string;
@@ -2301,7 +2311,7 @@ export declare const Outcome: {
2301
2311
  /**
2302
2312
  * Represents the result of the code execution.
2303
2313
  *
2304
- * @public
2314
+ * @beta
2305
2315
  */
2306
2316
  export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
2307
2317
 
@@ -2776,7 +2786,7 @@ export declare interface StartAudioConversationOptions {
2776
2786
  * The handler should perform the function call and return the result as a `Part`,
2777
2787
  * which will then be sent back to the model.
2778
2788
  */
2779
- functionCallingHandler?: (functionCalls: LiveServerToolCall['functionCalls']) => Promise<Part>;
2789
+ functionCallingHandler?: (functionCalls: FunctionCall[]) => Promise<FunctionResponse>;
2780
2790
  }
2781
2791
 
2782
2792
  /**
@@ -2854,7 +2864,7 @@ export declare interface ThinkingConfig {
2854
2864
  * Defines a tool that model can call to access external knowledge.
2855
2865
  * @public
2856
2866
  */
2857
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
2867
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
2858
2868
 
2859
2869
  /**
2860
2870
  * Tool config. This config is shared for all tools provided in the request.
@@ -2870,6 +2880,115 @@ export declare interface ToolConfig {
2870
2880
  */
2871
2881
  export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
2872
2882
 
2883
+ /**
2884
+ * Specifies the URL Context configuration.
2885
+ *
2886
+ * @beta
2887
+ */
2888
+ export declare interface URLContext {
2889
+ }
2890
+
2891
+ /**
2892
+ * Metadata related to {@link URLContextTool}.
2893
+ *
2894
+ * @beta
2895
+ */
2896
+ export declare interface URLContextMetadata {
2897
+ /**
2898
+ * List of URL metadata used to provide context to the Gemini model.
2899
+ */
2900
+ urlMetadata: URLMetadata[];
2901
+ }
2902
+
2903
+ /**
2904
+ * A tool that allows you to provide additional context to the models in the form of public web
2905
+ * URLs. By including URLs in your request, the Gemini model will access the content from those
2906
+ * pages to inform and enhance its response.
2907
+ *
2908
+ * @beta
2909
+ */
2910
+ export declare interface URLContextTool {
2911
+ /**
2912
+ * Specifies the URL Context configuration.
2913
+ */
2914
+ urlContext: URLContext;
2915
+ }
2916
+
2917
+ /**
2918
+ * Metadata for a single URL retrieved by the {@link URLContextTool} tool.
2919
+ *
2920
+ * @beta
2921
+ */
2922
+ export declare interface URLMetadata {
2923
+ /**
2924
+ * The retrieved URL.
2925
+ */
2926
+ retrievedUrl?: string;
2927
+ /**
2928
+ * The status of the URL retrieval.
2929
+ */
2930
+ urlRetrievalStatus?: URLRetrievalStatus;
2931
+ }
2932
+
2933
+ /**
2934
+ * The status of a URL retrieval.
2935
+ *
2936
+ * @remarks
2937
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
2938
+ * <br/>
2939
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
2940
+ * <br/>
2941
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
2942
+ * <br/>
2943
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
2944
+ * <br/>
2945
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
2946
+ * <br/>
2947
+ *
2948
+ * @beta
2949
+ */
2950
+ export declare const URLRetrievalStatus: {
2951
+ /**
2952
+ * Unspecified retrieval status.
2953
+ */
2954
+ URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
2955
+ /**
2956
+ * The URL retrieval was successful.
2957
+ */
2958
+ URL_RETRIEVAL_STATUS_SUCCESS: string;
2959
+ /**
2960
+ * The URL retrieval failed.
2961
+ */
2962
+ URL_RETRIEVAL_STATUS_ERROR: string;
2963
+ /**
2964
+ * The URL retrieval failed because the content is behind a paywall.
2965
+ */
2966
+ URL_RETRIEVAL_STATUS_PAYWALL: string;
2967
+ /**
2968
+ * The URL retrieval failed because the content is unsafe.
2969
+ */
2970
+ URL_RETRIEVAL_STATUS_UNSAFE: string;
2971
+ };
2972
+
2973
+ /**
2974
+ * The status of a URL retrieval.
2975
+ *
2976
+ * @remarks
2977
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
2978
+ * <br/>
2979
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
2980
+ * <br/>
2981
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
2982
+ * <br/>
2983
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
2984
+ * <br/>
2985
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
2986
+ * <br/>
2987
+ *
2988
+ * @beta
2989
+ */
2990
+ export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
2991
+
2873
2992
  /**
2874
2993
  * Usage metadata about a {@link GenerateContentResponse}.
2875
2994
  *
@@ -2883,8 +3002,16 @@ export declare interface UsageMetadata {
2883
3002
  */
2884
3003
  thoughtsTokenCount?: number;
2885
3004
  totalTokenCount: number;
3005
+ /**
3006
+ * The number of tokens used by tools.
3007
+ */
3008
+ toolUsePromptTokenCount?: number;
2886
3009
  promptTokensDetails?: ModalityTokenCount[];
2887
3010
  candidatesTokensDetails?: ModalityTokenCount[];
3011
+ /**
3012
+ * A list of tokens used by tools, broken down by modality.
3013
+ */
3014
+ toolUsePromptTokensDetails?: ModalityTokenCount[];
2888
3015
  }
2889
3016
 
2890
3017
  /**