@firebase/ai 1.4.0-canary.c0617a341 → 1.4.0-canary.ec5f37403

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.
@@ -58,7 +58,7 @@ export declare class AIError extends FirebaseError {
58
58
  *
59
59
  * @public
60
60
  */
61
- declare const enum AIErrorCode {
61
+ export declare const enum AIErrorCode {
62
62
  /** A generic error occurred. */
63
63
  ERROR = "error",
64
64
  /** An error occurred in a request. */
@@ -86,8 +86,6 @@ declare const enum AIErrorCode {
86
86
  /** An error occurred due an attempt to use an unsupported feature. */
87
87
  UNSUPPORTED = "unsupported"
88
88
  }
89
- export { AIErrorCode }
90
- export { AIErrorCode as VertexAIErrorCode }
91
89
 
92
90
  /**
93
91
  * Base class for Firebase AI model APIs.
@@ -346,11 +344,10 @@ export declare interface CountTokensResponse {
346
344
  */
347
345
  totalTokens: number;
348
346
  /**
347
+ * @deprecated Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`.
348
+ *
349
349
  * The total number of billable characters counted across all instances
350
350
  * 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
351
  */
355
352
  totalBillableCharacters?: number;
356
353
  /**
@@ -569,7 +566,7 @@ export declare interface FunctionDeclaration {
569
566
  * format. Reflects the Open API 3.03 Parameter Object. Parameter names are
570
567
  * case-sensitive. For a function with no parameters, this can be left unset.
571
568
  */
572
- parameters?: ObjectSchemaInterface;
569
+ parameters?: ObjectSchema | ObjectSchemaRequest;
573
570
  }
574
571
 
575
572
  /**
@@ -716,6 +713,10 @@ export declare interface GenerationConfig {
716
713
  * @beta
717
714
  */
718
715
  responseModalities?: ResponseModality[];
716
+ /**
717
+ * Configuration for "thinking" behavior of compatible Gemini models.
718
+ */
719
+ thinkingConfig?: ThinkingConfig;
719
720
  }
720
721
 
721
722
  /**
@@ -819,22 +820,6 @@ export declare function getGenerativeModel(ai: AI, modelParams: ModelParams, req
819
820
  */
820
821
  export declare function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
821
822
 
822
- /**
823
- * @deprecated Use the new {@link getAI | getAI()} instead. The Vertex AI in Firebase SDK has been
824
- * replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
825
- * services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
826
- *
827
- * Returns a {@link VertexAI} instance for the given app, configured to use the
828
- * Vertex AI Gemini API. This instance will be
829
- * configured to use the Vertex AI Gemini API.
830
- *
831
- * @param app - The {@link @firebase/app#FirebaseApp} to use.
832
- * @param options - Options to configure the Vertex AI instance, including the location.
833
- *
834
- * @public
835
- */
836
- export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI;
837
-
838
823
  /**
839
824
  * Configuration class for the Gemini Developer API.
840
825
  *
@@ -858,6 +843,42 @@ export declare class GoogleAIBackend extends Backend {
858
843
 
859
844
  /* Excluded from this release type: GoogleAIGenerateContentResponse */
860
845
 
846
+ /**
847
+ * Specifies the Google Search configuration.
848
+ *
849
+ * @remarks Currently, this is an empty object, but it's reserved for future configuration options.
850
+ *
851
+ * @public
852
+ */
853
+ export declare interface GoogleSearch {
854
+ }
855
+
856
+ /**
857
+ * A tool that allows a Gemini model to connect to Google Search to access and incorporate
858
+ * up-to-date information from the web into its responses.
859
+ *
860
+ * Important: If using Grounding with Google Search, you are required to comply with the
861
+ * "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}
862
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
863
+ * section within the Service Specific Terms).
864
+ *
865
+ * @public
866
+ */
867
+ export declare interface GoogleSearchTool {
868
+ /**
869
+ * Specifies the Google Search configuration.
870
+ * Currently, this is an empty object, but it's reserved for future configuration options.
871
+ * Specifies the Google Search configuration. Currently, this is an empty object, but it's
872
+ * reserved for future configuration options.
873
+ *
874
+ * When using this feature, you are required to comply with the "Grounding with Google Search"
875
+ * 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
+ googleSearch: GoogleSearch;
880
+ }
881
+
861
882
  /**
862
883
  * @deprecated
863
884
  * @public
@@ -870,18 +891,83 @@ export declare interface GroundingAttribution {
870
891
  }
871
892
 
872
893
  /**
873
- * Metadata returned to client when grounding is enabled.
894
+ * Represents a chunk of retrieved data that supports a claim in the model's response. This is part
895
+ * of the grounding information provided when grounding is enabled.
896
+ *
897
+ * @public
898
+ */
899
+ export declare interface GroundingChunk {
900
+ /**
901
+ * Contains details if the grounding chunk is from a web source.
902
+ */
903
+ web?: WebGroundingChunk;
904
+ }
905
+
906
+ /**
907
+ * Metadata returned when grounding is enabled.
908
+ *
909
+ * Currently, only Grounding with Google Search is supported (see {@link GoogleSearchTool}).
910
+ *
911
+ * Important: If using Grounding with Google Search, you are required to comply with the
912
+ * "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}
913
+ * or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
914
+ * section within the Service Specific Terms).
915
+ *
874
916
  * @public
875
917
  */
876
918
  export declare interface GroundingMetadata {
919
+ /**
920
+ * Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
921
+ * embedded in an app to display a Google Search entry point for follow-up web searches related to
922
+ * a model's “Grounded Response”.
923
+ */
924
+ searchEntryPoint?: SearchEntrypoint;
925
+ /**
926
+ * A list of {@link GroundingChunk} objects. Each chunk represents a piece of retrieved content
927
+ * (for example, from a web page). that the model used to ground its response.
928
+ */
929
+ groundingChunks?: GroundingChunk[];
930
+ /**
931
+ * A list of {@link GroundingSupport} objects. Each object details how specific segments of the
932
+ * model's response are supported by the `groundingChunks`.
933
+ */
934
+ groundingSupports?: GroundingSupport[];
935
+ /**
936
+ * A list of web search queries that the model performed to gather the grounding information.
937
+ * These can be used to allow users to explore the search results themselves.
938
+ */
877
939
  webSearchQueries?: string[];
940
+ /**
941
+ * @deprecated Use {@link GroundingSupport} instead.
942
+ */
878
943
  retrievalQueries?: string[];
879
944
  /**
880
- * @deprecated
945
+ * @deprecated Use {@link GroundingChunk} instead.
881
946
  */
882
947
  groundingAttributions: GroundingAttribution[];
883
948
  }
884
949
 
950
+ /**
951
+ * Provides information about how a specific segment of the model's response is supported by the
952
+ * retrieved grounding chunks.
953
+ *
954
+ * @public
955
+ */
956
+ export declare interface GroundingSupport {
957
+ /**
958
+ * Specifies the segment of the model's response content that this grounding support pertains to.
959
+ */
960
+ segment?: Segment;
961
+ /**
962
+ * A list of indices that refer to specific {@link GroundingChunk} objects within the
963
+ * {@link GroundingMetadata.groundingChunks} array. These referenced chunks
964
+ * are the sources that support the claim made in the associated `segment` of the response.
965
+ * For example, an array `[1, 3, 4]` means that `groundingChunks[1]`, `groundingChunks[3]`,
966
+ * and `groundingChunks[4]` are the retrieved content supporting this part of the response.
967
+ */
968
+ groundingChunkIndices?: number[];
969
+ }
970
+
885
971
  /**
886
972
  * This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
887
973
  *
@@ -1500,12 +1586,20 @@ export declare class ObjectSchema extends Schema {
1500
1586
  }
1501
1587
 
1502
1588
  /**
1503
- * Interface for {@link ObjectSchema} class.
1589
+ * Interface for JSON parameters in {@link SchemaType.OBJECT} format when
1590
+ * not using the {@link ObjectSchema} helper.
1504
1591
  * @public
1505
1592
  */
1506
- export declare interface ObjectSchemaInterface extends SchemaInterface {
1593
+ export declare interface ObjectSchemaRequest extends SchemaRequest {
1507
1594
  type: SchemaType.OBJECT;
1508
- optionalProperties?: string[];
1595
+ /**
1596
+ * This is not a property accepted in the final request to the backend, but is
1597
+ * a client-side convenience property that is only usable by constructing
1598
+ * a schema through the `Schema.object()` helper method. Populating this
1599
+ * property will cause response errors if the object is not wrapped with
1600
+ * `Schema.object()`.
1601
+ */
1602
+ optionalProperties?: never;
1509
1603
  }
1510
1604
 
1511
1605
  /**
@@ -1830,12 +1924,58 @@ export declare enum SchemaType {
1830
1924
  }
1831
1925
 
1832
1926
  /**
1927
+ * Google search entry point.
1928
+ *
1929
+ * @public
1930
+ */
1931
+ export declare interface SearchEntrypoint {
1932
+ /**
1933
+ * HTML/CSS snippet that must be embedded in a web page. The snippet is designed to avoid
1934
+ * undesired interaction with the rest of the page's CSS.
1935
+ *
1936
+ * To ensure proper rendering and prevent CSS conflicts, it is recommended
1937
+ * to encapsulate this `renderedContent` within a shadow DOM when embedding it
1938
+ * into a webpage. See {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM | MDN: Using shadow DOM}.
1939
+ *
1940
+ * @example
1941
+ * ```javascript
1942
+ * const container = document.createElement('div');
1943
+ * document.body.appendChild(container);
1944
+ * container.attachShadow({ mode: 'open' }).innerHTML = renderedContent;
1945
+ * ```
1946
+ */
1947
+ renderedContent?: string;
1948
+ }
1949
+
1950
+ /**
1951
+ * Represents a specific segment within a {@link Content} object, often used to
1952
+ * pinpoint the exact location of text or data that grounding information refers to.
1953
+ *
1833
1954
  * @public
1834
1955
  */
1835
1956
  export declare interface Segment {
1957
+ /**
1958
+ * The zero-based index of the {@link Part} object within the `parts` array
1959
+ * of its parent {@link Content} object. This identifies which part of the
1960
+ * content the segment belongs to.
1961
+ */
1836
1962
  partIndex: number;
1963
+ /**
1964
+ * The zero-based start index of the segment within the specified `Part`,
1965
+ * measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
1966
+ * beginning of the part's content (e.g., `Part.text`).
1967
+ */
1837
1968
  startIndex: number;
1969
+ /**
1970
+ * The zero-based end index of the segment within the specified `Part`,
1971
+ * measured in UTF-8 bytes. This offset is exclusive, meaning the character
1972
+ * at this index is not included in the segment.
1973
+ */
1838
1974
  endIndex: number;
1975
+ /**
1976
+ * The text corresponding to the segment from the response.
1977
+ */
1978
+ text: string;
1839
1979
  }
1840
1980
 
1841
1981
  /**
@@ -1871,11 +2011,36 @@ export declare interface TextPart {
1871
2011
  functionResponse?: never;
1872
2012
  }
1873
2013
 
2014
+ /**
2015
+ * Configuration for "thinking" behavior of compatible Gemini models.
2016
+ *
2017
+ * Certain models utilize a thinking process before generating a response. This allows them to
2018
+ * reason through complex problems and plan a more coherent and accurate answer.
2019
+ *
2020
+ * @public
2021
+ */
2022
+ export declare interface ThinkingConfig {
2023
+ /**
2024
+ * The thinking budget, in tokens.
2025
+ *
2026
+ * This parameter sets an upper limit on the number of tokens the model can use for its internal
2027
+ * "thinking" process. A higher budget may result in higher quality responses for complex tasks
2028
+ * but can also increase latency and cost.
2029
+ *
2030
+ * If you don't specify a budget, the model will determine the appropriate amount
2031
+ * of thinking based on the complexity of the prompt.
2032
+ *
2033
+ * An error will be thrown if you set a thinking budget for a model that does not support this
2034
+ * feature or if the specified budget is not within the model's supported range.
2035
+ */
2036
+ thinkingBudget?: number;
2037
+ }
2038
+
1874
2039
  /**
1875
2040
  * Defines a tool that model can call to access external knowledge.
1876
2041
  * @public
1877
2042
  */
1878
- export declare type Tool = FunctionDeclarationsTool;
2043
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
1879
2044
 
1880
2045
  /**
1881
2046
  * Tool config. This config is shared for all tools provided in the request.
@@ -1899,22 +2064,15 @@ export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema |
1899
2064
  export declare interface UsageMetadata {
1900
2065
  promptTokenCount: number;
1901
2066
  candidatesTokenCount: number;
2067
+ /**
2068
+ * The number of tokens used by the model's internal "thinking" process.
2069
+ */
2070
+ thoughtsTokenCount?: number;
1902
2071
  totalTokenCount: number;
1903
2072
  promptTokensDetails?: ModalityTokenCount[];
1904
2073
  candidatesTokensDetails?: ModalityTokenCount[];
1905
2074
  }
1906
2075
 
1907
- /**
1908
- * @deprecated Use the new {@link AI | AI} instead. The Vertex AI in Firebase SDK has been
1909
- * replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
1910
- * services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
1911
- *
1912
- * An instance of the Firebase AI SDK.
1913
- *
1914
- * @public
1915
- */
1916
- export declare type VertexAI = AI;
1917
-
1918
2076
  /**
1919
2077
  * Configuration class for the Vertex AI Gemini API.
1920
2078
  *
@@ -1940,37 +2098,6 @@ export declare class VertexAIBackend extends Backend {
1940
2098
  constructor(location?: string);
1941
2099
  }
1942
2100
 
1943
- /**
1944
- * @deprecated Use the new {@link AIError} instead. The Vertex AI in Firebase SDK has been
1945
- * replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
1946
- * services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
1947
- *
1948
- * Error class for the Firebase AI SDK.
1949
- *
1950
- * @public
1951
- */
1952
- export declare const VertexAIError: typeof AIError;
1953
-
1954
- /**
1955
- * @deprecated Use the new {@link AIModel} instead. The Vertex AI in Firebase SDK has been
1956
- * replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
1957
- * services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
1958
- *
1959
- * Base class for Firebase AI model APIs.
1960
- *
1961
- * @public
1962
- */
1963
- export declare const VertexAIModel: typeof AIModel;
1964
-
1965
- /**
1966
- * Options when initializing the Firebase AI SDK.
1967
- *
1968
- * @public
1969
- */
1970
- export declare interface VertexAIOptions {
1971
- location?: string;
1972
- }
1973
-
1974
2101
  /**
1975
2102
  * Describes the input video content.
1976
2103
  * @public
@@ -1996,4 +2123,31 @@ export declare interface WebAttribution {
1996
2123
  title: string;
1997
2124
  }
1998
2125
 
2126
+ /**
2127
+ * A grounding chunk from the web.
2128
+ *
2129
+ * Important: If using Grounding with Google Search, you are required to comply with the
2130
+ * {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Search".
2131
+ *
2132
+ * @public
2133
+ */
2134
+ export declare interface WebGroundingChunk {
2135
+ /**
2136
+ * The URI of the retrieved web page.
2137
+ */
2138
+ uri?: string;
2139
+ /**
2140
+ * The title of the retrieved web page.
2141
+ */
2142
+ title?: string;
2143
+ /**
2144
+ * The domain of the original URI from which the content was retrieved.
2145
+ *
2146
+ * This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
2147
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
2148
+ * `undefined`.
2149
+ */
2150
+ domain?: string;
2151
+ }
2152
+
1999
2153
  export { }