@firebase/ai 2.3.0-canary.cb3bdd812 → 2.3.0-canary.ea8512812
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-public.d.ts +128 -10
- package/dist/ai.d.ts +129 -10
- package/dist/esm/index.esm.js +78 -23
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/types/content.d.ts +4 -4
- package/dist/esm/src/types/enums.d.ts +4 -4
- package/dist/esm/src/types/googleai.d.ts +2 -1
- package/dist/esm/src/types/requests.d.ts +22 -2
- package/dist/esm/src/types/responses.d.ts +92 -0
- package/dist/index.cjs.js +78 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +78 -22
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +78 -23
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/types/content.d.ts +4 -4
- package/dist/src/types/enums.d.ts +4 -4
- package/dist/src/types/googleai.d.ts +2 -1
- package/dist/src/types/requests.d.ts +22 -2
- package/dist/src/types/responses.d.ts +92 -0
- package/package.json +8 -8
package/dist/ai-public.d.ts
CHANGED
|
@@ -396,7 +396,7 @@ export declare interface CitationMetadata {
|
|
|
396
396
|
/**
|
|
397
397
|
* The results of code execution run by the model.
|
|
398
398
|
*
|
|
399
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
/**
|
|
@@ -1862,7 +1863,7 @@ export declare class IntegerSchema extends Schema {
|
|
|
1862
1863
|
/**
|
|
1863
1864
|
* The programming language of the code.
|
|
1864
1865
|
*
|
|
1865
|
-
* @
|
|
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
|
-
* @
|
|
1876
|
+
* @beta
|
|
1876
1877
|
*/
|
|
1877
1878
|
export declare type Language = (typeof Language)[keyof typeof Language];
|
|
1878
1879
|
|
|
@@ -2289,7 +2290,7 @@ export declare interface OnDeviceParams {
|
|
|
2289
2290
|
/**
|
|
2290
2291
|
* Represents the result of the code execution.
|
|
2291
2292
|
*
|
|
2292
|
-
* @
|
|
2293
|
+
* @beta
|
|
2293
2294
|
*/
|
|
2294
2295
|
export declare const Outcome: {
|
|
2295
2296
|
UNSPECIFIED: string;
|
|
@@ -2301,7 +2302,7 @@ export declare const Outcome: {
|
|
|
2301
2302
|
/**
|
|
2302
2303
|
* Represents the result of the code execution.
|
|
2303
2304
|
*
|
|
2304
|
-
* @
|
|
2305
|
+
* @beta
|
|
2305
2306
|
*/
|
|
2306
2307
|
export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
|
|
2307
2308
|
|
|
@@ -2854,7 +2855,7 @@ export declare interface ThinkingConfig {
|
|
|
2854
2855
|
* Defines a tool that model can call to access external knowledge.
|
|
2855
2856
|
* @public
|
|
2856
2857
|
*/
|
|
2857
|
-
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
|
|
2858
|
+
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
|
|
2858
2859
|
|
|
2859
2860
|
/**
|
|
2860
2861
|
* Tool config. This config is shared for all tools provided in the request.
|
|
@@ -2870,6 +2871,115 @@ export declare interface ToolConfig {
|
|
|
2870
2871
|
*/
|
|
2871
2872
|
export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
|
|
2872
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
|
+
|
|
2873
2983
|
/**
|
|
2874
2984
|
* Usage metadata about a {@link GenerateContentResponse}.
|
|
2875
2985
|
*
|
|
@@ -2883,8 +2993,16 @@ export declare interface UsageMetadata {
|
|
|
2883
2993
|
*/
|
|
2884
2994
|
thoughtsTokenCount?: number;
|
|
2885
2995
|
totalTokenCount: number;
|
|
2996
|
+
/**
|
|
2997
|
+
* The number of tokens used by tools.
|
|
2998
|
+
*/
|
|
2999
|
+
toolUsePromptTokenCount?: number;
|
|
2886
3000
|
promptTokensDetails?: ModalityTokenCount[];
|
|
2887
3001
|
candidatesTokensDetails?: ModalityTokenCount[];
|
|
3002
|
+
/**
|
|
3003
|
+
* A list of tokens used by tools, broken down by modality.
|
|
3004
|
+
*/
|
|
3005
|
+
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
2888
3006
|
}
|
|
2889
3007
|
|
|
2890
3008
|
/**
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
/**
|
|
@@ -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
|
/**
|
|
@@ -1976,7 +1978,7 @@ export declare class IntegerSchema extends Schema {
|
|
|
1976
1978
|
/**
|
|
1977
1979
|
* The programming language of the code.
|
|
1978
1980
|
*
|
|
1979
|
-
* @
|
|
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
|
-
* @
|
|
1991
|
+
* @beta
|
|
1990
1992
|
*/
|
|
1991
1993
|
export declare type Language = (typeof Language)[keyof typeof Language];
|
|
1992
1994
|
|
|
@@ -2419,7 +2421,7 @@ export declare interface OnDeviceParams {
|
|
|
2419
2421
|
/**
|
|
2420
2422
|
* Represents the result of the code execution.
|
|
2421
2423
|
*
|
|
2422
|
-
* @
|
|
2424
|
+
* @beta
|
|
2423
2425
|
*/
|
|
2424
2426
|
export declare const Outcome: {
|
|
2425
2427
|
UNSPECIFIED: string;
|
|
@@ -2431,7 +2433,7 @@ export declare const Outcome: {
|
|
|
2431
2433
|
/**
|
|
2432
2434
|
* Represents the result of the code execution.
|
|
2433
2435
|
*
|
|
2434
|
-
* @
|
|
2436
|
+
* @beta
|
|
2435
2437
|
*/
|
|
2436
2438
|
export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
|
|
2437
2439
|
|
|
@@ -2995,7 +2997,7 @@ export declare interface ThinkingConfig {
|
|
|
2995
2997
|
* Defines a tool that model can call to access external knowledge.
|
|
2996
2998
|
* @public
|
|
2997
2999
|
*/
|
|
2998
|
-
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
|
|
3000
|
+
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
|
|
2999
3001
|
|
|
3000
3002
|
/**
|
|
3001
3003
|
* Tool config. This config is shared for all tools provided in the request.
|
|
@@ -3011,6 +3013,115 @@ export declare interface ToolConfig {
|
|
|
3011
3013
|
*/
|
|
3012
3014
|
export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
|
|
3013
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
|
+
|
|
3014
3125
|
/**
|
|
3015
3126
|
* Usage metadata about a {@link GenerateContentResponse}.
|
|
3016
3127
|
*
|
|
@@ -3024,8 +3135,16 @@ export declare interface UsageMetadata {
|
|
|
3024
3135
|
*/
|
|
3025
3136
|
thoughtsTokenCount?: number;
|
|
3026
3137
|
totalTokenCount: number;
|
|
3138
|
+
/**
|
|
3139
|
+
* The number of tokens used by tools.
|
|
3140
|
+
*/
|
|
3141
|
+
toolUsePromptTokenCount?: number;
|
|
3027
3142
|
promptTokensDetails?: ModalityTokenCount[];
|
|
3028
3143
|
candidatesTokensDetails?: ModalityTokenCount[];
|
|
3144
|
+
/**
|
|
3145
|
+
* A list of tokens used by tools, broken down by modality.
|
|
3146
|
+
*/
|
|
3147
|
+
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
3029
3148
|
}
|
|
3030
3149
|
|
|
3031
3150
|
/**
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FirebaseError, Deferred, getModularInstance } from '@firebase/util';
|
|
|
4
4
|
import { Logger } from '@firebase/logger';
|
|
5
5
|
|
|
6
6
|
var name = "@firebase/ai";
|
|
7
|
-
var version = "2.3.0-canary.
|
|
7
|
+
var version = "2.3.0-canary.ea8512812";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -382,7 +382,7 @@ const InferenceMode = {
|
|
|
382
382
|
/**
|
|
383
383
|
* Represents the result of the code execution.
|
|
384
384
|
*
|
|
385
|
-
* @
|
|
385
|
+
* @beta
|
|
386
386
|
*/
|
|
387
387
|
const Outcome = {
|
|
388
388
|
UNSPECIFIED: 'OUTCOME_UNSPECIFIED',
|
|
@@ -393,7 +393,7 @@ const Outcome = {
|
|
|
393
393
|
/**
|
|
394
394
|
* The programming language of the code.
|
|
395
395
|
*
|
|
396
|
-
* @
|
|
396
|
+
* @beta
|
|
397
397
|
*/
|
|
398
398
|
const Language = {
|
|
399
399
|
UNSPECIFIED: 'LANGUAGE_UNSPECIFIED',
|
|
@@ -416,6 +416,45 @@ const Language = {
|
|
|
416
416
|
* See the License for the specific language governing permissions and
|
|
417
417
|
* limitations under the License.
|
|
418
418
|
*/
|
|
419
|
+
/**
|
|
420
|
+
* The status of a URL retrieval.
|
|
421
|
+
*
|
|
422
|
+
* @remarks
|
|
423
|
+
* <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
|
|
424
|
+
* <br/>
|
|
425
|
+
* <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
|
|
426
|
+
* <br/>
|
|
427
|
+
* <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
|
|
428
|
+
* <br/>
|
|
429
|
+
* <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
|
|
430
|
+
* <br/>
|
|
431
|
+
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
432
|
+
* <br/>
|
|
433
|
+
*
|
|
434
|
+
* @beta
|
|
435
|
+
*/
|
|
436
|
+
const URLRetrievalStatus = {
|
|
437
|
+
/**
|
|
438
|
+
* Unspecified retrieval status.
|
|
439
|
+
*/
|
|
440
|
+
URL_RETRIEVAL_STATUS_UNSPECIFIED: 'URL_RETRIEVAL_STATUS_UNSPECIFIED',
|
|
441
|
+
/**
|
|
442
|
+
* The URL retrieval was successful.
|
|
443
|
+
*/
|
|
444
|
+
URL_RETRIEVAL_STATUS_SUCCESS: 'URL_RETRIEVAL_STATUS_SUCCESS',
|
|
445
|
+
/**
|
|
446
|
+
* The URL retrieval failed.
|
|
447
|
+
*/
|
|
448
|
+
URL_RETRIEVAL_STATUS_ERROR: 'URL_RETRIEVAL_STATUS_ERROR',
|
|
449
|
+
/**
|
|
450
|
+
* The URL retrieval failed because the content is behind a paywall.
|
|
451
|
+
*/
|
|
452
|
+
URL_RETRIEVAL_STATUS_PAYWALL: 'URL_RETRIEVAL_STATUS_PAYWALL',
|
|
453
|
+
/**
|
|
454
|
+
* The URL retrieval failed because the content is unsafe.
|
|
455
|
+
*/
|
|
456
|
+
URL_RETRIEVAL_STATUS_UNSAFE: 'URL_RETRIEVAL_STATUS_UNSAFE'
|
|
457
|
+
};
|
|
419
458
|
/**
|
|
420
459
|
* The types of responses that can be returned by {@link LiveSession.receive}.
|
|
421
460
|
*
|
|
@@ -1876,7 +1915,7 @@ function mapGenerateContentCandidates(candidates) {
|
|
|
1876
1915
|
// videoMetadata is not supported.
|
|
1877
1916
|
// Throw early since developers may send a long video as input and only expect to pay
|
|
1878
1917
|
// for inference on a small portion of the video.
|
|
1879
|
-
if (candidate.content?.parts
|
|
1918
|
+
if (candidate.content?.parts?.some(part => part?.videoMetadata)) {
|
|
1880
1919
|
throw new AIError(AIErrorCode.UNSUPPORTED, 'Part.videoMetadata is not supported in the Gemini Developer API. Please remove this property.');
|
|
1881
1920
|
}
|
|
1882
1921
|
const mappedCandidate = {
|
|
@@ -1886,7 +1925,8 @@ function mapGenerateContentCandidates(candidates) {
|
|
|
1886
1925
|
finishMessage: candidate.finishMessage,
|
|
1887
1926
|
safetyRatings: mappedSafetyRatings,
|
|
1888
1927
|
citationMetadata,
|
|
1889
|
-
groundingMetadata: candidate.groundingMetadata
|
|
1928
|
+
groundingMetadata: candidate.groundingMetadata,
|
|
1929
|
+
urlContextMetadata: candidate.urlContextMetadata
|
|
1890
1930
|
};
|
|
1891
1931
|
mappedCandidates.push(mappedCandidate);
|
|
1892
1932
|
});
|
|
@@ -1977,6 +2017,14 @@ async function* generateResponseSequence(stream, apiSettings) {
|
|
|
1977
2017
|
else {
|
|
1978
2018
|
enhancedResponse = createEnhancedContentResponse(value);
|
|
1979
2019
|
}
|
|
2020
|
+
const firstCandidate = enhancedResponse.candidates?.[0];
|
|
2021
|
+
// Don't yield a response with no useful data for the developer.
|
|
2022
|
+
if (!firstCandidate?.content?.parts &&
|
|
2023
|
+
!firstCandidate?.finishReason &&
|
|
2024
|
+
!firstCandidate?.citationMetadata &&
|
|
2025
|
+
!firstCandidate?.urlContextMetadata) {
|
|
2026
|
+
continue;
|
|
2027
|
+
}
|
|
1980
2028
|
yield enhancedResponse;
|
|
1981
2029
|
}
|
|
1982
2030
|
}
|
|
@@ -2056,36 +2104,43 @@ function aggregateResponses(responses) {
|
|
|
2056
2104
|
candidate.safetyRatings;
|
|
2057
2105
|
aggregatedResponse.candidates[i].groundingMetadata =
|
|
2058
2106
|
candidate.groundingMetadata;
|
|
2107
|
+
// The urlContextMetadata object is defined in the first chunk of the response stream.
|
|
2108
|
+
// In all subsequent chunks, the urlContextMetadata object will be undefined. We need to
|
|
2109
|
+
// make sure that we don't overwrite the first value urlContextMetadata object with undefined.
|
|
2110
|
+
// FIXME: What happens if we receive a second, valid urlContextMetadata object?
|
|
2111
|
+
const urlContextMetadata = candidate.urlContextMetadata;
|
|
2112
|
+
if (typeof urlContextMetadata === 'object' &&
|
|
2113
|
+
urlContextMetadata !== null &&
|
|
2114
|
+
Object.keys(urlContextMetadata).length > 0) {
|
|
2115
|
+
aggregatedResponse.candidates[i].urlContextMetadata =
|
|
2116
|
+
urlContextMetadata;
|
|
2117
|
+
}
|
|
2059
2118
|
/**
|
|
2060
2119
|
* Candidates should always have content and parts, but this handles
|
|
2061
2120
|
* possible malformed responses.
|
|
2062
2121
|
*/
|
|
2063
|
-
if (candidate.content
|
|
2122
|
+
if (candidate.content) {
|
|
2123
|
+
// Skip a candidate without parts.
|
|
2124
|
+
if (!candidate.content.parts) {
|
|
2125
|
+
continue;
|
|
2126
|
+
}
|
|
2064
2127
|
if (!aggregatedResponse.candidates[i].content) {
|
|
2065
2128
|
aggregatedResponse.candidates[i].content = {
|
|
2066
2129
|
role: candidate.content.role || 'user',
|
|
2067
2130
|
parts: []
|
|
2068
2131
|
};
|
|
2069
2132
|
}
|
|
2070
|
-
const newPart = {};
|
|
2071
2133
|
for (const part of candidate.content.parts) {
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
}
|
|
2079
|
-
newPart.text = part.text;
|
|
2080
|
-
}
|
|
2081
|
-
if (part.functionCall) {
|
|
2082
|
-
newPart.functionCall = part.functionCall;
|
|
2134
|
+
const newPart = { ...part };
|
|
2135
|
+
// The backend can send empty text parts. If these are sent back
|
|
2136
|
+
// (e.g. in chat history), the backend will respond with an error.
|
|
2137
|
+
// To prevent this, ignore empty text parts.
|
|
2138
|
+
if (part.text === '') {
|
|
2139
|
+
continue;
|
|
2083
2140
|
}
|
|
2084
|
-
if (Object.keys(newPart).length
|
|
2085
|
-
|
|
2086
|
-
'by a malformed response from the backend.');
|
|
2141
|
+
if (Object.keys(newPart).length > 0) {
|
|
2142
|
+
aggregatedResponse.candidates[i].content.parts.push(newPart);
|
|
2087
2143
|
}
|
|
2088
|
-
aggregatedResponse.candidates[i].content.parts.push(newPart);
|
|
2089
2144
|
}
|
|
2090
2145
|
}
|
|
2091
2146
|
}
|
|
@@ -4035,5 +4090,5 @@ function registerAI() {
|
|
|
4035
4090
|
}
|
|
4036
4091
|
registerAI();
|
|
4037
4092
|
|
|
4038
|
-
export { AIError, AIErrorCode, AIModel, AnyOfSchema, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, InferenceMode, IntegerSchema, Language, LiveGenerativeModel, LiveResponseType, LiveSession, Modality, NumberSchema, ObjectSchema, Outcome, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, getAI, getGenerativeModel, getImagenModel, getLiveGenerativeModel, startAudioConversation };
|
|
4093
|
+
export { AIError, AIErrorCode, AIModel, AnyOfSchema, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, InferenceMode, IntegerSchema, Language, LiveGenerativeModel, LiveResponseType, LiveSession, Modality, NumberSchema, ObjectSchema, Outcome, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, URLRetrievalStatus, VertexAIBackend, getAI, getGenerativeModel, getImagenModel, getLiveGenerativeModel, startAudioConversation };
|
|
4039
4094
|
//# sourceMappingURL=index.esm.js.map
|