@firebase/ai 0.0.1
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/README.md +5 -0
- package/dist/ai-public.d.ts +1972 -0
- package/dist/ai.d.ts +2073 -0
- package/dist/esm/index.esm2017.js +2624 -0
- package/dist/esm/index.esm2017.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/src/api.d.ts +120 -0
- package/dist/esm/src/backend.d.ts +74 -0
- package/dist/esm/src/constants.d.ts +23 -0
- package/dist/esm/src/errors.d.ts +35 -0
- package/dist/esm/src/googleai-mappers.d.ts +73 -0
- package/dist/esm/src/helpers.d.ts +30 -0
- package/dist/esm/src/index.d.ts +12 -0
- package/dist/esm/src/index.node.d.ts +7 -0
- package/dist/esm/src/logger.d.ts +18 -0
- package/dist/esm/src/methods/chat-session-helpers.d.ts +18 -0
- package/dist/esm/src/methods/chat-session.d.ts +50 -0
- package/dist/esm/src/methods/count-tokens.d.ts +19 -0
- package/dist/esm/src/methods/generate-content.d.ts +20 -0
- package/dist/esm/src/models/ai-model.d.ts +72 -0
- package/dist/esm/src/models/generative-model.d.ts +54 -0
- package/dist/esm/src/models/imagen-model.d.ts +102 -0
- package/dist/esm/src/models/index.d.ts +19 -0
- package/dist/esm/src/public-types.d.ts +106 -0
- package/dist/esm/src/requests/imagen-image-format.d.ts +61 -0
- package/dist/esm/src/requests/request-helpers.d.ts +28 -0
- package/dist/esm/src/requests/request.d.ts +43 -0
- package/dist/esm/src/requests/response-helpers.d.ts +53 -0
- package/dist/esm/src/requests/schema-builder.d.ts +145 -0
- package/dist/esm/src/requests/stream-reader.d.ts +38 -0
- package/dist/esm/src/service.d.ts +31 -0
- package/dist/esm/src/types/content.d.ts +144 -0
- package/dist/esm/src/types/enums.d.ts +263 -0
- package/dist/esm/src/types/error.d.ts +81 -0
- package/dist/esm/src/types/googleai.d.ts +56 -0
- package/dist/esm/src/types/imagen/index.d.ts +18 -0
- package/dist/esm/src/types/imagen/internal.d.ts +124 -0
- package/dist/esm/src/types/imagen/requests.d.ts +211 -0
- package/dist/esm/src/types/imagen/responses.d.ts +78 -0
- package/dist/esm/src/types/index.d.ts +24 -0
- package/dist/esm/src/types/internal.d.ts +33 -0
- package/dist/esm/src/types/requests.d.ts +213 -0
- package/dist/esm/src/types/responses.d.ts +257 -0
- package/dist/esm/src/types/schema.d.ts +102 -0
- package/dist/index.cjs.js +2652 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.node.cjs.js +2652 -0
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/index.node.mjs +2624 -0
- package/dist/index.node.mjs.map +1 -0
- package/dist/src/api.d.ts +120 -0
- package/dist/src/backend.d.ts +74 -0
- package/dist/src/constants.d.ts +23 -0
- package/dist/src/errors.d.ts +35 -0
- package/dist/src/googleai-mappers.d.ts +73 -0
- package/dist/src/helpers.d.ts +30 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.node.d.ts +7 -0
- package/dist/src/logger.d.ts +18 -0
- package/dist/src/methods/chat-session-helpers.d.ts +18 -0
- package/dist/src/methods/chat-session.d.ts +50 -0
- package/dist/src/methods/count-tokens.d.ts +19 -0
- package/dist/src/methods/generate-content.d.ts +20 -0
- package/dist/src/models/ai-model.d.ts +72 -0
- package/dist/src/models/generative-model.d.ts +54 -0
- package/dist/src/models/imagen-model.d.ts +102 -0
- package/dist/src/models/index.d.ts +19 -0
- package/dist/src/public-types.d.ts +106 -0
- package/dist/src/requests/imagen-image-format.d.ts +61 -0
- package/dist/src/requests/request-helpers.d.ts +28 -0
- package/dist/src/requests/request.d.ts +43 -0
- package/dist/src/requests/response-helpers.d.ts +53 -0
- package/dist/src/requests/schema-builder.d.ts +145 -0
- package/dist/src/requests/stream-reader.d.ts +38 -0
- package/dist/src/service.d.ts +31 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/types/content.d.ts +144 -0
- package/dist/src/types/enums.d.ts +263 -0
- package/dist/src/types/error.d.ts +81 -0
- package/dist/src/types/googleai.d.ts +56 -0
- package/dist/src/types/imagen/index.d.ts +18 -0
- package/dist/src/types/imagen/internal.d.ts +124 -0
- package/dist/src/types/imagen/requests.d.ts +211 -0
- package/dist/src/types/imagen/responses.d.ts +78 -0
- package/dist/src/types/index.d.ts +24 -0
- package/dist/src/types/internal.d.ts +33 -0
- package/dist/src/types/requests.d.ts +213 -0
- package/dist/src/types/responses.d.ts +257 -0
- package/dist/src/types/schema.d.ts +102 -0
- package/package.json +81 -0
|
@@ -0,0 +1,1972 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Firebase AI Web SDK.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
|
|
8
|
+
import { FirebaseApp } from '@firebase/app';
|
|
9
|
+
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
10
|
+
import { FirebaseError } from '@firebase/util';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* An instance of the Firebase AI SDK.
|
|
14
|
+
*
|
|
15
|
+
* Do not create this instance directly. Instead, use {@link getAI | getAI()}.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare interface AI {
|
|
20
|
+
/**
|
|
21
|
+
* The {@link @firebase/app#FirebaseApp} this {@link AI} instance is associated with.
|
|
22
|
+
*/
|
|
23
|
+
app: FirebaseApp;
|
|
24
|
+
/**
|
|
25
|
+
* A {@link Backend} instance that specifies the configuration for the target backend,
|
|
26
|
+
* either the Gemini Developer API (using {@link GoogleAIBackend}) or the
|
|
27
|
+
* Vertex AI Gemini API (using {@link VertexAIBackend}).
|
|
28
|
+
*/
|
|
29
|
+
backend: Backend;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated use `AI.backend.location` instead.
|
|
32
|
+
*
|
|
33
|
+
* The location configured for this AI service instance, relevant for Vertex AI backends.
|
|
34
|
+
*/
|
|
35
|
+
location: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Error class for the Firebase AI SDK.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare class AIError extends FirebaseError {
|
|
44
|
+
readonly code: AIErrorCode;
|
|
45
|
+
readonly customErrorData?: CustomErrorData | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Constructs a new instance of the `AIError` class.
|
|
48
|
+
*
|
|
49
|
+
* @param code - The error code from {@link AIErrorCode}.
|
|
50
|
+
* @param message - A human-readable message describing the error.
|
|
51
|
+
* @param customErrorData - Optional error data.
|
|
52
|
+
*/
|
|
53
|
+
constructor(code: AIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Standardized error codes that {@link AIError} can have.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
declare const enum AIErrorCode {
|
|
62
|
+
/** A generic error occurred. */
|
|
63
|
+
ERROR = "error",
|
|
64
|
+
/** An error occurred in a request. */
|
|
65
|
+
REQUEST_ERROR = "request-error",
|
|
66
|
+
/** An error occurred in a response. */
|
|
67
|
+
RESPONSE_ERROR = "response-error",
|
|
68
|
+
/** An error occurred while performing a fetch. */
|
|
69
|
+
FETCH_ERROR = "fetch-error",
|
|
70
|
+
/** An error associated with a Content object. */
|
|
71
|
+
INVALID_CONTENT = "invalid-content",
|
|
72
|
+
/** An error due to the Firebase API not being enabled in the Console. */
|
|
73
|
+
API_NOT_ENABLED = "api-not-enabled",
|
|
74
|
+
/** An error due to invalid Schema input. */
|
|
75
|
+
INVALID_SCHEMA = "invalid-schema",
|
|
76
|
+
/** An error occurred due to a missing Firebase API key. */
|
|
77
|
+
NO_API_KEY = "no-api-key",
|
|
78
|
+
/** An error occured due to a missing Firebase app ID. */
|
|
79
|
+
NO_APP_ID = "no-app-id",
|
|
80
|
+
/** An error occurred due to a model name not being specified during initialization. */
|
|
81
|
+
NO_MODEL = "no-model",
|
|
82
|
+
/** An error occurred due to a missing project ID. */
|
|
83
|
+
NO_PROJECT_ID = "no-project-id",
|
|
84
|
+
/** An error occurred while parsing. */
|
|
85
|
+
PARSE_FAILED = "parse-failed",
|
|
86
|
+
/** An error occured due an attempt to use an unsupported feature. */
|
|
87
|
+
UNSUPPORTED = "unsupported"
|
|
88
|
+
}
|
|
89
|
+
export { AIErrorCode }
|
|
90
|
+
export { AIErrorCode as VertexAIErrorCode }
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Base class for Firebase AI model APIs.
|
|
94
|
+
*
|
|
95
|
+
* Instances of this class are associated with a specific Firebase AI {@link Backend}
|
|
96
|
+
* and provide methods for interacting with the configured generative model.
|
|
97
|
+
*
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
export declare abstract class AIModel {
|
|
101
|
+
/**
|
|
102
|
+
* The fully qualified model resource name to use for generating images
|
|
103
|
+
* (for example, `publishers/google/models/imagen-3.0-generate-002`).
|
|
104
|
+
*/
|
|
105
|
+
readonly model: string;
|
|
106
|
+
/* Excluded from this release type: _apiSettings */
|
|
107
|
+
/* Excluded from this release type: __constructor */
|
|
108
|
+
/* Excluded from this release type: normalizeModelName */
|
|
109
|
+
/* Excluded from this release type: normalizeGoogleAIModelName */
|
|
110
|
+
/* Excluded from this release type: normalizeVertexAIModelName */
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Options for initializing the AI service using {@link getAI | getAI()}.
|
|
115
|
+
* This allows specifying which backend to use (Vertex AI Gemini API or Gemini Developer API)
|
|
116
|
+
* and configuring its specific options (like location for Vertex AI).
|
|
117
|
+
*
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export declare interface AIOptions {
|
|
121
|
+
/**
|
|
122
|
+
* The backend configuration to use for the AI service instance.
|
|
123
|
+
*/
|
|
124
|
+
backend: Backend;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare interface ApiSettings {
|
|
128
|
+
apiKey: string;
|
|
129
|
+
project: string;
|
|
130
|
+
appId: string;
|
|
131
|
+
automaticDataCollectionEnabled?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated Use `backend.location` instead.
|
|
134
|
+
*/
|
|
135
|
+
location: string;
|
|
136
|
+
backend: Backend;
|
|
137
|
+
getAuthToken?: () => Promise<FirebaseAuthTokenData | null>;
|
|
138
|
+
getAppCheckToken?: () => Promise<AppCheckTokenResult>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Schema class for "array" types.
|
|
143
|
+
* The `items` param should refer to the type of item that can be a member
|
|
144
|
+
* of the array.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare class ArraySchema extends Schema {
|
|
148
|
+
items: TypedSchema;
|
|
149
|
+
constructor(schemaParams: SchemaParams, items: TypedSchema);
|
|
150
|
+
/* Excluded from this release type: toJSON */
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Abstract base class representing the configuration for an AI service backend.
|
|
155
|
+
* This class should not be instantiated directly. Use its subclasses; {@link GoogleAIBackend} for
|
|
156
|
+
* the Gemini Developer API (via {@link https://ai.google/ | Google AI}), and
|
|
157
|
+
* {@link VertexAIBackend} for the Vertex AI Gemini API.
|
|
158
|
+
*
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
export declare abstract class Backend {
|
|
162
|
+
/**
|
|
163
|
+
* Specifies the backend type.
|
|
164
|
+
*/
|
|
165
|
+
readonly backendType: BackendType;
|
|
166
|
+
/**
|
|
167
|
+
* Protected constructor for use by subclasses.
|
|
168
|
+
* @param type - The backend type.
|
|
169
|
+
*/
|
|
170
|
+
protected constructor(type: BackendType);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* An enum-like object containing constants that represent the supported backends
|
|
175
|
+
* for the Firebase AI SDK.
|
|
176
|
+
* This determines which backend service (Vertex AI Gemini API or Gemini Developer API)
|
|
177
|
+
* the SDK will communicate with.
|
|
178
|
+
*
|
|
179
|
+
* These values are assigned to the `backendType` property within the specific backend
|
|
180
|
+
* configuration objects ({@link GoogleAIBackend} or {@link VertexAIBackend}) to identify
|
|
181
|
+
* which service to target.
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
export declare const BackendType: {
|
|
186
|
+
/**
|
|
187
|
+
* Identifies the backend service for the Vertex AI Gemini API provided through Google Cloud.
|
|
188
|
+
* Use this constant when creating a {@link VertexAIBackend} configuration.
|
|
189
|
+
*/
|
|
190
|
+
readonly VERTEX_AI: "VERTEX_AI";
|
|
191
|
+
/**
|
|
192
|
+
* Identifies the backend service for the Gemini Developer API ({@link https://ai.google/ | Google AI}).
|
|
193
|
+
* Use this constant when creating a {@link GoogleAIBackend} configuration.
|
|
194
|
+
*/
|
|
195
|
+
readonly GOOGLE_AI: "GOOGLE_AI";
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Type alias representing valid backend types.
|
|
200
|
+
* It can be either `'VERTEX_AI'` or `'GOOGLE_AI'`.
|
|
201
|
+
*
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export declare type BackendType = (typeof BackendType)[keyof typeof BackendType];
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Base parameters for a number of methods.
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
export declare interface BaseParams {
|
|
211
|
+
safetySettings?: SafetySetting[];
|
|
212
|
+
generationConfig?: GenerationConfig;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Reason that a prompt was blocked.
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
export declare enum BlockReason {
|
|
220
|
+
/**
|
|
221
|
+
* Content was blocked by safety settings.
|
|
222
|
+
*/
|
|
223
|
+
SAFETY = "SAFETY",
|
|
224
|
+
/**
|
|
225
|
+
* Content was blocked, but the reason is uncategorized.
|
|
226
|
+
*/
|
|
227
|
+
OTHER = "OTHER",
|
|
228
|
+
/**
|
|
229
|
+
* Content was blocked because it contained terms from the terminology blocklist.
|
|
230
|
+
*/
|
|
231
|
+
BLOCKLIST = "BLOCKLIST",
|
|
232
|
+
/**
|
|
233
|
+
* Content was blocked due to prohibited content.
|
|
234
|
+
*/
|
|
235
|
+
PROHIBITED_CONTENT = "PROHIBITED_CONTENT"
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Schema class for "boolean" types.
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
export declare class BooleanSchema extends Schema {
|
|
243
|
+
constructor(schemaParams?: SchemaParams);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* ChatSession class that enables sending chat messages and stores
|
|
248
|
+
* history of sent and received messages so far.
|
|
249
|
+
*
|
|
250
|
+
* @public
|
|
251
|
+
*/
|
|
252
|
+
export declare class ChatSession {
|
|
253
|
+
model: string;
|
|
254
|
+
params?: StartChatParams | undefined;
|
|
255
|
+
requestOptions?: RequestOptions | undefined;
|
|
256
|
+
private _apiSettings;
|
|
257
|
+
private _history;
|
|
258
|
+
private _sendPromise;
|
|
259
|
+
constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
|
|
260
|
+
/**
|
|
261
|
+
* Gets the chat history so far. Blocked prompts are not added to history.
|
|
262
|
+
* Neither blocked candidates nor the prompts that generated them are added
|
|
263
|
+
* to history.
|
|
264
|
+
*/
|
|
265
|
+
getHistory(): Promise<Content[]>;
|
|
266
|
+
/**
|
|
267
|
+
* Sends a chat message and receives a non-streaming
|
|
268
|
+
* {@link GenerateContentResult}
|
|
269
|
+
*/
|
|
270
|
+
sendMessage(request: string | Array<string | Part>): Promise<GenerateContentResult>;
|
|
271
|
+
/**
|
|
272
|
+
* Sends a chat message and receives the response as a
|
|
273
|
+
* {@link GenerateContentStreamResult} containing an iterable stream
|
|
274
|
+
* and a response promise.
|
|
275
|
+
*/
|
|
276
|
+
sendMessageStream(request: string | Array<string | Part>): Promise<GenerateContentStreamResult>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* A single citation.
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
export declare interface Citation {
|
|
284
|
+
startIndex?: number;
|
|
285
|
+
endIndex?: number;
|
|
286
|
+
uri?: string;
|
|
287
|
+
license?: string;
|
|
288
|
+
/**
|
|
289
|
+
* The title of the cited source, if available.
|
|
290
|
+
*
|
|
291
|
+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
292
|
+
*/
|
|
293
|
+
title?: string;
|
|
294
|
+
/**
|
|
295
|
+
* The publication date of the cited source, if available.
|
|
296
|
+
*
|
|
297
|
+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
298
|
+
*/
|
|
299
|
+
publicationDate?: Date_2;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Citation metadata that may be found on a {@link GenerateContentCandidate}.
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
export declare interface CitationMetadata {
|
|
307
|
+
citations: Citation[];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Content type for both prompts and response candidates.
|
|
312
|
+
* @public
|
|
313
|
+
*/
|
|
314
|
+
export declare interface Content {
|
|
315
|
+
role: Role;
|
|
316
|
+
parts: Part[];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Params for calling {@link GenerativeModel.countTokens}
|
|
321
|
+
* @public
|
|
322
|
+
*/
|
|
323
|
+
export declare interface CountTokensRequest {
|
|
324
|
+
contents: Content[];
|
|
325
|
+
/**
|
|
326
|
+
* Instructions that direct the model to behave a certain way.
|
|
327
|
+
*/
|
|
328
|
+
systemInstruction?: string | Part | Content;
|
|
329
|
+
/**
|
|
330
|
+
* {@link Tool} configuration.
|
|
331
|
+
*/
|
|
332
|
+
tools?: Tool[];
|
|
333
|
+
/**
|
|
334
|
+
* Configuration options that control how the model generates a response.
|
|
335
|
+
*/
|
|
336
|
+
generationConfig?: GenerationConfig;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Response from calling {@link GenerativeModel.countTokens}.
|
|
341
|
+
* @public
|
|
342
|
+
*/
|
|
343
|
+
export declare interface CountTokensResponse {
|
|
344
|
+
/**
|
|
345
|
+
* The total number of tokens counted across all instances from the request.
|
|
346
|
+
*/
|
|
347
|
+
totalTokens: number;
|
|
348
|
+
/**
|
|
349
|
+
* The total number of billable characters counted across all instances
|
|
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
|
+
*/
|
|
355
|
+
totalBillableCharacters?: number;
|
|
356
|
+
/**
|
|
357
|
+
* The breakdown, by modality, of how many tokens are consumed by the prompt.
|
|
358
|
+
*/
|
|
359
|
+
promptTokensDetails?: ModalityTokenCount[];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Details object that contains data originating from a bad HTTP response.
|
|
364
|
+
*
|
|
365
|
+
* @public
|
|
366
|
+
*/
|
|
367
|
+
export declare interface CustomErrorData {
|
|
368
|
+
/** HTTP status code of the error response. */
|
|
369
|
+
status?: number;
|
|
370
|
+
/** HTTP status text of the error response. */
|
|
371
|
+
statusText?: string;
|
|
372
|
+
/** Response from a {@link GenerateContentRequest} */
|
|
373
|
+
response?: GenerateContentResponse;
|
|
374
|
+
/** Optional additional details about the error. */
|
|
375
|
+
errorDetails?: ErrorDetails[];
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Protobuf google.type.Date
|
|
380
|
+
* @public
|
|
381
|
+
*/
|
|
382
|
+
declare interface Date_2 {
|
|
383
|
+
year: number;
|
|
384
|
+
month: number;
|
|
385
|
+
day: number;
|
|
386
|
+
}
|
|
387
|
+
export { Date_2 as Date }
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Response object wrapped with helper methods.
|
|
391
|
+
*
|
|
392
|
+
* @public
|
|
393
|
+
*/
|
|
394
|
+
export declare interface EnhancedGenerateContentResponse extends GenerateContentResponse {
|
|
395
|
+
/**
|
|
396
|
+
* Returns the text string from the response, if available.
|
|
397
|
+
* Throws if the prompt or candidate was blocked.
|
|
398
|
+
*/
|
|
399
|
+
text: () => string;
|
|
400
|
+
/**
|
|
401
|
+
* Aggregates and returns all {@link InlineDataPart}s from the {@link GenerateContentResponse}'s
|
|
402
|
+
* first candidate.
|
|
403
|
+
*
|
|
404
|
+
* @returns An array of {@link InlineDataPart}s containing data from the response, if available.
|
|
405
|
+
*
|
|
406
|
+
* @throws If the prompt or candidate was blocked.
|
|
407
|
+
*/
|
|
408
|
+
inlineDataParts: () => InlineDataPart[] | undefined;
|
|
409
|
+
functionCalls: () => FunctionCall[] | undefined;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Details object that may be included in an error response.
|
|
414
|
+
*
|
|
415
|
+
* @public
|
|
416
|
+
*/
|
|
417
|
+
export declare interface ErrorDetails {
|
|
418
|
+
'@type'?: string;
|
|
419
|
+
/** The reason for the error. */
|
|
420
|
+
reason?: string;
|
|
421
|
+
/** The domain where the error occurred. */
|
|
422
|
+
domain?: string;
|
|
423
|
+
/** Additional metadata about the error. */
|
|
424
|
+
metadata?: Record<string, unknown>;
|
|
425
|
+
/** Any other relevant information about the error. */
|
|
426
|
+
[key: string]: unknown;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Data pointing to a file uploaded on Google Cloud Storage.
|
|
431
|
+
* @public
|
|
432
|
+
*/
|
|
433
|
+
export declare interface FileData {
|
|
434
|
+
mimeType: string;
|
|
435
|
+
fileUri: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Content part interface if the part represents {@link FileData}
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
export declare interface FileDataPart {
|
|
443
|
+
text?: never;
|
|
444
|
+
inlineData?: never;
|
|
445
|
+
functionCall?: never;
|
|
446
|
+
functionResponse?: never;
|
|
447
|
+
fileData: FileData;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Reason that a candidate finished.
|
|
452
|
+
* @public
|
|
453
|
+
*/
|
|
454
|
+
export declare enum FinishReason {
|
|
455
|
+
/**
|
|
456
|
+
* Natural stop point of the model or provided stop sequence.
|
|
457
|
+
*/
|
|
458
|
+
STOP = "STOP",
|
|
459
|
+
/**
|
|
460
|
+
* The maximum number of tokens as specified in the request was reached.
|
|
461
|
+
*/
|
|
462
|
+
MAX_TOKENS = "MAX_TOKENS",
|
|
463
|
+
/**
|
|
464
|
+
* The candidate content was flagged for safety reasons.
|
|
465
|
+
*/
|
|
466
|
+
SAFETY = "SAFETY",
|
|
467
|
+
/**
|
|
468
|
+
* The candidate content was flagged for recitation reasons.
|
|
469
|
+
*/
|
|
470
|
+
RECITATION = "RECITATION",
|
|
471
|
+
/**
|
|
472
|
+
* Unknown reason.
|
|
473
|
+
*/
|
|
474
|
+
OTHER = "OTHER",
|
|
475
|
+
/**
|
|
476
|
+
* The candidate content contained forbidden terms.
|
|
477
|
+
*/
|
|
478
|
+
BLOCKLIST = "BLOCKLIST",
|
|
479
|
+
/**
|
|
480
|
+
* The candidate content potentially contained prohibited content.
|
|
481
|
+
*/
|
|
482
|
+
PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
|
|
483
|
+
/**
|
|
484
|
+
* The candidate content potentially contained Sensitive Personally Identifiable Information (SPII).
|
|
485
|
+
*/
|
|
486
|
+
SPII = "SPII",
|
|
487
|
+
/**
|
|
488
|
+
* The function call generated by the model was invalid.
|
|
489
|
+
*/
|
|
490
|
+
MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL"
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* A predicted {@link FunctionCall} returned from the model
|
|
495
|
+
* that contains a string representing the {@link FunctionDeclaration.name}
|
|
496
|
+
* and a structured JSON object containing the parameters and their values.
|
|
497
|
+
* @public
|
|
498
|
+
*/
|
|
499
|
+
export declare interface FunctionCall {
|
|
500
|
+
name: string;
|
|
501
|
+
args: object;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @public
|
|
506
|
+
*/
|
|
507
|
+
export declare interface FunctionCallingConfig {
|
|
508
|
+
mode?: FunctionCallingMode;
|
|
509
|
+
allowedFunctionNames?: string[];
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* @public
|
|
514
|
+
*/
|
|
515
|
+
export declare enum FunctionCallingMode {
|
|
516
|
+
/**
|
|
517
|
+
* Default model behavior; model decides to predict either a function call
|
|
518
|
+
* or a natural language response.
|
|
519
|
+
*/
|
|
520
|
+
AUTO = "AUTO",
|
|
521
|
+
/**
|
|
522
|
+
* Model is constrained to always predicting a function call only.
|
|
523
|
+
* If `allowed_function_names` is set, the predicted function call will be
|
|
524
|
+
* limited to any one of `allowed_function_names`, else the predicted
|
|
525
|
+
* function call will be any one of the provided `function_declarations`.
|
|
526
|
+
*/
|
|
527
|
+
ANY = "ANY",
|
|
528
|
+
/**
|
|
529
|
+
* Model will not predict any function call. Model behavior is same as when
|
|
530
|
+
* not passing any function declarations.
|
|
531
|
+
*/
|
|
532
|
+
NONE = "NONE"
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Content part interface if the part represents a {@link FunctionCall}.
|
|
537
|
+
* @public
|
|
538
|
+
*/
|
|
539
|
+
export declare interface FunctionCallPart {
|
|
540
|
+
text?: never;
|
|
541
|
+
inlineData?: never;
|
|
542
|
+
functionCall: FunctionCall;
|
|
543
|
+
functionResponse?: never;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Structured representation of a function declaration as defined by the
|
|
548
|
+
* {@link https://spec.openapis.org/oas/v3.0.3 | OpenAPI 3.0 specification}.
|
|
549
|
+
* Included
|
|
550
|
+
* in this declaration are the function name and parameters. This
|
|
551
|
+
* `FunctionDeclaration` is a representation of a block of code that can be used
|
|
552
|
+
* as a Tool by the model and executed by the client.
|
|
553
|
+
* @public
|
|
554
|
+
*/
|
|
555
|
+
export declare interface FunctionDeclaration {
|
|
556
|
+
/**
|
|
557
|
+
* The name of the function to call. Must start with a letter or an
|
|
558
|
+
* underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with
|
|
559
|
+
* a max length of 64.
|
|
560
|
+
*/
|
|
561
|
+
name: string;
|
|
562
|
+
/**
|
|
563
|
+
* Description and purpose of the function. Model uses it to decide
|
|
564
|
+
* how and whether to call the function.
|
|
565
|
+
*/
|
|
566
|
+
description: string;
|
|
567
|
+
/**
|
|
568
|
+
* Optional. Describes the parameters to this function in JSON Schema Object
|
|
569
|
+
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
|
|
570
|
+
* case-sensitive. For a function with no parameters, this can be left unset.
|
|
571
|
+
*/
|
|
572
|
+
parameters?: ObjectSchemaInterface;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* A `FunctionDeclarationsTool` is a piece of code that enables the system to
|
|
577
|
+
* interact with external systems to perform an action, or set of actions,
|
|
578
|
+
* outside of knowledge and scope of the model.
|
|
579
|
+
* @public
|
|
580
|
+
*/
|
|
581
|
+
export declare interface FunctionDeclarationsTool {
|
|
582
|
+
/**
|
|
583
|
+
* Optional. One or more function declarations
|
|
584
|
+
* to be passed to the model along with the current user query. Model may
|
|
585
|
+
* decide to call a subset of these functions by populating
|
|
586
|
+
* {@link FunctionCall} in the response. User should
|
|
587
|
+
* provide a {@link FunctionResponse} for each
|
|
588
|
+
* function call in the next turn. Based on the function responses, the model will
|
|
589
|
+
* generate the final response back to the user. Maximum 64 function
|
|
590
|
+
* declarations can be provided.
|
|
591
|
+
*/
|
|
592
|
+
functionDeclarations?: FunctionDeclaration[];
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* The result output from a {@link FunctionCall} that contains a string
|
|
597
|
+
* representing the {@link FunctionDeclaration.name}
|
|
598
|
+
* and a structured JSON object containing any output
|
|
599
|
+
* from the function is used as context to the model.
|
|
600
|
+
* This should contain the result of a {@link FunctionCall}
|
|
601
|
+
* made based on model prediction.
|
|
602
|
+
* @public
|
|
603
|
+
*/
|
|
604
|
+
export declare interface FunctionResponse {
|
|
605
|
+
name: string;
|
|
606
|
+
response: object;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Content part interface if the part represents {@link FunctionResponse}.
|
|
611
|
+
* @public
|
|
612
|
+
*/
|
|
613
|
+
export declare interface FunctionResponsePart {
|
|
614
|
+
text?: never;
|
|
615
|
+
inlineData?: never;
|
|
616
|
+
functionCall?: never;
|
|
617
|
+
functionResponse: FunctionResponse;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* A candidate returned as part of a {@link GenerateContentResponse}.
|
|
622
|
+
* @public
|
|
623
|
+
*/
|
|
624
|
+
export declare interface GenerateContentCandidate {
|
|
625
|
+
index: number;
|
|
626
|
+
content: Content;
|
|
627
|
+
finishReason?: FinishReason;
|
|
628
|
+
finishMessage?: string;
|
|
629
|
+
safetyRatings?: SafetyRating[];
|
|
630
|
+
citationMetadata?: CitationMetadata;
|
|
631
|
+
groundingMetadata?: GroundingMetadata;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Request sent through {@link GenerativeModel.generateContent}
|
|
636
|
+
* @public
|
|
637
|
+
*/
|
|
638
|
+
export declare interface GenerateContentRequest extends BaseParams {
|
|
639
|
+
contents: Content[];
|
|
640
|
+
tools?: Tool[];
|
|
641
|
+
toolConfig?: ToolConfig;
|
|
642
|
+
systemInstruction?: string | Part | Content;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Individual response from {@link GenerativeModel.generateContent} and
|
|
647
|
+
* {@link GenerativeModel.generateContentStream}.
|
|
648
|
+
* `generateContentStream()` will return one in each chunk until
|
|
649
|
+
* the stream is done.
|
|
650
|
+
* @public
|
|
651
|
+
*/
|
|
652
|
+
export declare interface GenerateContentResponse {
|
|
653
|
+
candidates?: GenerateContentCandidate[];
|
|
654
|
+
promptFeedback?: PromptFeedback;
|
|
655
|
+
usageMetadata?: UsageMetadata;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Result object returned from {@link GenerativeModel.generateContent} call.
|
|
660
|
+
*
|
|
661
|
+
* @public
|
|
662
|
+
*/
|
|
663
|
+
export declare interface GenerateContentResult {
|
|
664
|
+
response: EnhancedGenerateContentResponse;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Result object returned from {@link GenerativeModel.generateContentStream} call.
|
|
669
|
+
* Iterate over `stream` to get chunks as they come in and/or
|
|
670
|
+
* use the `response` promise to get the aggregated response when
|
|
671
|
+
* the stream is done.
|
|
672
|
+
*
|
|
673
|
+
* @public
|
|
674
|
+
*/
|
|
675
|
+
export declare interface GenerateContentStreamResult {
|
|
676
|
+
stream: AsyncGenerator<EnhancedGenerateContentResponse>;
|
|
677
|
+
response: Promise<EnhancedGenerateContentResponse>;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Config options for content-related requests
|
|
682
|
+
* @public
|
|
683
|
+
*/
|
|
684
|
+
export declare interface GenerationConfig {
|
|
685
|
+
candidateCount?: number;
|
|
686
|
+
stopSequences?: string[];
|
|
687
|
+
maxOutputTokens?: number;
|
|
688
|
+
temperature?: number;
|
|
689
|
+
topP?: number;
|
|
690
|
+
topK?: number;
|
|
691
|
+
presencePenalty?: number;
|
|
692
|
+
frequencyPenalty?: number;
|
|
693
|
+
/**
|
|
694
|
+
* Output response MIME type of the generated candidate text.
|
|
695
|
+
* Supported MIME types are `text/plain` (default, text output),
|
|
696
|
+
* `application/json` (JSON response in the candidates), and
|
|
697
|
+
* `text/x.enum`.
|
|
698
|
+
*/
|
|
699
|
+
responseMimeType?: string;
|
|
700
|
+
/**
|
|
701
|
+
* Output response schema of the generated candidate text. This
|
|
702
|
+
* value can be a class generated with a {@link Schema} static method
|
|
703
|
+
* like `Schema.string()` or `Schema.object()` or it can be a plain
|
|
704
|
+
* JS object matching the {@link SchemaRequest} interface.
|
|
705
|
+
* <br/>Note: This only applies when the specified `responseMIMEType` supports a schema; currently
|
|
706
|
+
* this is limited to `application/json` and `text/x.enum`.
|
|
707
|
+
*/
|
|
708
|
+
responseSchema?: TypedSchema | SchemaRequest;
|
|
709
|
+
/**
|
|
710
|
+
* Generation modalities to be returned in generation responses.
|
|
711
|
+
*
|
|
712
|
+
* @remarks
|
|
713
|
+
* - Multimodal response generation is only supported by some Gemini models and versions; see {@link https://firebase.google.com/docs/vertex-ai/models | model versions}.
|
|
714
|
+
* - Only image generation (`ResponseModality.IMAGE`) is supported.
|
|
715
|
+
*
|
|
716
|
+
* @beta
|
|
717
|
+
*/
|
|
718
|
+
responseModalities?: ResponseModality[];
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Interface for sending an image.
|
|
723
|
+
* @public
|
|
724
|
+
*/
|
|
725
|
+
export declare interface GenerativeContentBlob {
|
|
726
|
+
mimeType: string;
|
|
727
|
+
/**
|
|
728
|
+
* Image as a base64 string.
|
|
729
|
+
*/
|
|
730
|
+
data: string;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Class for generative model APIs.
|
|
735
|
+
* @public
|
|
736
|
+
*/
|
|
737
|
+
export declare class GenerativeModel extends AIModel {
|
|
738
|
+
generationConfig: GenerationConfig;
|
|
739
|
+
safetySettings: SafetySetting[];
|
|
740
|
+
requestOptions?: RequestOptions;
|
|
741
|
+
tools?: Tool[];
|
|
742
|
+
toolConfig?: ToolConfig;
|
|
743
|
+
systemInstruction?: Content;
|
|
744
|
+
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions);
|
|
745
|
+
/**
|
|
746
|
+
* Makes a single non-streaming call to the model
|
|
747
|
+
* and returns an object containing a single {@link GenerateContentResponse}.
|
|
748
|
+
*/
|
|
749
|
+
generateContent(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentResult>;
|
|
750
|
+
/**
|
|
751
|
+
* Makes a single streaming call to the model
|
|
752
|
+
* and returns an object containing an iterable stream that iterates
|
|
753
|
+
* over all chunks in the streaming response as well as
|
|
754
|
+
* a promise that returns the final aggregated response.
|
|
755
|
+
*/
|
|
756
|
+
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentStreamResult>;
|
|
757
|
+
/**
|
|
758
|
+
* Gets a new {@link ChatSession} instance which can be used for
|
|
759
|
+
* multi-turn chats.
|
|
760
|
+
*/
|
|
761
|
+
startChat(startChatParams?: StartChatParams): ChatSession;
|
|
762
|
+
/**
|
|
763
|
+
* Counts the tokens in the provided request.
|
|
764
|
+
*/
|
|
765
|
+
countTokens(request: CountTokensRequest | string | Array<string | Part>): Promise<CountTokensResponse>;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Returns the default {@link AI} instance that is associated with the provided
|
|
770
|
+
* {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new instance with the
|
|
771
|
+
* default settings.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```javascript
|
|
775
|
+
* const ai = getAI(app);
|
|
776
|
+
* ```
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* ```javascript
|
|
780
|
+
* // Get an AI instance configured to use the Gemini Developer API (via Google AI).
|
|
781
|
+
* const ai = getAI(app, { backend: new GoogleAIBackend() });
|
|
782
|
+
* ```
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* ```javascript
|
|
786
|
+
* // Get an AI instance configured to use the Vertex AI Gemini API.
|
|
787
|
+
* const ai = getAI(app, { backend: new VertexAIBackend() });
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @param app - The {@link @firebase/app#FirebaseApp} to use.
|
|
791
|
+
* @param options - {@link AIOptions} that configure the AI instance.
|
|
792
|
+
* @returns The default {@link AI} instance for the given {@link @firebase/app#FirebaseApp}.
|
|
793
|
+
*
|
|
794
|
+
* @public
|
|
795
|
+
*/
|
|
796
|
+
export declare function getAI(app?: FirebaseApp, options?: AIOptions): AI;
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Returns a {@link GenerativeModel} class with methods for inference
|
|
800
|
+
* and other functionality.
|
|
801
|
+
*
|
|
802
|
+
* @public
|
|
803
|
+
*/
|
|
804
|
+
export declare function getGenerativeModel(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Returns an {@link ImagenModel} class with methods for using Imagen.
|
|
808
|
+
*
|
|
809
|
+
* Only Imagen 3 models (named `imagen-3.0-*`) are supported.
|
|
810
|
+
*
|
|
811
|
+
* @param ai - An {@link AI} instance.
|
|
812
|
+
* @param modelParams - Parameters to use when making Imagen requests.
|
|
813
|
+
* @param requestOptions - Additional options to use when making requests.
|
|
814
|
+
*
|
|
815
|
+
* @throws If the `apiKey` or `projectId` fields are missing in your
|
|
816
|
+
* Firebase config.
|
|
817
|
+
*
|
|
818
|
+
* @beta
|
|
819
|
+
*/
|
|
820
|
+
export declare function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
|
|
821
|
+
|
|
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
|
+
/**
|
|
839
|
+
* Configuration class for the Gemini Developer API.
|
|
840
|
+
*
|
|
841
|
+
* Use this with {@link AIOptions} when initializing the AI service via
|
|
842
|
+
* {@link getAI | getAI()} to specify the Gemini Developer API as the backend.
|
|
843
|
+
*
|
|
844
|
+
* @public
|
|
845
|
+
*/
|
|
846
|
+
export declare class GoogleAIBackend extends Backend {
|
|
847
|
+
/**
|
|
848
|
+
* Creates a configuration object for the Gemini Developer API backend.
|
|
849
|
+
*/
|
|
850
|
+
constructor();
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/* Excluded from this release type: GoogleAICitationMetadata */
|
|
854
|
+
|
|
855
|
+
/* Excluded from this release type: GoogleAICountTokensRequest */
|
|
856
|
+
|
|
857
|
+
/* Excluded from this release type: GoogleAIGenerateContentCandidate */
|
|
858
|
+
|
|
859
|
+
/* Excluded from this release type: GoogleAIGenerateContentResponse */
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* @deprecated
|
|
863
|
+
* @public
|
|
864
|
+
*/
|
|
865
|
+
export declare interface GroundingAttribution {
|
|
866
|
+
segment: Segment;
|
|
867
|
+
confidenceScore?: number;
|
|
868
|
+
web?: WebAttribution;
|
|
869
|
+
retrievedContext?: RetrievedContextAttribution;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Metadata returned to client when grounding is enabled.
|
|
874
|
+
* @public
|
|
875
|
+
*/
|
|
876
|
+
export declare interface GroundingMetadata {
|
|
877
|
+
webSearchQueries?: string[];
|
|
878
|
+
retrievalQueries?: string[];
|
|
879
|
+
/**
|
|
880
|
+
* @deprecated
|
|
881
|
+
*/
|
|
882
|
+
groundingAttributions: GroundingAttribution[];
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
|
|
887
|
+
*
|
|
888
|
+
* @public
|
|
889
|
+
*/
|
|
890
|
+
export declare enum HarmBlockMethod {
|
|
891
|
+
/**
|
|
892
|
+
* The harm block method uses both probability and severity scores.
|
|
893
|
+
*/
|
|
894
|
+
SEVERITY = "SEVERITY",
|
|
895
|
+
/**
|
|
896
|
+
* The harm block method uses the probability score.
|
|
897
|
+
*/
|
|
898
|
+
PROBABILITY = "PROBABILITY"
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Threshold above which a prompt or candidate will be blocked.
|
|
903
|
+
* @public
|
|
904
|
+
*/
|
|
905
|
+
export declare enum HarmBlockThreshold {
|
|
906
|
+
/**
|
|
907
|
+
* Content with `NEGLIGIBLE` will be allowed.
|
|
908
|
+
*/
|
|
909
|
+
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
910
|
+
/**
|
|
911
|
+
* Content with `NEGLIGIBLE` and `LOW` will be allowed.
|
|
912
|
+
*/
|
|
913
|
+
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
914
|
+
/**
|
|
915
|
+
* Content with `NEGLIGIBLE`, `LOW`, and `MEDIUM` will be allowed.
|
|
916
|
+
*/
|
|
917
|
+
BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH",
|
|
918
|
+
/**
|
|
919
|
+
* All content will be allowed.
|
|
920
|
+
*/
|
|
921
|
+
BLOCK_NONE = "BLOCK_NONE"
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Harm categories that would cause prompts or candidates to be blocked.
|
|
926
|
+
* @public
|
|
927
|
+
*/
|
|
928
|
+
export declare enum HarmCategory {
|
|
929
|
+
HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH",
|
|
930
|
+
HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
931
|
+
HARM_CATEGORY_HARASSMENT = "HARM_CATEGORY_HARASSMENT",
|
|
932
|
+
HARM_CATEGORY_DANGEROUS_CONTENT = "HARM_CATEGORY_DANGEROUS_CONTENT"
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Probability that a prompt or candidate matches a harm category.
|
|
937
|
+
* @public
|
|
938
|
+
*/
|
|
939
|
+
export declare enum HarmProbability {
|
|
940
|
+
/**
|
|
941
|
+
* Content has a negligible chance of being unsafe.
|
|
942
|
+
*/
|
|
943
|
+
NEGLIGIBLE = "NEGLIGIBLE",
|
|
944
|
+
/**
|
|
945
|
+
* Content has a low chance of being unsafe.
|
|
946
|
+
*/
|
|
947
|
+
LOW = "LOW",
|
|
948
|
+
/**
|
|
949
|
+
* Content has a medium chance of being unsafe.
|
|
950
|
+
*/
|
|
951
|
+
MEDIUM = "MEDIUM",
|
|
952
|
+
/**
|
|
953
|
+
* Content has a high chance of being unsafe.
|
|
954
|
+
*/
|
|
955
|
+
HIGH = "HIGH"
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Harm severity levels.
|
|
960
|
+
* @public
|
|
961
|
+
*/
|
|
962
|
+
export declare enum HarmSeverity {
|
|
963
|
+
/**
|
|
964
|
+
* Negligible level of harm severity.
|
|
965
|
+
*/
|
|
966
|
+
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
|
|
967
|
+
/**
|
|
968
|
+
* Low level of harm severity.
|
|
969
|
+
*/
|
|
970
|
+
HARM_SEVERITY_LOW = "HARM_SEVERITY_LOW",
|
|
971
|
+
/**
|
|
972
|
+
* Medium level of harm severity.
|
|
973
|
+
*/
|
|
974
|
+
HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM",
|
|
975
|
+
/**
|
|
976
|
+
* High level of harm severity.
|
|
977
|
+
*/
|
|
978
|
+
HARM_SEVERITY_HIGH = "HARM_SEVERITY_HIGH",
|
|
979
|
+
/**
|
|
980
|
+
* Harm severity is not supported.
|
|
981
|
+
*
|
|
982
|
+
* @remarks
|
|
983
|
+
* The GoogleAI backend does not support `HarmSeverity`, so this value is used as a fallback.
|
|
984
|
+
*/
|
|
985
|
+
HARM_SEVERITY_UNSUPPORTED = "HARM_SEVERITY_UNSUPPORTED"
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Aspect ratios for Imagen images.
|
|
990
|
+
*
|
|
991
|
+
* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
|
|
992
|
+
* {@link ImagenGenerationConfig}.
|
|
993
|
+
*
|
|
994
|
+
* See the the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
995
|
+
* for more details and examples of the supported aspect ratios.
|
|
996
|
+
*
|
|
997
|
+
* @beta
|
|
998
|
+
*/
|
|
999
|
+
export declare enum ImagenAspectRatio {
|
|
1000
|
+
/**
|
|
1001
|
+
* Square (1:1) aspect ratio.
|
|
1002
|
+
*/
|
|
1003
|
+
SQUARE = "1:1",
|
|
1004
|
+
/**
|
|
1005
|
+
* Landscape (3:4) aspect ratio.
|
|
1006
|
+
*/
|
|
1007
|
+
LANDSCAPE_3x4 = "3:4",
|
|
1008
|
+
/**
|
|
1009
|
+
* Portrait (4:3) aspect ratio.
|
|
1010
|
+
*/
|
|
1011
|
+
PORTRAIT_4x3 = "4:3",
|
|
1012
|
+
/**
|
|
1013
|
+
* Landscape (16:9) aspect ratio.
|
|
1014
|
+
*/
|
|
1015
|
+
LANDSCAPE_16x9 = "16:9",
|
|
1016
|
+
/**
|
|
1017
|
+
* Portrait (9:16) aspect ratio.
|
|
1018
|
+
*/
|
|
1019
|
+
PORTRAIT_9x16 = "9:16"
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* An image generated by Imagen, stored in a Cloud Storage for Firebase bucket.
|
|
1024
|
+
*
|
|
1025
|
+
* This feature is not available yet.
|
|
1026
|
+
*/
|
|
1027
|
+
export declare interface ImagenGCSImage {
|
|
1028
|
+
/**
|
|
1029
|
+
* The MIME type of the image; either `"image/png"` or `"image/jpeg"`.
|
|
1030
|
+
*
|
|
1031
|
+
* To request a different format, set the `imageFormat` property in your {@link ImagenGenerationConfig}.
|
|
1032
|
+
*/
|
|
1033
|
+
mimeType: string;
|
|
1034
|
+
/**
|
|
1035
|
+
* The URI of the file stored in a Cloud Storage for Firebase bucket.
|
|
1036
|
+
*
|
|
1037
|
+
* @example `"gs://bucket-name/path/sample_0.jpg"`.
|
|
1038
|
+
*/
|
|
1039
|
+
gcsURI: string;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Configuration options for generating images with Imagen.
|
|
1044
|
+
*
|
|
1045
|
+
* See the {@link http://firebase.google.com/docs/vertex-ai/generate-images-imagen | documentation} for
|
|
1046
|
+
* more details.
|
|
1047
|
+
*
|
|
1048
|
+
* @beta
|
|
1049
|
+
*/
|
|
1050
|
+
export declare interface ImagenGenerationConfig {
|
|
1051
|
+
/**
|
|
1052
|
+
* A description of what should be omitted from the generated images.
|
|
1053
|
+
*
|
|
1054
|
+
* Support for negative prompts depends on the Imagen model.
|
|
1055
|
+
*
|
|
1056
|
+
* See the {@link http://firebase.google.com/docs/vertex-ai/model-parameters#imagen | documentation} for more details.
|
|
1057
|
+
*
|
|
1058
|
+
* This is no longer supported in the Gemini Developer API ({@link GoogleAIBackend}) in versions
|
|
1059
|
+
* greater than `imagen-3.0-generate-002`.
|
|
1060
|
+
*/
|
|
1061
|
+
negativePrompt?: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* The number of images to generate. The default value is 1.
|
|
1064
|
+
*
|
|
1065
|
+
* The number of sample images that may be generated in each request depends on the model
|
|
1066
|
+
* (typically up to 4); see the <a href="http://firebase.google.com/docs/vertex-ai/model-parameters#imagen">sampleCount</a>
|
|
1067
|
+
* documentation for more details.
|
|
1068
|
+
*/
|
|
1069
|
+
numberOfImages?: number;
|
|
1070
|
+
/**
|
|
1071
|
+
* The aspect ratio of the generated images. The default value is square 1:1.
|
|
1072
|
+
* Supported aspect ratios depend on the Imagen model, see {@link ImagenAspectRatio}
|
|
1073
|
+
* for more details.
|
|
1074
|
+
*/
|
|
1075
|
+
aspectRatio?: ImagenAspectRatio;
|
|
1076
|
+
/**
|
|
1077
|
+
* The image format of the generated images. The default is PNG.
|
|
1078
|
+
*
|
|
1079
|
+
* See {@link ImagenImageFormat} for more details.
|
|
1080
|
+
*/
|
|
1081
|
+
imageFormat?: ImagenImageFormat;
|
|
1082
|
+
/**
|
|
1083
|
+
* Whether to add an invisible watermark to generated images.
|
|
1084
|
+
*
|
|
1085
|
+
* If set to `true`, an invisible SynthID watermark is embedded in generated images to indicate
|
|
1086
|
+
* that they are AI generated. If set to `false`, watermarking will be disabled.
|
|
1087
|
+
*
|
|
1088
|
+
* For Imagen 3 models, the default value is `true`; see the <a href="http://firebase.google.com/docs/vertex-ai/model-parameters#imagen">addWatermark</a>
|
|
1089
|
+
* documentation for more details.
|
|
1090
|
+
*
|
|
1091
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this will default to true,
|
|
1092
|
+
* and cannot be turned off.
|
|
1093
|
+
*/
|
|
1094
|
+
addWatermark?: boolean;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* The response from a request to generate images with Imagen.
|
|
1099
|
+
*
|
|
1100
|
+
* @beta
|
|
1101
|
+
*/
|
|
1102
|
+
export declare interface ImagenGenerationResponse<T extends ImagenInlineImage | ImagenGCSImage> {
|
|
1103
|
+
/**
|
|
1104
|
+
* The images generated by Imagen.
|
|
1105
|
+
*
|
|
1106
|
+
* The number of images generated may be fewer than the number requested if one or more were
|
|
1107
|
+
* filtered out; see `filteredReason`.
|
|
1108
|
+
*/
|
|
1109
|
+
images: T[];
|
|
1110
|
+
/**
|
|
1111
|
+
* The reason that images were filtered out. This property will only be defined if one
|
|
1112
|
+
* or more images were filtered.
|
|
1113
|
+
*
|
|
1114
|
+
* Images may be filtered out due to the {@link ImagenSafetyFilterLevel},
|
|
1115
|
+
* {@link ImagenPersonFilterLevel}, or filtering included in the model.
|
|
1116
|
+
* The filter levels may be adjusted in your {@link ImagenSafetySettings}.
|
|
1117
|
+
*
|
|
1118
|
+
* See the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen | Responsible AI and usage guidelines for Imagen}
|
|
1119
|
+
* for more details.
|
|
1120
|
+
*/
|
|
1121
|
+
filteredReason?: string;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* @license
|
|
1126
|
+
* Copyright 2025 Google LLC
|
|
1127
|
+
*
|
|
1128
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1129
|
+
* you may not use this file except in compliance with the License.
|
|
1130
|
+
* You may obtain a copy of the License at
|
|
1131
|
+
*
|
|
1132
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1133
|
+
*
|
|
1134
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1135
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1136
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1137
|
+
* See the License for the specific language governing permissions and
|
|
1138
|
+
* limitations under the License.
|
|
1139
|
+
*/
|
|
1140
|
+
/**
|
|
1141
|
+
* Defines the image format for images generated by Imagen.
|
|
1142
|
+
*
|
|
1143
|
+
* Use this class to specify the desired format (JPEG or PNG) and compression quality
|
|
1144
|
+
* for images generated by Imagen. This is typically included as part of
|
|
1145
|
+
* {@link ImagenModelParams}.
|
|
1146
|
+
*
|
|
1147
|
+
* @example
|
|
1148
|
+
* ```javascript
|
|
1149
|
+
* const imagenModelParams = {
|
|
1150
|
+
* // ... other ImagenModelParams
|
|
1151
|
+
* imageFormat: ImagenImageFormat.jpeg(75) // JPEG with a compression level of 75.
|
|
1152
|
+
* }
|
|
1153
|
+
* ```
|
|
1154
|
+
*
|
|
1155
|
+
* @beta
|
|
1156
|
+
*/
|
|
1157
|
+
export declare class ImagenImageFormat {
|
|
1158
|
+
/**
|
|
1159
|
+
* The MIME type.
|
|
1160
|
+
*/
|
|
1161
|
+
mimeType: string;
|
|
1162
|
+
/**
|
|
1163
|
+
* The level of compression (a number between 0 and 100).
|
|
1164
|
+
*/
|
|
1165
|
+
compressionQuality?: number;
|
|
1166
|
+
private constructor();
|
|
1167
|
+
/**
|
|
1168
|
+
* Creates an {@link ImagenImageFormat} for a JPEG image.
|
|
1169
|
+
*
|
|
1170
|
+
* @param compressionQuality - The level of compression (a number between 0 and 100).
|
|
1171
|
+
* @returns An {@link ImagenImageFormat} object for a JPEG image.
|
|
1172
|
+
*
|
|
1173
|
+
* @beta
|
|
1174
|
+
*/
|
|
1175
|
+
static jpeg(compressionQuality?: number): ImagenImageFormat;
|
|
1176
|
+
/**
|
|
1177
|
+
* Creates an {@link ImagenImageFormat} for a PNG image.
|
|
1178
|
+
*
|
|
1179
|
+
* @returns An {@link ImagenImageFormat} object for a PNG image.
|
|
1180
|
+
*
|
|
1181
|
+
* @beta
|
|
1182
|
+
*/
|
|
1183
|
+
static png(): ImagenImageFormat;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* @license
|
|
1188
|
+
* Copyright 2025 Google LLC
|
|
1189
|
+
*
|
|
1190
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1191
|
+
* you may not use this file except in compliance with the License.
|
|
1192
|
+
* You may obtain a copy of the License at
|
|
1193
|
+
*
|
|
1194
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1195
|
+
*
|
|
1196
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1197
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1198
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1199
|
+
* See the License for the specific language governing permissions and
|
|
1200
|
+
* limitations under the License.
|
|
1201
|
+
*/
|
|
1202
|
+
/**
|
|
1203
|
+
* An image generated by Imagen, represented as inline data.
|
|
1204
|
+
*
|
|
1205
|
+
* @beta
|
|
1206
|
+
*/
|
|
1207
|
+
export declare interface ImagenInlineImage {
|
|
1208
|
+
/**
|
|
1209
|
+
* The MIME type of the image; either `"image/png"` or `"image/jpeg"`.
|
|
1210
|
+
*
|
|
1211
|
+
* To request a different format, set the `imageFormat` property in your {@link ImagenGenerationConfig}.
|
|
1212
|
+
*/
|
|
1213
|
+
mimeType: string;
|
|
1214
|
+
/**
|
|
1215
|
+
* The base64-encoded image data.
|
|
1216
|
+
*/
|
|
1217
|
+
bytesBase64Encoded: string;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Class for Imagen model APIs.
|
|
1222
|
+
*
|
|
1223
|
+
* This class provides methods for generating images using the Imagen model.
|
|
1224
|
+
*
|
|
1225
|
+
* @example
|
|
1226
|
+
* ```javascript
|
|
1227
|
+
* const imagen = new ImagenModel(
|
|
1228
|
+
* ai,
|
|
1229
|
+
* {
|
|
1230
|
+
* model: 'imagen-3.0-generate-002'
|
|
1231
|
+
* }
|
|
1232
|
+
* );
|
|
1233
|
+
*
|
|
1234
|
+
* const response = await imagen.generateImages('A photo of a cat');
|
|
1235
|
+
* if (response.images.length > 0) {
|
|
1236
|
+
* console.log(response.images[0].bytesBase64Encoded);
|
|
1237
|
+
* }
|
|
1238
|
+
* ```
|
|
1239
|
+
*
|
|
1240
|
+
* @beta
|
|
1241
|
+
*/
|
|
1242
|
+
export declare class ImagenModel extends AIModel {
|
|
1243
|
+
requestOptions?: RequestOptions | undefined;
|
|
1244
|
+
/**
|
|
1245
|
+
* The Imagen generation configuration.
|
|
1246
|
+
*/
|
|
1247
|
+
generationConfig?: ImagenGenerationConfig;
|
|
1248
|
+
/**
|
|
1249
|
+
* Safety settings for filtering inappropriate content.
|
|
1250
|
+
*/
|
|
1251
|
+
safetySettings?: ImagenSafetySettings;
|
|
1252
|
+
/**
|
|
1253
|
+
* Constructs a new instance of the {@link ImagenModel} class.
|
|
1254
|
+
*
|
|
1255
|
+
* @param ai - an {@link AI} instance.
|
|
1256
|
+
* @param modelParams - Parameters to use when making requests to Imagen.
|
|
1257
|
+
* @param requestOptions - Additional options to use when making requests.
|
|
1258
|
+
*
|
|
1259
|
+
* @throws If the `apiKey` or `projectId` fields are missing in your
|
|
1260
|
+
* Firebase config.
|
|
1261
|
+
*/
|
|
1262
|
+
constructor(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
|
|
1263
|
+
/**
|
|
1264
|
+
* Generates images using the Imagen model and returns them as
|
|
1265
|
+
* base64-encoded strings.
|
|
1266
|
+
*
|
|
1267
|
+
* @param prompt - A text prompt describing the image(s) to generate.
|
|
1268
|
+
* @returns A promise that resolves to an {@link ImagenGenerationResponse}
|
|
1269
|
+
* object containing the generated images.
|
|
1270
|
+
*
|
|
1271
|
+
* @throws If the request to generate images fails. This happens if the
|
|
1272
|
+
* prompt is blocked.
|
|
1273
|
+
*
|
|
1274
|
+
* @remarks
|
|
1275
|
+
* If the prompt was not blocked, but one or more of the generated images were filtered, the
|
|
1276
|
+
* returned object will have a `filteredReason` property.
|
|
1277
|
+
* If all images are filtered, the `images` array will be empty.
|
|
1278
|
+
*
|
|
1279
|
+
* @beta
|
|
1280
|
+
*/
|
|
1281
|
+
generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
|
|
1282
|
+
/* Excluded from this release type: generateImagesGCS */
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Parameters for configuring an {@link ImagenModel}.
|
|
1287
|
+
*
|
|
1288
|
+
* @beta
|
|
1289
|
+
*/
|
|
1290
|
+
export declare interface ImagenModelParams {
|
|
1291
|
+
/**
|
|
1292
|
+
* The Imagen model to use for generating images.
|
|
1293
|
+
* For example: `imagen-3.0-generate-002`.
|
|
1294
|
+
*
|
|
1295
|
+
* Only Imagen 3 models (named `imagen-3.0-*`) are supported.
|
|
1296
|
+
*
|
|
1297
|
+
* See {@link https://firebase.google.com/docs/vertex-ai/models | model versions}
|
|
1298
|
+
* for a full list of supported Imagen 3 models.
|
|
1299
|
+
*/
|
|
1300
|
+
model: string;
|
|
1301
|
+
/**
|
|
1302
|
+
* Configuration options for generating images with Imagen.
|
|
1303
|
+
*/
|
|
1304
|
+
generationConfig?: ImagenGenerationConfig;
|
|
1305
|
+
/**
|
|
1306
|
+
* Safety settings for filtering potentially inappropriate content.
|
|
1307
|
+
*/
|
|
1308
|
+
safetySettings?: ImagenSafetySettings;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* A filter level controlling whether generation of images containing people or faces is allowed.
|
|
1313
|
+
*
|
|
1314
|
+
* See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
|
|
1315
|
+
* documentation for more details.
|
|
1316
|
+
*
|
|
1317
|
+
* @beta
|
|
1318
|
+
*/
|
|
1319
|
+
export declare enum ImagenPersonFilterLevel {
|
|
1320
|
+
/**
|
|
1321
|
+
* Disallow generation of images containing people or faces; images of people are filtered out.
|
|
1322
|
+
*/
|
|
1323
|
+
BLOCK_ALL = "dont_allow",
|
|
1324
|
+
/**
|
|
1325
|
+
* Allow generation of images containing adults only; images of children are filtered out.
|
|
1326
|
+
*
|
|
1327
|
+
* Generation of images containing people or faces may require your use case to be
|
|
1328
|
+
* 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}
|
|
1329
|
+
* for more details.
|
|
1330
|
+
*/
|
|
1331
|
+
ALLOW_ADULT = "allow_adult",
|
|
1332
|
+
/**
|
|
1333
|
+
* Allow generation of images containing adults only; images of children are filtered out.
|
|
1334
|
+
*
|
|
1335
|
+
* Generation of images containing people or faces may require your use case to be
|
|
1336
|
+
* 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}
|
|
1337
|
+
* for more details.
|
|
1338
|
+
*/
|
|
1339
|
+
ALLOW_ALL = "allow_all"
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/**
|
|
1343
|
+
* A filter level controlling how aggressively to filter sensitive content.
|
|
1344
|
+
*
|
|
1345
|
+
* Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AI
|
|
1346
|
+
* are assessed against a list of safety filters, which include 'harmful categories' (for example,
|
|
1347
|
+
* `violence`, `sexual`, `derogatory`, and `toxic`). This filter level controls how aggressively to
|
|
1348
|
+
* filter out potentially harmful content from responses. See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
1349
|
+
* and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
|
|
1350
|
+
* for more details.
|
|
1351
|
+
*
|
|
1352
|
+
* @beta
|
|
1353
|
+
*/
|
|
1354
|
+
export declare enum ImagenSafetyFilterLevel {
|
|
1355
|
+
/**
|
|
1356
|
+
* The most aggressive filtering level; most strict blocking.
|
|
1357
|
+
*/
|
|
1358
|
+
BLOCK_LOW_AND_ABOVE = "block_low_and_above",
|
|
1359
|
+
/**
|
|
1360
|
+
* Blocks some sensitive prompts and responses.
|
|
1361
|
+
*/
|
|
1362
|
+
BLOCK_MEDIUM_AND_ABOVE = "block_medium_and_above",
|
|
1363
|
+
/**
|
|
1364
|
+
* Blocks few sensitive prompts and responses.
|
|
1365
|
+
*/
|
|
1366
|
+
BLOCK_ONLY_HIGH = "block_only_high",
|
|
1367
|
+
/**
|
|
1368
|
+
* The least aggressive filtering level; blocks very few sensitive prompts and responses.
|
|
1369
|
+
*
|
|
1370
|
+
* Access to this feature is restricted and may require your case to be reviewed and approved by
|
|
1371
|
+
* Cloud support.
|
|
1372
|
+
*/
|
|
1373
|
+
BLOCK_NONE = "block_none"
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Settings for controlling the aggressiveness of filtering out sensitive content.
|
|
1378
|
+
*
|
|
1379
|
+
* See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
1380
|
+
* for more details.
|
|
1381
|
+
*
|
|
1382
|
+
* @beta
|
|
1383
|
+
*/
|
|
1384
|
+
export declare interface ImagenSafetySettings {
|
|
1385
|
+
/**
|
|
1386
|
+
* A filter level controlling how aggressive to filter out sensitive content from generated
|
|
1387
|
+
* images.
|
|
1388
|
+
*/
|
|
1389
|
+
safetyFilterLevel?: ImagenSafetyFilterLevel;
|
|
1390
|
+
/**
|
|
1391
|
+
* A filter level controlling whether generation of images containing people or faces is allowed.
|
|
1392
|
+
*/
|
|
1393
|
+
personFilterLevel?: ImagenPersonFilterLevel;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Content part interface if the part represents an image.
|
|
1398
|
+
* @public
|
|
1399
|
+
*/
|
|
1400
|
+
export declare interface InlineDataPart {
|
|
1401
|
+
text?: never;
|
|
1402
|
+
inlineData: GenerativeContentBlob;
|
|
1403
|
+
functionCall?: never;
|
|
1404
|
+
functionResponse?: never;
|
|
1405
|
+
/**
|
|
1406
|
+
* Applicable if `inlineData` is a video.
|
|
1407
|
+
*/
|
|
1408
|
+
videoMetadata?: VideoMetadata;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* Schema class for "integer" types.
|
|
1413
|
+
* @public
|
|
1414
|
+
*/
|
|
1415
|
+
export declare class IntegerSchema extends Schema {
|
|
1416
|
+
constructor(schemaParams?: SchemaParams);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Content part modality.
|
|
1421
|
+
* @public
|
|
1422
|
+
*/
|
|
1423
|
+
export declare enum Modality {
|
|
1424
|
+
/**
|
|
1425
|
+
* Unspecified modality.
|
|
1426
|
+
*/
|
|
1427
|
+
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
1428
|
+
/**
|
|
1429
|
+
* Plain text.
|
|
1430
|
+
*/
|
|
1431
|
+
TEXT = "TEXT",
|
|
1432
|
+
/**
|
|
1433
|
+
* Image.
|
|
1434
|
+
*/
|
|
1435
|
+
IMAGE = "IMAGE",
|
|
1436
|
+
/**
|
|
1437
|
+
* Video.
|
|
1438
|
+
*/
|
|
1439
|
+
VIDEO = "VIDEO",
|
|
1440
|
+
/**
|
|
1441
|
+
* Audio.
|
|
1442
|
+
*/
|
|
1443
|
+
AUDIO = "AUDIO",
|
|
1444
|
+
/**
|
|
1445
|
+
* Document (for example, PDF).
|
|
1446
|
+
*/
|
|
1447
|
+
DOCUMENT = "DOCUMENT"
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Represents token counting info for a single modality.
|
|
1452
|
+
*
|
|
1453
|
+
* @public
|
|
1454
|
+
*/
|
|
1455
|
+
export declare interface ModalityTokenCount {
|
|
1456
|
+
/** The modality associated with this token count. */
|
|
1457
|
+
modality: Modality;
|
|
1458
|
+
/** The number of tokens counted. */
|
|
1459
|
+
tokenCount: number;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Params passed to {@link getGenerativeModel}.
|
|
1464
|
+
* @public
|
|
1465
|
+
*/
|
|
1466
|
+
export declare interface ModelParams extends BaseParams {
|
|
1467
|
+
model: string;
|
|
1468
|
+
tools?: Tool[];
|
|
1469
|
+
toolConfig?: ToolConfig;
|
|
1470
|
+
systemInstruction?: string | Part | Content;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* Schema class for "number" types.
|
|
1475
|
+
* @public
|
|
1476
|
+
*/
|
|
1477
|
+
export declare class NumberSchema extends Schema {
|
|
1478
|
+
constructor(schemaParams?: SchemaParams);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* Schema class for "object" types.
|
|
1483
|
+
* The `properties` param must be a map of `Schema` objects.
|
|
1484
|
+
* @public
|
|
1485
|
+
*/
|
|
1486
|
+
export declare class ObjectSchema extends Schema {
|
|
1487
|
+
properties: {
|
|
1488
|
+
[k: string]: TypedSchema;
|
|
1489
|
+
};
|
|
1490
|
+
optionalProperties: string[];
|
|
1491
|
+
constructor(schemaParams: SchemaParams, properties: {
|
|
1492
|
+
[k: string]: TypedSchema;
|
|
1493
|
+
}, optionalProperties?: string[]);
|
|
1494
|
+
/* Excluded from this release type: toJSON */
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/**
|
|
1498
|
+
* Interface for {@link ObjectSchema} class.
|
|
1499
|
+
* @public
|
|
1500
|
+
*/
|
|
1501
|
+
export declare interface ObjectSchemaInterface extends SchemaInterface {
|
|
1502
|
+
type: SchemaType.OBJECT;
|
|
1503
|
+
optionalProperties?: string[];
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Content part - includes text, image/video, or function call/response
|
|
1508
|
+
* part types.
|
|
1509
|
+
* @public
|
|
1510
|
+
*/
|
|
1511
|
+
export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* Possible roles.
|
|
1515
|
+
* @public
|
|
1516
|
+
*/
|
|
1517
|
+
export declare const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* If the prompt was blocked, this will be populated with `blockReason` and
|
|
1521
|
+
* the relevant `safetyRatings`.
|
|
1522
|
+
* @public
|
|
1523
|
+
*/
|
|
1524
|
+
export declare interface PromptFeedback {
|
|
1525
|
+
blockReason?: BlockReason;
|
|
1526
|
+
safetyRatings: SafetyRating[];
|
|
1527
|
+
/**
|
|
1528
|
+
* A human-readable description of the `blockReason`.
|
|
1529
|
+
*
|
|
1530
|
+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
1531
|
+
*/
|
|
1532
|
+
blockReasonMessage?: string;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Params passed to {@link getGenerativeModel}.
|
|
1537
|
+
* @public
|
|
1538
|
+
*/
|
|
1539
|
+
export declare interface RequestOptions {
|
|
1540
|
+
/**
|
|
1541
|
+
* Request timeout in milliseconds. Defaults to 180 seconds (180000ms).
|
|
1542
|
+
*/
|
|
1543
|
+
timeout?: number;
|
|
1544
|
+
/**
|
|
1545
|
+
* Base url for endpoint. Defaults to https://firebasevertexai.googleapis.com
|
|
1546
|
+
*/
|
|
1547
|
+
baseUrl?: string;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Generation modalities to be returned in generation responses.
|
|
1552
|
+
*
|
|
1553
|
+
* @beta
|
|
1554
|
+
*/
|
|
1555
|
+
export declare const ResponseModality: {
|
|
1556
|
+
/**
|
|
1557
|
+
* Text.
|
|
1558
|
+
* @beta
|
|
1559
|
+
*/
|
|
1560
|
+
readonly TEXT: "TEXT";
|
|
1561
|
+
/**
|
|
1562
|
+
* Image.
|
|
1563
|
+
* @beta
|
|
1564
|
+
*/
|
|
1565
|
+
readonly IMAGE: "IMAGE";
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* Generation modalities to be returned in generation responses.
|
|
1570
|
+
*
|
|
1571
|
+
* @beta
|
|
1572
|
+
*/
|
|
1573
|
+
export declare type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseModality];
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* @public
|
|
1577
|
+
*/
|
|
1578
|
+
export declare interface RetrievedContextAttribution {
|
|
1579
|
+
uri: string;
|
|
1580
|
+
title: string;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* @license
|
|
1585
|
+
* Copyright 2024 Google LLC
|
|
1586
|
+
*
|
|
1587
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1588
|
+
* you may not use this file except in compliance with the License.
|
|
1589
|
+
* You may obtain a copy of the License at
|
|
1590
|
+
*
|
|
1591
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1592
|
+
*
|
|
1593
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1594
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1595
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1596
|
+
* See the License for the specific language governing permissions and
|
|
1597
|
+
* limitations under the License.
|
|
1598
|
+
*/
|
|
1599
|
+
/**
|
|
1600
|
+
* Role is the producer of the content.
|
|
1601
|
+
* @public
|
|
1602
|
+
*/
|
|
1603
|
+
export declare type Role = (typeof POSSIBLE_ROLES)[number];
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* A safety rating associated with a {@link GenerateContentCandidate}
|
|
1607
|
+
* @public
|
|
1608
|
+
*/
|
|
1609
|
+
export declare interface SafetyRating {
|
|
1610
|
+
category: HarmCategory;
|
|
1611
|
+
probability: HarmProbability;
|
|
1612
|
+
/**
|
|
1613
|
+
* The harm severity level.
|
|
1614
|
+
*
|
|
1615
|
+
* This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
1616
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to `HarmSeverity.UNSUPPORTED`.
|
|
1617
|
+
*/
|
|
1618
|
+
severity: HarmSeverity;
|
|
1619
|
+
/**
|
|
1620
|
+
* The probability score of the harm category.
|
|
1621
|
+
*
|
|
1622
|
+
* This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
1623
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
|
|
1624
|
+
*/
|
|
1625
|
+
probabilityScore: number;
|
|
1626
|
+
/**
|
|
1627
|
+
* The severity score of the harm category.
|
|
1628
|
+
*
|
|
1629
|
+
* This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
1630
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
|
|
1631
|
+
*/
|
|
1632
|
+
severityScore: number;
|
|
1633
|
+
blocked: boolean;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/**
|
|
1637
|
+
* Safety setting that can be sent as part of request parameters.
|
|
1638
|
+
* @public
|
|
1639
|
+
*/
|
|
1640
|
+
export declare interface SafetySetting {
|
|
1641
|
+
category: HarmCategory;
|
|
1642
|
+
threshold: HarmBlockThreshold;
|
|
1643
|
+
/**
|
|
1644
|
+
* The harm block method.
|
|
1645
|
+
*
|
|
1646
|
+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
|
|
1647
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), an {@link AIError} will be
|
|
1648
|
+
* thrown if this property is defined.
|
|
1649
|
+
*/
|
|
1650
|
+
method?: HarmBlockMethod;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Parent class encompassing all Schema types, with static methods that
|
|
1655
|
+
* allow building specific Schema types. This class can be converted with
|
|
1656
|
+
* `JSON.stringify()` into a JSON string accepted by Vertex AI REST endpoints.
|
|
1657
|
+
* (This string conversion is automatically done when calling SDK methods.)
|
|
1658
|
+
* @public
|
|
1659
|
+
*/
|
|
1660
|
+
export declare abstract class Schema implements SchemaInterface {
|
|
1661
|
+
/**
|
|
1662
|
+
* Optional. The type of the property. {@link
|
|
1663
|
+
* SchemaType}.
|
|
1664
|
+
*/
|
|
1665
|
+
type: SchemaType;
|
|
1666
|
+
/** Optional. The format of the property.
|
|
1667
|
+
* Supported formats:<br/>
|
|
1668
|
+
* <ul>
|
|
1669
|
+
* <li>for NUMBER type: "float", "double"</li>
|
|
1670
|
+
* <li>for INTEGER type: "int32", "int64"</li>
|
|
1671
|
+
* <li>for STRING type: "email", "byte", etc</li>
|
|
1672
|
+
* </ul>
|
|
1673
|
+
*/
|
|
1674
|
+
format?: string;
|
|
1675
|
+
/** Optional. The description of the property. */
|
|
1676
|
+
description?: string;
|
|
1677
|
+
/** Optional. Whether the property is nullable. Defaults to false. */
|
|
1678
|
+
nullable: boolean;
|
|
1679
|
+
/** Optional. The example of the property. */
|
|
1680
|
+
example?: unknown;
|
|
1681
|
+
/**
|
|
1682
|
+
* Allows user to add other schema properties that have not yet
|
|
1683
|
+
* been officially added to the SDK.
|
|
1684
|
+
*/
|
|
1685
|
+
[key: string]: unknown;
|
|
1686
|
+
constructor(schemaParams: SchemaInterface);
|
|
1687
|
+
/* Excluded from this release type: toJSON */
|
|
1688
|
+
static array(arrayParams: SchemaParams & {
|
|
1689
|
+
items: Schema;
|
|
1690
|
+
}): ArraySchema;
|
|
1691
|
+
static object(objectParams: SchemaParams & {
|
|
1692
|
+
properties: {
|
|
1693
|
+
[k: string]: Schema;
|
|
1694
|
+
};
|
|
1695
|
+
optionalProperties?: string[];
|
|
1696
|
+
}): ObjectSchema;
|
|
1697
|
+
static string(stringParams?: SchemaParams): StringSchema;
|
|
1698
|
+
static enumString(stringParams: SchemaParams & {
|
|
1699
|
+
enum: string[];
|
|
1700
|
+
}): StringSchema;
|
|
1701
|
+
static integer(integerParams?: SchemaParams): IntegerSchema;
|
|
1702
|
+
static number(numberParams?: SchemaParams): NumberSchema;
|
|
1703
|
+
static boolean(booleanParams?: SchemaParams): BooleanSchema;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* Interface for {@link Schema} class.
|
|
1708
|
+
* @public
|
|
1709
|
+
*/
|
|
1710
|
+
export declare interface SchemaInterface extends SchemaShared<SchemaInterface> {
|
|
1711
|
+
/**
|
|
1712
|
+
* The type of the property. {@link
|
|
1713
|
+
* SchemaType}.
|
|
1714
|
+
*/
|
|
1715
|
+
type: SchemaType;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* Params passed to {@link Schema} static methods to create specific
|
|
1720
|
+
* {@link Schema} classes.
|
|
1721
|
+
* @public
|
|
1722
|
+
*/
|
|
1723
|
+
export declare interface SchemaParams extends SchemaShared<SchemaInterface> {
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/**
|
|
1727
|
+
* Final format for {@link Schema} params passed to backend requests.
|
|
1728
|
+
* @public
|
|
1729
|
+
*/
|
|
1730
|
+
export declare interface SchemaRequest extends SchemaShared<SchemaRequest> {
|
|
1731
|
+
/**
|
|
1732
|
+
* The type of the property. {@link
|
|
1733
|
+
* SchemaType}.
|
|
1734
|
+
*/
|
|
1735
|
+
type: SchemaType;
|
|
1736
|
+
/** Optional. Array of required property. */
|
|
1737
|
+
required?: string[];
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
/**
|
|
1741
|
+
* Basic {@link Schema} properties shared across several Schema-related
|
|
1742
|
+
* types.
|
|
1743
|
+
* @public
|
|
1744
|
+
*/
|
|
1745
|
+
export declare interface SchemaShared<T> {
|
|
1746
|
+
/** Optional. The format of the property.
|
|
1747
|
+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this must be either `'enum'` or
|
|
1748
|
+
* `'date-time'`, otherwise requests will fail.
|
|
1749
|
+
*/
|
|
1750
|
+
format?: string;
|
|
1751
|
+
/** Optional. The description of the property. */
|
|
1752
|
+
description?: string;
|
|
1753
|
+
/** Optional. The items of the property. */
|
|
1754
|
+
items?: T;
|
|
1755
|
+
/** Optional. Map of `Schema` objects. */
|
|
1756
|
+
properties?: {
|
|
1757
|
+
[k: string]: T;
|
|
1758
|
+
};
|
|
1759
|
+
/** Optional. The enum of the property. */
|
|
1760
|
+
enum?: string[];
|
|
1761
|
+
/** Optional. The example of the property. */
|
|
1762
|
+
example?: unknown;
|
|
1763
|
+
/** Optional. Whether the property is nullable. */
|
|
1764
|
+
nullable?: boolean;
|
|
1765
|
+
[key: string]: unknown;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* @license
|
|
1770
|
+
* Copyright 2024 Google LLC
|
|
1771
|
+
*
|
|
1772
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1773
|
+
* you may not use this file except in compliance with the License.
|
|
1774
|
+
* You may obtain a copy of the License at
|
|
1775
|
+
*
|
|
1776
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1777
|
+
*
|
|
1778
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1779
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1780
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1781
|
+
* See the License for the specific language governing permissions and
|
|
1782
|
+
* limitations under the License.
|
|
1783
|
+
*/
|
|
1784
|
+
/**
|
|
1785
|
+
* Contains the list of OpenAPI data types
|
|
1786
|
+
* as defined by the
|
|
1787
|
+
* {@link https://swagger.io/docs/specification/data-models/data-types/ | OpenAPI specification}
|
|
1788
|
+
* @public
|
|
1789
|
+
*/
|
|
1790
|
+
export declare enum SchemaType {
|
|
1791
|
+
/** String type. */
|
|
1792
|
+
STRING = "string",
|
|
1793
|
+
/** Number type. */
|
|
1794
|
+
NUMBER = "number",
|
|
1795
|
+
/** Integer type. */
|
|
1796
|
+
INTEGER = "integer",
|
|
1797
|
+
/** Boolean type. */
|
|
1798
|
+
BOOLEAN = "boolean",
|
|
1799
|
+
/** Array type. */
|
|
1800
|
+
ARRAY = "array",
|
|
1801
|
+
/** Object type. */
|
|
1802
|
+
OBJECT = "object"
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* @public
|
|
1807
|
+
*/
|
|
1808
|
+
export declare interface Segment {
|
|
1809
|
+
partIndex: number;
|
|
1810
|
+
startIndex: number;
|
|
1811
|
+
endIndex: number;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
/**
|
|
1815
|
+
* Params for {@link GenerativeModel.startChat}.
|
|
1816
|
+
* @public
|
|
1817
|
+
*/
|
|
1818
|
+
export declare interface StartChatParams extends BaseParams {
|
|
1819
|
+
history?: Content[];
|
|
1820
|
+
tools?: Tool[];
|
|
1821
|
+
toolConfig?: ToolConfig;
|
|
1822
|
+
systemInstruction?: string | Part | Content;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* Schema class for "string" types. Can be used with or without
|
|
1827
|
+
* enum values.
|
|
1828
|
+
* @public
|
|
1829
|
+
*/
|
|
1830
|
+
export declare class StringSchema extends Schema {
|
|
1831
|
+
enum?: string[];
|
|
1832
|
+
constructor(schemaParams?: SchemaParams, enumValues?: string[]);
|
|
1833
|
+
/* Excluded from this release type: toJSON */
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
/**
|
|
1837
|
+
* Content part interface if the part represents a text string.
|
|
1838
|
+
* @public
|
|
1839
|
+
*/
|
|
1840
|
+
export declare interface TextPart {
|
|
1841
|
+
text: string;
|
|
1842
|
+
inlineData?: never;
|
|
1843
|
+
functionCall?: never;
|
|
1844
|
+
functionResponse?: never;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
/**
|
|
1848
|
+
* Defines a tool that model can call to access external knowledge.
|
|
1849
|
+
* @public
|
|
1850
|
+
*/
|
|
1851
|
+
export declare type Tool = FunctionDeclarationsTool;
|
|
1852
|
+
|
|
1853
|
+
/**
|
|
1854
|
+
* Tool config. This config is shared for all tools provided in the request.
|
|
1855
|
+
* @public
|
|
1856
|
+
*/
|
|
1857
|
+
export declare interface ToolConfig {
|
|
1858
|
+
functionCallingConfig?: FunctionCallingConfig;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* A type that includes all specific Schema types.
|
|
1863
|
+
* @public
|
|
1864
|
+
*/
|
|
1865
|
+
export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema;
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Usage metadata about a {@link GenerateContentResponse}.
|
|
1869
|
+
*
|
|
1870
|
+
* @public
|
|
1871
|
+
*/
|
|
1872
|
+
export declare interface UsageMetadata {
|
|
1873
|
+
promptTokenCount: number;
|
|
1874
|
+
candidatesTokenCount: number;
|
|
1875
|
+
totalTokenCount: number;
|
|
1876
|
+
promptTokensDetails?: ModalityTokenCount[];
|
|
1877
|
+
candidatesTokensDetails?: ModalityTokenCount[];
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* @deprecated Use the new {@link AI | AI} instead. The Vertex AI in Firebase SDK has been
|
|
1882
|
+
* replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
|
|
1883
|
+
* services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
|
|
1884
|
+
*
|
|
1885
|
+
* An instance of the Firebase AI SDK.
|
|
1886
|
+
*
|
|
1887
|
+
* @public
|
|
1888
|
+
*/
|
|
1889
|
+
export declare type VertexAI = AI;
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* Configuration class for the Vertex AI Gemini API.
|
|
1893
|
+
*
|
|
1894
|
+
* Use this with {@link AIOptions} when initializing the AI service via
|
|
1895
|
+
* {@link getAI | getAI()} to specify the Vertex AI Gemini API as the backend.
|
|
1896
|
+
*
|
|
1897
|
+
* @public
|
|
1898
|
+
*/
|
|
1899
|
+
export declare class VertexAIBackend extends Backend {
|
|
1900
|
+
/**
|
|
1901
|
+
* The region identifier.
|
|
1902
|
+
* See {@link https://firebase.google.com/docs/vertex-ai/locations#available-locations | Vertex AI locations}
|
|
1903
|
+
* for a list of supported locations.
|
|
1904
|
+
*/
|
|
1905
|
+
readonly location: string;
|
|
1906
|
+
/**
|
|
1907
|
+
* Creates a configuration object for the Vertex AI backend.
|
|
1908
|
+
*
|
|
1909
|
+
* @param location - The region identifier, defaulting to `us-central1`;
|
|
1910
|
+
* see {@link https://firebase.google.com/docs/vertex-ai/locations#available-locations | Vertex AI locations}
|
|
1911
|
+
* for a list of supported locations.
|
|
1912
|
+
*/
|
|
1913
|
+
constructor(location?: string);
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
/**
|
|
1917
|
+
* @deprecated Use the new {@link AIError} instead. The Vertex AI in Firebase SDK has been
|
|
1918
|
+
* replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
|
|
1919
|
+
* services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
|
|
1920
|
+
*
|
|
1921
|
+
* Error class for the Firebase AI SDK.
|
|
1922
|
+
*
|
|
1923
|
+
* @public
|
|
1924
|
+
*/
|
|
1925
|
+
export declare const VertexAIError: typeof AIError;
|
|
1926
|
+
|
|
1927
|
+
/**
|
|
1928
|
+
* @deprecated Use the new {@link AIModel} instead. The Vertex AI in Firebase SDK has been
|
|
1929
|
+
* replaced with the Firebase AI SDK to accommodate the evolving set of supported features and
|
|
1930
|
+
* services. For migration details, see the {@link https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk | migration guide}.
|
|
1931
|
+
*
|
|
1932
|
+
* Base class for Firebase AI model APIs.
|
|
1933
|
+
*
|
|
1934
|
+
* @public
|
|
1935
|
+
*/
|
|
1936
|
+
export declare const VertexAIModel: typeof AIModel;
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* Options when initializing the Firebase AI SDK.
|
|
1940
|
+
*
|
|
1941
|
+
* @public
|
|
1942
|
+
*/
|
|
1943
|
+
export declare interface VertexAIOptions {
|
|
1944
|
+
location?: string;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
/**
|
|
1948
|
+
* Describes the input video content.
|
|
1949
|
+
* @public
|
|
1950
|
+
*/
|
|
1951
|
+
export declare interface VideoMetadata {
|
|
1952
|
+
/**
|
|
1953
|
+
* The start offset of the video in
|
|
1954
|
+
* protobuf {@link https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping | Duration} format.
|
|
1955
|
+
*/
|
|
1956
|
+
startOffset: string;
|
|
1957
|
+
/**
|
|
1958
|
+
* The end offset of the video in
|
|
1959
|
+
* protobuf {@link https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping | Duration} format.
|
|
1960
|
+
*/
|
|
1961
|
+
endOffset: string;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
/**
|
|
1965
|
+
* @public
|
|
1966
|
+
*/
|
|
1967
|
+
export declare interface WebAttribution {
|
|
1968
|
+
uri: string;
|
|
1969
|
+
title: string;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
export { }
|