@firebase/ai 1.4.0-canary.a0583094a → 1.4.0-canary.a4ccd254d

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.
@@ -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?: ObjectSchemaInterface;
571
+ parameters?: ObjectSchema | ObjectSchemaRequest;
573
572
  }
574
573
 
575
574
  /**
@@ -858,6 +857,42 @@ export declare class GoogleAIBackend extends Backend {
858
857
 
859
858
  /* Excluded from this release type: GoogleAIGenerateContentResponse */
860
859
 
860
+ /**
861
+ * Specifies the Google Search configuration.
862
+ *
863
+ * @remarks Currently, this is an empty object, but it's reserved for future configuration options.
864
+ *
865
+ * @public
866
+ */
867
+ export declare interface GoogleSearch {
868
+ }
869
+
870
+ /**
871
+ * A tool that allows a Gemini model to connect to Google Search to access and incorporate
872
+ * up-to-date information from the web into its responses.
873
+ *
874
+ * Important: If using Grounding with Google Search, you are required to comply with the
875
+ * "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}
876
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
877
+ * section within the Service Specific Terms).
878
+ *
879
+ * @public
880
+ */
881
+ export declare interface GoogleSearchTool {
882
+ /**
883
+ * Specifies the Google Search configuration.
884
+ * Currently, this is an empty object, but it's reserved for future configuration options.
885
+ * Specifies the Google Search configuration. Currently, this is an empty object, but it's
886
+ * reserved for future configuration options.
887
+ *
888
+ * When using this feature, you are required to comply with the "Grounding with Google Search"
889
+ * usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
890
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
891
+ * section within the Service Specific Terms).
892
+ */
893
+ googleSearch: GoogleSearch;
894
+ }
895
+
861
896
  /**
862
897
  * @deprecated
863
898
  * @public
@@ -870,18 +905,83 @@ export declare interface GroundingAttribution {
870
905
  }
871
906
 
872
907
  /**
873
- * Metadata returned to client when grounding is enabled.
908
+ * Represents a chunk of retrieved data that supports a claim in the model's response. This is part
909
+ * of the grounding information provided when grounding is enabled.
910
+ *
911
+ * @public
912
+ */
913
+ export declare interface GroundingChunk {
914
+ /**
915
+ * Contains details if the grounding chunk is from a web source.
916
+ */
917
+ web?: WebGroundingChunk;
918
+ }
919
+
920
+ /**
921
+ * Metadata returned when grounding is enabled.
922
+ *
923
+ * Currently, only Grounding with Google Search is supported (see {@link GoogleSearchTool}).
924
+ *
925
+ * Important: If using Grounding with Google Search, you are required to comply with the
926
+ * "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}
927
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
928
+ * section within the Service Specific Terms).
929
+ *
874
930
  * @public
875
931
  */
876
932
  export declare interface GroundingMetadata {
933
+ /**
934
+ * Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
935
+ * embedded in an app to display a Google Search entry point for follow-up web searches related to
936
+ * a model's “Grounded Response”.
937
+ */
938
+ searchEntryPoint?: SearchEntrypoint;
939
+ /**
940
+ * A list of {@link GroundingChunk} objects. Each chunk represents a piece of retrieved content
941
+ * (for example, from a web page). that the model used to ground its response.
942
+ */
943
+ groundingChunks?: GroundingChunk[];
944
+ /**
945
+ * A list of {@link GroundingSupport} objects. Each object details how specific segments of the
946
+ * model's response are supported by the `groundingChunks`.
947
+ */
948
+ groundingSupports?: GroundingSupport[];
949
+ /**
950
+ * A list of web search queries that the model performed to gather the grounding information.
951
+ * These can be used to allow users to explore the search results themselves.
952
+ */
877
953
  webSearchQueries?: string[];
954
+ /**
955
+ * @deprecated Use {@link GroundingSupport} instead.
956
+ */
878
957
  retrievalQueries?: string[];
879
958
  /**
880
- * @deprecated
959
+ * @deprecated Use {@link GroundingChunk} instead.
881
960
  */
882
961
  groundingAttributions: GroundingAttribution[];
883
962
  }
