@tanstack/ai-gemini 0.20.1 → 0.22.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 +15 -1
- package/dist/esm/adapters/audio.js +113 -61
- package/dist/esm/adapters/audio.js.map +1 -1
- package/dist/esm/adapters/embedding.d.ts +77 -0
- package/dist/esm/adapters/embedding.js +119 -0
- package/dist/esm/adapters/embedding.js.map +1 -0
- package/dist/esm/adapters/image.js +224 -225
- package/dist/esm/adapters/image.js.map +1 -1
- package/dist/esm/adapters/summarize.js +33 -12
- package/dist/esm/adapters/summarize.js.map +1 -1
- package/dist/esm/adapters/text.js +574 -650
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/adapters/tts.js +197 -178
- package/dist/esm/adapters/tts.js.map +1 -1
- package/dist/esm/adapters/video.js +456 -409
- package/dist/esm/adapters/video.js.map +1 -1
- package/dist/esm/embedding/embedding-provider-options.d.ts +20 -0
- package/dist/esm/experimental/index.js +1 -6
- package/dist/esm/experimental/text-interactions/adapter.js +877 -1014
- package/dist/esm/experimental/text-interactions/adapter.js.map +1 -1
- package/dist/esm/image/image-provider-options.js +74 -54
- package/dist/esm/image/image-provider-options.js.map +1 -1
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js +5 -36
- package/dist/esm/model-meta.d.ts +72 -5
- package/dist/esm/model-meta.js +737 -129
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/realtime/adapter.js +242 -228
- package/dist/esm/realtime/adapter.js.map +1 -1
- package/dist/esm/realtime/client.js +314 -381
- package/dist/esm/realtime/client.js.map +1 -1
- package/dist/esm/realtime/index.js +3 -0
- package/dist/esm/realtime/token.js +50 -36
- package/dist/esm/realtime/token.js.map +1 -1
- package/dist/esm/realtime/utils.js +202 -245
- package/dist/esm/realtime/utils.js.map +1 -1
- package/dist/esm/tools/code-execution-tool.js +11 -13
- package/dist/esm/tools/code-execution-tool.js.map +1 -1
- package/dist/esm/tools/computer-use-tool.js +18 -28
- package/dist/esm/tools/computer-use-tool.js.map +1 -1
- package/dist/esm/tools/file-search-tool.js +11 -14
- package/dist/esm/tools/file-search-tool.js.map +1 -1
- package/dist/esm/tools/function-declaration-tool.js +11 -25
- package/dist/esm/tools/function-declaration-tool.js.map +1 -1
- package/dist/esm/tools/google-maps-tool.js +11 -14
- package/dist/esm/tools/google-maps-tool.js.map +1 -1
- package/dist/esm/tools/google-search-retriveal-tool.js +11 -14
- package/dist/esm/tools/google-search-retriveal-tool.js.map +1 -1
- package/dist/esm/tools/google-search-tool.js +11 -14
- package/dist/esm/tools/google-search-tool.js.map +1 -1
- package/dist/esm/tools/index.js +2 -13
- package/dist/esm/tools/tool-converter.js +64 -57
- package/dist/esm/tools/tool-converter.js.map +1 -1
- package/dist/esm/tools/url-context-tool.js +11 -13
- package/dist/esm/tools/url-context-tool.js.map +1 -1
- package/dist/esm/usage.js +81 -87
- package/dist/esm/usage.js.map +1 -1
- package/dist/esm/utils/client.js +31 -24
- package/dist/esm/utils/client.js.map +1 -1
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/video/video-provider-options.js +73 -20
- package/dist/esm/video/video-provider-options.js.map +1 -1
- package/package.json +7 -7
- package/src/adapters/embedding.ts +173 -0
- package/src/embedding/embedding-provider-options.ts +29 -0
- package/src/index.ts +13 -0
- package/src/model-meta.ts +143 -10
- package/dist/esm/experimental/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/tools/index.js.map +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { BaseEmbeddingAdapter } from '@tanstack/ai/adapters'
|
|
2
|
+
import { toRunErrorPayload } from '@tanstack/ai/adapter-internals'
|
|
3
|
+
import { requireTextOnlyEmbeddingInput } from '@tanstack/ai'
|
|
4
|
+
import {
|
|
5
|
+
createGeminiClient,
|
|
6
|
+
generateId,
|
|
7
|
+
getGeminiApiKeyFromEnv,
|
|
8
|
+
} from '../utils'
|
|
9
|
+
import type { EmbeddingOptions, EmbeddingResult } from '@tanstack/ai'
|
|
10
|
+
import type { EmbedContentConfig, GoogleGenAI } from '@google/genai'
|
|
11
|
+
import type {
|
|
12
|
+
GeminiEmbeddingModel,
|
|
13
|
+
GeminiEmbeddingModelInputModalitiesByName,
|
|
14
|
+
GeminiEmbeddingModelProviderOptionsByName,
|
|
15
|
+
} from '../model-meta'
|
|
16
|
+
import type { GeminiEmbeddingProviderOptions } from '../embedding/embedding-provider-options'
|
|
17
|
+
import type { GeminiClientConfig } from '../utils/client'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for Gemini Embedding adapter
|
|
21
|
+
*/
|
|
22
|
+
export interface GeminiEmbeddingConfig extends GeminiClientConfig {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Gemini Embedding Adapter
|
|
26
|
+
*
|
|
27
|
+
* Tree-shakeable adapter for Gemini text embeddings.
|
|
28
|
+
* Supports gemini-embedding-001.
|
|
29
|
+
*
|
|
30
|
+
* Features:
|
|
31
|
+
* - Batch embedding (one request for the whole input array)
|
|
32
|
+
* - Matryoshka dimension reduction via the top-level `dimensions` option
|
|
33
|
+
* (mapped to the SDK's `outputDimensionality`)
|
|
34
|
+
* - Task-type hints (`taskType`, `title`) via provider options
|
|
35
|
+
*/
|
|
36
|
+
export class GeminiEmbeddingAdapter<
|
|
37
|
+
TModel extends GeminiEmbeddingModel,
|
|
38
|
+
> extends BaseEmbeddingAdapter<
|
|
39
|
+
TModel,
|
|
40
|
+
GeminiEmbeddingProviderOptions,
|
|
41
|
+
GeminiEmbeddingModelProviderOptionsByName,
|
|
42
|
+
GeminiEmbeddingModelInputModalitiesByName
|
|
43
|
+
> {
|
|
44
|
+
readonly name = 'gemini' as const
|
|
45
|
+
|
|
46
|
+
protected client: GoogleGenAI
|
|
47
|
+
|
|
48
|
+
constructor(config: GeminiEmbeddingConfig, model: TModel) {
|
|
49
|
+
super(model, {})
|
|
50
|
+
this.client = createGeminiClient(config)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async createEmbeddings(
|
|
54
|
+
options: EmbeddingOptions<GeminiEmbeddingProviderOptions>,
|
|
55
|
+
): Promise<EmbeddingResult> {
|
|
56
|
+
const { model, logger, modelOptions } = options
|
|
57
|
+
const texts = requireTextOnlyEmbeddingInput(options.input, this.name, model)
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
// Build the config incrementally so possibly-undefined values are never
|
|
61
|
+
// assigned to optional fields (exactOptionalPropertyTypes).
|
|
62
|
+
const config: EmbedContentConfig = {}
|
|
63
|
+
if (options.dimensions !== undefined) {
|
|
64
|
+
config.outputDimensionality = options.dimensions
|
|
65
|
+
}
|
|
66
|
+
if (modelOptions?.taskType !== undefined) {
|
|
67
|
+
config.taskType = modelOptions.taskType
|
|
68
|
+
}
|
|
69
|
+
if (modelOptions?.title !== undefined) {
|
|
70
|
+
config.title = modelOptions.title
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
logger.request(
|
|
74
|
+
`activity=embed provider=${this.name} model=${model} inputs=${texts.length}`,
|
|
75
|
+
{ provider: this.name, model },
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
const response = await this.client.models.embedContent({
|
|
79
|
+
model,
|
|
80
|
+
contents: texts,
|
|
81
|
+
config,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const embeddings = response.embeddings
|
|
85
|
+
if (!embeddings || embeddings.length !== texts.length) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Gemini embedContent returned ${embeddings ? embeddings.length : 'no'} embeddings for ${texts.length} inputs (model: ${model}).`,
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The Gemini embedding API does not report token usage, so `usage` is
|
|
92
|
+
// omitted from the result.
|
|
93
|
+
return {
|
|
94
|
+
id: generateId(this.name),
|
|
95
|
+
model,
|
|
96
|
+
embeddings: embeddings.map((embedding, index) => ({
|
|
97
|
+
vector: embedding.values ?? [],
|
|
98
|
+
index,
|
|
99
|
+
})),
|
|
100
|
+
}
|
|
101
|
+
} catch (error: unknown) {
|
|
102
|
+
logger.errors(`${this.name}.createEmbeddings fatal`, {
|
|
103
|
+
error: toRunErrorPayload(error, `${this.name}.createEmbeddings failed`),
|
|
104
|
+
source: `${this.name}.createEmbeddings`,
|
|
105
|
+
})
|
|
106
|
+
throw error
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Creates a Gemini embedding adapter with explicit API key.
|
|
113
|
+
* Type resolution happens here at the call site.
|
|
114
|
+
*
|
|
115
|
+
* @param model - The model name (e.g., 'gemini-embedding-001')
|
|
116
|
+
* @param apiKey - Your Google API key
|
|
117
|
+
* @param config - Optional additional configuration
|
|
118
|
+
* @returns Configured Gemini embedding adapter instance with resolved types
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const adapter = createGeminiEmbedding('gemini-embedding-001', "your-api-key");
|
|
123
|
+
*
|
|
124
|
+
* const result = await embed({
|
|
125
|
+
* adapter,
|
|
126
|
+
* input: 'a red guitar'
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export function createGeminiEmbedding<TModel extends GeminiEmbeddingModel>(
|
|
131
|
+
model: TModel,
|
|
132
|
+
apiKey: string,
|
|
133
|
+
config?: Omit<GeminiEmbeddingConfig, 'apiKey'>,
|
|
134
|
+
): GeminiEmbeddingAdapter<TModel> {
|
|
135
|
+
// Put apiKey LAST so caller-supplied config can't silently override the
|
|
136
|
+
// explicit argument.
|
|
137
|
+
return new GeminiEmbeddingAdapter({ ...config, apiKey }, model)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Creates a Gemini embedding adapter with automatic API key detection from environment variables.
|
|
142
|
+
* Type resolution happens here at the call site.
|
|
143
|
+
*
|
|
144
|
+
* Looks for `GOOGLE_API_KEY` or `GEMINI_API_KEY` in:
|
|
145
|
+
* - `process.env` (Node.js)
|
|
146
|
+
* - `window.env` (Browser with injected env)
|
|
147
|
+
*
|
|
148
|
+
* @param model - The model name (e.g., 'gemini-embedding-001')
|
|
149
|
+
* @param config - Optional configuration (excluding apiKey which is auto-detected)
|
|
150
|
+
* @returns Configured Gemini embedding adapter instance with resolved types
|
|
151
|
+
* @throws Error if GOOGLE_API_KEY or GEMINI_API_KEY is not found in environment
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* // Automatically uses GOOGLE_API_KEY from environment
|
|
156
|
+
* const adapter = geminiEmbedding('gemini-embedding-001');
|
|
157
|
+
*
|
|
158
|
+
* const result = await embed({
|
|
159
|
+
* adapter,
|
|
160
|
+
* input: ['a red guitar', 'a blue drum kit'],
|
|
161
|
+
* dimensions: 1536
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* console.log(result.embeddings[0].vector)
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export function geminiEmbedding<TModel extends GeminiEmbeddingModel>(
|
|
168
|
+
model: TModel,
|
|
169
|
+
config?: Omit<GeminiEmbeddingConfig, 'apiKey'>,
|
|
170
|
+
): GeminiEmbeddingAdapter<TModel> {
|
|
171
|
+
const apiKey = getGeminiApiKeyFromEnv()
|
|
172
|
+
return createGeminiEmbedding(model, apiKey, config)
|
|
173
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider options for Gemini embedding models.
|
|
3
|
+
*
|
|
4
|
+
* `dimensions` is deliberately absent: it's a first-class top-level option on
|
|
5
|
+
* `embed()` and is mapped to the SDK's `outputDimensionality` by the adapter.
|
|
6
|
+
*/
|
|
7
|
+
export interface GeminiEmbeddingProviderOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Type of task for which the embedding will be used. Helps the model
|
|
10
|
+
* produce embeddings optimized for the intended use case.
|
|
11
|
+
*
|
|
12
|
+
* @see https://ai.google.dev/gemini-api/docs/embeddings#task-types
|
|
13
|
+
*/
|
|
14
|
+
taskType?:
|
|
15
|
+
| 'SEMANTIC_SIMILARITY'
|
|
16
|
+
| 'CLASSIFICATION'
|
|
17
|
+
| 'CLUSTERING'
|
|
18
|
+
| 'RETRIEVAL_DOCUMENT'
|
|
19
|
+
| 'RETRIEVAL_QUERY'
|
|
20
|
+
| 'QUESTION_ANSWERING'
|
|
21
|
+
| 'FACT_VERIFICATION'
|
|
22
|
+
| 'CODE_RETRIEVAL_QUERY'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Title for the text. Only applicable when `taskType` is
|
|
26
|
+
* `RETRIEVAL_DOCUMENT`.
|
|
27
|
+
*/
|
|
28
|
+
title?: string
|
|
29
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,15 @@ export type {
|
|
|
36
36
|
ImagePromptLanguage,
|
|
37
37
|
} from './image/image-provider-options'
|
|
38
38
|
|
|
39
|
+
// Embedding adapter - for embedding vectors
|
|
40
|
+
export {
|
|
41
|
+
GeminiEmbeddingAdapter,
|
|
42
|
+
createGeminiEmbedding,
|
|
43
|
+
geminiEmbedding,
|
|
44
|
+
type GeminiEmbeddingConfig,
|
|
45
|
+
} from './adapters/embedding'
|
|
46
|
+
export type { GeminiEmbeddingProviderOptions } from './embedding/embedding-provider-options'
|
|
47
|
+
|
|
39
48
|
// TTS adapter (experimental)
|
|
40
49
|
/**
|
|
41
50
|
* @experimental Gemini TTS is an experimental feature and may change.
|
|
@@ -100,6 +109,7 @@ export { GEMINI_TTS_VOICES as GeminiTTSVoices } from './model-meta'
|
|
|
100
109
|
export { GEMINI_AUDIO_MODELS as GeminiAudioModels } from './model-meta'
|
|
101
110
|
export { GEMINI_VIDEO_MODELS as GeminiVideoModels } from './model-meta'
|
|
102
111
|
export { GEMINI_INTERACTIONS_VIDEO_MODELS as GeminiInteractionsVideoModels } from './model-meta'
|
|
112
|
+
export { GEMINI_EMBEDDING_MODELS } from './model-meta'
|
|
103
113
|
export type { GeminiModels as GeminiTextModel } from './model-meta'
|
|
104
114
|
export type { GeminiImageModels as GeminiImageModel } from './model-meta'
|
|
105
115
|
export type { GeminiTTSVoice } from './model-meta'
|
|
@@ -112,6 +122,9 @@ export type {
|
|
|
112
122
|
GeminiChatModelProviderOptionsByName,
|
|
113
123
|
GeminiChatModelToolCapabilitiesByName,
|
|
114
124
|
GeminiModelInputModalitiesByName,
|
|
125
|
+
GeminiEmbeddingModel,
|
|
126
|
+
GeminiEmbeddingModelProviderOptionsByName,
|
|
127
|
+
GeminiEmbeddingModelInputModalitiesByName,
|
|
115
128
|
} from './model-meta'
|
|
116
129
|
export type {
|
|
117
130
|
GeminiStructuredOutputOptions,
|
package/src/model-meta.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
GeminiThinkingOptions,
|
|
7
7
|
GeminiToolConfigOptions,
|
|
8
8
|
} from './text/text-provider-options'
|
|
9
|
+
import type { GeminiEmbeddingProviderOptions } from './embedding/embedding-provider-options'
|
|
9
10
|
|
|
10
11
|
interface ModelMeta<TProviderOptions = unknown> {
|
|
11
12
|
name: string
|
|
@@ -743,6 +744,48 @@ const GEMINI_OMNI_FLASH_PREVIEW = {
|
|
|
743
744
|
GeminiCachedContentOptions
|
|
744
745
|
>
|
|
745
746
|
|
|
747
|
+
const GEMINI_3_6_FLASH = {
|
|
748
|
+
name: 'gemini-3.6-flash',
|
|
749
|
+
max_input_tokens: 1_048_576,
|
|
750
|
+
max_output_tokens: 65_536,
|
|
751
|
+
knowledge_cutoff: '2026-03-01',
|
|
752
|
+
supports: {
|
|
753
|
+
input: ['text', 'image', 'video', 'audio', 'document'],
|
|
754
|
+
output: ['text'],
|
|
755
|
+
capabilities: [
|
|
756
|
+
'batch_api',
|
|
757
|
+
'caching',
|
|
758
|
+
'function_calling',
|
|
759
|
+
'structured_output',
|
|
760
|
+
'thinking',
|
|
761
|
+
],
|
|
762
|
+
tools: [
|
|
763
|
+
'code_execution',
|
|
764
|
+
'file_search',
|
|
765
|
+
'google_search',
|
|
766
|
+
'google_maps',
|
|
767
|
+
'url_context',
|
|
768
|
+
'computer_use',
|
|
769
|
+
],
|
|
770
|
+
},
|
|
771
|
+
pricing: {
|
|
772
|
+
input: {
|
|
773
|
+
normal: 1.5,
|
|
774
|
+
cached: 0.15,
|
|
775
|
+
},
|
|
776
|
+
output: {
|
|
777
|
+
normal: 7.5,
|
|
778
|
+
},
|
|
779
|
+
},
|
|
780
|
+
} as const satisfies ModelMeta<
|
|
781
|
+
GeminiToolConfigOptions &
|
|
782
|
+
GeminiSafetyOptions &
|
|
783
|
+
GeminiCommonConfigOptions &
|
|
784
|
+
GeminiCachedContentOptions &
|
|
785
|
+
GeminiStructuredOutputOptions &
|
|
786
|
+
GeminiThinkingOptions
|
|
787
|
+
>
|
|
788
|
+
|
|
746
789
|
const GEMINI_3_5_FLASH = {
|
|
747
790
|
name: 'gemini-3.5-flash',
|
|
748
791
|
max_input_tokens: 1_048_576,
|
|
@@ -757,7 +800,14 @@ const GEMINI_3_5_FLASH = {
|
|
|
757
800
|
'structured_output',
|
|
758
801
|
'thinking',
|
|
759
802
|
],
|
|
760
|
-
tools: [
|
|
803
|
+
tools: [
|
|
804
|
+
'code_execution',
|
|
805
|
+
'file_search',
|
|
806
|
+
'google_search',
|
|
807
|
+
'google_maps',
|
|
808
|
+
'url_context',
|
|
809
|
+
'computer_use',
|
|
810
|
+
],
|
|
761
811
|
},
|
|
762
812
|
pricing: {
|
|
763
813
|
input: {
|
|
@@ -777,8 +827,51 @@ const GEMINI_3_5_FLASH = {
|
|
|
777
827
|
GeminiThinkingOptions
|
|
778
828
|
>
|
|
779
829
|
|
|
830
|
+
const GEMINI_3_5_FLASH_LITE = {
|
|
831
|
+
name: 'gemini-3.5-flash-lite',
|
|
832
|
+
max_input_tokens: 1_048_576,
|
|
833
|
+
max_output_tokens: 65_536,
|
|
834
|
+
knowledge_cutoff: '2025-01-01',
|
|
835
|
+
supports: {
|
|
836
|
+
input: ['text', 'image', 'video', 'audio', 'document'],
|
|
837
|
+
output: ['text'],
|
|
838
|
+
capabilities: [
|
|
839
|
+
'batch_api',
|
|
840
|
+
'caching',
|
|
841
|
+
'function_calling',
|
|
842
|
+
'structured_output',
|
|
843
|
+
'thinking',
|
|
844
|
+
],
|
|
845
|
+
tools: [
|
|
846
|
+
'code_execution',
|
|
847
|
+
'file_search',
|
|
848
|
+
'google_search',
|
|
849
|
+
'google_maps',
|
|
850
|
+
'url_context',
|
|
851
|
+
],
|
|
852
|
+
},
|
|
853
|
+
pricing: {
|
|
854
|
+
input: {
|
|
855
|
+
normal: 0.3,
|
|
856
|
+
cached: 0.03,
|
|
857
|
+
},
|
|
858
|
+
output: {
|
|
859
|
+
normal: 2.5,
|
|
860
|
+
},
|
|
861
|
+
},
|
|
862
|
+
} as const satisfies ModelMeta<
|
|
863
|
+
GeminiToolConfigOptions &
|
|
864
|
+
GeminiSafetyOptions &
|
|
865
|
+
GeminiCommonConfigOptions &
|
|
866
|
+
GeminiCachedContentOptions &
|
|
867
|
+
GeminiStructuredOutputOptions &
|
|
868
|
+
GeminiThinkingOptions
|
|
869
|
+
>
|
|
870
|
+
|
|
780
871
|
export const GEMINI_MODELS = [
|
|
872
|
+
GEMINI_3_6_FLASH.name,
|
|
781
873
|
GEMINI_3_5_FLASH.name,
|
|
874
|
+
GEMINI_3_5_FLASH_LITE.name,
|
|
782
875
|
GEMINI_3_1_PRO.name,
|
|
783
876
|
GEMINI_3_FLASH.name,
|
|
784
877
|
GEMINI_3_1_FLASH_LITE.name,
|
|
@@ -796,11 +889,13 @@ export const GEMINI_MODELS = [
|
|
|
796
889
|
* brittle and keeps the engine's legacy finalization fallback.
|
|
797
890
|
*/
|
|
798
891
|
export const GEMINI_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([
|
|
892
|
+
GEMINI_3_6_FLASH.name,
|
|
893
|
+
GEMINI_3_5_FLASH.name,
|
|
894
|
+
GEMINI_3_5_FLASH_LITE.name,
|
|
799
895
|
GEMINI_3_1_PRO.name,
|
|
800
896
|
GEMINI_3_FLASH.name,
|
|
801
897
|
GEMINI_3_1_FLASH_LITE.name,
|
|
802
898
|
GEMINI_3_1_FLASH_LITE_PREVIEW.name,
|
|
803
|
-
GEMINI_3_5_FLASH.name,
|
|
804
899
|
])
|
|
805
900
|
|
|
806
901
|
export type GeminiModels = (typeof GEMINI_MODELS)[number]
|
|
@@ -897,9 +992,49 @@ export const GEMINI_INTERACTIONS_VIDEO_MODELS = [
|
|
|
897
992
|
GEMINI_OMNI_FLASH_PREVIEW.name,
|
|
898
993
|
] as const
|
|
899
994
|
|
|
995
|
+
/**
|
|
996
|
+
* Embedding models
|
|
997
|
+
*/
|
|
998
|
+
export const GEMINI_EMBEDDING_MODELS = ['gemini-embedding-001'] as const
|
|
999
|
+
|
|
1000
|
+
export type GeminiEmbeddingModel = (typeof GEMINI_EMBEDDING_MODELS)[number]
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Type-only map from embedding model name to its provider options type.
|
|
1004
|
+
*/
|
|
1005
|
+
export type GeminiEmbeddingModelProviderOptionsByName = {
|
|
1006
|
+
'gemini-embedding-001': GeminiEmbeddingProviderOptions
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Per-model input modalities for embedding models. Gemini embedding models
|
|
1011
|
+
* are text-only, so image inputs fail at compile time.
|
|
1012
|
+
*/
|
|
1013
|
+
export type GeminiEmbeddingModelInputModalitiesByName = {
|
|
1014
|
+
'gemini-embedding-001': readonly ['text']
|
|
1015
|
+
}
|
|
1016
|
+
|
|
900
1017
|
// Manual type map for per-model provider options
|
|
901
1018
|
export type GeminiChatModelProviderOptionsByName = {
|
|
902
1019
|
// Models with thinking and structured output support
|
|
1020
|
+
[GEMINI_3_6_FLASH.name]: GeminiToolConfigOptions &
|
|
1021
|
+
GeminiSafetyOptions &
|
|
1022
|
+
GeminiCommonConfigOptions &
|
|
1023
|
+
GeminiCachedContentOptions &
|
|
1024
|
+
GeminiStructuredOutputOptions &
|
|
1025
|
+
GeminiThinkingOptions
|
|
1026
|
+
[GEMINI_3_5_FLASH.name]: GeminiToolConfigOptions &
|
|
1027
|
+
GeminiSafetyOptions &
|
|
1028
|
+
GeminiCommonConfigOptions &
|
|
1029
|
+
GeminiCachedContentOptions &
|
|
1030
|
+
GeminiStructuredOutputOptions &
|
|
1031
|
+
GeminiThinkingOptions
|
|
1032
|
+
[GEMINI_3_5_FLASH_LITE.name]: GeminiToolConfigOptions &
|
|
1033
|
+
GeminiSafetyOptions &
|
|
1034
|
+
GeminiCommonConfigOptions &
|
|
1035
|
+
GeminiCachedContentOptions &
|
|
1036
|
+
GeminiStructuredOutputOptions &
|
|
1037
|
+
GeminiThinkingOptions
|
|
903
1038
|
[GEMINI_3_1_PRO.name]: GeminiToolConfigOptions &
|
|
904
1039
|
GeminiSafetyOptions &
|
|
905
1040
|
GeminiCommonConfigOptions &
|
|
@@ -942,12 +1077,6 @@ export type GeminiChatModelProviderOptionsByName = {
|
|
|
942
1077
|
GeminiCachedContentOptions &
|
|
943
1078
|
GeminiStructuredOutputOptions &
|
|
944
1079
|
GeminiThinkingOptions
|
|
945
|
-
[GEMINI_3_5_FLASH.name]: GeminiToolConfigOptions &
|
|
946
|
-
GeminiSafetyOptions &
|
|
947
|
-
GeminiCommonConfigOptions &
|
|
948
|
-
GeminiCachedContentOptions &
|
|
949
|
-
GeminiStructuredOutputOptions &
|
|
950
|
-
GeminiThinkingOptions
|
|
951
1080
|
}
|
|
952
1081
|
|
|
953
1082
|
/**
|
|
@@ -955,6 +1084,9 @@ export type GeminiChatModelProviderOptionsByName = {
|
|
|
955
1084
|
* Based on the 'supports.tools' arrays defined for each model.
|
|
956
1085
|
*/
|
|
957
1086
|
export type GeminiChatModelToolCapabilitiesByName = {
|
|
1087
|
+
[GEMINI_3_6_FLASH.name]: typeof GEMINI_3_6_FLASH.supports.tools
|
|
1088
|
+
[GEMINI_3_5_FLASH.name]: typeof GEMINI_3_5_FLASH.supports.tools
|
|
1089
|
+
[GEMINI_3_5_FLASH_LITE.name]: typeof GEMINI_3_5_FLASH_LITE.supports.tools
|
|
958
1090
|
[GEMINI_3_1_PRO.name]: typeof GEMINI_3_1_PRO.supports.tools
|
|
959
1091
|
[GEMINI_3_FLASH.name]: typeof GEMINI_3_FLASH.supports.tools
|
|
960
1092
|
[GEMINI_3_1_FLASH_LITE.name]: typeof GEMINI_3_1_FLASH_LITE.supports.tools
|
|
@@ -962,7 +1094,6 @@ export type GeminiChatModelToolCapabilitiesByName = {
|
|
|
962
1094
|
[GEMINI_2_5_PRO.name]: typeof GEMINI_2_5_PRO.supports.tools
|
|
963
1095
|
[GEMINI_2_5_FLASH.name]: typeof GEMINI_2_5_FLASH.supports.tools
|
|
964
1096
|
[GEMINI_2_5_FLASH_LITE.name]: typeof GEMINI_2_5_FLASH_LITE.supports.tools
|
|
965
|
-
[GEMINI_3_5_FLASH.name]: typeof GEMINI_3_5_FLASH.supports.tools
|
|
966
1097
|
}
|
|
967
1098
|
|
|
968
1099
|
/**
|
|
@@ -980,13 +1111,15 @@ export type GeminiChatModelToolCapabilitiesByName = {
|
|
|
980
1111
|
*/
|
|
981
1112
|
export type GeminiModelInputModalitiesByName = {
|
|
982
1113
|
// Models with full multimodal support (text, image, audio, video, document)
|
|
1114
|
+
[GEMINI_3_6_FLASH.name]: typeof GEMINI_3_6_FLASH.supports.input
|
|
1115
|
+
[GEMINI_3_5_FLASH.name]: typeof GEMINI_3_5_FLASH.supports.input
|
|
1116
|
+
[GEMINI_3_5_FLASH_LITE.name]: typeof GEMINI_3_5_FLASH_LITE.supports.input
|
|
983
1117
|
[GEMINI_3_1_PRO.name]: typeof GEMINI_3_1_PRO.supports.input
|
|
984
1118
|
[GEMINI_3_FLASH.name]: typeof GEMINI_3_FLASH.supports.input
|
|
985
1119
|
[GEMINI_3_1_FLASH_LITE.name]: typeof GEMINI_3_1_FLASH_LITE.supports.input
|
|
986
1120
|
[GEMINI_3_1_FLASH_LITE_PREVIEW.name]: typeof GEMINI_3_1_FLASH_LITE_PREVIEW.supports.input
|
|
987
1121
|
[GEMINI_2_5_PRO.name]: typeof GEMINI_2_5_PRO.supports.input
|
|
988
1122
|
[GEMINI_2_5_FLASH_LITE.name]: typeof GEMINI_2_5_FLASH_LITE.supports.input
|
|
989
|
-
[GEMINI_3_5_FLASH.name]: typeof GEMINI_3_5_FLASH.supports.input
|
|
990
1123
|
|
|
991
1124
|
// Models with text, image, audio, video (no document)
|
|
992
1125
|
[GEMINI_2_5_FLASH.name]: typeof GEMINI_2_5_FLASH.supports.input
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|