@langchain/google 0.1.0
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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/chat_models/api-types.d.cts +1506 -0
- package/dist/chat_models/api-types.d.ts +1506 -0
- package/dist/chat_models/base.cjs +445 -0
- package/dist/chat_models/base.cjs.map +1 -0
- package/dist/chat_models/base.d.cts +319 -0
- package/dist/chat_models/base.d.ts +319 -0
- package/dist/chat_models/base.js +442 -0
- package/dist/chat_models/base.js.map +1 -0
- package/dist/chat_models/index.cjs +23 -0
- package/dist/chat_models/index.cjs.map +1 -0
- package/dist/chat_models/index.d.cts +39 -0
- package/dist/chat_models/index.d.ts +39 -0
- package/dist/chat_models/index.js +22 -0
- package/dist/chat_models/index.js.map +1 -0
- package/dist/chat_models/node.cjs +35 -0
- package/dist/chat_models/node.cjs.map +1 -0
- package/dist/chat_models/node.d.cts +13 -0
- package/dist/chat_models/node.d.ts +13 -0
- package/dist/chat_models/node.js +34 -0
- package/dist/chat_models/node.js.map +1 -0
- package/dist/chat_models/profiles.cjs +373 -0
- package/dist/chat_models/profiles.cjs.map +1 -0
- package/dist/chat_models/profiles.js +372 -0
- package/dist/chat_models/profiles.js.map +1 -0
- package/dist/chat_models/types.d.cts +250 -0
- package/dist/chat_models/types.d.ts +250 -0
- package/dist/clients/index.cjs +219 -0
- package/dist/clients/index.cjs.map +1 -0
- package/dist/clients/index.d.cts +49 -0
- package/dist/clients/index.d.ts +49 -0
- package/dist/clients/index.js +217 -0
- package/dist/clients/index.js.map +1 -0
- package/dist/clients/node.cjs +327 -0
- package/dist/clients/node.cjs.map +1 -0
- package/dist/clients/node.d.cts +59 -0
- package/dist/clients/node.d.ts +59 -0
- package/dist/clients/node.js +325 -0
- package/dist/clients/node.js.map +1 -0
- package/dist/const.cjs +13 -0
- package/dist/const.cjs.map +1 -0
- package/dist/const.js +9 -0
- package/dist/const.js.map +1 -0
- package/dist/converters/messages.cjs +697 -0
- package/dist/converters/messages.cjs.map +1 -0
- package/dist/converters/messages.js +691 -0
- package/dist/converters/messages.js.map +1 -0
- package/dist/converters/params.cjs +205 -0
- package/dist/converters/params.cjs.map +1 -0
- package/dist/converters/params.js +202 -0
- package/dist/converters/params.js.map +1 -0
- package/dist/converters/tools.cjs +356 -0
- package/dist/converters/tools.cjs.map +1 -0
- package/dist/converters/tools.js +353 -0
- package/dist/converters/tools.js.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/node.cjs +7 -0
- package/dist/node.d.cts +3 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.js +4 -0
- package/dist/utils/errors.cjs +543 -0
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/errors.js +535 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gcp-auth.cjs +188 -0
- package/dist/utils/gcp-auth.cjs.map +1 -0
- package/dist/utils/gcp-auth.d.cts +43 -0
- package/dist/utils/gcp-auth.d.ts +43 -0
- package/dist/utils/gcp-auth.js +186 -0
- package/dist/utils/gcp-auth.js.map +1 -0
- package/dist/utils/handler.cjs +67 -0
- package/dist/utils/handler.cjs.map +1 -0
- package/dist/utils/handler.d.cts +34 -0
- package/dist/utils/handler.d.ts +34 -0
- package/dist/utils/handler.js +64 -0
- package/dist/utils/handler.js.map +1 -0
- package/dist/utils/misc.cjs +10 -0
- package/dist/utils/misc.cjs.map +1 -0
- package/dist/utils/misc.d.cts +14 -0
- package/dist/utils/misc.d.ts +14 -0
- package/dist/utils/misc.js +9 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/stream.cjs +26 -0
- package/dist/utils/stream.cjs.map +1 -0
- package/dist/utils/stream.js +25 -0
- package/dist/utils/stream.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,1506 @@
|
|
|
1
|
+
//#region src/chat_models/api-types.d.ts
|
|
2
|
+
declare namespace Gemini {
|
|
3
|
+
/**
|
|
4
|
+
* Safety setting, affecting the safety-blocking behavior.
|
|
5
|
+
*
|
|
6
|
+
* Passing a safety setting for a category changes the allowed probability that
|
|
7
|
+
* content is blocked.
|
|
8
|
+
*/
|
|
9
|
+
interface SafetySetting {
|
|
10
|
+
/** Required. The category for this setting. */
|
|
11
|
+
category: HarmCategory;
|
|
12
|
+
/**
|
|
13
|
+
* Required. Controls the probability threshold at which harm is blocked.
|
|
14
|
+
*/
|
|
15
|
+
threshold: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF" | (string & {});
|
|
16
|
+
}
|
|
17
|
+
type HarmCategory = "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_DEROGATORY" | "HARM_CATEGORY_TOXICITY" | "HARM_CATEGORY_VIOLENCE" | "HARM_CATEGORY_SEXUAL" | "HARM_CATEGORY_MEDICAL" | "HARM_CATEGORY_DANGEROUS" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_CIVIC_INTEGRITY" | (string & {});
|
|
18
|
+
/** Config for thinking features. */
|
|
19
|
+
interface ThinkingConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Indicates whether to include thoughts in the response.
|
|
22
|
+
* If true, thoughts are returned only when available.
|
|
23
|
+
*/
|
|
24
|
+
includeThoughts?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The number of thoughts tokens that the model should generate.
|
|
27
|
+
*/
|
|
28
|
+
thinkingBudget?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Optional. Controls the maximum depth of the model's internal reasoning process before
|
|
31
|
+
* it produces a response. If not specified, the default is HIGH. Recommended
|
|
32
|
+
* for Gemini 3 or later models. Use with earlier models results in an error.
|
|
33
|
+
*/
|
|
34
|
+
thinkingLevel?: "THINKING_LEVEL_UNSPECIFIED" | "MINIMAL" | "LOW" | "MEDIUM" | "HIGH" | (string & {});
|
|
35
|
+
}
|
|
36
|
+
type GenerativeLanguageModality = "MODALITY_UNSPECIFIED" | "TEXT" | "IMAGE" | "VIDEO" | "AUDIO" | "DOCUMENT" | (string & {});
|
|
37
|
+
/** Media resolution for the input media. */
|
|
38
|
+
interface MediaResolution {
|
|
39
|
+
level?: "MEDIA_RESOLUTION_UNSPECIFIED" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_HIGH" | "MEDIA_RESOLUTION_ULTRA_HIGH" | (string & {});
|
|
40
|
+
}
|
|
41
|
+
/** Config for speech generation and transcription. */
|
|
42
|
+
interface SpeechConfig {
|
|
43
|
+
/**
|
|
44
|
+
* Optional. The IETF [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language
|
|
45
|
+
* code that the user configured the app to use. Used for speech recognition
|
|
46
|
+
* and synthesis.
|
|
47
|
+
*
|
|
48
|
+
* Valid values are: `de-DE`, `en-AU`, `en-GB`, `en-IN`, `en-US`, `es-US`,
|
|
49
|
+
* `fr-FR`, `hi-IN`, `pt-BR`, `ar-XA`, `es-ES`, `fr-CA`, `id-ID`, `it-IT`,
|
|
50
|
+
* `ja-JP`, `tr-TR`, `vi-VN`, `bn-IN`, `gu-IN`, `kn-IN`, `ml-IN`, `mr-IN`,
|
|
51
|
+
* `ta-IN`, `te-IN`, `nl-NL`, `ko-KR`, `cmn-CN`, `pl-PL`, `ru-RU`, and
|
|
52
|
+
* `th-TH`.
|
|
53
|
+
*/
|
|
54
|
+
languageCode?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Optional. The configuration for the multi-speaker setup.
|
|
57
|
+
* It is mutually exclusive with the voice_config field.
|
|
58
|
+
*/
|
|
59
|
+
multiSpeakerVoiceConfig?: MultiSpeakerVoiceConfig;
|
|
60
|
+
/** The configuration in case of single-voice output. */
|
|
61
|
+
voiceConfig?: VoiceConfig;
|
|
62
|
+
}
|
|
63
|
+
/** The configuration for the voice to use. */
|
|
64
|
+
interface VoiceConfig {
|
|
65
|
+
/** The configuration for the prebuilt voice to use. */
|
|
66
|
+
prebuiltVoiceConfig?: PrebuiltVoiceConfig;
|
|
67
|
+
}
|
|
68
|
+
/** The configuration for the multi-speaker setup. */
|
|
69
|
+
interface MultiSpeakerVoiceConfig {
|
|
70
|
+
/** Required. All the enabled speaker voices. */
|
|
71
|
+
speakerVoiceConfigs: Array<SpeakerVoiceConfig>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The configuration for a single speaker in a multi speaker setup.
|
|
75
|
+
*/
|
|
76
|
+
interface SpeakerVoiceConfig {
|
|
77
|
+
/**
|
|
78
|
+
* Required. The name of the speaker to use. Should be the same as in the prompt.
|
|
79
|
+
*/
|
|
80
|
+
speaker: string;
|
|
81
|
+
/** Required. The configuration for the voice to use. */
|
|
82
|
+
voiceConfig: VoiceConfig;
|
|
83
|
+
}
|
|
84
|
+
/** Config for image generation features. */
|
|
85
|
+
interface ImageConfig {
|
|
86
|
+
/**
|
|
87
|
+
* Optional. The aspect ratio of the image to generate. Supported aspect ratios: `1:1`,
|
|
88
|
+
* `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, or `21:9`.
|
|
89
|
+
*
|
|
90
|
+
* If not specified, the model will choose a default aspect ratio based on any
|
|
91
|
+
* reference images provided.
|
|
92
|
+
*/
|
|
93
|
+
aspectRatio?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Optional. Specifies the size of generated images. Supported values are `1K`, `2K`,
|
|
96
|
+
* `4K`. If not specified, the model will use default value `1K`.
|
|
97
|
+
*/
|
|
98
|
+
imageSize?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A datatype containing media that is part of a multi-part `Content` message.
|
|
102
|
+
*
|
|
103
|
+
* A `Part` consists of data which has an associated datatype. A `Part` can only
|
|
104
|
+
* contain one of the accepted types in `Part.data`.
|
|
105
|
+
*
|
|
106
|
+
* A `Part` must have a fixed IANA MIME type identifying the type and subtype
|
|
107
|
+
* of the media if the `inline_data` field is filled with raw bytes.
|
|
108
|
+
*/
|
|
109
|
+
interface Part {
|
|
110
|
+
/** Result of executing the `ExecutableCode`. */
|
|
111
|
+
codeExecutionResult?: CodeExecutionResult;
|
|
112
|
+
/** Code generated by the model that is meant to be executed. */
|
|
113
|
+
executableCode?: ExecutableCode;
|
|
114
|
+
/** URI based data. */
|
|
115
|
+
fileData?: FileData;
|
|
116
|
+
/**
|
|
117
|
+
* A predicted `FunctionCall` returned from the model that contains
|
|
118
|
+
* a string representing the `FunctionDeclaration.name` with the
|
|
119
|
+
* arguments and their values.
|
|
120
|
+
*/
|
|
121
|
+
functionCall?: FunctionCall;
|
|
122
|
+
/**
|
|
123
|
+
* The result output of a `FunctionCall` that contains a string
|
|
124
|
+
* representing the `FunctionDeclaration.name` and a structured JSON
|
|
125
|
+
* object containing any output from the function is used as context to
|
|
126
|
+
* the model.
|
|
127
|
+
*/
|
|
128
|
+
functionResponse?: FunctionResponse;
|
|
129
|
+
/** Inline media bytes. */
|
|
130
|
+
inlineData?: Blob;
|
|
131
|
+
/** Optional. Media resolution for the input media. */
|
|
132
|
+
mediaResolution?: MediaResolution;
|
|
133
|
+
/**
|
|
134
|
+
* Custom metadata associated with the Part.
|
|
135
|
+
* Agents using genai.Part as content representation may need to keep track
|
|
136
|
+
* of the additional information. For example it can be name of a file/source
|
|
137
|
+
* from which the Part originates or a way to multiplex multiple Part streams.
|
|
138
|
+
*/
|
|
139
|
+
partMetadata?: Record<string, unknown>;
|
|
140
|
+
/** Inline text. */
|
|
141
|
+
text?: string;
|
|
142
|
+
/** Optional. Indicates if the part is thought from the model. */
|
|
143
|
+
thought?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Optional. An opaque signature for the thought so it can be reused in subsequent
|
|
146
|
+
* requests.
|
|
147
|
+
*/
|
|
148
|
+
thoughtSignature?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Optional. Video metadata. The metadata should only be specified while the video
|
|
151
|
+
* data is presented in inline_data or file_data.
|
|
152
|
+
*/
|
|
153
|
+
videoMetadata?: VideoMetadata;
|
|
154
|
+
}
|
|
155
|
+
/** Metadata describes the input video content. */
|
|
156
|
+
interface VideoMetadata {
|
|
157
|
+
/** Optional. The end offset of the video. */
|
|
158
|
+
endOffset?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Optional. The frame rate of the video sent to the model. If not specified, the
|
|
161
|
+
* default value will be 1.0.
|
|
162
|
+
* The fps range is (0.0, 24.0].
|
|
163
|
+
*/
|
|
164
|
+
fps?: number;
|
|
165
|
+
/** Optional. The start offset of the video. */
|
|
166
|
+
startOffset?: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Result of executing the `ExecutableCode`.
|
|
170
|
+
*
|
|
171
|
+
* Only generated when using the `CodeExecution`, and always follows a `part`
|
|
172
|
+
* containing the `ExecutableCode`.
|
|
173
|
+
*/
|
|
174
|
+
interface CodeExecutionResult {
|
|
175
|
+
/** Required. Outcome of the code execution. */
|
|
176
|
+
outcome: "OUTCOME_UNSPECIFIED" | "OUTCOME_OK" | "OUTCOME_FAILED" | "OUTCOME_DEADLINE_EXCEEDED" | (string & {});
|
|
177
|
+
/**
|
|
178
|
+
* Optional. Contains stdout when code execution is successful, stderr or other
|
|
179
|
+
* description otherwise.
|
|
180
|
+
*/
|
|
181
|
+
output?: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Code generated by the model that is meant to be executed, and the result
|
|
185
|
+
* returned to the model.
|
|
186
|
+
*
|
|
187
|
+
* Only generated when using the `CodeExecution` tool, in which the code will
|
|
188
|
+
* be automatically executed, and a corresponding `CodeExecutionResult` will
|
|
189
|
+
* also be generated.
|
|
190
|
+
*/
|
|
191
|
+
interface ExecutableCode {
|
|
192
|
+
/** Required. The code to be executed. */
|
|
193
|
+
code: string;
|
|
194
|
+
/** Required. Programming language of the `code`. */
|
|
195
|
+
language: "LANGUAGE_UNSPECIFIED" | "PYTHON" | (string & {});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The base structured datatype containing multi-part content of a message.
|
|
199
|
+
*
|
|
200
|
+
* A `Content` includes a `role` field designating the producer of the `Content`
|
|
201
|
+
* and a `parts` field containing multi-part data that contains the content of
|
|
202
|
+
* the message turn.
|
|
203
|
+
*/
|
|
204
|
+
interface Content {
|
|
205
|
+
/**
|
|
206
|
+
* Ordered `Parts` that constitute a single message. Parts may have different
|
|
207
|
+
* MIME types.
|
|
208
|
+
*/
|
|
209
|
+
parts?: Array<Part>;
|
|
210
|
+
/**
|
|
211
|
+
* Optional. The producer of the content. Must be either 'user' or 'model'.
|
|
212
|
+
*
|
|
213
|
+
* Useful to set for multi-turn conversations, otherwise can be left blank
|
|
214
|
+
* or unset.
|
|
215
|
+
*/
|
|
216
|
+
role?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Configuration options for model generation and outputs. Not all parameters
|
|
220
|
+
* are configurable for every model.
|
|
221
|
+
*/
|
|
222
|
+
interface GenerationConfig {
|
|
223
|
+
/**
|
|
224
|
+
* Optional. Output schema of the generated response. This is an alternative to
|
|
225
|
+
* `response_schema` that accepts [JSON Schema](https://json-schema.org/).
|
|
226
|
+
*
|
|
227
|
+
* If set, `response_schema` must be omitted, but `response_mime_type` is
|
|
228
|
+
* required.
|
|
229
|
+
*
|
|
230
|
+
* While the full JSON Schema may be sent, not all features are supported.
|
|
231
|
+
* Specifically, only the following properties are supported:
|
|
232
|
+
*
|
|
233
|
+
* - `$id`
|
|
234
|
+
* - `$defs`
|
|
235
|
+
* - `$ref`
|
|
236
|
+
* - `$anchor`
|
|
237
|
+
* - `type`
|
|
238
|
+
* - `format`
|
|
239
|
+
* - `title`
|
|
240
|
+
* - `description`
|
|
241
|
+
* - `enum` (for strings and numbers)
|
|
242
|
+
* - `items`
|
|
243
|
+
* - `prefixItems`
|
|
244
|
+
* - `minItems`
|
|
245
|
+
* - `maxItems`
|
|
246
|
+
* - `minimum`
|
|
247
|
+
* - `maximum`
|
|
248
|
+
* - `anyOf`
|
|
249
|
+
* - `oneOf` (interpreted the same as `anyOf`)
|
|
250
|
+
* - `properties`
|
|
251
|
+
* - `additionalProperties`
|
|
252
|
+
* - `required`
|
|
253
|
+
*
|
|
254
|
+
* The non-standard `propertyOrdering` property may also be set.
|
|
255
|
+
*
|
|
256
|
+
* Cyclic references are unrolled to a limited degree and, as such, may only
|
|
257
|
+
* be used within non-required properties. (Nullable properties are not
|
|
258
|
+
* sufficient.) If `$ref` is set on a sub-schema, no other properties, except
|
|
259
|
+
* for than those starting as a `$`, may be set.
|
|
260
|
+
*/
|
|
261
|
+
_responseJsonSchema?: unknown;
|
|
262
|
+
/**
|
|
263
|
+
* Optional. Number of generated responses to return. If unset, this will default
|
|
264
|
+
* to 1. Please note that this doesn't work for previous generation
|
|
265
|
+
* models (Gemini 1.0 family)
|
|
266
|
+
*/
|
|
267
|
+
candidateCount?: number;
|
|
268
|
+
/**
|
|
269
|
+
* Optional. Enables enhanced civic answers. It may not be available for all models.
|
|
270
|
+
*/
|
|
271
|
+
enableEnhancedCivicAnswers?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Optional. Frequency penalty applied to the next token's logprobs, multiplied by the
|
|
274
|
+
* number of times each token has been seen in the respponse so far.
|
|
275
|
+
*
|
|
276
|
+
* A positive penalty will discourage the use of tokens that have already
|
|
277
|
+
* been used, proportional to the number of times the token has been used:
|
|
278
|
+
* The more a token is used, the more difficult it is for the model to use
|
|
279
|
+
* that token again increasing the vocabulary of responses.
|
|
280
|
+
*
|
|
281
|
+
* Caution: A _negative_ penalty will encourage the model to reuse tokens
|
|
282
|
+
* proportional to the number of times the token has been used. Small
|
|
283
|
+
* negative values will reduce the vocabulary of a response. Larger negative
|
|
284
|
+
* values will cause the model to start repeating a common token until it
|
|
285
|
+
* hits the max_output_tokens
|
|
286
|
+
* limit.
|
|
287
|
+
*/
|
|
288
|
+
frequencyPenalty?: number;
|
|
289
|
+
/**
|
|
290
|
+
* Optional. Config for image generation.
|
|
291
|
+
* An error will be returned if this field is set for models that don't
|
|
292
|
+
* support these config options.
|
|
293
|
+
*/
|
|
294
|
+
imageConfig?: ImageConfig;
|
|
295
|
+
/**
|
|
296
|
+
* Optional. Only valid if response_logprobs=True.
|
|
297
|
+
* This sets the number of top logprobs to return at each decoding step in the
|
|
298
|
+
* Candidate.logprobs_result. The number must be in the range of [0, 20].
|
|
299
|
+
*/
|
|
300
|
+
logprobs?: number;
|
|
301
|
+
/**
|
|
302
|
+
* Optional. The maximum number of tokens to include in a response candidate.
|
|
303
|
+
*
|
|
304
|
+
* Note: The default value varies by model, see the `Model.output_token_limit`
|
|
305
|
+
* attribute of the `Model` returned from the `getModel` function.
|
|
306
|
+
*/
|
|
307
|
+
maxOutputTokens?: number;
|
|
308
|
+
/**
|
|
309
|
+
* Optional. If specified, the media resolution specified will be used.
|
|
310
|
+
*/
|
|
311
|
+
mediaResolution?: "MEDIA_RESOLUTION_UNSPECIFIED" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_HIGH" | (string & {});
|
|
312
|
+
/**
|
|
313
|
+
* Optional. Presence penalty applied to the next token's logprobs if the token has
|
|
314
|
+
* already been seen in the response.
|
|
315
|
+
*
|
|
316
|
+
* This penalty is binary on/off and not dependant on the number of times the
|
|
317
|
+
* token is used (after the first). Use
|
|
318
|
+
* frequency_penalty
|
|
319
|
+
* for a penalty that increases with each use.
|
|
320
|
+
*
|
|
321
|
+
* A positive penalty will discourage the use of tokens that have already
|
|
322
|
+
* been used in the response, increasing the vocabulary.
|
|
323
|
+
*
|
|
324
|
+
* A negative penalty will encourage the use of tokens that have already been
|
|
325
|
+
* used in the response, decreasing the vocabulary.
|
|
326
|
+
*/
|
|
327
|
+
presencePenalty?: number;
|
|
328
|
+
/**
|
|
329
|
+
* Optional. An internal detail. Use `responseJsonSchema` rather than this field.
|
|
330
|
+
*/
|
|
331
|
+
responseJsonSchema?: unknown;
|
|
332
|
+
/** Optional. If true, export the logprobs results in response. */
|
|
333
|
+
responseLogprobs?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Optional. MIME type of the generated candidate text.
|
|
336
|
+
* Supported MIME types are:
|
|
337
|
+
* `text/plain`: (default) Text output.
|
|
338
|
+
* `application/json`: JSON response in the response candidates.
|
|
339
|
+
* `text/x.enum`: ENUM as a string response in the response candidates.
|
|
340
|
+
* Refer to the
|
|
341
|
+
* [docs](https://ai.google.dev/gemini-api/docs/prompting_with_media#plain_text_formats)
|
|
342
|
+
* for a list of all supported text MIME types.
|
|
343
|
+
*/
|
|
344
|
+
responseMimeType?: string;
|
|
345
|
+
/**
|
|
346
|
+
* Optional. The requested modalities of the response. Represents the set of modalities
|
|
347
|
+
* that the model can return, and should be expected in the response. This is
|
|
348
|
+
* an exact match to the modalities of the response.
|
|
349
|
+
*
|
|
350
|
+
* A model may have multiple combinations of supported modalities. If the
|
|
351
|
+
* requested modalities do not match any of the supported combinations, an
|
|
352
|
+
* error will be returned.
|
|
353
|
+
*
|
|
354
|
+
* An empty list is equivalent to requesting only text.
|
|
355
|
+
*/
|
|
356
|
+
responseModalities?: Array<"MODALITY_UNSPECIFIED" | "TEXT" | "IMAGE" | "AUDIO" | (string & {})>;
|
|
357
|
+
/**
|
|
358
|
+
* Optional. Output schema of the generated candidate text. Schemas must be a
|
|
359
|
+
* subset of the [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema)
|
|
360
|
+
* and can be objects, primitives or arrays.
|
|
361
|
+
*
|
|
362
|
+
* If set, a compatible `response_mime_type` must also be set.
|
|
363
|
+
* Compatible MIME types:
|
|
364
|
+
* `application/json`: Schema for JSON response.
|
|
365
|
+
* Refer to the [JSON text generation
|
|
366
|
+
* guide](https://ai.google.dev/gemini-api/docs/json-mode) for more details.
|
|
367
|
+
*/
|
|
368
|
+
responseSchema?: Gemini.Tools.Schema;
|
|
369
|
+
/**
|
|
370
|
+
* Optional. Seed used in decoding. If not set, the request uses a randomly generated
|
|
371
|
+
* seed.
|
|
372
|
+
*/
|
|
373
|
+
seed?: number;
|
|
374
|
+
/** Optional. The speech generation config. */
|
|
375
|
+
speechConfig?: SpeechConfig;
|
|
376
|
+
/**
|
|
377
|
+
* Optional. The set of character sequences (up to 5) that will stop output generation.
|
|
378
|
+
* If specified, the API will stop at the first appearance of a
|
|
379
|
+
* `stop_sequence`. The stop sequence will not be included as part of the
|
|
380
|
+
* response.
|
|
381
|
+
*/
|
|
382
|
+
stopSequences?: Array<string>;
|
|
383
|
+
/**
|
|
384
|
+
* Optional. Controls the randomness of the output.
|
|
385
|
+
*
|
|
386
|
+
* Note: The default value varies by model, see the `Model.temperature`
|
|
387
|
+
* attribute of the `Model` returned from the `getModel` function.
|
|
388
|
+
*
|
|
389
|
+
* Values can range from [0.0, 2.0].
|
|
390
|
+
*/
|
|
391
|
+
temperature?: number;
|
|
392
|
+
/**
|
|
393
|
+
* Optional. Config for thinking features.
|
|
394
|
+
* An error will be returned if this field is set for models that don't
|
|
395
|
+
* support thinking.
|
|
396
|
+
*/
|
|
397
|
+
thinkingConfig?: ThinkingConfig;
|
|
398
|
+
/**
|
|
399
|
+
* Optional. The maximum number of tokens to consider when sampling.
|
|
400
|
+
*
|
|
401
|
+
* Gemini models use Top-p (nucleus) sampling or a combination of Top-k and
|
|
402
|
+
* nucleus sampling. Top-k sampling considers the set of `top_k` most probable
|
|
403
|
+
* tokens. Models running with nucleus sampling don't allow top_k setting.
|
|
404
|
+
*
|
|
405
|
+
* Note: The default value varies by `Model` and is specified by
|
|
406
|
+
* the`Model.top_p` attribute returned from the `getModel` function. An empty
|
|
407
|
+
* `top_k` attribute indicates that the model doesn't apply top-k sampling
|
|
408
|
+
* and doesn't allow setting `top_k` on requests.
|
|
409
|
+
*/
|
|
410
|
+
topK?: number;
|
|
411
|
+
/**
|
|
412
|
+
* Optional. The maximum cumulative probability of tokens to consider when sampling.
|
|
413
|
+
*
|
|
414
|
+
* The model uses combined Top-k and Top-p (nucleus) sampling.
|
|
415
|
+
*
|
|
416
|
+
* Tokens are sorted based on their assigned probabilities so that only the
|
|
417
|
+
* most likely tokens are considered. Top-k sampling directly limits the
|
|
418
|
+
* maximum number of tokens to consider, while Nucleus sampling limits the
|
|
419
|
+
* number of tokens based on the cumulative probability.
|
|
420
|
+
*
|
|
421
|
+
* Note: The default value varies by `Model` and is specified by
|
|
422
|
+
* the`Model.top_p` attribute returned from the `getModel` function. An empty
|
|
423
|
+
* `top_k` attribute indicates that the model doesn't apply top-k sampling
|
|
424
|
+
* and doesn't allow setting `top_k` on requests.
|
|
425
|
+
*/
|
|
426
|
+
topP?: number;
|
|
427
|
+
}
|
|
428
|
+
namespace Tools {
|
|
429
|
+
/**
|
|
430
|
+
* Structured representation of a function declaration as defined by the
|
|
431
|
+
* [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included
|
|
432
|
+
* in this declaration are the function name and parameters. This
|
|
433
|
+
* FunctionDeclaration is a representation of a block of code that can be used
|
|
434
|
+
* as a `Tool` by the model and executed by the client.
|
|
435
|
+
*/
|
|
436
|
+
interface FunctionDeclaration {
|
|
437
|
+
/**
|
|
438
|
+
* Optional. Specifies the function Behavior.
|
|
439
|
+
* Currently only supported by the BidiGenerateContent method.
|
|
440
|
+
*/
|
|
441
|
+
behavior?: "UNSPECIFIED" | "BLOCKING" | "NON_BLOCKING" | (string & {});
|
|
442
|
+
/** Required. A brief description of the function. */
|
|
443
|
+
description: string;
|
|
444
|
+
/**
|
|
445
|
+
* Required. The name of the function.
|
|
446
|
+
* Must be a-z, A-Z, 0-9, or contain underscores, colons, dots, and dashes,
|
|
447
|
+
* with a maximum length of 64.
|
|
448
|
+
*/
|
|
449
|
+
name: string;
|
|
450
|
+
/**
|
|
451
|
+
* Optional. Describes the parameters to this function. Reflects the Open API 3.03
|
|
452
|
+
* Parameter Object string Key: the name of the parameter. Parameter names are
|
|
453
|
+
* case sensitive. Schema Value: the Schema defining the type used for the
|
|
454
|
+
* parameter.
|
|
455
|
+
*/
|
|
456
|
+
parameters?: Schema;
|
|
457
|
+
/**
|
|
458
|
+
* Optional. Describes the parameters to the function in JSON Schema format. The schema
|
|
459
|
+
* must describe an object where the properties are the parameters to the
|
|
460
|
+
* function. For example:
|
|
461
|
+
*
|
|
462
|
+
* ```
|
|
463
|
+
* {
|
|
464
|
+
* "type": "object",
|
|
465
|
+
* "properties": {
|
|
466
|
+
* "name": { "type": "string" },
|
|
467
|
+
* "age": { "type": "integer" }
|
|
468
|
+
* },
|
|
469
|
+
* "additionalProperties": false,
|
|
470
|
+
* "required": ["name", "age"],
|
|
471
|
+
* "propertyOrdering": ["name", "age"]
|
|
472
|
+
* }
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* This field is mutually exclusive with `parameters`.
|
|
476
|
+
*/
|
|
477
|
+
parametersJsonSchema?: unknown;
|
|
478
|
+
/**
|
|
479
|
+
* Optional. Describes the output from this function in JSON Schema format. Reflects the
|
|
480
|
+
* Open API 3.03 Response Object. The Schema defines the type used for the
|
|
481
|
+
* response value of the function.
|
|
482
|
+
*/
|
|
483
|
+
response?: Schema;
|
|
484
|
+
/**
|
|
485
|
+
* Optional. Describes the output from this function in JSON Schema format. The value
|
|
486
|
+
* specified by the schema is the response value of the function.
|
|
487
|
+
*
|
|
488
|
+
* This field is mutually exclusive with `response`.
|
|
489
|
+
*/
|
|
490
|
+
responseJsonSchema?: unknown;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* GoogleSearch tool type.
|
|
494
|
+
* Tool to support Google Search in Model. Powered by Google.
|
|
495
|
+
*/
|
|
496
|
+
interface GoogleSearch {
|
|
497
|
+
/**
|
|
498
|
+
* Optional. Filter search results to a specific time range.
|
|
499
|
+
* If customers set a start time, they must set an end time (and vice
|
|
500
|
+
* versa).
|
|
501
|
+
*/
|
|
502
|
+
timeRangeFilter?: Interval;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Tool that executes code generated by the model, and automatically returns
|
|
506
|
+
* the result to the model.
|
|
507
|
+
*
|
|
508
|
+
* See also `ExecutableCode` and `CodeExecutionResult` which are only generated
|
|
509
|
+
* when using this tool.
|
|
510
|
+
*/
|
|
511
|
+
interface CodeExecution {}
|
|
512
|
+
/** Tool to support URL context retrieval. */
|
|
513
|
+
interface UrlContext {}
|
|
514
|
+
/**
|
|
515
|
+
* The GoogleMaps Tool that provides geospatial context for the user's query.
|
|
516
|
+
*/
|
|
517
|
+
interface GoogleMaps {
|
|
518
|
+
/**
|
|
519
|
+
* Optional. Whether to return a widget context token in the GroundingMetadata of the
|
|
520
|
+
* response. Developers can use the widget context token to render a Google
|
|
521
|
+
* Maps widget with geospatial context related to the places that the model
|
|
522
|
+
* references in the response.
|
|
523
|
+
*/
|
|
524
|
+
enableWidget?: boolean;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora.
|
|
528
|
+
* Files are imported to Semantic Retrieval corpora using the ImportFile API.
|
|
529
|
+
*/
|
|
530
|
+
interface FileSearch {
|
|
531
|
+
/**
|
|
532
|
+
* Required. The names of the file_search_stores to retrieve from.
|
|
533
|
+
* Example: `fileSearchStores/my-file-search-store-123`
|
|
534
|
+
*/
|
|
535
|
+
fileSearchStoreNames: Array<string>;
|
|
536
|
+
/**
|
|
537
|
+
* Optional. Metadata filter to apply to the semantic retrieval documents and chunks.
|
|
538
|
+
*/
|
|
539
|
+
metadataFilter?: string;
|
|
540
|
+
/**
|
|
541
|
+
* Optional. The number of semantic retrieval chunks to retrieve.
|
|
542
|
+
*/
|
|
543
|
+
topK?: number;
|
|
544
|
+
}
|
|
545
|
+
/** Computer Use tool type. */
|
|
546
|
+
interface ComputerUse {
|
|
547
|
+
/** Required. The environment being operated. */
|
|
548
|
+
environment: "ENVIRONMENT_UNSPECIFIED" | "ENVIRONMENT_BROWSER" | (string & {});
|
|
549
|
+
/**
|
|
550
|
+
* Optional. By default, predefined functions are included in the final model
|
|
551
|
+
* call.
|
|
552
|
+
* Some of them can be explicitly excluded from being automatically
|
|
553
|
+
* included. This can serve two purposes:
|
|
554
|
+
* 1. Using a more restricted / different action space.
|
|
555
|
+
* 2. Improving the definitions / instructions of predefined functions.
|
|
556
|
+
*/
|
|
557
|
+
excludedPredefinedFunctions?: Array<string>;
|
|
558
|
+
}
|
|
559
|
+
/** Configuration for specifying function calling behavior. */
|
|
560
|
+
interface FunctionCallingConfig {
|
|
561
|
+
/**
|
|
562
|
+
* Optional. A set of function names that, when provided, limits the functions the model
|
|
563
|
+
* will call.
|
|
564
|
+
*
|
|
565
|
+
* This should only be set when the Mode is ANY or VALIDATED. Function names
|
|
566
|
+
* should match [FunctionDeclaration.name]. When set, model will
|
|
567
|
+
* predict a function call from only allowed function names.
|
|
568
|
+
*/
|
|
569
|
+
allowedFunctionNames?: Array<string>;
|
|
570
|
+
/**
|
|
571
|
+
* Optional. Specifies the mode in which function calling should execute. If
|
|
572
|
+
* unspecified, the default value will be set to AUTO.
|
|
573
|
+
*/
|
|
574
|
+
mode?: "MODE_UNSPECIFIED" | "AUTO" | "ANY" | "NONE" | "VALIDATED" | (string & {});
|
|
575
|
+
}
|
|
576
|
+
/** Retrieval config. */
|
|
577
|
+
interface RetrievalConfig {
|
|
578
|
+
/**
|
|
579
|
+
* Optional. The language code of the user.
|
|
580
|
+
* Language code for content. Use language tags defined by
|
|
581
|
+
* [BCP47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt).
|
|
582
|
+
*/
|
|
583
|
+
languageCode?: string;
|
|
584
|
+
/** Optional. The location of the user. */
|
|
585
|
+
latLng?: LatLng;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* The Tool configuration containing parameters for specifying `Tool` use
|
|
589
|
+
* in the request.
|
|
590
|
+
*/
|
|
591
|
+
interface ToolConfig {
|
|
592
|
+
/** Optional. Function calling config. */
|
|
593
|
+
functionCallingConfig?: FunctionCallingConfig;
|
|
594
|
+
/** Optional. Retrieval config. */
|
|
595
|
+
retrievalConfig?: RetrievalConfig;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* The `Schema` object allows the definition of input and output data types.
|
|
599
|
+
* These types can be objects, but also primitives and arrays.
|
|
600
|
+
* Represents a select subset of an [OpenAPI 3.0 schema
|
|
601
|
+
* object](https://spec.openapis.org/oas/v3.0.3#schema).
|
|
602
|
+
*/
|
|
603
|
+
interface Schema {
|
|
604
|
+
/**
|
|
605
|
+
* Optional. The value should be validated against any (one or more) of the subschemas
|
|
606
|
+
* in the list.
|
|
607
|
+
*/
|
|
608
|
+
anyOf?: Array<Schema>;
|
|
609
|
+
/**
|
|
610
|
+
* Optional. Default value of the field. Per JSON Schema, this field is intended for
|
|
611
|
+
* documentation generators and doesn't affect validation. Thus it's included
|
|
612
|
+
* here and ignored so that developers who send schemas with a `default` field
|
|
613
|
+
* don't get unknown-field errors.
|
|
614
|
+
*/
|
|
615
|
+
default?: unknown;
|
|
616
|
+
/**
|
|
617
|
+
* Optional. A brief description of the parameter. This could contain examples of use.
|
|
618
|
+
* Parameter description may be formatted as Markdown.
|
|
619
|
+
*/
|
|
620
|
+
description?: string;
|
|
621
|
+
/**
|
|
622
|
+
* Optional. Possible values of the element of Type.STRING with enum format.
|
|
623
|
+
* For example we can define an Enum Direction as :
|
|
624
|
+
* {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]}
|
|
625
|
+
*/
|
|
626
|
+
enum?: Array<string>;
|
|
627
|
+
/**
|
|
628
|
+
* Optional. Example of the object. Will only populated when the object is the root.
|
|
629
|
+
*/
|
|
630
|
+
example?: unknown;
|
|
631
|
+
/**
|
|
632
|
+
* Optional. The format of the data. Any value is allowed, but most do not trigger any
|
|
633
|
+
* special functionality.
|
|
634
|
+
*/
|
|
635
|
+
format?: string;
|
|
636
|
+
/** Optional. Schema of the elements of Type.ARRAY. */
|
|
637
|
+
items?: Schema;
|
|
638
|
+
/** Optional. Maximum number of the elements for Type.ARRAY. */
|
|
639
|
+
maxItems?: string;
|
|
640
|
+
/** Optional. Maximum length of the Type.STRING */
|
|
641
|
+
maxLength?: string;
|
|
642
|
+
/** Optional. Maximum number of the properties for Type.OBJECT. */
|
|
643
|
+
maxProperties?: string;
|
|
644
|
+
/** Optional. Maximum value of the Type.INTEGER and Type.NUMBER */
|
|
645
|
+
maximum?: number;
|
|
646
|
+
/** Optional. Minimum number of the elements for Type.ARRAY. */
|
|
647
|
+
minItems?: string;
|
|
648
|
+
/**
|
|
649
|
+
* Optional. SCHEMA FIELDS FOR TYPE STRING
|
|
650
|
+
* Minimum length of the Type.STRING
|
|
651
|
+
*/
|
|
652
|
+
minLength?: string;
|
|
653
|
+
/** Optional. Minimum number of the properties for Type.OBJECT. */
|
|
654
|
+
minProperties?: string;
|
|
655
|
+
/**
|
|
656
|
+
* Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER
|
|
657
|
+
* Minimum value of the Type.INTEGER and Type.NUMBER
|
|
658
|
+
*/
|
|
659
|
+
minimum?: number;
|
|
660
|
+
/** Optional. Indicates if the value may be null. */
|
|
661
|
+
nullable?: boolean;
|
|
662
|
+
/**
|
|
663
|
+
* Optional. Pattern of the Type.STRING to restrict a string to a regular expression.
|
|
664
|
+
*/
|
|
665
|
+
pattern?: string;
|
|
666
|
+
/** Optional. Properties of Type.OBJECT. */
|
|
667
|
+
properties?: Record<string, unknown>;
|
|
668
|
+
/**
|
|
669
|
+
* Optional. The order of the properties.
|
|
670
|
+
* Not a standard field in open api spec. Used to determine the order of the
|
|
671
|
+
* properties in the response.
|
|
672
|
+
*/
|
|
673
|
+
propertyOrdering?: Array<string>;
|
|
674
|
+
/** Optional. Required properties of Type.OBJECT. */
|
|
675
|
+
required?: Array<string>;
|
|
676
|
+
/** Optional. The title of the schema. */
|
|
677
|
+
title?: string;
|
|
678
|
+
/** Required. Data type. */
|
|
679
|
+
type: Type;
|
|
680
|
+
}
|
|
681
|
+
type Type = "TYPE_UNSPECIFIED" | "STRING" | "NUMBER" | "INTEGER" | "BOOLEAN" | "ARRAY" | "OBJECT" | "NULL" | (string & {});
|
|
682
|
+
/**
|
|
683
|
+
* Represents a time interval, encoded as a Timestamp start (inclusive) and a
|
|
684
|
+
* Timestamp end (exclusive).
|
|
685
|
+
*
|
|
686
|
+
* The start must be less than or equal to the end.
|
|
687
|
+
* When the start equals the end, the interval is empty (matches no time).
|
|
688
|
+
* When both start and end are unspecified, the interval matches any time.
|
|
689
|
+
*/
|
|
690
|
+
interface Interval {
|
|
691
|
+
/**
|
|
692
|
+
* Optional. Exclusive end of the interval.
|
|
693
|
+
*
|
|
694
|
+
* If specified, a Timestamp matching this interval will have to be before the
|
|
695
|
+
* end.
|
|
696
|
+
*/
|
|
697
|
+
endTime?: string;
|
|
698
|
+
/**
|
|
699
|
+
* Optional. Inclusive start of the interval.
|
|
700
|
+
*
|
|
701
|
+
* If specified, a Timestamp matching this interval will have to be the same
|
|
702
|
+
* or after the start.
|
|
703
|
+
*/
|
|
704
|
+
startTime?: string;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* An object that represents a latitude/longitude pair. This is expressed as a
|
|
708
|
+
* pair of doubles to represent degrees latitude and degrees longitude. Unless
|
|
709
|
+
* specified otherwise, this object must conform to the
|
|
710
|
+
* WGS84 standard. Values must be within normalized ranges.
|
|
711
|
+
*/
|
|
712
|
+
interface LatLng {
|
|
713
|
+
/**
|
|
714
|
+
* The latitude in degrees. It must be in the range [-90.0, +90.0].
|
|
715
|
+
*/
|
|
716
|
+
latitude?: number;
|
|
717
|
+
/**
|
|
718
|
+
* The longitude in degrees. It must be in the range [-180.0, +180.0].
|
|
719
|
+
*/
|
|
720
|
+
longitude?: number;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/** Request to generate a completion from the model. */
|
|
724
|
+
interface GenerateContentRequest {
|
|
725
|
+
/**
|
|
726
|
+
* Optional. The name of the content
|
|
727
|
+
* [cached](https://ai.google.dev/gemini-api/docs/caching) to use as context
|
|
728
|
+
* to serve the prediction. Format: `cachedContents/{cachedContent}`
|
|
729
|
+
*/
|
|
730
|
+
cachedContent?: string;
|
|
731
|
+
/**
|
|
732
|
+
* Required. The content of the current conversation with the model.
|
|
733
|
+
*
|
|
734
|
+
* For single-turn queries, this is a single instance. For multi-turn queries
|
|
735
|
+
* like [chat](https://ai.google.dev/gemini-api/docs/text-generation#chat),
|
|
736
|
+
* this is a repeated field that contains the conversation history and the
|
|
737
|
+
* latest request.
|
|
738
|
+
*/
|
|
739
|
+
contents: Array<Content>;
|
|
740
|
+
/**
|
|
741
|
+
* Optional. Configuration options for model generation and outputs.
|
|
742
|
+
*/
|
|
743
|
+
generationConfig?: GenerationConfig;
|
|
744
|
+
/**
|
|
745
|
+
* Required. The name of the `Model` to use for generating the completion.
|
|
746
|
+
*
|
|
747
|
+
* Format: `models/{model}`.
|
|
748
|
+
*/
|
|
749
|
+
model: string;
|
|
750
|
+
/**
|
|
751
|
+
* Optional. A list of unique `SafetySetting` instances for blocking unsafe content.
|
|
752
|
+
*
|
|
753
|
+
* This will be enforced on the `GenerateContentRequest.contents` and
|
|
754
|
+
* `GenerateContentResponse.candidates`. There should not be more than one
|
|
755
|
+
* setting for each `SafetyCategory` type. The API will block any contents and
|
|
756
|
+
* responses that fail to meet the thresholds set by these settings. This list
|
|
757
|
+
* overrides the default settings for each `SafetyCategory` specified in the
|
|
758
|
+
* safety_settings. If there is no `SafetySetting` for a given
|
|
759
|
+
* `SafetyCategory` provided in the list, the API will use the default safety
|
|
760
|
+
* setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH,
|
|
761
|
+
* HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT,
|
|
762
|
+
* HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY are supported.
|
|
763
|
+
* Refer to the [guide](https://ai.google.dev/gemini-api/docs/safety-settings)
|
|
764
|
+
* for detailed information on available safety settings. Also refer to the
|
|
765
|
+
* [Safety guidance](https://ai.google.dev/gemini-api/docs/safety-guidance) to
|
|
766
|
+
* learn how to incorporate safety considerations in your AI applications.
|
|
767
|
+
*/
|
|
768
|
+
safetySettings?: Array<SafetySetting>;
|
|
769
|
+
/**
|
|
770
|
+
* Optional. Developer set [system
|
|
771
|
+
* instruction(s)](https://ai.google.dev/gemini-api/docs/system-instructions).
|
|
772
|
+
* Currently, text only.
|
|
773
|
+
*/
|
|
774
|
+
systemInstruction?: Content;
|
|
775
|
+
/**
|
|
776
|
+
* Optional. Tool configuration for any `Tool` specified in the request. Refer to the
|
|
777
|
+
* [Function calling
|
|
778
|
+
* guide](https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode)
|
|
779
|
+
* for a usage example.
|
|
780
|
+
*/
|
|
781
|
+
toolConfig?: Gemini.Tools.ToolConfig;
|
|
782
|
+
/**
|
|
783
|
+
* Optional. A list of `Tools` the `Model` may use to generate the next response.
|
|
784
|
+
*
|
|
785
|
+
* A `Tool` is a piece of code that enables the system to interact with
|
|
786
|
+
* external systems to perform an action, or set of actions, outside of
|
|
787
|
+
* knowledge and scope of the `Model`. Supported `Tool`s are `Function` and
|
|
788
|
+
* `code_execution`. Refer to the [Function
|
|
789
|
+
* calling](https://ai.google.dev/gemini-api/docs/function-calling) and the
|
|
790
|
+
* [Code execution](https://ai.google.dev/gemini-api/docs/code-execution)
|
|
791
|
+
* guides to learn more.
|
|
792
|
+
*/
|
|
793
|
+
tools?: Array<Tool>;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Safety rating for a piece of content.
|
|
797
|
+
*
|
|
798
|
+
* The safety rating contains the category of harm and the
|
|
799
|
+
* harm probability level in that category for a piece of content.
|
|
800
|
+
* Content is classified for safety across a number of
|
|
801
|
+
* harm categories and the probability of the harm classification is included
|
|
802
|
+
* here.
|
|
803
|
+
*/
|
|
804
|
+
interface SafetyRating {
|
|
805
|
+
/** Was this content blocked because of this rating? */
|
|
806
|
+
blocked?: boolean;
|
|
807
|
+
/** Required. The category for this rating. */
|
|
808
|
+
category: HarmCategory;
|
|
809
|
+
/** Required. The probability of harm for this content. */
|
|
810
|
+
probability: "HARM_PROBABILITY_UNSPECIFIED" | "NEGLIGIBLE" | "LOW" | "MEDIUM" | "HIGH" | (string & {});
|
|
811
|
+
}
|
|
812
|
+
/** A collection of source attributions for a piece of content. */
|
|
813
|
+
interface CitationMetadata {
|
|
814
|
+
/** Citations to sources for a specific response. */
|
|
815
|
+
citationSources?: Array<CitationSource>;
|
|
816
|
+
}
|
|
817
|
+
/** Metadata returned to client when grounding is enabled. */
|
|
818
|
+
interface GroundingMetadata {
|
|
819
|
+
/**
|
|
820
|
+
* Optional. Resource name of the Google Maps widget context token that can be used
|
|
821
|
+
* with the PlacesContextElement widget in order to render contextual data.
|
|
822
|
+
* Only populated in the case that grounding with Google Maps is enabled.
|
|
823
|
+
*/
|
|
824
|
+
googleMapsWidgetContextToken?: string;
|
|
825
|
+
/**
|
|
826
|
+
* List of supporting references retrieved from specified grounding source.
|
|
827
|
+
* When streaming, this only contains the grounding chunks that have not been
|
|
828
|
+
* included in the grounding metadata of previous responses.
|
|
829
|
+
*/
|
|
830
|
+
groundingChunks?: Array<GroundingChunk>;
|
|
831
|
+
/** List of grounding support. */
|
|
832
|
+
groundingSupports?: Array<GoogleAiGenerativelanguageV1betaGroundingSupport>;
|
|
833
|
+
/** Metadata related to retrieval in the grounding flow. */
|
|
834
|
+
retrievalMetadata?: RetrievalMetadata;
|
|
835
|
+
/**
|
|
836
|
+
* Optional. Google search entry for the following-up web searches.
|
|
837
|
+
*/
|
|
838
|
+
searchEntryPoint?: SearchEntryPoint;
|
|
839
|
+
/** Web search queries for the following-up web search. */
|
|
840
|
+
webSearchQueries?: Array<string>;
|
|
841
|
+
}
|
|
842
|
+
/** Grounding chunk. */
|
|
843
|
+
interface GroundingChunk {
|
|
844
|
+
/** Optional. Grounding chunk from Google Maps. */
|
|
845
|
+
maps?: Maps;
|
|
846
|
+
/**
|
|
847
|
+
* Optional. Grounding chunk from context retrieved by the file search tool.
|
|
848
|
+
*/
|
|
849
|
+
retrievedContext?: RetrievedContext;
|
|
850
|
+
/** Grounding chunk from the web. */
|
|
851
|
+
web?: Web;
|
|
852
|
+
}
|
|
853
|
+
/** Chunk from context retrieved by the file search tool. */
|
|
854
|
+
interface RetrievedContext {
|
|
855
|
+
/**
|
|
856
|
+
* Optional. Name of the `FileSearchStore` containing the document.
|
|
857
|
+
* Example: `fileSearchStores/123`
|
|
858
|
+
*/
|
|
859
|
+
fileSearchStore?: string;
|
|
860
|
+
/** Optional. Text of the chunk. */
|
|
861
|
+
text?: string;
|
|
862
|
+
/** Optional. Title of the document. */
|
|
863
|
+
title?: string;
|
|
864
|
+
/** Optional. URI reference of the semantic retrieval document. */
|
|
865
|
+
uri?: string;
|
|
866
|
+
}
|
|
867
|
+
/** Grounding support. */
|
|
868
|
+
interface GoogleAiGenerativelanguageV1betaGroundingSupport {
|
|
869
|
+
/**
|
|
870
|
+
* Optional. Confidence score of the support references. Ranges from 0 to 1. 1 is the
|
|
871
|
+
* most confident. This list must have the same size as the
|
|
872
|
+
* grounding_chunk_indices.
|
|
873
|
+
*/
|
|
874
|
+
confidenceScores?: Array<number>;
|
|
875
|
+
/**
|
|
876
|
+
* Optional. A list of indices (into 'grounding_chunk' in
|
|
877
|
+
* `response.candidate.grounding_metadata`) specifying the citations
|
|
878
|
+
* associated with the claim. For instance [1,3,4] means that
|
|
879
|
+
* grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the
|
|
880
|
+
* retrieved content attributed to the claim. If the response is streaming,
|
|
881
|
+
* the grounding_chunk_indices refer to the indices across all responses.
|
|
882
|
+
* It is the client's responsibility to accumulate the grounding chunks from
|
|
883
|
+
* all responses (while maintaining the same order).
|
|
884
|
+
*/
|
|
885
|
+
groundingChunkIndices?: Array<number>;
|
|
886
|
+
/** Segment of the content this support belongs to. */
|
|
887
|
+
segment?: GoogleAiGenerativelanguageV1betaSegment;
|
|
888
|
+
}
|
|
889
|
+
/** Segment of the content. */
|
|
890
|
+
interface GoogleAiGenerativelanguageV1betaSegment {
|
|
891
|
+
/**
|
|
892
|
+
* End index in the given Part, measured in bytes. Offset from the start of
|
|
893
|
+
* the Part, exclusive, starting at zero.
|
|
894
|
+
*/
|
|
895
|
+
endIndex?: number;
|
|
896
|
+
/** The index of a Part object within its parent Content object. */
|
|
897
|
+
partIndex?: number;
|
|
898
|
+
/**
|
|
899
|
+
* Start index in the given Part, measured in bytes. Offset from the start of
|
|
900
|
+
* the Part, inclusive, starting at zero.
|
|
901
|
+
*/
|
|
902
|
+
startIndex?: number;
|
|
903
|
+
/** The text corresponding to the segment from the response. */
|
|
904
|
+
text?: string;
|
|
905
|
+
}
|
|
906
|
+
/** Metadata related to retrieval in the grounding flow. */
|
|
907
|
+
interface RetrievalMetadata {
|
|
908
|
+
/**
|
|
909
|
+
* Optional. Score indicating how likely information from google search could help
|
|
910
|
+
* answer the prompt. The score is in the range [0, 1], where 0 is the least
|
|
911
|
+
* likely and 1 is the most likely. This score is only populated when
|
|
912
|
+
* google search grounding and dynamic retrieval is enabled. It will be
|
|
913
|
+
* compared to the threshold to determine whether to trigger google search.
|
|
914
|
+
*/
|
|
915
|
+
googleSearchDynamicRetrievalScore?: number;
|
|
916
|
+
}
|
|
917
|
+
/** Identifier for a part within a `GroundingPassage`. */
|
|
918
|
+
interface GroundingPassageId {
|
|
919
|
+
/**
|
|
920
|
+
* Output only. Index of the part within the `GenerateAnswerRequest`'s
|
|
921
|
+
* `GroundingPassage.content`.
|
|
922
|
+
*/
|
|
923
|
+
readonly partIndex?: number;
|
|
924
|
+
/**
|
|
925
|
+
* Output only. ID of the passage matching the `GenerateAnswerRequest`'s
|
|
926
|
+
* `GroundingPassage.id`.
|
|
927
|
+
*/
|
|
928
|
+
readonly passageId?: string;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Identifier for a `Chunk` retrieved via Semantic Retriever specified in the
|
|
932
|
+
* `GenerateAnswerRequest` using `SemanticRetrieverConfig`.
|
|
933
|
+
*/
|
|
934
|
+
interface SemanticRetrieverChunk {
|
|
935
|
+
/**
|
|
936
|
+
* Output only. Name of the `Chunk` containing the attributed text.
|
|
937
|
+
* Example: `corpora/123/documents/abc/chunks/xyz`
|
|
938
|
+
*/
|
|
939
|
+
readonly chunk?: string;
|
|
940
|
+
/**
|
|
941
|
+
* Output only. Name of the source matching the request's
|
|
942
|
+
* `SemanticRetrieverConfig.source`. Example: `corpora/123` or
|
|
943
|
+
* `corpora/123/documents/abc`
|
|
944
|
+
*/
|
|
945
|
+
readonly source?: string;
|
|
946
|
+
}
|
|
947
|
+
/** Identifier for the source contributing to this attribution. */
|
|
948
|
+
interface AttributionSourceId {
|
|
949
|
+
/** Identifier for an inline passage. */
|
|
950
|
+
groundingPassage?: GroundingPassageId;
|
|
951
|
+
/** Identifier for a `Chunk` fetched via Semantic Retriever. */
|
|
952
|
+
semanticRetrieverChunk?: SemanticRetrieverChunk;
|
|
953
|
+
}
|
|
954
|
+
/** Attribution for a source that contributed to an answer. */
|
|
955
|
+
interface GroundingAttribution {
|
|
956
|
+
/** Grounding source content that makes up this attribution. */
|
|
957
|
+
content?: Content;
|
|
958
|
+
/**
|
|
959
|
+
* Output only. Identifier for the source contributing to this attribution.
|
|
960
|
+
*/
|
|
961
|
+
readonly sourceId?: AttributionSourceId;
|
|
962
|
+
}
|
|
963
|
+
/** Context of the a single url retrieval. */
|
|
964
|
+
interface UrlMetadata {
|
|
965
|
+
/** Retrieved url by the tool. */
|
|
966
|
+
retrievedUrl?: string;
|
|
967
|
+
/** Status of the url retrieval. */
|
|
968
|
+
urlRetrievalStatus?: "URL_RETRIEVAL_STATUS_UNSPECIFIED" | "URL_RETRIEVAL_STATUS_SUCCESS" | "URL_RETRIEVAL_STATUS_ERROR" | "URL_RETRIEVAL_STATUS_PAYWALL" | "URL_RETRIEVAL_STATUS_UNSAFE" | (string & {});
|
|
969
|
+
}
|
|
970
|
+
/** Metadata related to url context retrieval tool. */
|
|
971
|
+
interface UrlContextMetadata {
|
|
972
|
+
/** List of url context. */
|
|
973
|
+
urlMetadata?: Array<UrlMetadata>;
|
|
974
|
+
}
|
|
975
|
+
/** Logprobs Result */
|
|
976
|
+
interface LogprobsResult {
|
|
977
|
+
/**
|
|
978
|
+
* Length = total number of decoding steps.
|
|
979
|
+
* The chosen candidates may or may not be in top_candidates.
|
|
980
|
+
*/
|
|
981
|
+
chosenCandidates?: Array<LogprobsResultCandidate>;
|
|
982
|
+
/** Sum of log probabilities for all tokens. */
|
|
983
|
+
logProbabilitySum?: number;
|
|
984
|
+
/** Length = total number of decoding steps. */
|
|
985
|
+
topCandidates?: Array<TopCandidates>;
|
|
986
|
+
}
|
|
987
|
+
/** Candidates with top log probabilities at each decoding step. */
|
|
988
|
+
interface TopCandidates {
|
|
989
|
+
/** Sorted by log probability in descending order. */
|
|
990
|
+
candidates?: Array<LogprobsResultCandidate>;
|
|
991
|
+
}
|
|
992
|
+
/** Candidate for the logprobs token and score. */
|
|
993
|
+
interface LogprobsResultCandidate {
|
|
994
|
+
/** The candidate's log probability. */
|
|
995
|
+
logProbability?: number;
|
|
996
|
+
/** The candidate’s token string value. */
|
|
997
|
+
token?: string;
|
|
998
|
+
/** The candidate’s token id value. */
|
|
999
|
+
tokenId?: number;
|
|
1000
|
+
}
|
|
1001
|
+
/** A response candidate generated from the model. */
|
|
1002
|
+
interface Candidate {
|
|
1003
|
+
/** Output only. Average log probability score of the candidate. */
|
|
1004
|
+
readonly avgLogprobs?: number;
|
|
1005
|
+
/**
|
|
1006
|
+
* Output only. Citation information for model-generated candidate.
|
|
1007
|
+
*
|
|
1008
|
+
* This field may be populated with recitation information for any text
|
|
1009
|
+
* included in the `content`. These are passages that are "recited" from
|
|
1010
|
+
* copyrighted material in the foundational LLM's training data.
|
|
1011
|
+
*/
|
|
1012
|
+
readonly citationMetadata?: CitationMetadata;
|
|
1013
|
+
/** Output only. Generated content returned from the model. */
|
|
1014
|
+
readonly content?: Content;
|
|
1015
|
+
/**
|
|
1016
|
+
* Optional. Output only. Details the reason why the model stopped generating tokens.
|
|
1017
|
+
* This is populated only when `finish_reason` is set.
|
|
1018
|
+
*/
|
|
1019
|
+
readonly finishMessage?: string;
|
|
1020
|
+
/**
|
|
1021
|
+
* Optional. Output only. The reason why the model stopped generating tokens.
|
|
1022
|
+
*
|
|
1023
|
+
* If empty, the model has not stopped generating tokens.
|
|
1024
|
+
*/
|
|
1025
|
+
readonly finishReason?: "FINISH_REASON_UNSPECIFIED" | "STOP" | "MAX_TOKENS" | "SAFETY" | "RECITATION" | "LANGUAGE" | "OTHER" | "BLOCKLIST" | "PROHIBITED_CONTENT" | "SPII" | "MALFORMED_FUNCTION_CALL" | "IMAGE_SAFETY" | "IMAGE_PROHIBITED_CONTENT" | "IMAGE_OTHER" | "NO_IMAGE" | "IMAGE_RECITATION" | "UNEXPECTED_TOOL_CALL" | "TOO_MANY_TOOL_CALLS" | "MISSING_THOUGHT_SIGNATURE" | "MALFORMED_RESPONSE" | (string & {});
|
|
1026
|
+
/**
|
|
1027
|
+
* Output only. Attribution information for sources that contributed to a grounded answer.
|
|
1028
|
+
*
|
|
1029
|
+
* This field is populated for `GenerateAnswer` calls.
|
|
1030
|
+
*/
|
|
1031
|
+
readonly groundingAttributions?: Array<GroundingAttribution>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Output only. Grounding metadata for the candidate.
|
|
1034
|
+
*
|
|
1035
|
+
* This field is populated for `GenerateContent` calls.
|
|
1036
|
+
*/
|
|
1037
|
+
readonly groundingMetadata?: GroundingMetadata;
|
|
1038
|
+
/**
|
|
1039
|
+
* Output only. Index of the candidate in the list of response candidates.
|
|
1040
|
+
*/
|
|
1041
|
+
readonly index?: number;
|
|
1042
|
+
/**
|
|
1043
|
+
* Output only. Log-likelihood scores for the response tokens and top tokens
|
|
1044
|
+
*/
|
|
1045
|
+
readonly logprobsResult?: LogprobsResult;
|
|
1046
|
+
/**
|
|
1047
|
+
* List of ratings for the safety of a response candidate.
|
|
1048
|
+
*
|
|
1049
|
+
* There is at most one rating per category.
|
|
1050
|
+
*/
|
|
1051
|
+
safetyRatings?: Array<SafetyRating>;
|
|
1052
|
+
/** Output only. Token count for this candidate. */
|
|
1053
|
+
readonly tokenCount?: number;
|
|
1054
|
+
/** Output only. Metadata related to url context retrieval tool. */
|
|
1055
|
+
readonly urlContextMetadata?: UrlContextMetadata;
|
|
1056
|
+
}
|
|
1057
|
+
/** Represents token counting info for a single modality. */
|
|
1058
|
+
interface ModalityTokenCount {
|
|
1059
|
+
/** The modality associated with this token count. */
|
|
1060
|
+
modality?: GenerativeLanguageModality;
|
|
1061
|
+
/** Number of tokens. */
|
|
1062
|
+
tokenCount?: number;
|
|
1063
|
+
}
|
|
1064
|
+
/** Metadata on the generation request's token usage. */
|
|
1065
|
+
interface UsageMetadata {
|
|
1066
|
+
/**
|
|
1067
|
+
* Output only. List of modalities of the cached content in the request input.
|
|
1068
|
+
*/
|
|
1069
|
+
readonly cacheTokensDetails?: Array<ModalityTokenCount>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Number of tokens in the cached part of the prompt (the cached content)
|
|
1072
|
+
*/
|
|
1073
|
+
cachedContentTokenCount?: number;
|
|
1074
|
+
/**
|
|
1075
|
+
* Total number of tokens across all the generated response candidates.
|
|
1076
|
+
*/
|
|
1077
|
+
candidatesTokenCount?: number;
|
|
1078
|
+
/**
|
|
1079
|
+
* Output only. List of modalities that were returned in the response.
|
|
1080
|
+
*/
|
|
1081
|
+
readonly candidatesTokensDetails?: Array<ModalityTokenCount>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Number of tokens in the prompt. When `cached_content` is set, this is
|
|
1084
|
+
* still the total effective prompt size meaning this includes the number of
|
|
1085
|
+
* tokens in the cached content.
|
|
1086
|
+
*/
|
|
1087
|
+
promptTokenCount?: number;
|
|
1088
|
+
/**
|
|
1089
|
+
* Output only. List of modalities that were processed in the request input.
|
|
1090
|
+
*/
|
|
1091
|
+
readonly promptTokensDetails?: Array<ModalityTokenCount>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Output only. Number of tokens of thoughts for thinking models.
|
|
1094
|
+
*/
|
|
1095
|
+
readonly thoughtsTokenCount?: number;
|
|
1096
|
+
/** Output only. Number of tokens present in tool-use prompt(s). */
|
|
1097
|
+
readonly toolUsePromptTokenCount?: number;
|
|
1098
|
+
/**
|
|
1099
|
+
* Output only. List of modalities that were processed for tool-use request inputs.
|
|
1100
|
+
*/
|
|
1101
|
+
readonly toolUsePromptTokensDetails?: Array<ModalityTokenCount>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Total token count for the generation request (prompt + response
|
|
1104
|
+
* candidates).
|
|
1105
|
+
*/
|
|
1106
|
+
totalTokenCount?: number;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* A set of the feedback metadata the prompt specified in
|
|
1110
|
+
* `GenerateContentRequest.content`.
|
|
1111
|
+
*/
|
|
1112
|
+
interface PromptFeedback {
|
|
1113
|
+
/**
|
|
1114
|
+
* Optional. If set, the prompt was blocked and no candidates are returned.
|
|
1115
|
+
* Rephrase the prompt.
|
|
1116
|
+
*/
|
|
1117
|
+
blockReason?: "BLOCK_REASON_UNSPECIFIED" | "SAFETY" | "OTHER" | "BLOCKLIST" | "PROHIBITED_CONTENT" | "IMAGE_SAFETY" | (string & {});
|
|
1118
|
+
/**
|
|
1119
|
+
* Ratings for safety of the prompt.
|
|
1120
|
+
* There is at most one rating per category.
|
|
1121
|
+
*/
|
|
1122
|
+
safetyRatings?: Array<SafetyRating>;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Response from the model supporting multiple candidate responses.
|
|
1126
|
+
*
|
|
1127
|
+
* Safety ratings and content filtering are reported for both
|
|
1128
|
+
* prompt in `GenerateContentResponse.prompt_feedback` and for each candidate
|
|
1129
|
+
* in `finish_reason` and in `safety_ratings`. The API:
|
|
1130
|
+
* - Returns either all requested candidates or none of them
|
|
1131
|
+
* - Returns no candidates at all only if there was something wrong with the
|
|
1132
|
+
* prompt (check `prompt_feedback`)
|
|
1133
|
+
* - Reports feedback on each candidate in `finish_reason` and
|
|
1134
|
+
* `safety_ratings`.
|
|
1135
|
+
*/
|
|
1136
|
+
interface GenerateContentResponse {
|
|
1137
|
+
/** Candidate responses from the model. */
|
|
1138
|
+
candidates?: Array<Candidate>;
|
|
1139
|
+
/** Output only. The current model status of this model. */
|
|
1140
|
+
readonly modelStatus?: ModelStatus;
|
|
1141
|
+
/**
|
|
1142
|
+
* Output only. The model version used to generate the response.
|
|
1143
|
+
*/
|
|
1144
|
+
readonly modelVersion?: string;
|
|
1145
|
+
/**
|
|
1146
|
+
* Returns the prompt's feedback related to the content filters.
|
|
1147
|
+
*/
|
|
1148
|
+
promptFeedback?: PromptFeedback;
|
|
1149
|
+
/** Output only. response_id is used to identify each response. */
|
|
1150
|
+
readonly responseId?: string;
|
|
1151
|
+
/**
|
|
1152
|
+
* Output only. Metadata on the generation requests' token usage.
|
|
1153
|
+
*/
|
|
1154
|
+
readonly usageMetadata?: UsageMetadata;
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* A grounding chunk from Google Maps. A Maps chunk corresponds to a single
|
|
1158
|
+
* place.
|
|
1159
|
+
*/
|
|
1160
|
+
interface Maps {
|
|
1161
|
+
/**
|
|
1162
|
+
* Sources that provide answers about the features of a given place in
|
|
1163
|
+
* Google Maps.
|
|
1164
|
+
*/
|
|
1165
|
+
placeAnswerSources?: PlaceAnswerSources;
|
|
1166
|
+
/**
|
|
1167
|
+
* This ID of the place, in `places/{place_id}` format. A user can use this
|
|
1168
|
+
* ID to look up that place.
|
|
1169
|
+
*/
|
|
1170
|
+
placeId?: string;
|
|
1171
|
+
/** Text description of the place answer. */
|
|
1172
|
+
text?: string;
|
|
1173
|
+
/** Title of the place. */
|
|
1174
|
+
title?: string;
|
|
1175
|
+
/** URI reference of the place. */
|
|
1176
|
+
uri?: string;
|
|
1177
|
+
}
|
|
1178
|
+
/** The configuration for the prebuilt speaker to use. */
|
|
1179
|
+
interface PrebuiltVoiceConfig {
|
|
1180
|
+
/** The name of the preset voice to use. */
|
|
1181
|
+
voiceName?: string;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* A predicted `FunctionCall` returned from the model that contains
|
|
1185
|
+
* a string representing the `FunctionDeclaration.name` with the
|
|
1186
|
+
* arguments and their values.
|
|
1187
|
+
*/
|
|
1188
|
+
interface FunctionCall {
|
|
1189
|
+
/**
|
|
1190
|
+
* Optional. The function parameters and values in JSON object format.
|
|
1191
|
+
*/
|
|
1192
|
+
args?: Record<string, unknown>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Optional. The unique identifier of the function call. If populated, the client to
|
|
1195
|
+
* execute the `function_call` and return the response with the matching `id`.
|
|
1196
|
+
*/
|
|
1197
|
+
id?: string;
|
|
1198
|
+
/**
|
|
1199
|
+
* Required. The name of the function to call.
|
|
1200
|
+
* Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum
|
|
1201
|
+
* length of 64.
|
|
1202
|
+
*/
|
|
1203
|
+
name: string;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* The result output from a `FunctionCall` that contains a string
|
|
1207
|
+
* representing the `FunctionDeclaration.name` and a structured JSON
|
|
1208
|
+
* object containing any output from the function is used as context to
|
|
1209
|
+
* the model. This should contain the result of a`FunctionCall` made
|
|
1210
|
+
* based on model prediction.
|
|
1211
|
+
*/
|
|
1212
|
+
interface FunctionResponse {
|
|
1213
|
+
/**
|
|
1214
|
+
* Optional. The identifier of the function call this response is for. Populated by the
|
|
1215
|
+
* client to match the corresponding function call `id`.
|
|
1216
|
+
*/
|
|
1217
|
+
id?: string;
|
|
1218
|
+
/**
|
|
1219
|
+
* Required. The name of the function to call.
|
|
1220
|
+
* Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum
|
|
1221
|
+
* length of 64.
|
|
1222
|
+
*/
|
|
1223
|
+
name: string;
|
|
1224
|
+
/**
|
|
1225
|
+
* Optional. Ordered `Parts` that constitute a function response. Parts may have
|
|
1226
|
+
* different IANA MIME types.
|
|
1227
|
+
*/
|
|
1228
|
+
parts?: Array<FunctionResponsePart>;
|
|
1229
|
+
/**
|
|
1230
|
+
* Required. The function response in JSON object format.
|
|
1231
|
+
* Callers can use any keys of their choice that fit the function's syntax
|
|
1232
|
+
* to return the function output, e.g. "output", "result", etc.
|
|
1233
|
+
* In particular, if the function call failed to execute, the response can
|
|
1234
|
+
* have an "error" key to return error details to the model.
|
|
1235
|
+
*/
|
|
1236
|
+
response: Record<string, unknown>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Optional. Specifies how the response should be scheduled in the conversation.
|
|
1239
|
+
* Only applicable to NON_BLOCKING function calls, is ignored otherwise.
|
|
1240
|
+
* Defaults to WHEN_IDLE.
|
|
1241
|
+
*/
|
|
1242
|
+
scheduling?: "SCHEDULING_UNSPECIFIED" | "SILENT" | "WHEN_IDLE" | "INTERRUPT" | (string & {});
|
|
1243
|
+
/**
|
|
1244
|
+
* Optional. Signals that function call continues, and more responses will be
|
|
1245
|
+
* returned, turning the function call into a generator.
|
|
1246
|
+
* Is only applicable to NON_BLOCKING function calls, is ignored otherwise.
|
|
1247
|
+
* If set to false, future responses will not be considered.
|
|
1248
|
+
* It is allowed to return empty `response` with `will_continue=False` to
|
|
1249
|
+
* signal that the function call is finished. This may still trigger the model
|
|
1250
|
+
* generation. To avoid triggering the generation and finish the function
|
|
1251
|
+
* call, additionally set `scheduling` to `SILENT`.
|
|
1252
|
+
*/
|
|
1253
|
+
willContinue?: boolean;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Tool details that the model may use to generate response.
|
|
1257
|
+
*
|
|
1258
|
+
* A `Tool` is a piece of code that enables the system to interact with
|
|
1259
|
+
* external systems to perform an action, or set of actions, outside of
|
|
1260
|
+
* knowledge and scope of the model.
|
|
1261
|
+
*
|
|
1262
|
+
* Next ID: 15
|
|
1263
|
+
*/
|
|
1264
|
+
interface Tool {
|
|
1265
|
+
/**
|
|
1266
|
+
* Optional. Enables the model to execute code as part of generation.
|
|
1267
|
+
*/
|
|
1268
|
+
codeExecution?: Gemini.Tools.CodeExecution;
|
|
1269
|
+
/**
|
|
1270
|
+
* Optional. Tool to support the model interacting directly with the computer.
|
|
1271
|
+
* If enabled, it automatically populates computer-use specific Function
|
|
1272
|
+
* Declarations.
|
|
1273
|
+
*/
|
|
1274
|
+
computerUse?: Gemini.Tools.ComputerUse;
|
|
1275
|
+
/**
|
|
1276
|
+
* Optional. FileSearch tool type.
|
|
1277
|
+
* Tool to retrieve knowledge from Semantic Retrieval corpora.
|
|
1278
|
+
*/
|
|
1279
|
+
fileSearch?: Gemini.Tools.FileSearch;
|
|
1280
|
+
/**
|
|
1281
|
+
* Optional. A list of `FunctionDeclarations` available to the model that can be used
|
|
1282
|
+
* for function calling.
|
|
1283
|
+
*
|
|
1284
|
+
* The model or system does not execute the function. Instead the defined
|
|
1285
|
+
* function may be returned as a FunctionCall
|
|
1286
|
+
* with arguments to the client side for execution. The model may decide to
|
|
1287
|
+
* call a subset of these functions by populating
|
|
1288
|
+
* FunctionCall in the response. The next
|
|
1289
|
+
* conversation turn may contain a
|
|
1290
|
+
* FunctionResponse
|
|
1291
|
+
* with the Content.role "function" generation context for the next model
|
|
1292
|
+
* turn.
|
|
1293
|
+
*/
|
|
1294
|
+
functionDeclarations?: Array<Gemini.Tools.FunctionDeclaration>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Optional. Tool that allows grounding the model's response with geospatial context
|
|
1297
|
+
* related to the user's query.
|
|
1298
|
+
*/
|
|
1299
|
+
googleMaps?: Gemini.Tools.GoogleMaps;
|
|
1300
|
+
/**
|
|
1301
|
+
* Optional. GoogleSearch tool type.
|
|
1302
|
+
* Tool to support Google Search in Model. Powered by Google.
|
|
1303
|
+
*/
|
|
1304
|
+
googleSearch?: Gemini.Tools.GoogleSearch;
|
|
1305
|
+
/** Optional. Retrieval tool that is powered by Google search. */
|
|
1306
|
+
googleSearchRetrieval?: GoogleSearchRetrieval;
|
|
1307
|
+
/** Optional. MCP Servers to connect to. */
|
|
1308
|
+
mcpServers?: Array<McpServer>;
|
|
1309
|
+
/** Optional. Tool to support URL context retrieval. */
|
|
1310
|
+
urlContext?: Gemini.Tools.UrlContext;
|
|
1311
|
+
}
|
|
1312
|
+
/** Chunk from the web. */
|
|
1313
|
+
interface Web {
|
|
1314
|
+
/** Title of the chunk. */
|
|
1315
|
+
title?: string;
|
|
1316
|
+
/** URI reference of the chunk. */
|
|
1317
|
+
uri?: string;
|
|
1318
|
+
}
|
|
1319
|
+
/** A citation to a source for a portion of a specific response. */
|
|
1320
|
+
interface CitationSource {
|
|
1321
|
+
/** Optional. End of the attributed segment, exclusive. */
|
|
1322
|
+
endIndex?: number;
|
|
1323
|
+
/**
|
|
1324
|
+
* Optional. License for the GitHub project that is attributed as a source for segment.
|
|
1325
|
+
*
|
|
1326
|
+
* License info is required for code citations.
|
|
1327
|
+
*/
|
|
1328
|
+
license?: string;
|
|
1329
|
+
/**
|
|
1330
|
+
* Optional. Start of segment of the response that is attributed to this source.
|
|
1331
|
+
*
|
|
1332
|
+
* Index indicates the start of the segment, measured in bytes.
|
|
1333
|
+
*/
|
|
1334
|
+
startIndex?: number;
|
|
1335
|
+
/**
|
|
1336
|
+
* Optional. URI that is attributed as a source for a portion of the text.
|
|
1337
|
+
*/
|
|
1338
|
+
uri?: string;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* The status of the underlying model. This is used to indicate the stage of the
|
|
1342
|
+
* underlying model and the retirement time if applicable.
|
|
1343
|
+
*/
|
|
1344
|
+
interface ModelStatus {
|
|
1345
|
+
/** A message explaining the model status. */
|
|
1346
|
+
message?: string;
|
|
1347
|
+
/** The stage of the underlying model. */
|
|
1348
|
+
modelStage?: ModelStage;
|
|
1349
|
+
/** The time at which the model will be retired. */
|
|
1350
|
+
retirementTime?: string;
|
|
1351
|
+
}
|
|
1352
|
+
/** URI based data. */
|
|
1353
|
+
interface FileData {
|
|
1354
|
+
/** Required. URI. */
|
|
1355
|
+
fileUri: string;
|
|
1356
|
+
/** Optional. The IANA standard MIME type of the source data. */
|
|
1357
|
+
mimeType?: string;
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Raw media bytes.
|
|
1361
|
+
*
|
|
1362
|
+
* Text should not be sent as raw bytes, use the 'text' field.
|
|
1363
|
+
*/
|
|
1364
|
+
interface Blob {
|
|
1365
|
+
/** Raw bytes for media formats. */
|
|
1366
|
+
data?: string;
|
|
1367
|
+
/**
|
|
1368
|
+
* The IANA standard MIME type of the source data.
|
|
1369
|
+
* Examples:
|
|
1370
|
+
* - image/png
|
|
1371
|
+
* - image/jpeg
|
|
1372
|
+
* If an unsupported MIME type is provided, an error will be returned. For a
|
|
1373
|
+
* complete list of supported types, see [Supported file
|
|
1374
|
+
* formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats).
|
|
1375
|
+
*/
|
|
1376
|
+
mimeType?: string;
|
|
1377
|
+
}
|
|
1378
|
+
/** Google search entry point. */
|
|
1379
|
+
interface SearchEntryPoint {
|
|
1380
|
+
/**
|
|
1381
|
+
* Optional. Web content snippet that can be embedded in a web page or an app webview.
|
|
1382
|
+
*/
|
|
1383
|
+
renderedContent?: string;
|
|
1384
|
+
/** Optional. Base64 encoded JSON representing array of tuple. */
|
|
1385
|
+
sdkBlob?: string;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* A MCPServer is a server that can be called by the model to perform actions.
|
|
1389
|
+
* It is a server that implements the MCP protocol.
|
|
1390
|
+
* Next ID: 5
|
|
1391
|
+
*/
|
|
1392
|
+
interface McpServer {
|
|
1393
|
+
/** The name of the MCPServer. */
|
|
1394
|
+
name?: string;
|
|
1395
|
+
/** A transport that can stream HTTP requests and responses. */
|
|
1396
|
+
streamableHttpTransport?: StreamableHttpTransport;
|
|
1397
|
+
}
|
|
1398
|
+
type ModelStage = "MODEL_STAGE_UNSPECIFIED" | "UNSTABLE_EXPERIMENTAL" | "EXPERIMENTAL" | "PREVIEW" | "STABLE" | "LEGACY" | "DEPRECATED" | "RETIRED" | (string & {});
|
|
1399
|
+
/**
|
|
1400
|
+
* Collection of sources that provide answers about the features of a given
|
|
1401
|
+
* place in Google Maps. Each PlaceAnswerSources message corresponds to a
|
|
1402
|
+
* specific place in Google Maps. The Google Maps tool used these sources in
|
|
1403
|
+
* order to answer questions about features of the place (e.g: "does Bar Foo
|
|
1404
|
+
* have Wifi" or "is Foo Bar wheelchair accessible?"). Currently we only
|
|
1405
|
+
* support review snippets as sources.
|
|
1406
|
+
*/
|
|
1407
|
+
interface PlaceAnswerSources {
|
|
1408
|
+
/**
|
|
1409
|
+
* Snippets of reviews that are used to generate answers about the
|
|
1410
|
+
* features of a given place in Google Maps.
|
|
1411
|
+
*/
|
|
1412
|
+
reviewSnippets?: Array<ReviewSnippet>;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* A datatype containing media that is part of a `FunctionResponse` message.
|
|
1416
|
+
*
|
|
1417
|
+
* A `FunctionResponsePart` consists of data which has an associated datatype. A
|
|
1418
|
+
* `FunctionResponsePart` can only contain one of the accepted types in
|
|
1419
|
+
* `FunctionResponsePart.data`.
|
|
1420
|
+
*
|
|
1421
|
+
* A `FunctionResponsePart` must have a fixed IANA MIME type identifying the
|
|
1422
|
+
* type and subtype of the media if the `inline_data` field is filled with raw
|
|
1423
|
+
* bytes.
|
|
1424
|
+
*/
|
|
1425
|
+
interface FunctionResponsePart {
|
|
1426
|
+
/** Inline media bytes. */
|
|
1427
|
+
inlineData?: FunctionResponseBlob;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Tool to retrieve public web data for grounding, powered by Google.
|
|
1431
|
+
*/
|
|
1432
|
+
interface GoogleSearchRetrieval {
|
|
1433
|
+
/**
|
|
1434
|
+
* Specifies the dynamic retrieval configuration for the given source.
|
|
1435
|
+
*/
|
|
1436
|
+
dynamicRetrievalConfig?: DynamicRetrievalConfig;
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* A transport that can stream HTTP requests and responses.
|
|
1440
|
+
* Next ID: 6
|
|
1441
|
+
*/
|
|
1442
|
+
interface StreamableHttpTransport {
|
|
1443
|
+
/**
|
|
1444
|
+
* Optional: Fields for authentication headers, timeouts, etc., if needed.
|
|
1445
|
+
*/
|
|
1446
|
+
headers?: Record<string, unknown>;
|
|
1447
|
+
/** Timeout for SSE read operations. */
|
|
1448
|
+
sseReadTimeout?: string;
|
|
1449
|
+
/**
|
|
1450
|
+
* Whether to close the client session when the transport closes.
|
|
1451
|
+
*/
|
|
1452
|
+
terminateOnClose?: boolean;
|
|
1453
|
+
/** HTTP timeout for regular operations. */
|
|
1454
|
+
timeout?: string;
|
|
1455
|
+
/**
|
|
1456
|
+
* The full URL for the MCPServer endpoint.
|
|
1457
|
+
* Example: "https://api.example.com/mcp"
|
|
1458
|
+
*/
|
|
1459
|
+
url?: string;
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Encapsulates a snippet of a user review that answers a question about
|
|
1463
|
+
* the features of a specific place in Google Maps.
|
|
1464
|
+
*/
|
|
1465
|
+
interface ReviewSnippet {
|
|
1466
|
+
/** A link that corresponds to the user review on Google Maps. */
|
|
1467
|
+
googleMapsUri?: string;
|
|
1468
|
+
/** The ID of the review snippet. */
|
|
1469
|
+
reviewId?: string;
|
|
1470
|
+
/** Title of the review. */
|
|
1471
|
+
title?: string;
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Raw media bytes for function response.
|
|
1475
|
+
*
|
|
1476
|
+
* Text should not be sent as raw bytes, use the 'FunctionResponse.response'
|
|
1477
|
+
* field.
|
|
1478
|
+
*/
|
|
1479
|
+
interface FunctionResponseBlob {
|
|
1480
|
+
/** Raw bytes for media formats. */
|
|
1481
|
+
data?: string;
|
|
1482
|
+
/**
|
|
1483
|
+
* The IANA standard MIME type of the source data.
|
|
1484
|
+
* Examples:
|
|
1485
|
+
* - image/png
|
|
1486
|
+
* - image/jpeg
|
|
1487
|
+
* If an unsupported MIME type is provided, an error will be returned. For a
|
|
1488
|
+
* complete list of supported types, see [Supported file
|
|
1489
|
+
* formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats).
|
|
1490
|
+
*/
|
|
1491
|
+
mimeType?: string;
|
|
1492
|
+
}
|
|
1493
|
+
/** Describes the options to customize dynamic retrieval. */
|
|
1494
|
+
interface DynamicRetrievalConfig {
|
|
1495
|
+
/**
|
|
1496
|
+
* The threshold to be used in dynamic retrieval.
|
|
1497
|
+
* If not set, a system default value is used.
|
|
1498
|
+
*/
|
|
1499
|
+
dynamicThreshold?: number;
|
|
1500
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
1501
|
+
mode?: "MODE_UNSPECIFIED" | "MODE_DYNAMIC" | (string & {});
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
//#endregion
|
|
1505
|
+
export { Gemini };
|
|
1506
|
+
//# sourceMappingURL=api-types.d.cts.map
|