884
963
 
964
+ /**
965
+ * Provides information about how a specific segment of the model's response is supported by the
966
+ * retrieved grounding chunks.
967
+ *
968
+ * @public
969
+ */
970
+ export declare interface GroundingSupport {
971
+ /**
972
+ * Specifies the segment of the model's response content that this grounding support pertains to.
973
+ */
974
+ segment?: Segment;
975
+ /**
976
+ * A list of indices that refer to specific {@link GroundingChunk} objects within the
977
+ * {@link GroundingMetadata.groundingChunks} array. These referenced chunks
978
+ * are the sources that support the claim made in the associated `segment` of the response.
979
+ * For example, an array `[1, 3, 4]` means that `groundingChunks[1]`, `groundingChunks[3]`,
980
+ * and `groundingChunks[4]` are the retrieved content supporting this part of the response.
981
+ */
982
+ groundingChunkIndices?: number[];
983
+ }
984
+
885
985
  /**
886
986
  * This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
887
987
  *
@@ -1500,12 +1600,20 @@ export declare class ObjectSchema extends Schema {
1500
1600
  }
1501
1601
 
1502
1602
  /**
1503
- * Interface for {@link ObjectSchema} class.
1603
+ * Interface for JSON parameters in {@link SchemaType.OBJECT} format when
1604
+ * not using the {@link ObjectSchema} helper.
1504
1605
  * @public
1505
1606
  */
1506
- export declare interface ObjectSchemaInterface extends SchemaInterface {
1607
+ export declare interface ObjectSchemaRequest extends SchemaRequest {
1507
1608
  type: SchemaType.OBJECT;
1508
- optionalProperties?: string[];
1609
+ /**
1610
+ * This is not a property accepted in the final request to the backend, but is
1611
+ * a client-side convenience property that is only usable by constructing
1612
+ * a schema through the `Schema.object()` helper method. Populating this
1613
+ * property will cause response errors if the object is not wrapped with
1614
+ * `Schema.object()`.
1615
+ */
1616
+ optionalProperties?: never;
1509
1617
  }
1510
1618
 
1511
1619
  /**
@@ -1830,12 +1938,58 @@ export declare enum SchemaType {
1830
1938
  }
1831
1939
 
1832
1940
  /**
1941
+ * Google search entry point.
1942
+ *
1943
+ * @public
1944
+ */
1945
+ export declare interface SearchEntrypoint {
1946
+ /**
1947
+ * HTML/CSS snippet that must be embedded in a web page. The snippet is designed to avoid
1948
+ * undesired interaction with the rest of the page's CSS.
1949
+ *
1950
+ * To ensure proper rendering and prevent CSS conflicts, it is recommended
1951
+ * to encapsulate this `renderedContent` within a shadow DOM when embedding it
1952
+ * into a webpage. See {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM | MDN: Using shadow DOM}.
1953
+ *
1954
+ * @example
1955
+ * ```javascript
1956
+ * const container = document.createElement('div');
1957
+ * document.body.appendChild(container);
1958
+ * container.attachShadow({ mode: 'open' }).innerHTML = renderedContent;
1959
+ * ```
1960
+ */
1961
+ renderedContent?: string;
1962
+ }
1963
+
1964
+ /**
1965
+ * Represents a specific segment within a {@link Content} object, often used to
1966
+ * pinpoint the exact location of text or data that grounding information refers to.
1967
+ *
1833
1968
  * @public
1834
1969
  */
1835
1970
  export declare interface Segment {
1971
+ /**
1972
+ * The zero-based index of the {@link Part} object within the `parts` array
1973
+ * of its parent {@link Content} object. This identifies which part of the
1974
+ * content the segment belongs to.
1975
+ */
1836
1976
  partIndex: number;
1977
+ /**
1978
+ * The zero-based start index of the segment within the specified `Part`,
1979
+ * measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
1980
+ * beginning of the part's content (e.g., `Part.text`).
1981
+ */
1837
1982
  startIndex: number;
1983
+ /**
1984
+ * The zero-based end index of the segment within the specified `Part`,
1985
+ * measured in UTF-8 bytes. This offset is exclusive, meaning the character
1986
+ * at this index is not included in the segment.
1987
+ */
1838
1988
  endIndex: number;
1989
+ /**
1990
+ * The text corresponding to the segment from the response.
1991
+ */
1992
+ text: string;
1839
1993
  }
1840
1994
 
1841
1995
  /**
@@ -1875,7 +2029,7 @@ export declare interface TextPart {
1875
2029
  * Defines a tool that model can call to access external knowledge.
1876
2030
  * @public
1877
2031
  */
1878
- export declare type Tool = FunctionDeclarationsTool;
2032
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
1879
2033
 
1880
2034
  /**
1881
2035
  * Tool config. This config is shared for all tools provided in the request.
@@ -1996,4 +2150,31 @@ export declare interface WebAttribution {
1996
2150
  title: string;
1997
2151
  }
1998
2152
 
2153
+ /**
2154
+ * A grounding chunk from the web.
2155
+ *
2156
+ * Important: If using Grounding with Google Search, you are required to comply with the
2157
+ * {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Search".
2158
+ *
2159
+ * @public
2160
+ */
2161
+ export declare interface WebGroundingChunk {
2162
+ /**
2163
+ * The URI of the retrieved web page.
2164
+ */
2165
+ uri?: string;
2166
+ /**
2167
+ * The title of the retrieved web page.
2168
+ */
2169
+ title?: string;
2170
+ /**
2171
+ * The domain of the original URI from which the content was retrieved.
2172
+ *
2173
+ * This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
2174
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
2175
+ * `undefined`.
2176
+ */
2177
+ domain?: string;
2178
+ }
2179
+
1999
2180
  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?: ObjectSchemaInterface;
608
+ parameters?: ObjectSchema | ObjectSchemaRequest;
610
609
  }
