@firebase/ai 1.4.0-canary.5871fd656 → 1.4.0-canary.6ab4e13a1
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 +224 -10
- package/dist/ai.d.ts +224 -10
- package/dist/esm/index.esm2017.js +4 -1
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/types/requests.d.ts +68 -6
- package/dist/esm/src/types/responses.d.ts +148 -11
- package/dist/esm/src/types/schema.d.ts +11 -3
- package/dist/index.cjs.js +4 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +4 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +4 -1
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/types/requests.d.ts +68 -6
- package/dist/src/types/responses.d.ts +148 -11
- package/dist/src/types/schema.d.ts +11 -3
- package/package.json +8 -8
package/dist/ai-public.d.ts
CHANGED
|
@@ -346,11 +346,10 @@ export declare interface CountTokensResponse {
|
|
|
346
346
|
*/
|
|
347
347
|
totalTokens: number;
|
|
348
348
|
/**
|
|
349
|
+
* @deprecated Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`.
|
|
350
|
+
*
|
|
349
351
|
* The total number of billable characters counted across all instances
|
|
350
352
|
* from the request.
|
|
351
|
-
*
|
|
352
|
-
* This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
353
|
-
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
|
|
354
353
|
*/
|
|
355
354
|
totalBillableCharacters?: number;
|
|
356
355
|
/**
|
|
@@ -569,7 +568,7 @@ export declare interface FunctionDeclaration {
|
|
|
569
568
|
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
|
|
570
569
|
* case-sensitive. For a function with no parameters, this can be left unset.
|
|
571
570
|
*/
|
|
572
|
-
parameters?:
|
|
571
|
+
parameters?: ObjectSchema | ObjectSchemaRequest;
|
|
573
572
|
}
|
|
574
573
|
|
|
575
574
|
/**
|
|
@@ -716,6 +715,10 @@ export declare interface GenerationConfig {
|
|
|
716
715
|
* @beta
|
|
717
716
|
*/
|
|
718
717
|
responseModalities?: ResponseModality[];
|
|
718
|
+
/**
|
|
719
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
720
|
+
*/
|
|
721
|
+
thinkingConfig?: ThinkingConfig;
|
|
719
722
|
}
|
|
720
723
|
|
|
721
724
|
/**
|
|
@@ -858,6 +861,42 @@ export declare class GoogleAIBackend extends Backend {
|
|
|
858
861
|
|
|
859
862
|
/* Excluded from this release type: GoogleAIGenerateContentResponse */
|
|
860
863
|
|
|
864
|
+
/**
|
|
865
|
+
* Specifies the Google Search configuration.
|
|
866
|
+
*
|
|
867
|
+
* @remarks Currently, this is an empty object, but it's reserved for future configuration options.
|
|
868
|
+
*
|
|
869
|
+
* @public
|
|
870
|
+
*/
|
|
871
|
+
export declare interface GoogleSearch {
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* A tool that allows a Gemini model to connect to Google Search to access and incorporate
|
|
876
|
+
* up-to-date information from the web into its responses.
|
|
877
|
+
*
|
|
878
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
879
|
+
* "Grounding with Google Search" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
880
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
881
|
+
* section within the Service Specific Terms).
|
|
882
|
+
*
|
|
883
|
+
* @public
|
|
884
|
+
*/
|
|
885
|
+
export declare interface GoogleSearchTool {
|
|
886
|
+
/**
|
|
887
|
+
* Specifies the Google Search configuration.
|
|
888
|
+
* Currently, this is an empty object, but it's reserved for future configuration options.
|
|
889
|
+
* Specifies the Google Search configuration. Currently, this is an empty object, but it's
|
|
890
|
+
* reserved for future configuration options.
|
|
891
|
+
*
|
|
892
|
+
* When using this feature, you are required to comply with the "Grounding with Google Search"
|
|
893
|
+
* usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
894
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
895
|
+
* section within the Service Specific Terms).
|
|
896
|
+
*/
|
|
897
|
+
googleSearch: GoogleSearch;
|
|
898
|
+
}
|
|
899
|
+
|
|
861
900
|
/**
|
|
862
901
|
* @deprecated
|
|
863
902
|
* @public
|
|
@@ -870,18 +909,83 @@ export declare interface GroundingAttribution {
|
|
|
870
909
|
}
|
|
871
910
|
|
|
872
911
|
/**
|
|
873
|
-
*
|
|
912
|
+
* Represents a chunk of retrieved data that supports a claim in the model's response. This is part
|
|
913
|
+
* of the grounding information provided when grounding is enabled.
|
|
914
|
+
*
|
|
915
|
+
* @public
|
|
916
|
+
*/
|
|
917
|
+
export declare interface GroundingChunk {
|
|
918
|
+
/**
|
|
919
|
+
* Contains details if the grounding chunk is from a web source.
|
|
920
|
+
*/
|
|
921
|
+
web?: WebGroundingChunk;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Metadata returned when grounding is enabled.
|
|
926
|
+
*
|
|
927
|
+
* Currently, only Grounding with Google Search is supported (see {@link GoogleSearchTool}).
|
|
928
|
+
*
|
|
929
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
930
|
+
* "Grounding with Google Search" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
931
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
932
|
+
* section within the Service Specific Terms).
|
|
933
|
+
*
|
|
874
934
|
* @public
|
|
875
935
|
*/
|
|
876
936
|
export declare interface GroundingMetadata {
|
|
937
|
+
/**
|
|
938
|
+
* Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
|
|
939
|
+
* embedded in an app to display a Google Search entry point for follow-up web searches related to
|
|
940
|
+
* a model's “Grounded Response”.
|
|
941
|
+
*/
|
|
942
|
+
searchEntryPoint?: SearchEntrypoint;
|
|
943
|
+
/**
|
|
944
|
+
* A list of {@link GroundingChunk} objects. Each chunk represents a piece of retrieved content
|
|
945
|
+
* (for example, from a web page). that the model used to ground its response.
|
|
946
|
+
*/
|
|
947
|
+
groundingChunks?: GroundingChunk[];
|
|
948
|
+
/**
|
|
949
|
+
* A list of {@link GroundingSupport} objects. Each object details how specific segments of the
|
|
950
|
+
* model's response are supported by the `groundingChunks`.
|
|
951
|
+
*/
|
|
952
|
+
groundingSupports?: GroundingSupport[];
|
|
953
|
+
/**
|
|
954
|
+
* A list of web search queries that the model performed to gather the grounding information.
|
|
955
|
+
* These can be used to allow users to explore the search results themselves.
|
|
956
|
+
*/
|
|
877
957
|
webSearchQueries?: string[];
|
|
958
|
+
/**
|
|
959
|
+
* @deprecated Use {@link GroundingSupport} instead.
|
|
960
|
+
*/
|
|
878
961
|
retrievalQueries?: string[];
|
|
879
962
|
/**
|
|
880
|
-
* @deprecated
|
|
963
|
+
* @deprecated Use {@link GroundingChunk} instead.
|
|
881
964
|
*/
|
|
882
965
|
groundingAttributions: GroundingAttribution[];
|
|
883
966
|
}
|
|
884
967
|
|
|
968
|
+
/**
|
|
969
|
+
* Provides information about how a specific segment of the model's response is supported by the
|
|
970
|
+
* retrieved grounding chunks.
|
|
971
|
+
*
|
|
972
|
+
* @public
|
|
973
|
+
*/
|
|
974
|
+
export declare interface GroundingSupport {
|
|
975
|
+
/**
|
|
976
|
+
* Specifies the segment of the model's response content that this grounding support pertains to.
|
|
977
|
+
*/
|
|
978
|
+
segment?: Segment;
|
|
979
|
+
/**
|
|
980
|
+
* A list of indices that refer to specific {@link GroundingChunk} objects within the
|
|
981
|
+
* {@link GroundingMetadata.groundingChunks} array. These referenced chunks
|
|
982
|
+
* are the sources that support the claim made in the associated `segment` of the response.
|
|
983
|
+
* For example, an array `[1, 3, 4]` means that `groundingChunks[1]`, `groundingChunks[3]`,
|
|
984
|
+
* and `groundingChunks[4]` are the retrieved content supporting this part of the response.
|
|
985
|
+
*/
|
|
986
|
+
groundingChunkIndices?: number[];
|
|
987
|
+
}
|
|
988
|
+
|
|
885
989
|
/**
|
|
886
990
|
* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
|
|
887
991
|
*
|
|
@@ -1500,12 +1604,20 @@ export declare class ObjectSchema extends Schema {
|
|
|
1500
1604
|
}
|
|
1501
1605
|
|
|
1502
1606
|
/**
|
|
1503
|
-
* Interface for {@link
|
|
1607
|
+
* Interface for JSON parameters in {@link SchemaType.OBJECT} format when
|
|
1608
|
+
* not using the {@link ObjectSchema} helper.
|
|
1504
1609
|
* @public
|
|
1505
1610
|
*/
|
|
1506
|
-
export declare interface
|
|
1611
|
+
export declare interface ObjectSchemaRequest extends SchemaRequest {
|
|
1507
1612
|
type: SchemaType.OBJECT;
|
|
1508
|
-
|
|
1613
|
+
/**
|
|
1614
|
+
* This is not a property accepted in the final request to the backend, but is
|
|
1615
|
+
* a client-side convenience property that is only usable by constructing
|
|
1616
|
+
* a schema through the `Schema.object()` helper method. Populating this
|
|
1617
|
+
* property will cause response errors if the object is not wrapped with
|
|
1618
|
+
* `Schema.object()`.
|
|
1619
|
+
*/
|
|
1620
|
+
optionalProperties?: never;
|
|
1509
1621
|
}
|
|
1510
1622
|
|
|
1511
1623
|
/**
|
|
@@ -1830,12 +1942,58 @@ export declare enum SchemaType {
|
|
|
1830
1942
|
}
|
|
1831
1943
|
|
|
1832
1944
|
/**
|
|
1945
|
+
* Google search entry point.
|
|
1946
|
+
*
|
|
1947
|
+
* @public
|
|
1948
|
+
*/
|
|
1949
|
+
export declare interface SearchEntrypoint {
|
|
1950
|
+
/**
|
|
1951
|
+
* HTML/CSS snippet that must be embedded in a web page. The snippet is designed to avoid
|
|
1952
|
+
* undesired interaction with the rest of the page's CSS.
|
|
1953
|
+
*
|
|
1954
|
+
* To ensure proper rendering and prevent CSS conflicts, it is recommended
|
|
1955
|
+
* to encapsulate this `renderedContent` within a shadow DOM when embedding it
|
|
1956
|
+
* into a webpage. See {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM | MDN: Using shadow DOM}.
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* ```javascript
|
|
1960
|
+
* const container = document.createElement('div');
|
|
1961
|
+
* document.body.appendChild(container);
|
|
1962
|
+
* container.attachShadow({ mode: 'open' }).innerHTML = renderedContent;
|
|
1963
|
+
* ```
|
|
1964
|
+
*/
|
|
1965
|
+
renderedContent?: string;
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
/**
|
|
1969
|
+
* Represents a specific segment within a {@link Content} object, often used to
|
|
1970
|
+
* pinpoint the exact location of text or data that grounding information refers to.
|
|
1971
|
+
*
|
|
1833
1972
|
* @public
|
|
1834
1973
|
*/
|
|
1835
1974
|
export declare interface Segment {
|
|
1975
|
+
/**
|
|
1976
|
+
* The zero-based index of the {@link Part} object within the `parts` array
|
|
1977
|
+
* of its parent {@link Content} object. This identifies which part of the
|
|
1978
|
+
* content the segment belongs to.
|
|
1979
|
+
*/
|
|
1836
1980
|
partIndex: number;
|
|
1981
|
+
/**
|
|
1982
|
+
* The zero-based start index of the segment within the specified `Part`,
|
|
1983
|
+
* measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
|
|
1984
|
+
* beginning of the part's content (e.g., `Part.text`).
|
|
1985
|
+
*/
|
|
1837
1986
|
startIndex: number;
|
|
1987
|
+
/**
|
|
1988
|
+
* The zero-based end index of the segment within the specified `Part`,
|
|
1989
|
+
* measured in UTF-8 bytes. This offset is exclusive, meaning the character
|
|
1990
|
+
* at this index is not included in the segment.
|
|
1991
|
+
*/
|
|
1838
1992
|
endIndex: number;
|
|
1993
|
+
/**
|
|
1994
|
+
* The text corresponding to the segment from the response.
|
|
1995
|
+
*/
|
|
1996
|
+
text: string;
|
|
1839
1997
|
}
|
|
1840
1998
|
|
|
1841
1999
|
/**
|
|
@@ -1871,11 +2029,36 @@ export declare interface TextPart {
|
|
|
1871
2029
|
functionResponse?: never;
|
|
1872
2030
|
}
|
|
1873
2031
|
|
|
2032
|
+
/**
|
|
2033
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
2034
|
+
*
|
|
2035
|
+
* Certain models utilize a thinking process before generating a response. This allows them to
|
|
2036
|
+
* reason through complex problems and plan a more coherent and accurate answer.
|
|
2037
|
+
*
|
|
2038
|
+
* @public
|
|
2039
|
+
*/
|
|
2040
|
+
export declare interface ThinkingConfig {
|
|
2041
|
+
/**
|
|
2042
|
+
* The thinking budget, in tokens.
|
|
2043
|
+
*
|
|
2044
|
+
* This parameter sets an upper limit on the number of tokens the model can use for its internal
|
|
2045
|
+
* "thinking" process. A higher budget may result in higher quality responses for complex tasks
|
|
2046
|
+
* but can also increase latency and cost.
|
|
2047
|
+
*
|
|
2048
|
+
* If you don't specify a budget, the model will determine the appropriate amount
|
|
2049
|
+
* of thinking based on the complexity of the prompt.
|
|
2050
|
+
*
|
|
2051
|
+
* An error will be thrown if you set a thinking budget for a model that does not support this
|
|
2052
|
+
* feature or if the specified budget is not within the model's supported range.
|
|
2053
|
+
*/
|
|
2054
|
+
thinkingBudget?: number;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
1874
2057
|
/**
|
|
1875
2058
|
* Defines a tool that model can call to access external knowledge.
|
|
1876
2059
|
* @public
|
|
1877
2060
|
*/
|
|
1878
|
-
export declare type Tool = FunctionDeclarationsTool;
|
|
2061
|
+
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
|
|
1879
2062
|
|
|
1880
2063
|
/**
|
|
1881
2064
|
* Tool config. This config is shared for all tools provided in the request.
|
|
@@ -1899,6 +2082,10 @@ export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema |
|
|
|
1899
2082
|
export declare interface UsageMetadata {
|
|
1900
2083
|
promptTokenCount: number;
|
|
1901
2084
|
candidatesTokenCount: number;
|
|
2085
|
+
/**
|
|
2086
|
+
* The number of tokens used by the model's internal "thinking" process.
|
|
2087
|
+
*/
|
|
2088
|
+
thoughtsTokenCount?: number;
|
|
1902
2089
|
totalTokenCount: number;
|
|
1903
2090
|
promptTokensDetails?: ModalityTokenCount[];
|
|
1904
2091
|
candidatesTokensDetails?: ModalityTokenCount[];
|
|
@@ -1996,4 +2183,31 @@ export declare interface WebAttribution {
|
|
|
1996
2183
|
title: string;
|
|
1997
2184
|
}
|
|
1998
2185
|
|
|
2186
|
+
/**
|
|
2187
|
+
* A grounding chunk from the web.
|
|
2188
|
+
*
|
|
2189
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
2190
|
+
* {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Search".
|
|
2191
|
+
*
|
|
2192
|
+
* @public
|
|
2193
|
+
*/
|
|
2194
|
+
export declare interface WebGroundingChunk {
|
|
2195
|
+
/**
|
|
2196
|
+
* The URI of the retrieved web page.
|
|
2197
|
+
*/
|
|
2198
|
+
uri?: string;
|
|
2199
|
+
/**
|
|
2200
|
+
* The title of the retrieved web page.
|
|
2201
|
+
*/
|
|
2202
|
+
title?: string;
|
|
2203
|
+
/**
|
|
2204
|
+
* The domain of the original URI from which the content was retrieved.
|
|
2205
|
+
*
|
|
2206
|
+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
2207
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
|
|
2208
|
+
* `undefined`.
|
|
2209
|
+
*/
|
|
2210
|
+
domain?: string;
|
|
2211
|
+
}
|
|
2212
|
+
|
|
1999
2213
|
export { }
|
package/dist/ai.d.ts
CHANGED
|
@@ -383,11 +383,10 @@ export declare interface CountTokensResponse {
|
|
|
383
383
|
*/
|
|
384
384
|
totalTokens: number;
|
|
385
385
|
/**
|
|
386
|
+
* @deprecated Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`.
|
|
387
|
+
*
|
|
386
388
|
* The total number of billable characters counted across all instances
|
|
387
389
|
* from the request.
|
|
388
|
-
*
|
|
389
|
-
* This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
390
|
-
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
|
|
391
390
|
*/
|
|
392
391
|
totalBillableCharacters?: number;
|
|
393
392
|
/**
|
|
@@ -606,7 +605,7 @@ export declare interface FunctionDeclaration {
|
|
|
606
605
|
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
|
|
607
606
|
* case-sensitive. For a function with no parameters, this can be left unset.
|
|
608
607
|
*/
|
|
609
|
-
parameters?:
|
|
608
|
+
parameters?: ObjectSchema | ObjectSchemaRequest;
|
|
610
609
|
}
|
|
611
610
|
|
|
612
611
|
/**
|
|
@@ -753,6 +752,10 @@ export declare interface GenerationConfig {
|
|
|
753
752
|
* @beta
|
|
754
753
|
*/
|
|
755
754
|
responseModalities?: ResponseModality[];
|
|
755
|
+
/**
|
|
756
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
757
|
+
*/
|
|
758
|
+
thinkingConfig?: ThinkingConfig;
|
|
756
759
|
}
|
|
757
760
|
|
|
758
761
|
/**
|
|
@@ -929,6 +932,42 @@ export declare interface GoogleAIGenerateContentResponse {
|
|
|
929
932
|
usageMetadata?: UsageMetadata;
|
|
930
933
|
}
|
|
931
934
|
|
|
935
|
+
/**
|
|
936
|
+
* Specifies the Google Search configuration.
|
|
937
|
+
*
|
|
938
|
+
* @remarks Currently, this is an empty object, but it's reserved for future configuration options.
|
|
939
|
+
*
|
|
940
|
+
* @public
|
|
941
|
+
*/
|
|
942
|
+
export declare interface GoogleSearch {
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* A tool that allows a Gemini model to connect to Google Search to access and incorporate
|
|
947
|
+
* up-to-date information from the web into its responses.
|
|
948
|
+
*
|
|
949
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
950
|
+
* "Grounding with Google Search" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
951
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
952
|
+
* section within the Service Specific Terms).
|
|
953
|
+
*
|
|
954
|
+
* @public
|
|
955
|
+
*/
|
|
956
|
+
export declare interface GoogleSearchTool {
|
|
957
|
+
/**
|
|
958
|
+
* Specifies the Google Search configuration.
|
|
959
|
+
* Currently, this is an empty object, but it's reserved for future configuration options.
|
|
960
|
+
* Specifies the Google Search configuration. Currently, this is an empty object, but it's
|
|
961
|
+
* reserved for future configuration options.
|
|
962
|
+
*
|
|
963
|
+
* When using this feature, you are required to comply with the "Grounding with Google Search"
|
|
964
|
+
* usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
965
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
966
|
+
* section within the Service Specific Terms).
|
|
967
|
+
*/
|
|
968
|
+
googleSearch: GoogleSearch;
|
|
969
|
+
}
|
|
970
|
+
|
|
932
971
|
/**
|
|
933
972
|
* @deprecated
|
|
934
973
|
* @public
|
|
@@ -941,18 +980,83 @@ export declare interface GroundingAttribution {
|
|
|
941
980
|
}
|
|
942
981
|
|
|
943
982
|
/**
|
|
944
|
-
*
|
|
983
|
+
* Represents a chunk of retrieved data that supports a claim in the model's response. This is part
|
|
984
|
+
* of the grounding information provided when grounding is enabled.
|
|
985
|
+
*
|
|
986
|
+
* @public
|
|
987
|
+
*/
|
|
988
|
+
export declare interface GroundingChunk {
|
|
989
|
+
/**
|
|
990
|
+
* Contains details if the grounding chunk is from a web source.
|
|
991
|
+
*/
|
|
992
|
+
web?: WebGroundingChunk;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Metadata returned when grounding is enabled.
|
|
997
|
+
*
|
|
998
|
+
* Currently, only Grounding with Google Search is supported (see {@link GoogleSearchTool}).
|
|
999
|
+
*
|
|
1000
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
1001
|
+
* "Grounding with Google Search" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
1002
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
1003
|
+
* section within the Service Specific Terms).
|
|
1004
|
+
*
|
|
945
1005
|
* @public
|
|
946
1006
|
*/
|
|
947
1007
|
export declare interface GroundingMetadata {
|
|
1008
|
+
/**
|
|
1009
|
+
* Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
|
|
1010
|
+
* embedded in an app to display a Google Search entry point for follow-up web searches related to
|
|
1011
|
+
* a model's “Grounded Response”.
|
|
1012
|
+
*/
|
|
1013
|
+
searchEntryPoint?: SearchEntrypoint;
|
|
1014
|
+
/**
|
|
1015
|
+
* A list of {@link GroundingChunk} objects. Each chunk represents a piece of retrieved content
|
|
1016
|
+
* (for example, from a web page). that the model used to ground its response.
|
|
1017
|
+
*/
|
|
1018
|
+
groundingChunks?: GroundingChunk[];
|
|
1019
|
+
/**
|
|
1020
|
+
* A list of {@link GroundingSupport} objects. Each object details how specific segments of the
|
|
1021
|
+
* model's response are supported by the `groundingChunks`.
|
|
1022
|
+
*/
|
|
1023
|
+
groundingSupports?: GroundingSupport[];
|
|
1024
|
+
/**
|
|
1025
|
+
* A list of web search queries that the model performed to gather the grounding information.
|
|
1026
|
+
* These can be used to allow users to explore the search results themselves.
|
|
1027
|
+
*/
|
|
948
1028
|
webSearchQueries?: string[];
|
|
1029
|
+
/**
|
|
1030
|
+
* @deprecated Use {@link GroundingSupport} instead.
|
|
1031
|
+
*/
|
|
949
1032
|
retrievalQueries?: string[];
|
|
950
1033
|
/**
|
|
951
|
-
* @deprecated
|
|
1034
|
+
* @deprecated Use {@link GroundingChunk} instead.
|
|
952
1035
|
*/
|
|
953
1036
|
groundingAttributions: GroundingAttribution[];
|
|
954
1037
|
}
|
|
955
1038
|
|
|
1039
|
+
/**
|
|
1040
|
+
* Provides information about how a specific segment of the model's response is supported by the
|
|
1041
|
+
* retrieved grounding chunks.
|
|
1042
|
+
*
|
|
1043
|
+
* @public
|
|
1044
|
+
*/
|
|
1045
|
+
export declare interface GroundingSupport {
|
|
1046
|
+
/**
|
|
1047
|
+
* Specifies the segment of the model's response content that this grounding support pertains to.
|
|
1048
|
+
*/
|
|
1049
|
+
segment?: Segment;
|
|
1050
|
+
/**
|
|
1051
|
+
* A list of indices that refer to specific {@link GroundingChunk} objects within the
|
|
1052
|
+
* {@link GroundingMetadata.groundingChunks} array. These referenced chunks
|
|
1053
|
+
* are the sources that support the claim made in the associated `segment` of the response.
|
|
1054
|
+
* For example, an array `[1, 3, 4]` means that `groundingChunks[1]`, `groundingChunks[3]`,
|
|
1055
|
+
* and `groundingChunks[4]` are the retrieved content supporting this part of the response.
|
|
1056
|
+
*/
|
|
1057
|
+
groundingChunkIndices?: number[];
|
|
1058
|
+
}
|
|
1059
|
+
|
|
956
1060
|
/**
|
|
957
1061
|
* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
|
|
958
1062
|
*
|
|
@@ -1593,12 +1697,20 @@ export declare class ObjectSchema extends Schema {
|
|
|
1593
1697
|
}
|
|
1594
1698
|
|
|
1595
1699
|
/**
|
|
1596
|
-
* Interface for {@link
|
|
1700
|
+
* Interface for JSON parameters in {@link SchemaType.OBJECT} format when
|
|
1701
|
+
* not using the {@link ObjectSchema} helper.
|
|
1597
1702
|
* @public
|
|
1598
1703
|
*/
|
|
1599
|
-
export declare interface
|
|
1704
|
+
export declare interface ObjectSchemaRequest extends SchemaRequest {
|
|
1600
1705
|
type: SchemaType.OBJECT;
|
|
1601
|
-
|
|
1706
|
+
/**
|
|
1707
|
+
* This is not a property accepted in the final request to the backend, but is
|
|
1708
|
+
* a client-side convenience property that is only usable by constructing
|
|
1709
|
+
* a schema through the `Schema.object()` helper method. Populating this
|
|
1710
|
+
* property will cause response errors if the object is not wrapped with
|
|
1711
|
+
* `Schema.object()`.
|
|
1712
|
+
*/
|
|
1713
|
+
optionalProperties?: never;
|
|
1602
1714
|
}
|
|
1603
1715
|
|
|
1604
1716
|
/**
|
|
@@ -1928,12 +2040,58 @@ export declare enum SchemaType {
|
|
|
1928
2040
|
}
|
|
1929
2041
|
|
|
1930
2042
|
/**
|
|
2043
|
+
* Google search entry point.
|
|
2044
|
+
*
|
|
2045
|
+
* @public
|
|
2046
|
+
*/
|
|
2047
|
+
export declare interface SearchEntrypoint {
|
|
2048
|
+
/**
|
|
2049
|
+
* HTML/CSS snippet that must be embedded in a web page. The snippet is designed to avoid
|
|
2050
|
+
* undesired interaction with the rest of the page's CSS.
|
|
2051
|
+
*
|
|
2052
|
+
* To ensure proper rendering and prevent CSS conflicts, it is recommended
|
|
2053
|
+
* to encapsulate this `renderedContent` within a shadow DOM when embedding it
|
|
2054
|
+
* into a webpage. See {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM | MDN: Using shadow DOM}.
|
|
2055
|
+
*
|
|
2056
|
+
* @example
|
|
2057
|
+
* ```javascript
|
|
2058
|
+
* const container = document.createElement('div');
|
|
2059
|
+
* document.body.appendChild(container);
|
|
2060
|
+
* container.attachShadow({ mode: 'open' }).innerHTML = renderedContent;
|
|
2061
|
+
* ```
|
|
2062
|
+
*/
|
|
2063
|
+
renderedContent?: string;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* Represents a specific segment within a {@link Content} object, often used to
|
|
2068
|
+
* pinpoint the exact location of text or data that grounding information refers to.
|
|
2069
|
+
*
|
|
1931
2070
|
* @public
|
|
1932
2071
|
*/
|
|
1933
2072
|
export declare interface Segment {
|
|
2073
|
+
/**
|
|
2074
|
+
* The zero-based index of the {@link Part} object within the `parts` array
|
|
2075
|
+
* of its parent {@link Content} object. This identifies which part of the
|
|
2076
|
+
* content the segment belongs to.
|
|
2077
|
+
*/
|
|
1934
2078
|
partIndex: number;
|
|
2079
|
+
/**
|
|
2080
|
+
* The zero-based start index of the segment within the specified `Part`,
|
|
2081
|
+
* measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
|
|
2082
|
+
* beginning of the part's content (e.g., `Part.text`).
|
|
2083
|
+
*/
|
|
1935
2084
|
startIndex: number;
|
|
2085
|
+
/**
|
|
2086
|
+
* The zero-based end index of the segment within the specified `Part`,
|
|
2087
|
+
* measured in UTF-8 bytes. This offset is exclusive, meaning the character
|
|
2088
|
+
* at this index is not included in the segment.
|
|
2089
|
+
*/
|
|
1936
2090
|
endIndex: number;
|
|
2091
|
+
/**
|
|
2092
|
+
* The text corresponding to the segment from the response.
|
|
2093
|
+
*/
|
|
2094
|
+
text: string;
|
|
1937
2095
|
}
|
|
1938
2096
|
|
|
1939
2097
|
/**
|
|
@@ -1972,11 +2130,36 @@ export declare interface TextPart {
|
|
|
1972
2130
|
functionResponse?: never;
|
|
1973
2131
|
}
|
|
1974
2132
|
|
|
2133
|
+
/**
|
|
2134
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
2135
|
+
*
|
|
2136
|
+
* Certain models utilize a thinking process before generating a response. This allows them to
|
|
2137
|
+
* reason through complex problems and plan a more coherent and accurate answer.
|
|
2138
|
+
*
|
|
2139
|
+
* @public
|
|
2140
|
+
*/
|
|
2141
|
+
export declare interface ThinkingConfig {
|
|
2142
|
+
/**
|
|
2143
|
+
* The thinking budget, in tokens.
|
|
2144
|
+
*
|
|
2145
|
+
* This parameter sets an upper limit on the number of tokens the model can use for its internal
|
|
2146
|
+
* "thinking" process. A higher budget may result in higher quality responses for complex tasks
|
|
2147
|
+
* but can also increase latency and cost.
|
|
2148
|
+
*
|
|
2149
|
+
* If you don't specify a budget, the model will determine the appropriate amount
|
|
2150
|
+
* of thinking based on the complexity of the prompt.
|
|
2151
|
+
*
|
|
2152
|
+
* An error will be thrown if you set a thinking budget for a model that does not support this
|
|
2153
|
+
* feature or if the specified budget is not within the model's supported range.
|
|
2154
|
+
*/
|
|
2155
|
+
thinkingBudget?: number;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
1975
2158
|
/**
|
|
1976
2159
|
* Defines a tool that model can call to access external knowledge.
|
|
1977
2160
|
* @public
|
|
1978
2161
|
*/
|
|
1979
|
-
export declare type Tool = FunctionDeclarationsTool;
|
|
2162
|
+
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
|
|
1980
2163
|
|
|
1981
2164
|
/**
|
|
1982
2165
|
* Tool config. This config is shared for all tools provided in the request.
|
|
@@ -2000,6 +2183,10 @@ export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema |
|
|
|
2000
2183
|
export declare interface UsageMetadata {
|
|
2001
2184
|
promptTokenCount: number;
|
|
2002
2185
|
candidatesTokenCount: number;
|
|
2186
|
+
/**
|
|
2187
|
+
* The number of tokens used by the model's internal "thinking" process.
|
|
2188
|
+
*/
|
|
2189
|
+
thoughtsTokenCount?: number;
|
|
2003
2190
|
totalTokenCount: number;
|
|
2004
2191
|
promptTokensDetails?: ModalityTokenCount[];
|
|
2005
2192
|
candidatesTokensDetails?: ModalityTokenCount[];
|
|
@@ -2097,4 +2284,31 @@ export declare interface WebAttribution {
|
|
|
2097
2284
|
title: string;
|
|
2098
2285
|
}
|
|
2099
2286
|
|
|
2287
|
+
/**
|
|
2288
|
+
* A grounding chunk from the web.
|
|
2289
|
+
*
|
|
2290
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
2291
|
+
* {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Search".
|
|
2292
|
+
*
|
|
2293
|
+
* @public
|
|
2294
|
+
*/
|
|
2295
|
+
export declare interface WebGroundingChunk {
|
|
2296
|
+
/**
|
|
2297
|
+
* The URI of the retrieved web page.
|
|
2298
|
+
*/
|
|
2299
|
+
uri?: string;
|
|
2300
|
+
/**
|
|
2301
|
+
* The title of the retrieved web page.
|
|
2302
|
+
*/
|
|
2303
|
+
title?: string;
|
|
2304
|
+
/**
|
|
2305
|
+
* The domain of the original URI from which the content was retrieved.
|
|
2306
|
+
*
|
|
2307
|
+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
2308
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
|
|
2309
|
+
* `undefined`.
|
|
2310
|
+
*/
|
|
2311
|
+
domain?: string;
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2100
2314
|
export { }
|
|
@@ -5,7 +5,7 @@ import { Logger } from '@firebase/logger';
|
|
|
5
5
|
import { __asyncGenerator, __await } from 'tslib';
|
|
6
6
|
|
|
7
7
|
var name = "@firebase/ai";
|
|
8
|
-
var version = "1.4.0-canary.
|
|
8
|
+
var version = "1.4.0-canary.6ab4e13a1";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
@@ -996,6 +996,7 @@ async function makeRequest(model, task, apiSettings, stream, body, requestOption
|
|
|
996
996
|
// ignored
|
|
997
997
|
}
|
|
998
998
|
if (response.status === 403 &&
|
|
999
|
+
errorDetails &&
|
|
999
1000
|
errorDetails.some((detail) => detail.reason === 'SERVICE_DISABLED') &&
|
|
1000
1001
|
errorDetails.some((detail) => {
|
|
1001
1002
|
var _a, _b;
|
|
@@ -1575,6 +1576,8 @@ function aggregateResponses(responses) {
|
|
|
1575
1576
|
candidate.finishMessage;
|
|
1576
1577
|
aggregatedResponse.candidates[i].safetyRatings =
|
|
1577
1578
|
candidate.safetyRatings;
|
|
1579
|
+
aggregatedResponse.candidates[i].groundingMetadata =
|
|
1580
|
+
candidate.groundingMetadata;
|
|
1578
1581
|
/**
|
|
1579
1582
|
* Candidates should always have content and parts, but this handles
|
|
1580
1583
|
* possible malformed responses.
|