@firebase/ai 2.11.1 → 2.12.0-20260505164105
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 +358 -9
- package/dist/ai.d.ts +386 -12
- package/dist/esm/index.esm.js +375 -223
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/methods/live-session.d.ts +40 -5
- package/dist/esm/src/models/live-generative-model.d.ts +6 -4
- package/dist/esm/src/models/template-generative-model.d.ts +7 -3
- package/dist/esm/src/types/enums.d.ts +80 -0
- package/dist/esm/src/types/live-responses.d.ts +3 -1
- package/dist/esm/src/types/requests.d.ts +148 -2
- package/dist/esm/src/types/responses.d.ts +69 -2
- package/dist/index.cjs.js +376 -222
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +376 -222
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +375 -223
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/methods/live-session.d.ts +40 -5
- package/dist/src/models/live-generative-model.d.ts +6 -4
- package/dist/src/models/template-generative-model.d.ts +7 -3
- package/dist/src/types/enums.d.ts +80 -0
- package/dist/src/types/live-responses.d.ts +3 -1
- package/dist/src/types/requests.d.ts +148 -2
- package/dist/src/types/responses.d.ts +69 -2
- package/package.json +9 -9
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { FunctionResponse, GenerativeContentBlob, LiveServerContent, LiveServerGoingAwayNotice, LiveServerToolCall, LiveServerToolCallCancellation, Part } from '../public-types';
|
|
17
|
+
import { FunctionResponse, GenerativeContentBlob, LiveServerContent, LiveServerGoingAwayNotice, LiveServerToolCall, LiveServerToolCallCancellation, LiveSessionResumptionUpdate, Part, SessionResumptionConfig } from '../public-types';
|
|
18
18
|
import { WebSocketHandler } from '../websocket';
|
|
19
|
+
import { _LiveClientSetup } from '../types/live-responses';
|
|
20
|
+
import { ApiSettings } from '../types/internal';
|
|
19
21
|
/**
|
|
20
22
|
* Represents an active, real-time, bidirectional conversation with the model.
|
|
21
23
|
*
|
|
@@ -24,8 +26,9 @@ import { WebSocketHandler } from '../websocket';
|
|
|
24
26
|
* @beta
|
|
25
27
|
*/
|
|
26
28
|
export declare class LiveSession {
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
+
private _setupMessage;
|
|
30
|
+
private _apiSettings;
|
|
31
|
+
private _sessionResumption?;
|
|
29
32
|
/**
|
|
30
33
|
* Indicates whether this Live session is closed.
|
|
31
34
|
*
|
|
@@ -39,9 +42,41 @@ export declare class LiveSession {
|
|
|
39
42
|
*/
|
|
40
43
|
inConversation: boolean;
|
|
41
44
|
/**
|
|
45
|
+
* Allows external code to await the opening of the WebSocket connection.
|
|
46
|
+
*/
|
|
47
|
+
connectionPromise: Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Generator yielding WebSocket messages from the server.
|
|
50
|
+
*/
|
|
51
|
+
private _serverMessages;
|
|
52
|
+
/**
|
|
53
|
+
* WebSocket handler. Injectable for testing.
|
|
54
|
+
*/
|
|
55
|
+
private _webSocketHandler;
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
constructor(_setupMessage: _LiveClientSetup, _apiSettings: ApiSettings, _sessionResumption?: SessionResumptionConfig | undefined, webSocketHandler?: WebSocketHandler);
|
|
60
|
+
/**
|
|
61
|
+
* Initializes connection to the WebSocket. Should be called immediately
|
|
62
|
+
* after instantiation.
|
|
63
|
+
*
|
|
42
64
|
* @internal
|
|
43
65
|
*/
|
|
44
|
-
|
|
66
|
+
private _connectSession;
|
|
67
|
+
/**
|
|
68
|
+
* Resumes an existing live session with the server.
|
|
69
|
+
*
|
|
70
|
+
* This closes the current WebSocket connection and establishes a new one using
|
|
71
|
+
* the same configuration (URI, headers, model, system instruction, tools, etc.)
|
|
72
|
+
* as the original session.
|
|
73
|
+
*
|
|
74
|
+
* @param sessionResumption - The configuration for session resumption, such as the handle to the previous session state to restore.
|
|
75
|
+
* @throws If the session resumption configuration is unsupported.
|
|
76
|
+
*
|
|
77
|
+
* @beta
|
|
78
|
+
*/
|
|
79
|
+
resumeSession(sessionResumption?: SessionResumptionConfig): Promise<void>;
|
|
45
80
|
/**
|
|
46
81
|
* Sends content to the server.
|
|
47
82
|
*
|
|
@@ -121,7 +156,7 @@ export declare class LiveSession {
|
|
|
121
156
|
*
|
|
122
157
|
* @beta
|
|
123
158
|
*/
|
|
124
|
-
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice>;
|
|
159
|
+
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice | LiveSessionResumptionUpdate>;
|
|
125
160
|
/**
|
|
126
161
|
* Closes this session.
|
|
127
162
|
* All methods on this session will throw an error once this resolves.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { AIModel } from './ai-model';
|
|
18
18
|
import { LiveSession } from '../methods/live-session';
|
|
19
|
-
import { AI, Content, LiveGenerationConfig, LiveModelParams, Tool, ToolConfig } from '../public-types';
|
|
19
|
+
import { AI, Content, LiveGenerationConfig, LiveModelParams, SessionResumptionConfig, Tool, ToolConfig } from '../public-types';
|
|
20
20
|
import { WebSocketHandler } from '../websocket';
|
|
21
21
|
/**
|
|
22
22
|
* Class for Live generative model APIs. The Live API enables low-latency, two-way multimodal
|
|
@@ -28,9 +28,10 @@ import { WebSocketHandler } from '../websocket';
|
|
|
28
28
|
*/
|
|
29
29
|
export declare class LiveGenerativeModel extends AIModel {
|
|
30
30
|
/**
|
|
31
|
+
* For testing injection
|
|
31
32
|
* @internal
|
|
32
33
|
*/
|
|
33
|
-
private _webSocketHandler
|
|
34
|
+
private _webSocketHandler?;
|
|
34
35
|
generationConfig: LiveGenerationConfig;
|
|
35
36
|
tools?: Tool[];
|
|
36
37
|
toolConfig?: ToolConfig;
|
|
@@ -40,9 +41,10 @@ export declare class LiveGenerativeModel extends AIModel {
|
|
|
40
41
|
*/
|
|
41
42
|
constructor(ai: AI, modelParams: LiveModelParams,
|
|
42
43
|
/**
|
|
44
|
+
* For testing injection
|
|
43
45
|
* @internal
|
|
44
46
|
*/
|
|
45
|
-
_webSocketHandler
|
|
47
|
+
_webSocketHandler?: WebSocketHandler | undefined);
|
|
46
48
|
/**
|
|
47
49
|
* Starts a {@link LiveSession}.
|
|
48
50
|
*
|
|
@@ -51,5 +53,5 @@ export declare class LiveGenerativeModel extends AIModel {
|
|
|
51
53
|
*
|
|
52
54
|
* @beta
|
|
53
55
|
*/
|
|
54
|
-
connect(): Promise<LiveSession>;
|
|
56
|
+
connect(sessionResumption?: SessionResumptionConfig): Promise<LiveSession>;
|
|
55
57
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { GenerateContentResult, RequestOptions } from '../types';
|
|
18
|
-
import { AI, GenerateContentStreamResult, SingleRequestOptions, StartTemplateChatParams, TemplateChatSession } from '../public-types';
|
|
18
|
+
import { AI, GenerateContentStreamResult, SingleRequestOptions, StartTemplateChatParams, TemplateChatSession, TemplateToolConfig } from '../public-types';
|
|
19
19
|
import { ApiSettings } from '../types/internal';
|
|
20
20
|
/**
|
|
21
21
|
* {@link GenerativeModel} APIs that execute on a server-side template.
|
|
@@ -44,10 +44,12 @@ export declare class TemplateGenerativeModel {
|
|
|
44
44
|
* @param templateId - The ID of the server-side template to execute.
|
|
45
45
|
* @param templateVariables - A key-value map of variables to populate the
|
|
46
46
|
* template with.
|
|
47
|
+
* @param singleRequestOptions - Optional. Options to use for this request.
|
|
48
|
+
* @param templateToolConfig - Optional. Configuration for tools to use with this request.
|
|
47
49
|
*
|
|
48
50
|
* @beta
|
|
49
51
|
*/
|
|
50
|
-
generateContent(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;
|
|
52
|
+
generateContent(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions, templateToolConfig?: TemplateToolConfig): Promise<GenerateContentResult>;
|
|
51
53
|
/**
|
|
52
54
|
* Makes a single streaming call to the model and returns an object
|
|
53
55
|
* containing an iterable stream that iterates over all chunks in the
|
|
@@ -57,10 +59,12 @@ export declare class TemplateGenerativeModel {
|
|
|
57
59
|
* @param templateId - The ID of the server-side template to execute.
|
|
58
60
|
* @param templateVariables - A key-value map of variables to populate the
|
|
59
61
|
* template with.
|
|
62
|
+
* @param singleRequestOptions - Optional.Options to use for this request.
|
|
63
|
+
* @param templateToolConfig - Optional. Configuration for tools to use with this request.
|
|
60
64
|
*
|
|
61
65
|
* @beta
|
|
62
66
|
*/
|
|
63
|
-
generateContentStream(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;
|
|
67
|
+
generateContentStream(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions, templateToolConfig?: TemplateToolConfig): Promise<GenerateContentStreamResult>;
|
|
64
68
|
/**
|
|
65
69
|
* Starts a {@link TemplateChatSession} that will use this template to
|
|
66
70
|
* respond to messages.
|
|
@@ -221,12 +221,92 @@ export declare const FinishReason: {
|
|
|
221
221
|
* The function call generated by the model was invalid.
|
|
222
222
|
*/
|
|
223
223
|
readonly MALFORMED_FUNCTION_CALL: "MALFORMED_FUNCTION_CALL";
|
|
224
|
+
/**
|
|
225
|
+
* Token generation stopped because generated images contain safety violations.
|
|
226
|
+
*/
|
|
227
|
+
readonly IMAGE_SAFETY: "IMAGE_SAFETY";
|
|
228
|
+
/**
|
|
229
|
+
* Image generation stopped because generated images have other prohibited content.
|
|
230
|
+
*/
|
|
231
|
+
readonly IMAGE_PROHIBITED_CONTENT: "IMAGE_PROHIBITED_CONTENT";
|
|
232
|
+
/**
|
|
233
|
+
* Image generation stopped because of other miscellaneous issue.
|
|
234
|
+
*/
|
|
235
|
+
readonly IMAGE_OTHER: "IMAGE_OTHER";
|
|
236
|
+
/**
|
|
237
|
+
* The model was expected to generate an image, but none was generated.
|
|
238
|
+
*/
|
|
239
|
+
readonly NO_IMAGE: "NO_IMAGE";
|
|
240
|
+
/**
|
|
241
|
+
* Image generation stopped due to recitation.
|
|
242
|
+
*/
|
|
243
|
+
readonly IMAGE_RECITATION: "IMAGE_RECITATION";
|
|
244
|
+
/**
|
|
245
|
+
* The response candidate content was flagged for using an unsupported language.
|
|
246
|
+
*/
|
|
247
|
+
readonly LANGUAGE: "LANGUAGE";
|
|
248
|
+
/**
|
|
249
|
+
* Model generated a tool call but no tools were enabled in the request.
|
|
250
|
+
*/
|
|
251
|
+
readonly UNEXPECTED_TOOL_CALL: "UNEXPECTED_TOOL_CALL";
|
|
252
|
+
/**
|
|
253
|
+
* Model called too many tools consecutively, thus the system exited execution.
|
|
254
|
+
*/
|
|
255
|
+
readonly TOO_MANY_TOOL_CALLS: "TOO_MANY_TOOL_CALLS";
|
|
256
|
+
/**
|
|
257
|
+
* Request has at least one thought signature missing.
|
|
258
|
+
*/
|
|
259
|
+
readonly MISSING_THOUGHT_SIGNATURE: "MISSING_THOUGHT_SIGNATURE";
|
|
260
|
+
/**
|
|
261
|
+
* Finished due to malformed response.
|
|
262
|
+
*/
|
|
263
|
+
readonly MALFORMED_RESPONSE: "MALFORMED_RESPONSE";
|
|
224
264
|
};
|
|
225
265
|
/**
|
|
226
266
|
* Reason that a candidate finished.
|
|
227
267
|
* @public
|
|
228
268
|
*/
|
|
229
269
|
export type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
|
|
270
|
+
/**
|
|
271
|
+
* Aspect ratios for generated images.
|
|
272
|
+
* @public
|
|
273
|
+
*/
|
|
274
|
+
export declare const ImageConfigAspectRatio: {
|
|
275
|
+
readonly SQUARE_1x1: "1:1";
|
|
276
|
+
readonly PORTRAIT_9x16: "9:16";
|
|
277
|
+
readonly LANDSCAPE_16x9: "16:9";
|
|
278
|
+
readonly PORTRAIT_3x4: "3:4";
|
|
279
|
+
readonly LANDSCAPE_4x3: "4:3";
|
|
280
|
+
readonly PORTRAIT_2x3: "2:3";
|
|
281
|
+
readonly LANDSCAPE_3x2: "3:2";
|
|
282
|
+
readonly PORTRAIT_4x5: "4:5";
|
|
283
|
+
readonly LANDSCAPE_5x4: "5:4";
|
|
284
|
+
readonly PORTRAIT_1x4: "1:4";
|
|
285
|
+
readonly LANDSCAPE_4x1: "4:1";
|
|
286
|
+
readonly PORTRAIT_1x8: "1:8";
|
|
287
|
+
readonly LANDSCAPE_8x1: "8:1";
|
|
288
|
+
readonly ULTRAWIDE_21x9: "21:9";
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Aspect ratios for generated images.
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
export type ImageConfigAspectRatio = (typeof ImageConfigAspectRatio)[keyof typeof ImageConfigAspectRatio];
|
|
295
|
+
/**
|
|
296
|
+
* Sizes for generated images. For example, '1K' is 1024px, '2K' is 2048px, and '4K' is 4096px.
|
|
297
|
+
* @public
|
|
298
|
+
*/
|
|
299
|
+
export declare const ImageConfigImageSize: {
|
|
300
|
+
readonly SIZE_512: "512";
|
|
301
|
+
readonly SIZE_1K: "1K";
|
|
302
|
+
readonly SIZE_2K: "2K";
|
|
303
|
+
readonly SIZE_4K: "4K";
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Sizes for generated images.
|
|
307
|
+
* @public
|
|
308
|
+
*/
|
|
309
|
+
export type ImageConfigImageSize = (typeof ImageConfigImageSize)[keyof typeof ImageConfigImageSize];
|
|
230
310
|
/**
|
|
231
311
|
* @public
|
|
232
312
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { Content, FunctionResponse, GenerativeContentBlob, Part } from './content';
|
|
18
|
-
import { AudioTranscriptionConfig, LiveGenerationConfig, Tool, ToolConfig } from './requests';
|
|
18
|
+
import { AudioTranscriptionConfig, ContextWindowCompressionConfig, LiveGenerationConfig, SessionResumptionConfig, Tool, ToolConfig } from './requests';
|
|
19
19
|
import { Transcription } from './responses';
|
|
20
20
|
/**
|
|
21
21
|
* User input that is sent to the model.
|
|
@@ -68,6 +68,8 @@ export interface _LiveClientSetup {
|
|
|
68
68
|
systemInstruction?: string | Part | Content;
|
|
69
69
|
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
70
70
|
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
71
|
+
sessionResumption?: SessionResumptionConfig;
|
|
72
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { ObjectSchema, TypedSchema } from '../requests/schema-builder';
|
|
18
18
|
import { Content, Part } from './content';
|
|
19
19
|
import { LanguageModelCreateOptions, LanguageModelPromptOptions } from './language-model';
|
|
20
|
-
import { FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, HarmCategory, InferenceMode, ResponseModality, ThinkingLevel } from './enums';
|
|
20
|
+
import { FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, HarmCategory, ImageConfigAspectRatio, ImageConfigImageSize, InferenceMode, ResponseModality, ThinkingLevel } from './enums';
|
|
21
21
|
import { ObjectSchemaRequest, SchemaRequest } from './schema';
|
|
22
22
|
/**
|
|
23
23
|
* Base parameters for a number of methods.
|
|
@@ -92,6 +92,20 @@ export interface SafetySetting {
|
|
|
92
92
|
*/
|
|
93
93
|
method?: HarmBlockMethod;
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Configuration options for generating images with Gemini models.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export interface ImageConfig {
|
|
100
|
+
/**
|
|
101
|
+
* The aspect ratio of generated images.
|
|
102
|
+
*/
|
|
103
|
+
aspectRatio?: ImageConfigAspectRatio;
|
|
104
|
+
/**
|
|
105
|
+
* The size of the generated images.
|
|
106
|
+
*/
|
|
107
|
+
imageSize?: ImageConfigImageSize;
|
|
108
|
+
}
|
|
95
109
|
/**
|
|
96
110
|
* Config options for content-related requests
|
|
97
111
|
* @public
|
|
@@ -145,6 +159,11 @@ export interface GenerationConfig {
|
|
|
145
159
|
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
146
160
|
*/
|
|
147
161
|
thinkingConfig?: ThinkingConfig;
|
|
162
|
+
/**
|
|
163
|
+
* Configuration options for generating images with Gemini models.
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
imageConfig?: ImageConfig;
|
|
148
167
|
}
|
|
149
168
|
/**
|
|
150
169
|
* Configuration parameters used by {@link LiveGenerativeModel} to control live content generation.
|
|
@@ -213,6 +232,66 @@ export interface LiveGenerationConfig {
|
|
|
213
232
|
* "How are you today?", the model may transcribe that output across three messages, broken up as "How a", "re yo", "u today?".
|
|
214
233
|
*/
|
|
215
234
|
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
235
|
+
/**
|
|
236
|
+
* The context window compression configuration.
|
|
237
|
+
*
|
|
238
|
+
* @beta
|
|
239
|
+
*/
|
|
240
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Configures the sliding window context compression mechanism.
|
|
244
|
+
*
|
|
245
|
+
* @remarks
|
|
246
|
+
* The sliding window discards content at the beginning of the
|
|
247
|
+
* context window. The resulting context will always begin at
|
|
248
|
+
* the start of a `user` role turn. System instructions
|
|
249
|
+
* will always remain at the start of the result.
|
|
250
|
+
*
|
|
251
|
+
* @beta
|
|
252
|
+
*/
|
|
253
|
+
export interface SlidingWindow {
|
|
254
|
+
/**
|
|
255
|
+
* The session reduction target, for example, how many tokens the model
|
|
256
|
+
* should keep.
|
|
257
|
+
*/
|
|
258
|
+
targetTokens?: number;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Enables context window compression to manage the model's context window.
|
|
262
|
+
*
|
|
263
|
+
* @remarks
|
|
264
|
+
* This mechanism prevents the context from exceeding a given length.
|
|
265
|
+
*
|
|
266
|
+
* @beta
|
|
267
|
+
*/
|
|
268
|
+
export interface ContextWindowCompressionConfig {
|
|
269
|
+
/**
|
|
270
|
+
* The number of tokens (before running a turn) that triggers the context
|
|
271
|
+
* window compression.
|
|
272
|
+
*/
|
|
273
|
+
triggerTokens?: number;
|
|
274
|
+
/**
|
|
275
|
+
* The sliding window compression mechanism.
|
|
276
|
+
*/
|
|
277
|
+
slidingWindow?: SlidingWindow;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Configuration for the session resumption mechanism.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* When included in the session setup, the server will send
|
|
284
|
+
* {@link LiveSessionResumptionUpdate} messages in the response stream.
|
|
285
|
+
*
|
|
286
|
+
* @beta
|
|
287
|
+
*/
|
|
288
|
+
export interface SessionResumptionConfig {
|
|
289
|
+
/**
|
|
290
|
+
* The session resumption handle of the previous session to restore.
|
|
291
|
+
*
|
|
292
|
+
* If not present, a new session will be started.
|
|
293
|
+
*/
|
|
294
|
+
handle?: string;
|
|
216
295
|
}
|
|
217
296
|
/**
|
|
218
297
|
* Params for {@link GenerativeModel.startChat}.
|
|
@@ -328,7 +407,7 @@ export interface SingleRequestOptions extends RequestOptions {
|
|
|
328
407
|
* Defines a tool that model can call to access external knowledge.
|
|
329
408
|
* @public
|
|
330
409
|
*/
|
|
331
|
-
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
|
|
410
|
+
export type Tool = FunctionDeclarationsTool | GoogleMapsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
|
|
332
411
|
/**
|
|
333
412
|
* Structured representation of a function declaration as defined by the
|
|
334
413
|
* {@link https://spec.openapis.org/oas/v3.0.3 | OpenAPI 3.0 specification}.
|
|
@@ -385,6 +464,28 @@ export interface GoogleSearchTool {
|
|
|
385
464
|
*/
|
|
386
465
|
googleSearch: GoogleSearch;
|
|
387
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* A tool that allows a Gemini model to connect to Google Maps to access and incorporate
|
|
469
|
+
* location-based information into its responses.
|
|
470
|
+
*
|
|
471
|
+
* Important: If using Grounding with Google Maps, you are required to comply with the
|
|
472
|
+
* "Grounding with Google Maps" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-maps | Gemini Developer API}
|
|
473
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
474
|
+
* section within the Service Specific Terms).
|
|
475
|
+
*
|
|
476
|
+
* @public
|
|
477
|
+
*/
|
|
478
|
+
export interface GoogleMapsTool {
|
|
479
|
+
/**
|
|
480
|
+
* Specifies the Google Maps configuration.
|
|
481
|
+
*
|
|
482
|
+
* When using this feature, you are required to comply with the "Grounding with Google Maps"
|
|
483
|
+
* usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-maps | Gemini Developer API}
|
|
484
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
485
|
+
* section within the Service Specific Terms).
|
|
486
|
+
*/
|
|
487
|
+
googleMaps: GoogleMaps;
|
|
488
|
+
}
|
|
388
489
|
/**
|
|
389
490
|
* A tool that enables the model to use code execution.
|
|
390
491
|
*
|
|
@@ -405,6 +506,14 @@ export interface CodeExecutionTool {
|
|
|
405
506
|
*/
|
|
406
507
|
export interface GoogleSearch {
|
|
407
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Specifies the Google Maps configuration.
|
|
511
|
+
*
|
|
512
|
+
* @public
|
|
513
|
+
*/
|
|
514
|
+
export interface GoogleMaps {
|
|
515
|
+
enableWidget?: boolean;
|
|
516
|
+
}
|
|
408
517
|
/**
|
|
409
518
|
* A tool that allows you to provide additional context to the models in the form of public web
|
|
410
519
|
* URLs. By including URLs in your request, the Gemini model will access the content from those
|
|
@@ -444,6 +553,20 @@ export interface FunctionDeclarationsTool {
|
|
|
444
553
|
*/
|
|
445
554
|
functionDeclarations?: FunctionDeclaration[];
|
|
446
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* An object that represents a latitude/longitude pair.
|
|
558
|
+
* @public
|
|
559
|
+
*/
|
|
560
|
+
export interface LatLng {
|
|
561
|
+
/**
|
|
562
|
+
* The latitude in degrees. It must be in the range `[-90.0, +90.0]`.
|
|
563
|
+
*/
|
|
564
|
+
latitude?: number;
|
|
565
|
+
/**
|
|
566
|
+
* The longitude in degrees. It must be in the range `[-180.0, +180.0]`.
|
|
567
|
+
*/
|
|
568
|
+
longitude?: number;
|
|
569
|
+
}
|
|
447
570
|
/**
|
|
448
571
|
* Structured representation of a template function declaration.
|
|
449
572
|
* Included in this declaration are the function name and parameters. This
|
|
@@ -516,6 +639,15 @@ export type TemplateTool = TemplateFunctionDeclarationsTool;
|
|
|
516
639
|
*/
|
|
517
640
|
export interface ToolConfig {
|
|
518
641
|
functionCallingConfig?: FunctionCallingConfig;
|
|
642
|
+
retrievalConfig?: RetrievalConfig;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Tool configuration for `TemplateGenerativeModel`s.
|
|
646
|
+
* This config is shared for all tools provided in the server prompt template request.
|
|
647
|
+
* @public
|
|
648
|
+
*/
|
|
649
|
+
export interface TemplateToolConfig {
|
|
650
|
+
retrievalConfig?: RetrievalConfig;
|
|
519
651
|
}
|
|
520
652
|
/**
|
|
521
653
|
* @public
|
|
@@ -524,6 +656,20 @@ export interface FunctionCallingConfig {
|
|
|
524
656
|
mode?: FunctionCallingMode;
|
|
525
657
|
allowedFunctionNames?: string[];
|
|
526
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* Configuration options for data retrieval tools.
|
|
661
|
+
* @public
|
|
662
|
+
*/
|
|
663
|
+
export interface RetrievalConfig {
|
|
664
|
+
/**
|
|
665
|
+
* The location of the user.
|
|
666
|
+
*/
|
|
667
|
+
latLng?: LatLng;
|
|
668
|
+
/**
|
|
669
|
+
* The language code of the user.
|
|
670
|
+
*/
|
|
671
|
+
languageCode?: string;
|
|
672
|
+
}
|
|
527
673
|
/**
|
|
528
674
|
* Encapsulates configuration for on-device inference.
|
|
529
675
|
*
|
|
@@ -203,13 +203,19 @@ export interface Citation {
|
|
|
203
203
|
/**
|
|
204
204
|
* Metadata returned when grounding is enabled.
|
|
205
205
|
*
|
|
206
|
-
* Currently, only Grounding with Google Search
|
|
206
|
+
* Currently, only Grounding with Google Search and Grounding with Google Maps are supported
|
|
207
|
+
* (see {@link GoogleSearchTool} and {@link GoogleMapsTool}, respectively).
|
|
207
208
|
*
|
|
208
209
|
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
209
210
|
* "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}
|
|
210
211
|
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
211
212
|
* section within the Service Specific Terms).
|
|
212
213
|
*
|
|
214
|
+
* Important: If using Grounding with Google Maps, you are required to comply with the
|
|
215
|
+
* "Grounding with Google Maps" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-maps | Gemini Developer API}
|
|
216
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
217
|
+
* section within the Service Specific Terms).
|
|
218
|
+
*
|
|
213
219
|
* @public
|
|
214
220
|
*/
|
|
215
221
|
export interface GroundingMetadata {
|
|
@@ -238,6 +244,12 @@ export interface GroundingMetadata {
|
|
|
238
244
|
* @deprecated Use {@link GroundingSupport} instead.
|
|
239
245
|
*/
|
|
240
246
|
retrievalQueries?: string[];
|
|
247
|
+
/**
|
|
248
|
+
* Resource name of the Google Maps widget context token that can be used with the
|
|
249
|
+
* `PlacesContextElement` widget in order to render contextual data. Only populated in the case
|
|
250
|
+
* that grounding with Google Maps is enabled.
|
|
251
|
+
*/
|
|
252
|
+
googleMapsWidgetContextToken?: string;
|
|
241
253
|
}
|
|
242
254
|
/**
|
|
243
255
|
* Google search entry point.
|
|
@@ -273,6 +285,10 @@ export interface GroundingChunk {
|
|
|
273
285
|
* Contains details if the grounding chunk is from a web source.
|
|
274
286
|
*/
|
|
275
287
|
web?: WebGroundingChunk;
|
|
288
|
+
/**
|
|
289
|
+
* Contains details if the grounding chunk is from a Google Maps source.
|
|
290
|
+
*/
|
|
291
|
+
maps?: GoogleMapsGroundingChunk;
|
|
276
292
|
}
|
|
277
293
|
/**
|
|
278
294
|
* A grounding chunk from the web.
|
|
@@ -300,6 +316,33 @@ export interface WebGroundingChunk {
|
|
|
300
316
|
*/
|
|
301
317
|
domain?: string;
|
|
302
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* A grounding chunk from Google Maps.
|
|
321
|
+
*
|
|
322
|
+
* Important: If using Grounding with Google Maps, you are required to comply with the
|
|
323
|
+
* {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Maps".
|
|
324
|
+
*
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
export interface GoogleMapsGroundingChunk {
|
|
328
|
+
/**
|
|
329
|
+
* The URI of the place.
|
|
330
|
+
*/
|
|
331
|
+
uri?: string;
|
|
332
|
+
/**
|
|
333
|
+
* The title of the place.
|
|
334
|
+
*/
|
|
335
|
+
title?: string;
|
|
336
|
+
/**
|
|
337
|
+
* The text of the place answer.
|
|
338
|
+
*/
|
|
339
|
+
text?: string;
|
|
340
|
+
/**
|
|
341
|
+
* This Place's resource name, in `places/{place_id}` format. This can be used to look up the
|
|
342
|
+
* place in the Google Maps API.
|
|
343
|
+
*/
|
|
344
|
+
placeId?: string;
|
|
345
|
+
}
|
|
303
346
|
/**
|
|
304
347
|
* Provides information about how a specific segment of the model's response is supported by the
|
|
305
348
|
* retrieved grounding chunks.
|
|
@@ -336,7 +379,7 @@ export interface Segment {
|
|
|
336
379
|
/**
|
|
337
380
|
* The zero-based start index of the segment within the specified `Part`,
|
|
338
381
|
* measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
|
|
339
|
-
* beginning of the part's content (
|
|
382
|
+
* beginning of the part's content (for example, `Part.text`).
|
|
340
383
|
*/
|
|
341
384
|
startIndex: number;
|
|
342
385
|
/**
|
|
@@ -586,6 +629,29 @@ export interface LiveServerGoingAwayNotice {
|
|
|
586
629
|
*/
|
|
587
630
|
timeLeft: number;
|
|
588
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* An update of the session resumption state.
|
|
634
|
+
*
|
|
635
|
+
* This message is only sent if {@link SessionResumptionConfig} was set in the
|
|
636
|
+
* session setup.
|
|
637
|
+
*
|
|
638
|
+
* @beta
|
|
639
|
+
*/
|
|
640
|
+
export interface LiveSessionResumptionUpdate {
|
|
641
|
+
type: 'sessionResumptionUpdate';
|
|
642
|
+
/**
|
|
643
|
+
* The new handle that represents the state that can be resumed. Empty if `resumable` is false.
|
|
644
|
+
*/
|
|
645
|
+
newHandle?: string;
|
|
646
|
+
/**
|
|
647
|
+
* Indicates if the session can be resumed at this point.
|
|
648
|
+
*/
|
|
649
|
+
resumable?: boolean;
|
|
650
|
+
/**
|
|
651
|
+
* The index of the last client message that is included in the state represented by this update.
|
|
652
|
+
*/
|
|
653
|
+
lastConsumedClientMessageIndex?: number;
|
|
654
|
+
}
|
|
589
655
|
/**
|
|
590
656
|
* The types of responses that can be returned by {@link LiveSession.receive}.
|
|
591
657
|
*
|
|
@@ -596,6 +662,7 @@ export declare const LiveResponseType: {
|
|
|
596
662
|
TOOL_CALL: string;
|
|
597
663
|
TOOL_CALL_CANCELLATION: string;
|
|
598
664
|
GOING_AWAY_NOTICE: string;
|
|
665
|
+
SESSION_RESUMPTION_UPDATE: string;
|
|
599
666
|
};
|
|
600
667
|
/**
|
|
601
668
|
* The types of responses that can be returned by {@link LiveSession.receive}.
|