611
610
 
612
611
  /**
@@ -929,6 +928,42 @@ export declare interface GoogleAIGenerateContentResponse {
929
928
  usageMetadata?: UsageMetadata;
930
929
  }
931
930
 
931
+ /**
932
+ * Specifies the Google Search configuration.
933
+ *
934
+ * @remarks Currently, this is an empty object, but it's reserved for future configuration options.
935
+ *
936
+ * @public
937
+ */
938
+ export declare interface GoogleSearch {
939
+ }
940
+
941
+ /**
942
+ * A tool that allows a Gemini model to connect to Google Search to access and incorporate
943
+ * up-to-date information from the web into its responses.
944
+ *
945
+ * Important: If using Grounding with Google Search, you are required to comply with the
946
+ * "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}
947
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
948
+ * section within the Service Specific Terms).
949
+ *
950
+ * @public
951
+ */
952
+ export declare interface GoogleSearchTool {
953
+ /**
954
+ * Specifies the Google Search configuration.
955
+ * Currently, this is an empty object, but it's reserved for future configuration options.
956
+ * Specifies the Google Search configuration. Currently, this is an empty object, but it's
957
+ * reserved for future configuration options.
958
+ *
959
+ * When using this feature, you are required to comply with the "Grounding with Google Search"
960
+ * usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
961
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
962
+ * section within the Service Specific Terms).
963
+ */
964
+ googleSearch: GoogleSearch;
965
+ }
966
+
932
967
  /**
933
968
  * @deprecated
934
969
  * @public
@@ -941,18 +976,83 @@ export declare interface GroundingAttribution {
941
976
  }
942
977
 
943
978
  /**
944
- * Metadata returned to client when grounding is enabled.
979
+ * Represents a chunk of retrieved data that supports a claim in the model's response. This is part
980
+ * of the grounding information provided when grounding is enabled.
981
+ *
982
+ * @public
983
+ */
984
+ export declare interface GroundingChunk {
985
+ /**
986
+ * Contains details if the grounding chunk is from a web source.
987
+ */
988
+ web?: WebGroundingChunk;
989
+ }
990
+
991
+ /**
992
+ * Metadata returned when grounding is enabled.
993
+ *
994
+ * Currently, only Grounding with Google Search is supported (see {@link GoogleSearchTool}).
995
+ *
996
+ * Important: If using Grounding with Google Search, you are required to comply with the
997
+ * "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}
998
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
999
+ * section within the Service Specific Terms).
1000
+ *
945
1001
  * @public
946
1002
  */
