@tanstack/ai-gemini 0.3.1 → 0.4.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/README.md +1 -0
- package/dist/esm/adapters/summarize.js +5 -6
- package/dist/esm/adapters/summarize.js.map +1 -1
- package/dist/esm/adapters/text.js +156 -63
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/model-meta.d.ts +10 -10
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/text/text-provider-options.d.ts +99 -94
- package/package.json +3 -3
- package/src/adapters/summarize.ts +4 -5
- package/src/adapters/text.ts +191 -81
- package/src/index.ts +0 -4
- package/src/model-meta.ts +39 -33
- package/src/text/text-provider-options.ts +118 -110
package/src/adapters/text.ts
CHANGED
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
GenerateContentResponse,
|
|
21
21
|
GoogleGenAI,
|
|
22
22
|
Part,
|
|
23
|
+
ThinkingLevel,
|
|
23
24
|
} from '@google/genai'
|
|
24
25
|
import type {
|
|
25
26
|
ContentPart,
|
|
@@ -29,13 +30,7 @@ import type {
|
|
|
29
30
|
TextOptions,
|
|
30
31
|
} from '@tanstack/ai'
|
|
31
32
|
import type { ExternalTextProviderOptions } from '../text/text-provider-options'
|
|
32
|
-
import type {
|
|
33
|
-
GeminiAudioMetadata,
|
|
34
|
-
GeminiDocumentMetadata,
|
|
35
|
-
GeminiImageMetadata,
|
|
36
|
-
GeminiMessageMetadataByModality,
|
|
37
|
-
GeminiVideoMetadata,
|
|
38
|
-
} from '../message-types'
|
|
33
|
+
import type { GeminiMessageMetadataByModality } from '../message-types'
|
|
39
34
|
import type { GeminiClientConfig } from '../utils'
|
|
40
35
|
|
|
41
36
|
/**
|
|
@@ -114,8 +109,7 @@ export class GeminiTextAdapter<
|
|
|
114
109
|
} catch (error) {
|
|
115
110
|
const timestamp = Date.now()
|
|
116
111
|
yield {
|
|
117
|
-
type: '
|
|
118
|
-
id: generateId(this.name),
|
|
112
|
+
type: 'RUN_ERROR',
|
|
119
113
|
model: options.model,
|
|
120
114
|
timestamp,
|
|
121
115
|
error: {
|
|
@@ -202,25 +196,79 @@ export class GeminiTextAdapter<
|
|
|
202
196
|
let accumulatedContent = ''
|
|
203
197
|
const toolCallMap = new Map<
|
|
204
198
|
string,
|
|
205
|
-
{ name: string; args: string; index: number }
|
|
199
|
+
{ name: string; args: string; index: number; started: boolean }
|
|
206
200
|
>()
|
|
207
201
|
let nextToolIndex = 0
|
|
208
202
|
|
|
203
|
+
// AG-UI lifecycle tracking
|
|
204
|
+
const runId = generateId(this.name)
|
|
205
|
+
const messageId = generateId(this.name)
|
|
206
|
+
let stepId: string | null = null
|
|
207
|
+
let hasEmittedRunStarted = false
|
|
208
|
+
let hasEmittedTextMessageStart = false
|
|
209
|
+
let hasEmittedStepStarted = false
|
|
210
|
+
|
|
209
211
|
for await (const chunk of result) {
|
|
212
|
+
// Emit RUN_STARTED on first chunk
|
|
213
|
+
if (!hasEmittedRunStarted) {
|
|
214
|
+
hasEmittedRunStarted = true
|
|
215
|
+
yield {
|
|
216
|
+
type: 'RUN_STARTED',
|
|
217
|
+
runId,
|
|
218
|
+
model,
|
|
219
|
+
timestamp,
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
210
223
|
if (chunk.candidates?.[0]?.content?.parts) {
|
|
211
224
|
const parts = chunk.candidates[0].content.parts
|
|
212
225
|
|
|
213
226
|
for (const part of parts) {
|
|
214
227
|
if (part.text) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
228
|
+
if (part.thought) {
|
|
229
|
+
// Emit STEP_STARTED on first thinking content
|
|
230
|
+
if (!hasEmittedStepStarted) {
|
|
231
|
+
hasEmittedStepStarted = true
|
|
232
|
+
stepId = generateId(this.name)
|
|
233
|
+
yield {
|
|
234
|
+
type: 'STEP_STARTED',
|
|
235
|
+
stepId,
|
|
236
|
+
model,
|
|
237
|
+
timestamp,
|
|
238
|
+
stepType: 'thinking',
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
yield {
|
|
243
|
+
type: 'STEP_FINISHED',
|
|
244
|
+
stepId: stepId || generateId(this.name),
|
|
245
|
+
model,
|
|
246
|
+
timestamp,
|
|
247
|
+
delta: part.text,
|
|
248
|
+
content: part.text,
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
// Emit TEXT_MESSAGE_START on first text content
|
|
252
|
+
if (!hasEmittedTextMessageStart) {
|
|
253
|
+
hasEmittedTextMessageStart = true
|
|
254
|
+
yield {
|
|
255
|
+
type: 'TEXT_MESSAGE_START',
|
|
256
|
+
messageId,
|
|
257
|
+
model,
|
|
258
|
+
timestamp,
|
|
259
|
+
role: 'assistant',
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
accumulatedContent += part.text
|
|
264
|
+
yield {
|
|
265
|
+
type: 'TEXT_MESSAGE_CONTENT',
|
|
266
|
+
messageId,
|
|
267
|
+
model,
|
|
268
|
+
timestamp,
|
|
269
|
+
delta: part.text,
|
|
270
|
+
content: accumulatedContent,
|
|
271
|
+
}
|
|
224
272
|
}
|
|
225
273
|
}
|
|
226
274
|
|
|
@@ -240,6 +288,7 @@ export class GeminiTextAdapter<
|
|
|
240
288
|
? functionArgs
|
|
241
289
|
: JSON.stringify(functionArgs),
|
|
242
290
|
index: nextToolIndex++,
|
|
291
|
+
started: false,
|
|
243
292
|
}
|
|
244
293
|
toolCallMap.set(toolCallId, toolCallData)
|
|
245
294
|
} else {
|
|
@@ -259,33 +308,51 @@ export class GeminiTextAdapter<
|
|
|
259
308
|
}
|
|
260
309
|
}
|
|
261
310
|
|
|
311
|
+
// Emit TOOL_CALL_START if not already started
|
|
312
|
+
if (!toolCallData.started) {
|
|
313
|
+
toolCallData.started = true
|
|
314
|
+
yield {
|
|
315
|
+
type: 'TOOL_CALL_START',
|
|
316
|
+
toolCallId,
|
|
317
|
+
toolName: toolCallData.name,
|
|
318
|
+
model,
|
|
319
|
+
timestamp,
|
|
320
|
+
index: toolCallData.index,
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Emit TOOL_CALL_ARGS
|
|
262
325
|
yield {
|
|
263
|
-
type: '
|
|
264
|
-
|
|
326
|
+
type: 'TOOL_CALL_ARGS',
|
|
327
|
+
toolCallId,
|
|
265
328
|
model,
|
|
266
329
|
timestamp,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
type: 'function',
|
|
270
|
-
function: {
|
|
271
|
-
name: toolCallData.name,
|
|
272
|
-
arguments: toolCallData.args,
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
index: toolCallData.index,
|
|
330
|
+
delta: toolCallData.args,
|
|
331
|
+
args: toolCallData.args,
|
|
276
332
|
}
|
|
277
333
|
}
|
|
278
334
|
}
|
|
279
335
|
} else if (chunk.data) {
|
|
336
|
+
// Emit TEXT_MESSAGE_START on first text content
|
|
337
|
+
if (!hasEmittedTextMessageStart) {
|
|
338
|
+
hasEmittedTextMessageStart = true
|
|
339
|
+
yield {
|
|
340
|
+
type: 'TEXT_MESSAGE_START',
|
|
341
|
+
messageId,
|
|
342
|
+
model,
|
|
343
|
+
timestamp,
|
|
344
|
+
role: 'assistant',
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
280
348
|
accumulatedContent += chunk.data
|
|
281
349
|
yield {
|
|
282
|
-
type: '
|
|
283
|
-
|
|
350
|
+
type: 'TEXT_MESSAGE_CONTENT',
|
|
351
|
+
messageId,
|
|
284
352
|
model,
|
|
285
353
|
timestamp,
|
|
286
354
|
delta: chunk.data,
|
|
287
355
|
content: accumulatedContent,
|
|
288
|
-
role: 'assistant',
|
|
289
356
|
}
|
|
290
357
|
}
|
|
291
358
|
|
|
@@ -302,53 +369,98 @@ export class GeminiTextAdapter<
|
|
|
302
369
|
`${functionCall.name}_${Date.now()}_${nextToolIndex}`
|
|
303
370
|
const functionArgs = functionCall.args || {}
|
|
304
371
|
|
|
372
|
+
const argsString =
|
|
373
|
+
typeof functionArgs === 'string'
|
|
374
|
+
? functionArgs
|
|
375
|
+
: JSON.stringify(functionArgs)
|
|
376
|
+
|
|
305
377
|
toolCallMap.set(toolCallId, {
|
|
306
378
|
name: functionCall.name || '',
|
|
307
|
-
args:
|
|
308
|
-
typeof functionArgs === 'string'
|
|
309
|
-
? functionArgs
|
|
310
|
-
: JSON.stringify(functionArgs),
|
|
379
|
+
args: argsString,
|
|
311
380
|
index: nextToolIndex++,
|
|
381
|
+
started: true,
|
|
312
382
|
})
|
|
313
383
|
|
|
384
|
+
// Emit TOOL_CALL_START
|
|
314
385
|
yield {
|
|
315
|
-
type: '
|
|
316
|
-
|
|
386
|
+
type: 'TOOL_CALL_START',
|
|
387
|
+
toolCallId,
|
|
388
|
+
toolName: functionCall.name || '',
|
|
317
389
|
model,
|
|
318
390
|
timestamp,
|
|
319
|
-
toolCall: {
|
|
320
|
-
id: toolCallId,
|
|
321
|
-
type: 'function',
|
|
322
|
-
function: {
|
|
323
|
-
name: functionCall.name || '',
|
|
324
|
-
arguments:
|
|
325
|
-
typeof functionArgs === 'string'
|
|
326
|
-
? functionArgs
|
|
327
|
-
: JSON.stringify(functionArgs),
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
391
|
index: nextToolIndex - 1,
|
|
331
392
|
}
|
|
393
|
+
|
|
394
|
+
// Emit TOOL_CALL_END with parsed input
|
|
395
|
+
let parsedInput: unknown = {}
|
|
396
|
+
try {
|
|
397
|
+
parsedInput =
|
|
398
|
+
typeof functionArgs === 'string'
|
|
399
|
+
? JSON.parse(functionArgs)
|
|
400
|
+
: functionArgs
|
|
401
|
+
} catch {
|
|
402
|
+
parsedInput = {}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
yield {
|
|
406
|
+
type: 'TOOL_CALL_END',
|
|
407
|
+
toolCallId,
|
|
408
|
+
toolName: functionCall.name || '',
|
|
409
|
+
model,
|
|
410
|
+
timestamp,
|
|
411
|
+
input: parsedInput,
|
|
412
|
+
}
|
|
332
413
|
}
|
|
333
414
|
}
|
|
334
415
|
}
|
|
335
416
|
}
|
|
417
|
+
|
|
418
|
+
// Emit TOOL_CALL_END for all tracked tool calls
|
|
419
|
+
for (const [toolCallId, toolCallData] of toolCallMap.entries()) {
|
|
420
|
+
let parsedInput: unknown = {}
|
|
421
|
+
try {
|
|
422
|
+
parsedInput = JSON.parse(toolCallData.args)
|
|
423
|
+
} catch {
|
|
424
|
+
parsedInput = {}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
yield {
|
|
428
|
+
type: 'TOOL_CALL_END',
|
|
429
|
+
toolCallId,
|
|
430
|
+
toolName: toolCallData.name,
|
|
431
|
+
model,
|
|
432
|
+
timestamp,
|
|
433
|
+
input: parsedInput,
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
336
437
|
if (finishReason === FinishReason.MAX_TOKENS) {
|
|
337
438
|
yield {
|
|
338
|
-
type: '
|
|
339
|
-
|
|
439
|
+
type: 'RUN_ERROR',
|
|
440
|
+
runId,
|
|
340
441
|
model,
|
|
341
442
|
timestamp,
|
|
342
443
|
error: {
|
|
343
444
|
message:
|
|
344
445
|
'The response was cut off because the maximum token limit was reached.',
|
|
446
|
+
code: 'max_tokens',
|
|
345
447
|
},
|
|
346
448
|
}
|
|
347
449
|
}
|
|
348
450
|
|
|
451
|
+
// Emit TEXT_MESSAGE_END if we had text content
|
|
452
|
+
if (hasEmittedTextMessageStart) {
|
|
453
|
+
yield {
|
|
454
|
+
type: 'TEXT_MESSAGE_END',
|
|
455
|
+
messageId,
|
|
456
|
+
model,
|
|
457
|
+
timestamp,
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
349
461
|
yield {
|
|
350
|
-
type: '
|
|
351
|
-
|
|
462
|
+
type: 'RUN_FINISHED',
|
|
463
|
+
runId,
|
|
352
464
|
model,
|
|
353
465
|
timestamp,
|
|
354
466
|
finishReason: toolCallMap.size > 0 ? 'tool_calls' : 'stop',
|
|
@@ -365,20 +477,6 @@ export class GeminiTextAdapter<
|
|
|
365
477
|
}
|
|
366
478
|
|
|
367
479
|
private convertContentPartToGemini(part: ContentPart): Part {
|
|
368
|
-
const getDefaultFileType = (
|
|
369
|
-
part: 'image' | 'audio' | 'video' | 'document',
|
|
370
|
-
) => {
|
|
371
|
-
switch (part) {
|
|
372
|
-
case 'image':
|
|
373
|
-
return 'image/jpeg'
|
|
374
|
-
case 'audio':
|
|
375
|
-
return 'audio/mp3'
|
|
376
|
-
case 'video':
|
|
377
|
-
return 'video/mp4'
|
|
378
|
-
case 'document':
|
|
379
|
-
return 'application/pdf'
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
480
|
switch (part.type) {
|
|
383
481
|
case 'text':
|
|
384
482
|
return { text: part.content }
|
|
@@ -386,24 +484,26 @@ export class GeminiTextAdapter<
|
|
|
386
484
|
case 'audio':
|
|
387
485
|
case 'video':
|
|
388
486
|
case 'document': {
|
|
389
|
-
const metadata = part.metadata as
|
|
390
|
-
| GeminiDocumentMetadata
|
|
391
|
-
| GeminiImageMetadata
|
|
392
|
-
| GeminiVideoMetadata
|
|
393
|
-
| GeminiAudioMetadata
|
|
394
|
-
| undefined
|
|
395
487
|
if (part.source.type === 'data') {
|
|
396
488
|
return {
|
|
397
489
|
inlineData: {
|
|
398
490
|
data: part.source.value,
|
|
399
|
-
mimeType:
|
|
491
|
+
mimeType: part.source.mimeType,
|
|
400
492
|
},
|
|
401
493
|
}
|
|
402
494
|
} else {
|
|
495
|
+
// For URL sources, use provided mimeType or fall back to reasonable defaults
|
|
496
|
+
const defaultMimeType = {
|
|
497
|
+
image: 'image/jpeg',
|
|
498
|
+
audio: 'audio/mp3',
|
|
499
|
+
video: 'video/mp4',
|
|
500
|
+
document: 'application/pdf',
|
|
501
|
+
}[part.type]
|
|
502
|
+
|
|
403
503
|
return {
|
|
404
504
|
fileData: {
|
|
405
505
|
fileUri: part.source.value,
|
|
406
|
-
mimeType:
|
|
506
|
+
mimeType: part.source.mimeType ?? defaultMimeType,
|
|
407
507
|
},
|
|
408
508
|
}
|
|
409
509
|
}
|
|
@@ -476,19 +576,29 @@ export class GeminiTextAdapter<
|
|
|
476
576
|
})
|
|
477
577
|
}
|
|
478
578
|
|
|
479
|
-
private mapCommonOptionsToGemini(
|
|
480
|
-
|
|
579
|
+
private mapCommonOptionsToGemini(
|
|
580
|
+
options: TextOptions<GeminiTextProviderOptions>,
|
|
581
|
+
) {
|
|
582
|
+
const modelOpts = options.modelOptions
|
|
583
|
+
const thinkingConfig = modelOpts?.thinkingConfig
|
|
481
584
|
const requestOptions: GenerateContentParameters = {
|
|
482
585
|
model: options.model,
|
|
483
586
|
contents: this.formatMessages(options.messages),
|
|
484
587
|
config: {
|
|
485
|
-
...
|
|
588
|
+
...modelOpts,
|
|
486
589
|
temperature: options.temperature,
|
|
487
590
|
topP: options.topP,
|
|
488
591
|
maxOutputTokens: options.maxTokens,
|
|
592
|
+
thinkingConfig: thinkingConfig
|
|
593
|
+
? {
|
|
594
|
+
...thinkingConfig,
|
|
595
|
+
thinkingLevel: thinkingConfig.thinkingLevel
|
|
596
|
+
? // Enum is provided by the SDK, we use it for the type but cast it to string constants, here we just cast them back
|
|
597
|
+
(thinkingConfig.thinkingLevel as ThinkingLevel)
|
|
598
|
+
: undefined,
|
|
599
|
+
}
|
|
600
|
+
: undefined,
|
|
489
601
|
systemInstruction: options.systemPrompts?.join('\n'),
|
|
490
|
-
...((providerOpts as Record<string, unknown> | undefined)
|
|
491
|
-
?.generationConfig as Record<string, unknown> | undefined),
|
|
492
602
|
tools: convertToolsToProviderFormat(options.tools),
|
|
493
603
|
},
|
|
494
604
|
}
|
package/src/index.ts
CHANGED
package/src/model-meta.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
GeminiCachedContentOptions,
|
|
3
|
-
|
|
3
|
+
GeminiCommonConfigOptions,
|
|
4
4
|
GeminiSafetyOptions,
|
|
5
5
|
GeminiStructuredOutputOptions,
|
|
6
|
+
GeminiThinkingAdvancedOptions,
|
|
6
7
|
GeminiThinkingOptions,
|
|
7
8
|
GeminiToolConfigOptions,
|
|
8
9
|
} from './text/text-provider-options'
|
|
@@ -77,10 +78,11 @@ const GEMINI_3_PRO = {
|
|
|
77
78
|
} as const satisfies ModelMeta<
|
|
78
79
|
GeminiToolConfigOptions &
|
|
79
80
|
GeminiSafetyOptions &
|
|
80
|
-
|
|
81
|
+
GeminiCommonConfigOptions &
|
|
81
82
|
GeminiCachedContentOptions &
|
|
82
83
|
GeminiStructuredOutputOptions &
|
|
83
|
-
GeminiThinkingOptions
|
|
84
|
+
GeminiThinkingOptions &
|
|
85
|
+
GeminiThinkingAdvancedOptions
|
|
84
86
|
>
|
|
85
87
|
|
|
86
88
|
const GEMINI_3_FLASH = {
|
|
@@ -114,10 +116,11 @@ const GEMINI_3_FLASH = {
|
|
|
114
116
|
} as const satisfies ModelMeta<
|
|
115
117
|
GeminiToolConfigOptions &
|
|
116
118
|
GeminiSafetyOptions &
|
|
117
|
-
|
|
119
|
+
GeminiCommonConfigOptions &
|
|
118
120
|
GeminiCachedContentOptions &
|
|
119
121
|
GeminiStructuredOutputOptions &
|
|
120
|
-
GeminiThinkingOptions
|
|
122
|
+
GeminiThinkingOptions &
|
|
123
|
+
GeminiThinkingAdvancedOptions
|
|
121
124
|
>
|
|
122
125
|
|
|
123
126
|
const GEMINI_3_PRO_IMAGE = {
|
|
@@ -147,10 +150,11 @@ const GEMINI_3_PRO_IMAGE = {
|
|
|
147
150
|
} as const satisfies ModelMeta<
|
|
148
151
|
GeminiToolConfigOptions &
|
|
149
152
|
GeminiSafetyOptions &
|
|
150
|
-
|
|
153
|
+
GeminiCommonConfigOptions &
|
|
151
154
|
GeminiCachedContentOptions &
|
|
152
155
|
GeminiStructuredOutputOptions &
|
|
153
|
-
GeminiThinkingOptions
|
|
156
|
+
GeminiThinkingOptions &
|
|
157
|
+
GeminiThinkingAdvancedOptions
|
|
154
158
|
>
|
|
155
159
|
|
|
156
160
|
const GEMINI_2_5_PRO = {
|
|
@@ -185,7 +189,7 @@ const GEMINI_2_5_PRO = {
|
|
|
185
189
|
} as const satisfies ModelMeta<
|
|
186
190
|
GeminiToolConfigOptions &
|
|
187
191
|
GeminiSafetyOptions &
|
|
188
|
-
|
|
192
|
+
GeminiCommonConfigOptions &
|
|
189
193
|
GeminiCachedContentOptions &
|
|
190
194
|
GeminiStructuredOutputOptions &
|
|
191
195
|
GeminiThinkingOptions
|
|
@@ -212,7 +216,7 @@ const GEMINI_2_5_PRO_TTS = {
|
|
|
212
216
|
} as const satisfies ModelMeta<
|
|
213
217
|
GeminiToolConfigOptions &
|
|
214
218
|
GeminiSafetyOptions &
|
|
215
|
-
|
|
219
|
+
GeminiCommonConfigOptions &
|
|
216
220
|
GeminiCachedContentOptions
|
|
217
221
|
>
|
|
218
222
|
|
|
@@ -248,7 +252,7 @@ const GEMINI_2_5_FLASH = {
|
|
|
248
252
|
} as const satisfies ModelMeta<
|
|
249
253
|
GeminiToolConfigOptions &
|
|
250
254
|
GeminiSafetyOptions &
|
|
251
|
-
|
|
255
|
+
GeminiCommonConfigOptions &
|
|
252
256
|
GeminiCachedContentOptions &
|
|
253
257
|
GeminiStructuredOutputOptions &
|
|
254
258
|
GeminiThinkingOptions
|
|
@@ -285,7 +289,7 @@ const GEMINI_2_5_FLASH_PREVIEW = {
|
|
|
285
289
|
} as const satisfies ModelMeta<
|
|
286
290
|
GeminiToolConfigOptions &
|
|
287
291
|
GeminiSafetyOptions &
|
|
288
|
-
|
|
292
|
+
GeminiCommonConfigOptions &
|
|
289
293
|
GeminiCachedContentOptions &
|
|
290
294
|
GeminiStructuredOutputOptions &
|
|
291
295
|
GeminiThinkingOptions
|
|
@@ -318,7 +322,7 @@ const GEMINI_2_5_FLASH_IMAGE = {
|
|
|
318
322
|
} as const satisfies ModelMeta<
|
|
319
323
|
GeminiToolConfigOptions &
|
|
320
324
|
GeminiSafetyOptions &
|
|
321
|
-
|
|
325
|
+
GeminiCommonConfigOptions &
|
|
322
326
|
GeminiCachedContentOptions
|
|
323
327
|
>
|
|
324
328
|
/**
|
|
@@ -377,7 +381,7 @@ const GEMINI_2_5_FLASH_TTS = {
|
|
|
377
381
|
} as const satisfies ModelMeta<
|
|
378
382
|
GeminiToolConfigOptions &
|
|
379
383
|
GeminiSafetyOptions &
|
|
380
|
-
|
|
384
|
+
GeminiCommonConfigOptions &
|
|
381
385
|
GeminiCachedContentOptions
|
|
382
386
|
>
|
|
383
387
|
|
|
@@ -412,7 +416,7 @@ const GEMINI_2_5_FLASH_LITE = {
|
|
|
412
416
|
} as const satisfies ModelMeta<
|
|
413
417
|
GeminiToolConfigOptions &
|
|
414
418
|
GeminiSafetyOptions &
|
|
415
|
-
|
|
419
|
+
GeminiCommonConfigOptions &
|
|
416
420
|
GeminiCachedContentOptions &
|
|
417
421
|
GeminiStructuredOutputOptions &
|
|
418
422
|
GeminiThinkingOptions
|
|
@@ -448,7 +452,7 @@ const GEMINI_2_5_FLASH_LITE_PREVIEW = {
|
|
|
448
452
|
} as const satisfies ModelMeta<
|
|
449
453
|
GeminiToolConfigOptions &
|
|
450
454
|
GeminiSafetyOptions &
|
|
451
|
-
|
|
455
|
+
GeminiCommonConfigOptions &
|
|
452
456
|
GeminiCachedContentOptions &
|
|
453
457
|
GeminiStructuredOutputOptions &
|
|
454
458
|
GeminiThinkingOptions
|
|
@@ -484,7 +488,7 @@ const GEMINI_2_FLASH = {
|
|
|
484
488
|
} as const satisfies ModelMeta<
|
|
485
489
|
GeminiToolConfigOptions &
|
|
486
490
|
GeminiSafetyOptions &
|
|
487
|
-
|
|
491
|
+
GeminiCommonConfigOptions &
|
|
488
492
|
GeminiCachedContentOptions &
|
|
489
493
|
GeminiStructuredOutputOptions
|
|
490
494
|
>
|
|
@@ -515,7 +519,7 @@ const GEMINI_2_FLASH_IMAGE = {
|
|
|
515
519
|
} as const satisfies ModelMeta<
|
|
516
520
|
GeminiToolConfigOptions &
|
|
517
521
|
GeminiSafetyOptions &
|
|
518
|
-
|
|
522
|
+
GeminiCommonConfigOptions &
|
|
519
523
|
GeminiCachedContentOptions
|
|
520
524
|
>
|
|
521
525
|
/*
|
|
@@ -579,7 +583,7 @@ const GEMINI_2_FLASH_LITE = {
|
|
|
579
583
|
} as const satisfies ModelMeta<
|
|
580
584
|
GeminiToolConfigOptions &
|
|
581
585
|
GeminiSafetyOptions &
|
|
582
|
-
|
|
586
|
+
GeminiCommonConfigOptions &
|
|
583
587
|
GeminiCachedContentOptions &
|
|
584
588
|
GeminiStructuredOutputOptions
|
|
585
589
|
>
|
|
@@ -603,7 +607,7 @@ const IMAGEN_4_GENERATE = {
|
|
|
603
607
|
} as const satisfies ModelMeta<
|
|
604
608
|
GeminiToolConfigOptions &
|
|
605
609
|
GeminiSafetyOptions &
|
|
606
|
-
|
|
610
|
+
GeminiCommonConfigOptions &
|
|
607
611
|
GeminiCachedContentOptions
|
|
608
612
|
>
|
|
609
613
|
|
|
@@ -626,7 +630,7 @@ const IMAGEN_4_GENERATE_ULTRA = {
|
|
|
626
630
|
} as const satisfies ModelMeta<
|
|
627
631
|
GeminiToolConfigOptions &
|
|
628
632
|
GeminiSafetyOptions &
|
|
629
|
-
|
|
633
|
+
GeminiCommonConfigOptions &
|
|
630
634
|
GeminiCachedContentOptions
|
|
631
635
|
>
|
|
632
636
|
|
|
@@ -649,7 +653,7 @@ const IMAGEN_4_GENERATE_FAST = {
|
|
|
649
653
|
} as const satisfies ModelMeta<
|
|
650
654
|
GeminiToolConfigOptions &
|
|
651
655
|
GeminiSafetyOptions &
|
|
652
|
-
|
|
656
|
+
GeminiCommonConfigOptions &
|
|
653
657
|
GeminiCachedContentOptions
|
|
654
658
|
>
|
|
655
659
|
|
|
@@ -671,7 +675,7 @@ const IMAGEN_3 = {
|
|
|
671
675
|
} as const satisfies ModelMeta<
|
|
672
676
|
GeminiToolConfigOptions &
|
|
673
677
|
GeminiSafetyOptions &
|
|
674
|
-
|
|
678
|
+
GeminiCommonConfigOptions &
|
|
675
679
|
GeminiCachedContentOptions
|
|
676
680
|
>
|
|
677
681
|
/**
|
|
@@ -909,55 +913,57 @@ export type GeminiChatModelProviderOptionsByName = {
|
|
|
909
913
|
// Models with thinking and structured output support
|
|
910
914
|
[GEMINI_3_PRO.name]: GeminiToolConfigOptions &
|
|
911
915
|
GeminiSafetyOptions &
|
|
912
|
-
|
|
916
|
+
GeminiCommonConfigOptions &
|
|
913
917
|
GeminiCachedContentOptions &
|
|
914
918
|
GeminiStructuredOutputOptions &
|
|
915
|
-
GeminiThinkingOptions
|
|
919
|
+
GeminiThinkingOptions &
|
|
920
|
+
GeminiThinkingAdvancedOptions
|
|
916
921
|
[GEMINI_3_FLASH.name]: GeminiToolConfigOptions &
|
|
917
922
|
GeminiSafetyOptions &
|
|
918
|
-
|
|
923
|
+
GeminiCommonConfigOptions &
|
|
919
924
|
GeminiCachedContentOptions &
|
|
920
925
|
GeminiStructuredOutputOptions &
|
|
921
|
-
GeminiThinkingOptions
|
|
926
|
+
GeminiThinkingOptions &
|
|
927
|
+
GeminiThinkingAdvancedOptions
|
|
922
928
|
[GEMINI_2_5_PRO.name]: GeminiToolConfigOptions &
|
|
923
929
|
GeminiSafetyOptions &
|
|
924
|
-
|
|
930
|
+
GeminiCommonConfigOptions &
|
|
925
931
|
GeminiCachedContentOptions &
|
|
926
932
|
GeminiStructuredOutputOptions &
|
|
927
933
|
GeminiThinkingOptions
|
|
928
934
|
[GEMINI_2_5_FLASH.name]: GeminiToolConfigOptions &
|
|
929
935
|
GeminiSafetyOptions &
|
|
930
|
-
|
|
936
|
+
GeminiCommonConfigOptions &
|
|
931
937
|
GeminiCachedContentOptions &
|
|
932
938
|
GeminiStructuredOutputOptions &
|
|
933
939
|
GeminiThinkingOptions
|
|
934
940
|
[GEMINI_2_5_FLASH_PREVIEW.name]: GeminiToolConfigOptions &
|
|
935
941
|
GeminiSafetyOptions &
|
|
936
|
-
|
|
942
|
+
GeminiCommonConfigOptions &
|
|
937
943
|
GeminiCachedContentOptions &
|
|
938
944
|
GeminiStructuredOutputOptions &
|
|
939
945
|
GeminiThinkingOptions
|
|
940
946
|
[GEMINI_2_5_FLASH_LITE.name]: GeminiToolConfigOptions &
|
|
941
947
|
GeminiSafetyOptions &
|
|
942
|
-
|
|
948
|
+
GeminiCommonConfigOptions &
|
|
943
949
|
GeminiCachedContentOptions &
|
|
944
950
|
GeminiStructuredOutputOptions &
|
|
945
951
|
GeminiThinkingOptions
|
|
946
952
|
[GEMINI_2_5_FLASH_LITE_PREVIEW.name]: GeminiToolConfigOptions &
|
|
947
953
|
GeminiSafetyOptions &
|
|
948
|
-
|
|
954
|
+
GeminiCommonConfigOptions &
|
|
949
955
|
GeminiCachedContentOptions &
|
|
950
956
|
GeminiStructuredOutputOptions &
|
|
951
957
|
GeminiThinkingOptions
|
|
952
958
|
// Models with structured output but no thinking support
|
|
953
959
|
[GEMINI_2_FLASH.name]: GeminiToolConfigOptions &
|
|
954
960
|
GeminiSafetyOptions &
|
|
955
|
-
|
|
961
|
+
GeminiCommonConfigOptions &
|
|
956
962
|
GeminiCachedContentOptions &
|
|
957
963
|
GeminiStructuredOutputOptions
|
|
958
964
|
[GEMINI_2_FLASH_LITE.name]: GeminiToolConfigOptions &
|
|
959
965
|
GeminiSafetyOptions &
|
|
960
|
-
|
|
966
|
+
GeminiCommonConfigOptions &
|
|
961
967
|
GeminiCachedContentOptions &
|
|
962
968
|
GeminiStructuredOutputOptions
|
|
963
969
|
}
|