@firebase/ai 1.4.0 → 1.4.1-canary.25b60fdaa
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 +462 -213
- package/dist/ai.d.ts +465 -213
- package/dist/esm/{index.esm2017.js → index.esm.js} +349 -276
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/src/api.d.ts +2 -38
- package/dist/esm/src/errors.d.ts +1 -1
- package/dist/esm/src/public-types.d.ts +0 -18
- package/dist/esm/src/requests/schema-builder.d.ts +25 -6
- package/dist/esm/src/types/enums.d.ts +102 -60
- package/dist/esm/src/types/error.d.ts +21 -15
- package/dist/esm/src/types/imagen/requests.d.ts +53 -19
- package/dist/esm/src/types/imagen/responses.d.ts +2 -2
- package/dist/esm/src/types/requests.d.ts +69 -7
- package/dist/esm/src/types/responses.d.ts +135 -12
- package/dist/esm/src/types/schema.d.ts +41 -20
- package/dist/index.cjs.js +364 -279
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +364 -279
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +348 -275
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/api.d.ts +2 -38
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/public-types.d.ts +0 -18
- package/dist/src/requests/schema-builder.d.ts +25 -6
- package/dist/src/types/enums.d.ts +102 -60
- package/dist/src/types/error.d.ts +21 -15
- package/dist/src/types/imagen/requests.d.ts +53 -19
- package/dist/src/types/imagen/responses.d.ts +2 -2
- package/dist/src/types/requests.d.ts +69 -7
- package/dist/src/types/responses.d.ts +135 -12
- package/dist/src/types/schema.d.ts +41 -20
- package/package.json +14 -13
- package/dist/esm/index.esm2017.js.map +0 -1
|
@@ -70,7 +70,7 @@ export interface ImagenGenerationConfig {
|
|
|
70
70
|
numberOfImages?: number;
|
|
71
71
|
/**
|
|
72
72
|
* The aspect ratio of the generated images. The default value is square 1:1.
|
|
73
|
-
* Supported aspect ratios depend on the Imagen model, see {@link ImagenAspectRatio}
|
|
73
|
+
* Supported aspect ratios depend on the Imagen model, see {@link (ImagenAspectRatio:type)}
|
|
74
74
|
* for more details.
|
|
75
75
|
*/
|
|
76
76
|
aspectRatio?: ImagenAspectRatio;
|
|
@@ -106,27 +106,40 @@ export interface ImagenGenerationConfig {
|
|
|
106
106
|
*
|
|
107
107
|
* @beta
|
|
108
108
|
*/
|
|
109
|
-
export declare
|
|
109
|
+
export declare const ImagenSafetyFilterLevel: {
|
|
110
110
|
/**
|
|
111
111
|
* The most aggressive filtering level; most strict blocking.
|
|
112
112
|
*/
|
|
113
|
-
BLOCK_LOW_AND_ABOVE
|
|
113
|
+
readonly BLOCK_LOW_AND_ABOVE: "block_low_and_above";
|
|
114
114
|
/**
|
|
115
115
|
* Blocks some sensitive prompts and responses.
|
|
116
116
|
*/
|
|
117
|
-
BLOCK_MEDIUM_AND_ABOVE
|
|
117
|
+
readonly BLOCK_MEDIUM_AND_ABOVE: "block_medium_and_above";
|
|
118
118
|
/**
|
|
119
119
|
* Blocks few sensitive prompts and responses.
|
|
120
120
|
*/
|
|
121
|
-
BLOCK_ONLY_HIGH
|
|
121
|
+
readonly BLOCK_ONLY_HIGH: "block_only_high";
|
|
122
122
|
/**
|
|
123
123
|
* The least aggressive filtering level; blocks very few sensitive prompts and responses.
|
|
124
124
|
*
|
|
125
125
|
* Access to this feature is restricted and may require your case to be reviewed and approved by
|
|
126
126
|
* Cloud support.
|
|
127
127
|
*/
|
|
128
|
-
BLOCK_NONE
|
|
129
|
-
}
|
|
128
|
+
readonly BLOCK_NONE: "block_none";
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* A filter level controlling how aggressively to filter sensitive content.
|
|
132
|
+
*
|
|
133
|
+
* Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AI
|
|
134
|
+
* are assessed against a list of safety filters, which include 'harmful categories' (for example,
|
|
135
|
+
* `violence`, `sexual`, `derogatory`, and `toxic`). This filter level controls how aggressively to
|
|
136
|
+
* filter out potentially harmful content from responses. See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
137
|
+
* and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
|
|
138
|
+
* for more details.
|
|
139
|
+
*
|
|
140
|
+
* @beta
|
|
141
|
+
*/
|
|
142
|
+
export type ImagenSafetyFilterLevel = (typeof ImagenSafetyFilterLevel)[keyof typeof ImagenSafetyFilterLevel];
|
|
130
143
|
/**
|
|
131
144
|
* A filter level controlling whether generation of images containing people or faces is allowed.
|
|
132
145
|
*
|
|
@@ -135,11 +148,11 @@ export declare enum ImagenSafetyFilterLevel {
|
|
|
135
148
|
*
|
|
136
149
|
* @beta
|
|
137
150
|
*/
|
|
138
|
-
export declare
|
|
151
|
+
export declare const ImagenPersonFilterLevel: {
|
|
139
152
|
/**
|
|
140
153
|
* Disallow generation of images containing people or faces; images of people are filtered out.
|
|
141
154
|
*/
|
|
142
|
-
BLOCK_ALL
|
|
155
|
+
readonly BLOCK_ALL: "dont_allow";
|
|
143
156
|
/**
|
|
144
157
|
* Allow generation of images containing adults only; images of children are filtered out.
|
|
145
158
|
*
|
|
@@ -147,7 +160,7 @@ export declare enum ImagenPersonFilterLevel {
|
|
|
147
160
|
* reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
|
|
148
161
|
* for more details.
|
|
149
162
|
*/
|
|
150
|
-
ALLOW_ADULT
|
|
163
|
+
readonly ALLOW_ADULT: "allow_adult";
|
|
151
164
|
/**
|
|
152
165
|
* Allow generation of images containing adults only; images of children are filtered out.
|
|
153
166
|
*
|
|
@@ -155,8 +168,17 @@ export declare enum ImagenPersonFilterLevel {
|
|
|
155
168
|
* reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
|
|
156
169
|
* for more details.
|
|
157
170
|
*/
|
|
158
|
-
ALLOW_ALL
|
|
159
|
-
}
|
|
171
|
+
readonly ALLOW_ALL: "allow_all";
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* A filter level controlling whether generation of images containing people or faces is allowed.
|
|
175
|
+
*
|
|
176
|
+
* See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
|
|
177
|
+
* documentation for more details.
|
|
178
|
+
*
|
|
179
|
+
* @beta
|
|
180
|
+
*/
|
|
181
|
+
export type ImagenPersonFilterLevel = (typeof ImagenPersonFilterLevel)[keyof typeof ImagenPersonFilterLevel];
|
|
160
182
|
/**
|
|
161
183
|
* Settings for controlling the aggressiveness of filtering out sensitive content.
|
|
162
184
|
*
|
|
@@ -187,25 +209,37 @@ export interface ImagenSafetySettings {
|
|
|
187
209
|
*
|
|
188
210
|
* @beta
|
|
189
211
|
*/
|
|
190
|
-
export declare
|
|
212
|
+
export declare const ImagenAspectRatio: {
|
|
191
213
|
/**
|
|
192
214
|
* Square (1:1) aspect ratio.
|
|
193
215
|
*/
|
|
194
|
-
SQUARE
|
|
216
|
+
readonly SQUARE: "1:1";
|
|
195
217
|
/**
|
|
196
218
|
* Landscape (3:4) aspect ratio.
|
|
197
219
|
*/
|
|
198
|
-
LANDSCAPE_3x4
|
|
220
|
+
readonly LANDSCAPE_3x4: "3:4";
|
|
199
221
|
/**
|
|
200
222
|
* Portrait (4:3) aspect ratio.
|
|
201
223
|
*/
|
|
202
|
-
PORTRAIT_4x3
|
|
224
|
+
readonly PORTRAIT_4x3: "4:3";
|
|
203
225
|
/**
|
|
204
226
|
* Landscape (16:9) aspect ratio.
|
|
205
227
|
*/
|
|
206
|
-
LANDSCAPE_16x9
|
|
228
|
+
readonly LANDSCAPE_16x9: "16:9";
|
|
207
229
|
/**
|
|
208
230
|
* Portrait (9:16) aspect ratio.
|
|
209
231
|
*/
|
|
210
|
-
PORTRAIT_9x16
|
|
211
|
-
}
|
|
232
|
+
readonly PORTRAIT_9x16: "9:16";
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Aspect ratios for Imagen images.
|
|
236
|
+
*
|
|
237
|
+
* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
|
|
238
|
+
* {@link ImagenGenerationConfig}.
|
|
239
|
+
*
|
|
240
|
+
* See the the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
241
|
+
* for more details and examples of the supported aspect ratios.
|
|
242
|
+
*
|
|
243
|
+
* @beta
|
|
244
|
+
*/
|
|
245
|
+
export type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof ImagenAspectRatio];
|
|
@@ -67,8 +67,8 @@ export interface ImagenGenerationResponse<T extends ImagenInlineImage | ImagenGC
|
|
|
67
67
|
* The reason that images were filtered out. This property will only be defined if one
|
|
68
68
|
* or more images were filtered.
|
|
69
69
|
*
|
|
70
|
-
* Images may be filtered out due to the {@link ImagenSafetyFilterLevel},
|
|
71
|
-
* {@link ImagenPersonFilterLevel}, or filtering included in the model.
|
|
70
|
+
* Images may be filtered out due to the {@link (ImagenSafetyFilterLevel:type)},
|
|
71
|
+
* {@link (ImagenPersonFilterLevel:type)}, or filtering included in the model.
|
|
72
72
|
* The filter levels may be adjusted in your {@link ImagenSafetySettings}.
|
|
73
73
|
*
|
|
74
74
|
* See the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen | Responsible AI and usage guidelines for Imagen}
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { TypedSchema } from '../requests/schema-builder';
|
|
17
|
+
import { ObjectSchema, TypedSchema } from '../requests/schema-builder';
|
|
18
18
|
import { Content, Part } from './content';
|
|
19
19
|
import { FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, HarmCategory, ResponseModality } from './enums';
|
|
20
|
-
import {
|
|
20
|
+
import { ObjectSchemaRequest, SchemaRequest } from './schema';
|
|
21
21
|
/**
|
|
22
22
|
* Base parameters for a number of methods.
|
|
23
23
|
* @public
|
|
@@ -87,7 +87,7 @@ export interface GenerationConfig {
|
|
|
87
87
|
* value can be a class generated with a {@link Schema} static method
|
|
88
88
|
* like `Schema.string()` or `Schema.object()` or it can be a plain
|
|
89
89
|
* JS object matching the {@link SchemaRequest} interface.
|
|
90
|
-
* <br/>Note: This only applies when the specified `
|
|
90
|
+
* <br/>Note: This only applies when the specified `responseMimeType` supports a schema; currently
|
|
91
91
|
* this is limited to `application/json` and `text/x.enum`.
|
|
92
92
|
*/
|
|
93
93
|
responseSchema?: TypedSchema | SchemaRequest;
|
|
@@ -101,6 +101,10 @@ export interface GenerationConfig {
|
|
|
101
101
|
* @beta
|
|
102
102
|
*/
|
|
103
103
|
responseModalities?: ResponseModality[];
|
|
104
|
+
/**
|
|
105
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
106
|
+
*/
|
|
107
|
+
thinkingConfig?: ThinkingConfig;
|
|
104
108
|
}
|
|
105
109
|
/**
|
|
106
110
|
* Params for {@link GenerativeModel.startChat}.
|
|
@@ -149,7 +153,7 @@ export interface RequestOptions {
|
|
|
149
153
|
* Defines a tool that model can call to access external knowledge.
|
|
150
154
|
* @public
|
|
151
155
|
*/
|
|
152
|
-
export
|
|
156
|
+
export type Tool = FunctionDeclarationsTool | GoogleSearchTool;
|
|
153
157
|
/**
|
|
154
158
|
* Structured representation of a function declaration as defined by the
|
|
155
159
|
* {@link https://spec.openapis.org/oas/v3.0.3 | OpenAPI 3.0 specification}.
|
|
@@ -159,7 +163,7 @@ export declare type Tool = FunctionDeclarationsTool;
|
|
|
159
163
|
* as a Tool by the model and executed by the client.
|
|
160
164
|
* @public
|
|
161
165
|
*/
|
|
162
|
-
export
|
|
166
|
+
export interface FunctionDeclaration {
|
|
163
167
|
/**
|
|
164
168
|
* The name of the function to call. Must start with a letter or an
|
|
165
169
|
* underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with
|
|
@@ -176,7 +180,41 @@ export declare interface FunctionDeclaration {
|
|
|
176
180
|
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
|
|
177
181
|
* case-sensitive. For a function with no parameters, this can be left unset.
|
|
178
182
|
*/
|
|
179
|
-
parameters?:
|
|
183
|
+
parameters?: ObjectSchema | ObjectSchemaRequest;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A tool that allows a Gemini model to connect to Google Search to access and incorporate
|
|
187
|
+
* up-to-date information from the web into its responses.
|
|
188
|
+
*
|
|
189
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
190
|
+
* "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}
|
|
191
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
192
|
+
* section within the Service Specific Terms).
|
|
193
|
+
*
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
export interface GoogleSearchTool {
|
|
197
|
+
/**
|
|
198
|
+
* Specifies the Google Search configuration.
|
|
199
|
+
* Currently, this is an empty object, but it's reserved for future configuration options.
|
|
200
|
+
* Specifies the Google Search configuration. Currently, this is an empty object, but it's
|
|
201
|
+
* reserved for future configuration options.
|
|
202
|
+
*
|
|
203
|
+
* When using this feature, you are required to comply with the "Grounding with Google Search"
|
|
204
|
+
* usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
205
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
206
|
+
* section within the Service Specific Terms).
|
|
207
|
+
*/
|
|
208
|
+
googleSearch: GoogleSearch;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Specifies the Google Search configuration.
|
|
212
|
+
*
|
|
213
|
+
* @remarks Currently, this is an empty object, but it's reserved for future configuration options.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
export interface GoogleSearch {
|
|
180
218
|
}
|
|
181
219
|
/**
|
|
182
220
|
* A `FunctionDeclarationsTool` is a piece of code that enables the system to
|
|
@@ -184,7 +222,7 @@ export declare interface FunctionDeclaration {
|
|
|
184
222
|
* outside of knowledge and scope of the model.
|
|
185
223
|
* @public
|
|
186
224
|
*/
|
|
187
|
-
export
|
|
225
|
+
export interface FunctionDeclarationsTool {
|
|
188
226
|
/**
|
|
189
227
|
* Optional. One or more function declarations
|
|
190
228
|
* to be passed to the model along with the current user query. Model may
|
|
@@ -211,3 +249,27 @@ export interface FunctionCallingConfig {
|
|
|
211
249
|
mode?: FunctionCallingMode;
|
|
212
250
|
allowedFunctionNames?: string[];
|
|
213
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
254
|
+
*
|
|
255
|
+
* Certain models utilize a thinking process before generating a response. This allows them to
|
|
256
|
+
* reason through complex problems and plan a more coherent and accurate answer.
|
|
257
|
+
*
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
export interface ThinkingConfig {
|
|
261
|
+
/**
|
|
262
|
+
* The thinking budget, in tokens.
|
|
263
|
+
*
|
|
264
|
+
* This parameter sets an upper limit on the number of tokens the model can use for its internal
|
|
265
|
+
* "thinking" process. A higher budget may result in higher quality responses for complex tasks
|
|
266
|
+
* but can also increase latency and cost.
|
|
267
|
+
*
|
|
268
|
+
* If you don't specify a budget, the model will determine the appropriate amount
|
|
269
|
+
* of thinking based on the complexity of the prompt.
|
|
270
|
+
*
|
|
271
|
+
* An error will be thrown if you set a thinking budget for a model that does not support this
|
|
272
|
+
* feature or if the specified budget is not within the model's supported range.
|
|
273
|
+
*/
|
|
274
|
+
thinkingBudget?: number;
|
|
275
|
+
}
|
|
@@ -78,6 +78,10 @@ export interface GenerateContentResponse {
|
|
|
78
78
|
export interface UsageMetadata {
|
|
79
79
|
promptTokenCount: number;
|
|
80
80
|
candidatesTokenCount: number;
|
|
81
|
+
/**
|
|
82
|
+
* The number of tokens used by the model's internal "thinking" process.
|
|
83
|
+
*/
|
|
84
|
+
thoughtsTokenCount?: number;
|
|
81
85
|
totalTokenCount: number;
|
|
82
86
|
promptTokensDetails?: ModalityTokenCount[];
|
|
83
87
|
candidatesTokensDetails?: ModalityTokenCount[];
|
|
@@ -151,34 +155,154 @@ export interface Citation {
|
|
|
151
155
|
publicationDate?: Date;
|
|
152
156
|
}
|
|
153
157
|
/**
|
|
154
|
-
* Metadata returned
|
|
158
|
+
* Metadata returned when grounding is enabled.
|
|
159
|
+
*
|
|
160
|
+
* Currently, only Grounding with Google Search is supported (see {@link GoogleSearchTool}).
|
|
161
|
+
*
|
|
162
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
163
|
+
* "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}
|
|
164
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
165
|
+
* section within the Service Specific Terms).
|
|
166
|
+
*
|
|
155
167
|
* @public
|
|
156
168
|
*/
|
|
157
169
|
export interface GroundingMetadata {
|
|
170
|
+
/**
|
|
171
|
+
* Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
|
|
172
|
+
* embedded in an app to display a Google Search entry point for follow-up web searches related to
|
|
173
|
+
* a model's “Grounded Response”.
|
|
174
|
+
*/
|
|
175
|
+
searchEntryPoint?: SearchEntrypoint;
|
|
176
|
+
/**
|
|
177
|
+
* A list of {@link GroundingChunk} objects. Each chunk represents a piece of retrieved content
|
|
178
|
+
* (for example, from a web page). that the model used to ground its response.
|
|
179
|
+
*/
|
|
180
|
+
groundingChunks?: GroundingChunk[];
|
|
181
|
+
/**
|
|
182
|
+
* A list of {@link GroundingSupport} objects. Each object details how specific segments of the
|
|
183
|
+
* model's response are supported by the `groundingChunks`.
|
|
184
|
+
*/
|
|
185
|
+
groundingSupports?: GroundingSupport[];
|
|
186
|
+
/**
|
|
187
|
+
* A list of web search queries that the model performed to gather the grounding information.
|
|
188
|
+
* These can be used to allow users to explore the search results themselves.
|
|
189
|
+
*/
|
|
158
190
|
webSearchQueries?: string[];
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated Use {@link GroundingSupport} instead.
|
|
193
|
+
*/
|
|
159
194
|
retrievalQueries?: string[];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Google search entry point.
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
export interface SearchEntrypoint {
|
|
160
202
|
/**
|
|
161
|
-
*
|
|
203
|
+
* HTML/CSS snippet that must be embedded in a web page. The snippet is designed to avoid
|
|
204
|
+
* undesired interaction with the rest of the page's CSS.
|
|
205
|
+
*
|
|
206
|
+
* To ensure proper rendering and prevent CSS conflicts, it is recommended
|
|
207
|
+
* to encapsulate this `renderedContent` within a shadow DOM when embedding it
|
|
208
|
+
* into a webpage. See {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM | MDN: Using shadow DOM}.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```javascript
|
|
212
|
+
* const container = document.createElement('div');
|
|
213
|
+
* document.body.appendChild(container);
|
|
214
|
+
* container.attachShadow({ mode: 'open' }).innerHTML = renderedContent;
|
|
215
|
+
* ```
|
|
162
216
|
*/
|
|
163
|
-
|
|
217
|
+
renderedContent?: string;
|
|
164
218
|
}
|
|
165
219
|
/**
|
|
166
|
-
*
|
|
220
|
+
* Represents a chunk of retrieved data that supports a claim in the model's response. This is part
|
|
221
|
+
* of the grounding information provided when grounding is enabled.
|
|
222
|
+
*
|
|
167
223
|
* @public
|
|
168
224
|
*/
|
|
169
|
-
export interface
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
225
|
+
export interface GroundingChunk {
|
|
226
|
+
/**
|
|
227
|
+
* Contains details if the grounding chunk is from a web source.
|
|
228
|
+
*/
|
|
229
|
+
web?: WebGroundingChunk;
|
|
174
230
|
}
|
|
175
231
|
/**
|
|
232
|
+
* A grounding chunk from the web.
|
|
233
|
+
*
|
|
234
|
+
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
235
|
+
* {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Search".
|
|
236
|
+
*
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
export interface WebGroundingChunk {
|
|
240
|
+
/**
|
|
241
|
+
* The URI of the retrieved web page.
|
|
242
|
+
*/
|
|
243
|
+
uri?: string;
|
|
244
|
+
/**
|
|
245
|
+
* The title of the retrieved web page.
|
|
246
|
+
*/
|
|
247
|
+
title?: string;
|
|
248
|
+
/**
|
|
249
|
+
* The domain of the original URI from which the content was retrieved.
|
|
250
|
+
*
|
|
251
|
+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
252
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
|
|
253
|
+
* `undefined`.
|
|
254
|
+
*/
|
|
255
|
+
domain?: string;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Provides information about how a specific segment of the model's response is supported by the
|
|
259
|
+
* retrieved grounding chunks.
|
|
260
|
+
*
|
|
261
|
+
* @public
|
|
262
|
+
*/
|
|
263
|
+
export interface GroundingSupport {
|
|
264
|
+
/**
|
|
265
|
+
* Specifies the segment of the model's response content that this grounding support pertains to.
|
|
266
|
+
*/
|
|
267
|
+
segment?: Segment;
|
|
268
|
+
/**
|
|
269
|
+
* A list of indices that refer to specific {@link GroundingChunk} objects within the
|
|
270
|
+
* {@link GroundingMetadata.groundingChunks} array. These referenced chunks
|
|
271
|
+
* are the sources that support the claim made in the associated `segment` of the response.
|
|
272
|
+
* For example, an array `[1, 3, 4]` means that `groundingChunks[1]`, `groundingChunks[3]`,
|
|
273
|
+
* and `groundingChunks[4]` are the retrieved content supporting this part of the response.
|
|
274
|
+
*/
|
|
275
|
+
groundingChunkIndices?: number[];
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Represents a specific segment within a {@link Content} object, often used to
|
|
279
|
+
* pinpoint the exact location of text or data that grounding information refers to.
|
|
280
|
+
*
|
|
176
281
|
* @public
|
|
177
282
|
*/
|
|
178
283
|
export interface Segment {
|
|
284
|
+
/**
|
|
285
|
+
* The zero-based index of the {@link Part} object within the `parts` array
|
|
286
|
+
* of its parent {@link Content} object. This identifies which part of the
|
|
287
|
+
* content the segment belongs to.
|
|
288
|
+
*/
|
|
179
289
|
partIndex: number;
|
|
290
|
+
/**
|
|
291
|
+
* The zero-based start index of the segment within the specified `Part`,
|
|
292
|
+
* measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
|
|
293
|
+
* beginning of the part's content (e.g., `Part.text`).
|
|
294
|
+
*/
|
|
180
295
|
startIndex: number;
|
|
296
|
+
/**
|
|
297
|
+
* The zero-based end index of the segment within the specified `Part`,
|
|
298
|
+
* measured in UTF-8 bytes. This offset is exclusive, meaning the character
|
|
299
|
+
* at this index is not included in the segment.
|
|
300
|
+
*/
|
|
181
301
|
endIndex: number;
|
|
302
|
+
/**
|
|
303
|
+
* The text corresponding to the segment from the response.
|
|
304
|
+
*/
|
|
305
|
+
text: string;
|
|
182
306
|
}
|
|
183
307
|
/**
|
|
184
308
|
* @public
|
|
@@ -243,11 +367,10 @@ export interface CountTokensResponse {
|
|
|
243
367
|
*/
|
|
244
368
|
totalTokens: number;
|
|
245
369
|
/**
|
|
370
|
+
* @deprecated Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`.
|
|
371
|
+
*
|
|
246
372
|
* The total number of billable characters counted across all instances
|
|
247
373
|
* from the request.
|
|
248
|
-
*
|
|
249
|
-
* This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
250
|
-
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
|
|
251
374
|
*/
|
|
252
375
|
totalBillableCharacters?: number;
|
|
253
376
|
/**
|
|
@@ -20,26 +20,39 @@
|
|
|
20
20
|
* {@link https://swagger.io/docs/specification/data-models/data-types/ | OpenAPI specification}
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
|
-
export declare
|
|
23
|
+
export declare const SchemaType: {
|
|
24
24
|
/** String type. */
|
|
25
|
-
STRING
|
|
25
|
+
readonly STRING: "string";
|
|
26
26
|
/** Number type. */
|
|
27
|
-
NUMBER
|
|
27
|
+
readonly NUMBER: "number";
|
|
28
28
|
/** Integer type. */
|
|
29
|
-
INTEGER
|
|
29
|
+
readonly INTEGER: "integer";
|
|
30
30
|
/** Boolean type. */
|
|
31
|
-
BOOLEAN
|
|
31
|
+
readonly BOOLEAN: "boolean";
|
|
32
32
|
/** Array type. */
|
|
33
|
-
ARRAY
|
|
33
|
+
readonly ARRAY: "array";
|
|
34
34
|
/** Object type. */
|
|
35
|
-
OBJECT
|
|
36
|
-
}
|
|
35
|
+
readonly OBJECT: "object";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Contains the list of OpenAPI data types
|
|
39
|
+
* as defined by the
|
|
40
|
+
* {@link https://swagger.io/docs/specification/data-models/data-types/ | OpenAPI specification}
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
|
|
37
44
|
/**
|
|
38
45
|
* Basic {@link Schema} properties shared across several Schema-related
|
|
39
46
|
* types.
|
|
40
47
|
* @public
|
|
41
48
|
*/
|
|
42
49
|
export interface SchemaShared<T> {
|
|
50
|
+
/**
|
|
51
|
+
* An array of {@link Schema}. The generated data must be valid against any of the schemas
|
|
52
|
+
* listed in this array. This allows specifying multiple possible structures or types for a
|
|
53
|
+
* single field.
|
|
54
|
+
*/
|
|
55
|
+
anyOf?: T[];
|
|
43
56
|
/** Optional. The format of the property.
|
|
44
57
|
* When using the Gemini Developer API ({@link GoogleAIBackend}), this must be either `'enum'` or
|
|
45
58
|
* `'date-time'`, otherwise requests will fail.
|
|
@@ -55,9 +68,9 @@ export interface SchemaShared<T> {
|
|
|
55
68
|
title?: string;
|
|
56
69
|
/** Optional. The items of the property. */
|
|
57
70
|
items?: T;
|
|
58
|
-
/** The minimum number of items (elements) in a schema of
|
|
71
|
+
/** The minimum number of items (elements) in a schema of {@link (SchemaType:type)} `array`. */
|
|
59
72
|
minItems?: number;
|
|
60
|
-
/** The maximum number of items (elements) in a schema of
|
|
73
|
+
/** The maximum number of items (elements) in a schema of {@link (SchemaType:type)} `array`. */
|
|
61
74
|
maxItems?: number;
|
|
62
75
|
/** Optional. Map of `Schema` objects. */
|
|
63
76
|
properties?: {
|
|
@@ -90,10 +103,10 @@ export interface SchemaParams extends SchemaShared<SchemaInterface> {
|
|
|
90
103
|
*/
|
|
91
104
|
export interface SchemaRequest extends SchemaShared<SchemaRequest> {
|
|
92
105
|
/**
|
|
93
|
-
* The type of the property.
|
|
94
|
-
*
|
|
106
|
+
* The type of the property. this can only be undefined when using `anyOf` schemas,
|
|
107
|
+
* which do not have an explicit type in the {@link https://swagger.io/docs/specification/v3_0/data-models/data-types/#any-type | OpenAPI specification }.
|
|
95
108
|
*/
|
|
96
|
-
type
|
|
109
|
+
type?: SchemaType;
|
|
97
110
|
/** Optional. Array of required property. */
|
|
98
111
|
required?: string[];
|
|
99
112
|
}
|
|
@@ -103,16 +116,24 @@ export interface SchemaRequest extends SchemaShared<SchemaRequest> {
|
|
|
103
116
|
*/
|
|
104
117
|
export interface SchemaInterface extends SchemaShared<SchemaInterface> {
|
|
105
118
|
/**
|
|
106
|
-
* The type of the property.
|
|
107
|
-
*
|
|
119
|
+
* The type of the property. this can only be undefined when using `anyof` schemas,
|
|
120
|
+
* which do not have an explicit type in the {@link https://swagger.io/docs/specification/v3_0/data-models/data-types/#any-type | OpenAPI Specification}.
|
|
108
121
|
*/
|
|
109
|
-
type
|
|
122
|
+
type?: SchemaType;
|
|
110
123
|
}
|
|
111
124
|
/**
|
|
112
|
-
* Interface for {@link
|
|
125
|
+
* Interface for JSON parameters in a schema of {@link SchemaType}
|
|
126
|
+
* "object" when not using the `Schema.object()` helper.
|
|
113
127
|
* @public
|
|
114
128
|
*/
|
|
115
|
-
export interface
|
|
116
|
-
type:
|
|
117
|
-
|
|
129
|
+
export interface ObjectSchemaRequest extends SchemaRequest {
|
|
130
|
+
type: 'object';
|
|
131
|
+
/**
|
|
132
|
+
* This is not a property accepted in the final request to the backend, but is
|
|
133
|
+
* a client-side convenience property that is only usable by constructing
|
|
134
|
+
* a schema through the `Schema.object()` helper method. Populating this
|
|
135
|
+
* property will cause response errors if the object is not wrapped with
|
|
136
|
+
* `Schema.object()`.
|
|
137
|
+
*/
|
|
138
|
+
optionalProperties?: never;
|
|
118
139
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/ai",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1-canary.25b60fdaa",
|
|
4
4
|
"description": "The Firebase AI SDK",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=20.0.0"
|
|
8
8
|
},
|
|
9
9
|
"main": "dist/index.cjs.js",
|
|
10
|
-
"browser": "dist/esm/index.
|
|
11
|
-
"module": "dist/esm/index.
|
|
10
|
+
"browser": "dist/esm/index.esm.js",
|
|
11
|
+
"module": "dist/esm/index.esm.js",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/ai-public.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"browser": {
|
|
20
20
|
"require": "./dist/index.cjs.js",
|
|
21
|
-
"import": "./dist/esm/index.
|
|
21
|
+
"import": "./dist/esm/index.esm.js"
|
|
22
22
|
},
|
|
23
|
-
"default": "./dist/esm/index.
|
|
23
|
+
"default": "./dist/esm/index.esm.js"
|
|
24
24
|
},
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
@@ -39,24 +39,25 @@
|
|
|
39
39
|
"test:ci": "yarn testsetup && node ../../scripts/run_tests_in_ci.js -s test",
|
|
40
40
|
"test:skip-clone": "karma start",
|
|
41
41
|
"test:browser": "yarn testsetup && karma start",
|
|
42
|
+
"test:integration": "karma start --integration",
|
|
42
43
|
"api-report": "api-extractor run --local --verbose",
|
|
43
44
|
"typings:public": "node ../../scripts/build/use_typings.js ./dist/ai-public.d.ts",
|
|
44
45
|
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@firebase/app": "0.
|
|
48
|
-
"@firebase/app-types": "0.
|
|
48
|
+
"@firebase/app": "0.13.2-canary.25b60fdaa",
|
|
49
|
+
"@firebase/app-types": "0.9.3-canary.25b60fdaa"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@firebase/app-check-interop-types": "0.3.3",
|
|
52
|
-
"@firebase/component": "0.6.
|
|
53
|
-
"@firebase/logger": "0.4.4",
|
|
54
|
-
"@firebase/util": "1.12.
|
|
52
|
+
"@firebase/app-check-interop-types": "0.3.3-canary.25b60fdaa",
|
|
53
|
+
"@firebase/component": "0.6.18-canary.25b60fdaa",
|
|
54
|
+
"@firebase/logger": "0.4.4-canary.25b60fdaa",
|
|
55
|
+
"@firebase/util": "1.12.1-canary.25b60fdaa",
|
|
55
56
|
"tslib": "^2.1.0"
|
|
56
57
|
},
|
|
57
58
|
"license": "Apache-2.0",
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@firebase/app": "0.13.
|
|
60
|
+
"@firebase/app": "0.13.2-canary.25b60fdaa",
|
|
60
61
|
"@rollup/plugin-json": "6.1.0",
|
|
61
62
|
"rollup": "2.79.2",
|
|
62
63
|
"rollup-plugin-replace": "2.2.0",
|