947
1003
  export declare interface GroundingMetadata {
1004
+ /**
1005
+ * Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
1006
+ * embedded in an app to display a Google Search entry point for follow-up web searches related to
1007
+ * a model's “Grounded Response”.
1008
+ */
1009
+ searchEntryPoint?: SearchEntrypoint;
1010
+ /**
1011
+ * A list of {@link GroundingChunk} objects. Each chunk represents a piece of retrieved content
1012
+ * (for example, from a web page). that the model used to ground its response.
1013
+ */
1014
+ groundingChunks?: GroundingChunk[];
1015
+ /**
1016
+ * A list of {@link GroundingSupport} objects. Each object details how specific segments of the
1017
+ * model's response are supported by the `groundingChunks`.
1018
+ */
1019
+ groundingSupports?: GroundingSupport[];
1020
+ /**
1021
+ * A list of web search queries that the model performed to gather the grounding information.
1022
+ * These can be used to allow users to explore the search results themselves.
1023
+ */
948
1024
  webSearchQueries?: string[];
1025
+ /**
1026
+ * @deprecated Use {@link GroundingSupport} instead.
1027
+ */
949
1028
  retrievalQueries?: string[];
950
1029
  /**
951
- * @deprecated
1030
+ * @deprecated Use {@link GroundingChunk} instead.
952
1031
  */
953
1032
  groundingAttributions: GroundingAttribution[];
954
1033
  }
955
1034
 
1035
+ /**
1036
+ * Provides information about how a specific segment of the model's response is supported by the
1037
+ * retrieved grounding chunks.
1038
+ *
1039
+ * @public
1040
+ */
1041
+ export declare interface GroundingSupport {
1042
+ /**
1043
+ * Specifies the segment of the model's response content that this grounding support pertains to.
1044
+ */
1045
+ segment?: Segment;
1046
+ /**
1047
+ * A list of indices that refer to specific {@link GroundingChunk} objects within the
1048
+ * {@link GroundingMetadata.groundingChunks} array. These referenced chunks
1049
+ * are the sources that support the claim made in the associated `segment` of the response.
1050
+ * For example, an array `[1, 3, 4]` means that `groundingChunks[1]`, `groundingChunks[3]`,
1051
+ * and `groundingChunks[4]` are the retrieved content supporting this part of the response.
1052
+ */
1053
+ groundingChunkIndices?: number[];
1054
+ }
1055
+
956
1056
  /**
957
1057
  * This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
958
1058
  *
@@ -1593,12 +1693,20 @@ export declare class ObjectSchema extends Schema {
1593
1693
  }
1594
1694
 
1595
1695
  /**
1596
- * Interface for {@link ObjectSchema} class.
1696
+ * Interface for JSON parameters in {@link SchemaType.OBJECT} format when
1697
+ * not using the {@link ObjectSchema} helper.
1597
1698
  * @public
1598
1699
  */
1599
- export declare interface ObjectSchemaInterface extends SchemaInterface {
1700
+ export declare interface ObjectSchemaRequest extends SchemaRequest {
1600
1701
  type: SchemaType.OBJECT;
1601
- optionalProperties?: string[];
1702
+ /**
1703
+ * This is not a property accepted in the final request to the backend, but is
1704
+ * a client-side convenience property that is only usable by constructing
1705
+ * a schema through the `Schema.object()` helper method. Populating this
1706
+ * property will cause response errors if the object is not wrapped with
1707
+ * `Schema.object()`.
1708
+ */
1709
+ optionalProperties?: never;
1602
1710
  }
1603
1711
 
1604
1712
  /**
@@ -1928,12 +2036,58 @@ export declare enum SchemaType {
1928
2036
  }
1929
2037
 
1930
2038
  /**
2039
+ * Google search entry point.
2040
+ *
2041
+ * @public
2042
+ */
2043
+ export declare interface SearchEntrypoint {
2044
+ /**
2045
+ * HTML/CSS snippet that must be embedded in a web page. The snippet is designed to avoid
2046
+ * undesired interaction with the rest of the page's CSS.
2047
+ *
2048
+ * To ensure proper rendering and prevent CSS conflicts, it is recommended
2049
+ * to encapsulate this `renderedContent` within a shadow DOM when embedding it
2050
+ * into a webpage. See {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM | MDN: Using shadow DOM}.
2051
+ *
2052
+ * @example
2053
+ * ```javascript
2054
+ * const container = document.createElement('div');
2055
+ * document.body.appendChild(container);
2056
+ * container.attachShadow({ mode: 'open' }).innerHTML = renderedContent;
2057
+ * ```
2058
+ */
2059
+ renderedContent?: string;
2060
+ }
2061
+
2062
+ /**
2063
+ * Represents a specific segment within a {@link Content} object, often used to
2064
+ * pinpoint the exact location of text or data that grounding information refers to.
2065
+ *
1931
2066
  * @public
1932
2067
  */
1933
2068
  export declare interface Segment {
2069
+ /**
2070
+ * The zero-based index of the {@link Part} object within the `parts` array
2071
+ * of its parent {@link Content} object. This identifies which part of the
2072
+ * content the segment belongs to.
2073
+ */
1934
2074
  partIndex: number;
2075
+ /**
2076
+ * The zero-based start index of the segment within the specified `Part`,
2077
+ * measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
2078
+ * beginning of the part's content (e.g., `Part.text`).
2079
+ */
1935
2080
  startIndex: number;
2081
+ /**
2082
+ * The zero-based end index of the segment within the specified `Part`,
2083
+ * measured in UTF-8 bytes. This offset is exclusive, meaning the character
2084
+ * at this index is not included in the segment.
2085
+ */
1936
2086
  endIndex: number;
2087
+ /**
2088
+ * The text corresponding to the segment from the response.
2089
+ */
2090
+ text: string;
1937
2091
  }
1938
2092
 
1939
2093
  /**
@@ -1976,7 +2130,7 @@ export declare interface TextPart {
1976
2130
  * Defines a tool that model can call to access external knowledge.
1977
2131
  * @public
1978
2132
  */
1979
- export declare type Tool = FunctionDeclarationsTool;
2133
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
1980
2134
 
1981
2135
  /**
1982
2136
  * Tool config. This config is shared for all tools provided in the request.
@@ -2097,4 +2251,31 @@ export declare interface WebAttribution {
2097
2251
  title: string;
2098
2252
  }
2099
2253
 
2254
+ /**
2255
+ * A grounding chunk from the web.
2256
+ *
2257
+ * Important: If using Grounding with Google Search, you are required to comply with the
2258
+ * {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Search".
2259
+ *
2260
+ * @public
2261
+ */
2262
+ export declare interface WebGroundingChunk {
2263
+ /**
2264
+ * The URI of the retrieved web page.
2265
+ */
2266
+ uri?: string;
2267
+ /**
2268
+ * The title of the retrieved web page.
2269
+ */
2270
+ title?: string;
2271
+ /**
2272
+ * The domain of the original URI from which the content was retrieved.
2273
+ *
2274
+ * This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
2275
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
2276
+ * `undefined`.
2277
+ */
2278
+ domain?: string;
2279
+ }
2280
+
2100
2281
  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.a0583094a";
8
+ var version = "1.4.0-canary.a4ccd254d";
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.