@llumiverse/common 1.1.0 → 1.2.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/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/options/bedrock.js +32 -76
- package/lib/cjs/options/bedrock.js.map +1 -1
- package/lib/cjs/options/context-windows.js +2 -0
- package/lib/cjs/options/context-windows.js.map +1 -1
- package/lib/cjs/options/openai.js +22 -3
- package/lib/cjs/options/openai.js.map +1 -1
- package/lib/cjs/options/shared-parsing.js +144 -0
- package/lib/cjs/options/shared-parsing.js.map +1 -0
- package/lib/cjs/options/version-parsing.js +326 -0
- package/lib/cjs/options/version-parsing.js.map +1 -0
- package/lib/cjs/options/vertexai.js +35 -199
- package/lib/cjs/options/vertexai.js.map +1 -1
- package/lib/cjs/types.js +2 -1
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/options/bedrock.js +32 -76
- package/lib/esm/options/bedrock.js.map +1 -1
- package/lib/esm/options/context-windows.js +2 -0
- package/lib/esm/options/context-windows.js.map +1 -1
- package/lib/esm/options/openai.js +22 -3
- package/lib/esm/options/openai.js.map +1 -1
- package/lib/esm/options/shared-parsing.js +135 -0
- package/lib/esm/options/shared-parsing.js.map +1 -0
- package/lib/esm/options/version-parsing.js +310 -0
- package/lib/esm/options/version-parsing.js.map +1 -0
- package/lib/esm/options/vertexai.js +28 -190
- package/lib/esm/options/vertexai.js.map +1 -1
- package/lib/esm/types.js +2 -1
- package/lib/esm/types.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/options/bedrock.d.ts +2 -2
- package/lib/types/options/bedrock.d.ts.map +1 -1
- package/lib/types/options/context-windows.d.ts.map +1 -1
- package/lib/types/options/openai.d.ts +3 -2
- package/lib/types/options/openai.d.ts.map +1 -1
- package/lib/types/options/shared-parsing.d.ts +50 -0
- package/lib/types/options/shared-parsing.d.ts.map +1 -0
- package/lib/types/options/version-parsing.d.ts +184 -0
- package/lib/types/options/version-parsing.d.ts.map +1 -0
- package/lib/types/options/vertexai.d.ts +3 -11
- package/lib/types/options/vertexai.d.ts.map +1 -1
- package/lib/types/types.d.ts +2 -0
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/options/bedrock.ts +46 -80
- package/src/options/context-windows.ts +1 -0
- package/src/options/openai.ts +28 -6
- package/src/options/shared-parsing.ts +144 -0
- package/src/options/version-parsing.ts +360 -0
- package/src/options/vertexai.ts +46 -211
- package/src/types.ts +4 -1
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Version parsing utilities for Claude and Gemini models.
|
|
4
|
+
*
|
|
5
|
+
* Provides version detection helpers that are forward-compatible with future
|
|
6
|
+
* model releases (e.g., Haiku 4.7, Sonnet 4.7, Opus 4.8, Opus 5).
|
|
7
|
+
*
|
|
8
|
+
* These helpers are used to:
|
|
9
|
+
* - Control option visibility in the UI
|
|
10
|
+
* - Construct appropriate API payloads for each model version
|
|
11
|
+
*
|
|
12
|
+
* Note: llumiverse does NOT validate options here. Errors from invalid
|
|
13
|
+
* parameters propagate to the provider side.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.parseClaudeVersion = parseClaudeVersion;
|
|
17
|
+
exports.isClaudeVersionGTE = isClaudeVersionGTE;
|
|
18
|
+
exports.hasSamplingParameterRemoval = hasSamplingParameterRemoval;
|
|
19
|
+
exports.requiresAdaptiveThinking = requiresAdaptiveThinking;
|
|
20
|
+
exports.supportsAdaptiveThinking = supportsAdaptiveThinking;
|
|
21
|
+
exports.isExtendedThinkingDeprecated = isExtendedThinkingDeprecated;
|
|
22
|
+
exports.requiresAdaptiveThinkingOnly = requiresAdaptiveThinkingOnly;
|
|
23
|
+
exports.hasSamplingParameterRestriction = hasSamplingParameterRestriction;
|
|
24
|
+
exports.supportsEffort = supportsEffort;
|
|
25
|
+
exports.supportsXHighEffort = supportsXHighEffort;
|
|
26
|
+
exports.getAvailableEffortLevels = getAvailableEffortLevels;
|
|
27
|
+
exports.getGeminiModelVersion = getGeminiModelVersion;
|
|
28
|
+
exports.parseGeminiVersion = parseGeminiVersion;
|
|
29
|
+
exports.isGeminiModelVersionGte = isGeminiModelVersionGte;
|
|
30
|
+
/**
|
|
31
|
+
* Parse Claude model version from a model string.
|
|
32
|
+
*
|
|
33
|
+
* Examples:
|
|
34
|
+
* - "claude-opus-4-7" -> { major: 4, minor: 7, variant: 'opus' }
|
|
35
|
+
* - "claude-sonnet-4-6" -> { major: 4, minor: 6, variant: 'sonnet' }
|
|
36
|
+
* - "claude-3-7-sonnet-20250219" -> { major: 3, minor: 7, variant: 'sonnet' }
|
|
37
|
+
* - "claude-opus-4-6" -> { major: 4, minor: 6, variant: 'opus' }
|
|
38
|
+
*
|
|
39
|
+
* @param modelString - The model identifier string
|
|
40
|
+
* @returns Parsed version info, or null if not parseable
|
|
41
|
+
*/
|
|
42
|
+
function parseClaudeVersion(modelString) {
|
|
43
|
+
// Match pattern: claude-[variant-]-{major}-[optional minor]
|
|
44
|
+
// The minor version is limited to 1-2 digits to avoid matching dates (YYYYMMDD format)
|
|
45
|
+
const match = modelString.match(/claude-(opus|sonnet|haiku)-?(\d+)(?:-(\d{1,2}))?(?:-|\b)/i);
|
|
46
|
+
if (match) {
|
|
47
|
+
const variant = match[1].toLowerCase();
|
|
48
|
+
const major = parseInt(match[2], 10);
|
|
49
|
+
const minor = match[3] ? parseInt(match[3], 10) : 0;
|
|
50
|
+
return { major, minor, variant };
|
|
51
|
+
}
|
|
52
|
+
// Fallback for older format: claude-3-7-sonnet-20250219
|
|
53
|
+
const fallbackMatch = modelString.match(/claude-(\d+)-(\d+)-(\w+)/i);
|
|
54
|
+
if (fallbackMatch) {
|
|
55
|
+
const major = parseInt(fallbackMatch[1], 10);
|
|
56
|
+
const minor = parseInt(fallbackMatch[2], 10);
|
|
57
|
+
const variant = fallbackMatch[3].toLowerCase();
|
|
58
|
+
return { major, minor, variant };
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if a Claude model version is greater than or equal to a target version.
|
|
64
|
+
*
|
|
65
|
+
* @param modelString - The model identifier string
|
|
66
|
+
* @param targetMajor - Target major version
|
|
67
|
+
* @param targetMinor - Target minor version
|
|
68
|
+
* @returns true if the model version is >= target version, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
function isClaudeVersionGTE(modelString, targetMajor, targetMinor) {
|
|
71
|
+
const version = parseClaudeVersion(modelString);
|
|
72
|
+
if (!version) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (version.major > targetMajor) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (version.major === targetMajor && version.minor >= targetMinor) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if a Claude variant model version is greater than or equal to a target version.
|
|
85
|
+
*
|
|
86
|
+
* @param modelString - The model identifier string
|
|
87
|
+
* @param variant - Model variant: "opus" or "sonnet"
|
|
88
|
+
* @param targetMajor - Target major version
|
|
89
|
+
* @param targetMinor - Target minor version
|
|
90
|
+
* @returns true if the model matches the variant and version >= target
|
|
91
|
+
*/
|
|
92
|
+
function isClaudeVariantVersionGTE(modelString, variant, targetMajor, targetMinor) {
|
|
93
|
+
const version = parseClaudeVersion(modelString);
|
|
94
|
+
if (!version)
|
|
95
|
+
return false;
|
|
96
|
+
if (version.variant.toLowerCase() !== variant)
|
|
97
|
+
return false;
|
|
98
|
+
return version.major > targetMajor || (version.major === targetMajor && version.minor >= targetMinor);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if a model requires sampling parameter removal (behavior: sampling params removed on Opus 4.7+).
|
|
102
|
+
*
|
|
103
|
+
* This includes:
|
|
104
|
+
* - claude-opus-4-7
|
|
105
|
+
* - Future Opus 4.x with minor >= 7
|
|
106
|
+
* - Future Opus 5.x+
|
|
107
|
+
*
|
|
108
|
+
* @param modelString - The model identifier string
|
|
109
|
+
* @returns true if Opus 4.7+ or equivalent future model
|
|
110
|
+
*/
|
|
111
|
+
function hasSamplingParameterRemoval(modelString) {
|
|
112
|
+
return isClaudeVariantVersionGTE(modelString, "opus", 4, 7);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if a model requires adaptive thinking (behavior: adaptive thinking required on Opus 4.6+).
|
|
116
|
+
*
|
|
117
|
+
* This includes:
|
|
118
|
+
* - claude-opus-4-6
|
|
119
|
+
* - claude-opus-4-7
|
|
120
|
+
* - Future Opus 4.x with minor >= 6
|
|
121
|
+
* - Future Opus 5.x+
|
|
122
|
+
*
|
|
123
|
+
* @param modelString - The model identifier string
|
|
124
|
+
* @returns true if Opus 4.6+ or equivalent future model
|
|
125
|
+
*/
|
|
126
|
+
function requiresAdaptiveThinking(modelString) {
|
|
127
|
+
return isClaudeVariantVersionGTE(modelString, "opus", 4, 6);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Check if a model supports adaptive thinking.
|
|
131
|
+
*
|
|
132
|
+
* Adaptive thinking was introduced in:
|
|
133
|
+
* - Claude Opus 4.6
|
|
134
|
+
* - Claude Sonnet 4.6
|
|
135
|
+
*
|
|
136
|
+
* @param modelString - The model identifier string
|
|
137
|
+
* @returns true if the model supports adaptive thinking
|
|
138
|
+
*/
|
|
139
|
+
function supportsAdaptiveThinking(modelString) {
|
|
140
|
+
return requiresAdaptiveThinking(modelString) || isClaudeVariantVersionGTE(modelString, "sonnet", 4, 6);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Check if extended thinking is deprecated for this model.
|
|
144
|
+
*
|
|
145
|
+
* Extended thinking (thinking.type: "enabled" with budget_tokens) is deprecated
|
|
146
|
+
* but still functional on:
|
|
147
|
+
* - Claude Opus 4.6+
|
|
148
|
+
* - Claude Sonnet 4.6+
|
|
149
|
+
*
|
|
150
|
+
* @param modelString - The model identifier string
|
|
151
|
+
* @returns true if extended thinking is deprecated (adaptive thinking recommended)
|
|
152
|
+
*/
|
|
153
|
+
function isExtendedThinkingDeprecated(modelString) {
|
|
154
|
+
return supportsAdaptiveThinking(modelString);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Check if a model requires adaptive thinking ONLY (extended thinking removed).
|
|
158
|
+
*
|
|
159
|
+
* On Opus 4.7+, extended thinking returns a 400 error. Only adaptive thinking is supported.
|
|
160
|
+
* Future models (Sonnet 4.7+, Haiku 4.7+, any 5.0+) follow the same pattern.
|
|
161
|
+
*
|
|
162
|
+
* @param modelString - The model identifier string
|
|
163
|
+
* @returns true if extended thinking is removed (returns 400 error)
|
|
164
|
+
*/
|
|
165
|
+
function requiresAdaptiveThinkingOnly(modelString) {
|
|
166
|
+
return hasSamplingParameterRestriction(modelString);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Check if a model has sampling parameter restrictions.
|
|
170
|
+
*
|
|
171
|
+
* On Opus 4.7+, setting temperature, top_p, or top_k to any non-default value
|
|
172
|
+
* returns a 400 error. Future models following the same pattern will also match:
|
|
173
|
+
* - Opus 4.7+ (current restriction)
|
|
174
|
+
* - Sonnet 4.7+, Haiku 4.7+ (future minor versions >= 7)
|
|
175
|
+
* - Sonnet 5.0+, Haiku 5.0+, Opus 5.0+ (future major versions)
|
|
176
|
+
*
|
|
177
|
+
* @param modelString - The model identifier string
|
|
178
|
+
* @returns true if sampling parameters are restricted
|
|
179
|
+
*/
|
|
180
|
+
function hasSamplingParameterRestriction(modelString) {
|
|
181
|
+
const version = parseClaudeVersion(modelString);
|
|
182
|
+
if (!version) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
// Future major versions (5.0+) follow the same pattern as 4.7
|
|
186
|
+
if (version.major > 4) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
// Version 4.7+ (Opus 4.7, Sonnet 4.7, Haiku 4.7, etc.)
|
|
190
|
+
if (version.major === 4 && version.minor >= 7) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Check if a model supports the effort parameter.
|
|
197
|
+
*
|
|
198
|
+
* Effort is supported on:
|
|
199
|
+
* - Claude Opus 4.5+
|
|
200
|
+
* - Claude Opus 4.6+
|
|
201
|
+
* - Claude Sonnet 4.6+
|
|
202
|
+
* - All variants at 4.7+ (Opus, Sonnet, Haiku)
|
|
203
|
+
* - All variants at 5.0+
|
|
204
|
+
*
|
|
205
|
+
* @param modelString - The model identifier string
|
|
206
|
+
* @returns true if the model supports the effort parameter
|
|
207
|
+
*/
|
|
208
|
+
function supportsEffort(modelString) {
|
|
209
|
+
// All 4.7+ variants support effort (covers future Sonnet 4.7, Haiku 4.7, etc.)
|
|
210
|
+
if (hasSamplingParameterRestriction(modelString)) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
// Opus 4.5+ supports effort
|
|
214
|
+
if (isClaudeVariantVersionGTE(modelString, "opus", 4, 5)) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
// Sonnet 4.6+ supports effort
|
|
218
|
+
if (isClaudeVariantVersionGTE(modelString, "sonnet", 4, 6)) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Check if a model supports the xhigh effort level.
|
|
225
|
+
*
|
|
226
|
+
* xhigh is only available on Opus 4.7+.
|
|
227
|
+
*
|
|
228
|
+
* @param modelString - The model identifier string
|
|
229
|
+
* @returns true if the model supports xhigh effort
|
|
230
|
+
*/
|
|
231
|
+
function supportsXHighEffort(modelString) {
|
|
232
|
+
return isClaudeVariantVersionGTE(modelString, "opus", 4, 7);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get the available effort levels for a given Claude model.
|
|
236
|
+
*
|
|
237
|
+
* - Opus 4.7+: low, medium, high, xhigh, max
|
|
238
|
+
* - Opus 4.5+, Opus 4.6+, Sonnet 4.6+: low, medium, high, max
|
|
239
|
+
* - Other models: empty (effort not supported)
|
|
240
|
+
*
|
|
241
|
+
* @param modelString - The model identifier string
|
|
242
|
+
* @returns Record of display label to effort level value, or null if not supported
|
|
243
|
+
*/
|
|
244
|
+
function getAvailableEffortLevels(modelString) {
|
|
245
|
+
if (!supportsEffort(modelString)) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
const levels = {
|
|
249
|
+
"Low": "low",
|
|
250
|
+
"Medium": "medium",
|
|
251
|
+
"High (default)": "high",
|
|
252
|
+
"Max": "max",
|
|
253
|
+
};
|
|
254
|
+
if (supportsXHighEffort(modelString)) {
|
|
255
|
+
// Insert xhigh between high and max
|
|
256
|
+
return {
|
|
257
|
+
"Low": "low",
|
|
258
|
+
"Medium": "medium",
|
|
259
|
+
"High (default)": "high",
|
|
260
|
+
"Extra High": "xhigh",
|
|
261
|
+
"Max": "max",
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
return levels;
|
|
265
|
+
}
|
|
266
|
+
// ============================================================================
|
|
267
|
+
// Gemini Version Parsing
|
|
268
|
+
// ============================================================================
|
|
269
|
+
/**
|
|
270
|
+
* Extract Gemini version from a model ID.
|
|
271
|
+
*
|
|
272
|
+
* Examples:
|
|
273
|
+
* - "locations/global/publishers/google/models/gemini-2.5-flash" -> "2.5"
|
|
274
|
+
* - "publishers/google/models/gemini-3-pro-image-preview" -> "3"
|
|
275
|
+
* - "gemini-3.1-flash-lite-preview" -> "3.1"
|
|
276
|
+
*
|
|
277
|
+
* @param modelId - The model identifier string
|
|
278
|
+
* @returns Version string (e.g., "2.5", "3", "3.1"), or undefined if not parseable
|
|
279
|
+
*/
|
|
280
|
+
function getGeminiModelVersion(modelId) {
|
|
281
|
+
const modelName = modelId.split('/').pop() ?? modelId;
|
|
282
|
+
const match = modelName.match(/^gemini-(\d+(?:\.\d+)?)/i);
|
|
283
|
+
return match?.[1];
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Parse a version string into major.minor components.
|
|
287
|
+
*
|
|
288
|
+
* @param version - Version string (e.g., "2.5", "3", "3.1")
|
|
289
|
+
* @returns Parsed version, or undefined if not parseable
|
|
290
|
+
*/
|
|
291
|
+
function parseGeminiVersion(version) {
|
|
292
|
+
const match = version.match(/^(\d+)(?:\.(\d+))?$/);
|
|
293
|
+
if (!match) {
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
major: Number(match[1]),
|
|
298
|
+
minor: Number(match[2] ?? '0'),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Check if a Gemini model version is greater than or equal to a minimum version.
|
|
303
|
+
*
|
|
304
|
+
* @param modelId - The model identifier string
|
|
305
|
+
* @param minVersion - Minimum version string (e.g., "2.5", "3.0")
|
|
306
|
+
* @returns true if model version >= min version
|
|
307
|
+
*/
|
|
308
|
+
function isGeminiModelVersionGte(modelId, minVersion) {
|
|
309
|
+
const modelVersion = getGeminiModelVersion(modelId);
|
|
310
|
+
if (!modelVersion) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
const current = parseGeminiVersion(modelVersion);
|
|
314
|
+
const target = parseGeminiVersion(minVersion);
|
|
315
|
+
if (!current || !target) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
if (current.major > target.major) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
if (current.major < target.major) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
return current.minor >= target.minor;
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=version-parsing.js.map
|
|
@@ -0,0 +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AAe;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO;QACH,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;KACjC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CAAC,OAAe,EAAE,UAAkB;IACvE,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACpD,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,OAAO,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;AACzC,CAAC"}
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ThinkingLevel = exports.ImagenMaskMode = exports.ImagenTaskType = void 0;
|
|
4
4
|
exports.isFlexSupportedGeminiModel = isFlexSupportedGeminiModel;
|
|
5
5
|
exports.getVertexAiOptions = getVertexAiOptions;
|
|
6
|
-
exports.getGeminiModelVersion = getGeminiModelVersion;
|
|
7
|
-
exports.isGeminiModelVersionGte = isGeminiModelVersionGte;
|
|
8
6
|
exports.getMaxTokensLimitVertexAi = getMaxTokensLimitVertexAi;
|
|
9
7
|
const types_js_1 = require("../types.js");
|
|
10
|
-
const context_windows_js_1 = require("./context-windows.js");
|
|
11
8
|
const fallback_js_1 = require("./fallback.js");
|
|
9
|
+
const shared_parsing_js_1 = require("./shared-parsing.js");
|
|
10
|
+
const version_parsing_js_1 = require("./version-parsing.js");
|
|
12
11
|
var ImagenTaskType;
|
|
13
12
|
(function (ImagenTaskType) {
|
|
14
13
|
ImagenTaskType["TEXT_IMAGE"] = "TEXT_IMAGE";
|
|
@@ -63,125 +62,6 @@ function getVertexAiOptions(model, option) {
|
|
|
63
62
|
}
|
|
64
63
|
return fallback_js_1.textOptionsFallback;
|
|
65
64
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Extract Gemini version from a model ID.
|
|
68
|
-
*
|
|
69
|
-
* Examples:
|
|
70
|
-
* - locations/global/publishers/google/models/gemini-2.5-flash -> 2.5
|
|
71
|
-
* - publishers/google/models/gemini-3-pro-image-preview -> 3
|
|
72
|
-
*/
|
|
73
|
-
function getGeminiModelVersion(modelId) {
|
|
74
|
-
const modelName = modelId.split('/').pop() ?? modelId;
|
|
75
|
-
const match = modelName.match(/^gemini-(\d+(?:\.\d+)?)/i);
|
|
76
|
-
return match?.[1];
|
|
77
|
-
}
|
|
78
|
-
function parseVersion(version) {
|
|
79
|
-
const match = version.match(/^(\d+)(?:\.(\d+))?$/);
|
|
80
|
-
if (!match) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
major: Number(match[1]),
|
|
85
|
-
minor: Number(match[2] ?? '0'),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function isGeminiModelVersionGte(modelId, minVersion) {
|
|
89
|
-
const modelVersion = getGeminiModelVersion(modelId);
|
|
90
|
-
if (!modelVersion) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
const current = parseVersion(modelVersion);
|
|
94
|
-
const target = parseVersion(minVersion);
|
|
95
|
-
if (!current || !target) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
if (current.major > target.major) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
if (current.major < target.major) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
return current.minor >= target.minor;
|
|
105
|
-
}
|
|
106
|
-
function getGeminiThinkingLevels(model) {
|
|
107
|
-
const normalized = model.toLowerCase();
|
|
108
|
-
const isGemini3OrLater = isGeminiModelVersionGte(model, "3.0");
|
|
109
|
-
const isGemini31OrLater = isGeminiModelVersionGte(model, "3.1");
|
|
110
|
-
const isFlashLite = normalized.includes("flash-lite");
|
|
111
|
-
const isFlash = normalized.includes("flash") && !isFlashLite;
|
|
112
|
-
const isPro = normalized.includes("pro");
|
|
113
|
-
// Gemini 3 / 3.1 thinking_level support summary:
|
|
114
|
-
// - MINIMAL: Gemini 3 Flash and Gemini 3.1 Flash-Lite only.
|
|
115
|
-
// Gemini 3.1 Flash-Lite defaults to MINIMAL.
|
|
116
|
-
// - LOW: Supported by Gemini 3+ models.
|
|
117
|
-
// - MEDIUM: Gemini 3 Flash, Gemini 3.1 Pro, Gemini 3.1 Flash-Lite.
|
|
118
|
-
// - HIGH: Supported by Gemini 3+ models.
|
|
119
|
-
// - Thinking cannot be turned off for Gemini 3 Pro and Gemini 3.1 Pro.
|
|
120
|
-
if (isFlashLite && isGemini31OrLater) {
|
|
121
|
-
return {
|
|
122
|
-
levels: {
|
|
123
|
-
"Minimal": ThinkingLevel.MINIMAL,
|
|
124
|
-
"Low": ThinkingLevel.LOW,
|
|
125
|
-
"Medium": ThinkingLevel.MEDIUM,
|
|
126
|
-
"High": ThinkingLevel.HIGH,
|
|
127
|
-
},
|
|
128
|
-
defaultLevel: ThinkingLevel.MINIMAL,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
// Gemini 3+ Flash supports MINIMAL and MEDIUM in addition to LOW/HIGH.
|
|
132
|
-
if (isFlash) {
|
|
133
|
-
return {
|
|
134
|
-
levels: {
|
|
135
|
-
"Minimal": ThinkingLevel.MINIMAL,
|
|
136
|
-
"Low": ThinkingLevel.LOW,
|
|
137
|
-
"Medium": ThinkingLevel.MEDIUM,
|
|
138
|
-
"High": ThinkingLevel.HIGH,
|
|
139
|
-
},
|
|
140
|
-
defaultLevel: ThinkingLevel.MINIMAL,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
// Gemini 3.1 Pro adds MEDIUM, but does not support turning thinking off.
|
|
144
|
-
if (isPro && isGemini31OrLater) {
|
|
145
|
-
return {
|
|
146
|
-
levels: {
|
|
147
|
-
"Low": ThinkingLevel.LOW,
|
|
148
|
-
"Medium": ThinkingLevel.MEDIUM,
|
|
149
|
-
"High": ThinkingLevel.HIGH,
|
|
150
|
-
},
|
|
151
|
-
defaultLevel: ThinkingLevel.LOW,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
// Gemini 3 Pro supports LOW/HIGH. Thinking cannot be turned off.
|
|
155
|
-
if (isPro) {
|
|
156
|
-
return {
|
|
157
|
-
levels: {
|
|
158
|
-
"Low": ThinkingLevel.LOW,
|
|
159
|
-
"High": ThinkingLevel.HIGH,
|
|
160
|
-
},
|
|
161
|
-
defaultLevel: ThinkingLevel.LOW,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
// Fallback for unknown Gemini 3+/4+ families:
|
|
165
|
-
// prefer future-safe propagation by enabling the guaranteed baseline levels.
|
|
166
|
-
if (isGemini3OrLater) {
|
|
167
|
-
return {
|
|
168
|
-
levels: {
|
|
169
|
-
"Low": ThinkingLevel.LOW,
|
|
170
|
-
"Medium": ThinkingLevel.MEDIUM,
|
|
171
|
-
"High": ThinkingLevel.HIGH,
|
|
172
|
-
},
|
|
173
|
-
defaultLevel: ThinkingLevel.LOW,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
// Non-3.x models should not reach this helper in normal flow.
|
|
177
|
-
return {
|
|
178
|
-
levels: {
|
|
179
|
-
"Low": ThinkingLevel.LOW,
|
|
180
|
-
"High": ThinkingLevel.HIGH,
|
|
181
|
-
},
|
|
182
|
-
defaultLevel: ThinkingLevel.LOW,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
65
|
function getImagenOptions(model, option) {
|
|
186
66
|
const commonOptions = [
|
|
187
67
|
{
|
|
@@ -321,8 +201,16 @@ function getImagenOptions(model, option) {
|
|
|
321
201
|
}
|
|
322
202
|
return fallback_js_1.textOptionsFallback;
|
|
323
203
|
}
|
|
204
|
+
function getGeminiEffortOptions(model) {
|
|
205
|
+
if (model.includes("gemini-3-pro-image")) {
|
|
206
|
+
return { "High": "high" };
|
|
207
|
+
}
|
|
208
|
+
if (model.includes("gemini-3.1-flash-image")) {
|
|
209
|
+
return { "Low": "low", "High": "high" };
|
|
210
|
+
}
|
|
211
|
+
return { "Low": "low", "Medium": "medium", "High": "high" };
|
|
212
|
+
}
|
|
324
213
|
function getGeminiThinkingOptionItems(model) {
|
|
325
|
-
const thinkingLevelConfig = getGeminiThinkingLevels(model);
|
|
326
214
|
return [
|
|
327
215
|
{
|
|
328
216
|
name: "include_thoughts",
|
|
@@ -331,10 +219,9 @@ function getGeminiThinkingOptionItems(model) {
|
|
|
331
219
|
description: "Include the model's reasoning process in the response"
|
|
332
220
|
},
|
|
333
221
|
{
|
|
334
|
-
name:
|
|
222
|
+
name: types_js_1.SharedOptions.effort,
|
|
335
223
|
type: types_js_1.OptionType.enum,
|
|
336
|
-
enum:
|
|
337
|
-
default: thinkingLevelConfig.defaultLevel,
|
|
224
|
+
enum: getGeminiEffortOptions(model),
|
|
338
225
|
description: "Higher thinking levels may improve quality, but increase response times and token costs"
|
|
339
226
|
}
|
|
340
227
|
];
|
|
@@ -342,8 +229,8 @@ function getGeminiThinkingOptionItems(model) {
|
|
|
342
229
|
function getGeminiOptions(model, option) {
|
|
343
230
|
// Special handling for gemini image / nano banana models
|
|
344
231
|
if (model.includes("image")) {
|
|
345
|
-
const isGemini25OrLater = isGeminiModelVersionGte(model, "2.5");
|
|
346
|
-
const isGemini3OrLater = isGeminiModelVersionGte(model, "3.0");
|
|
232
|
+
const isGemini25OrLater = (0, version_parsing_js_1.isGeminiModelVersionGte)(model, "2.5");
|
|
233
|
+
const isGemini3OrLater = (0, version_parsing_js_1.isGeminiModelVersionGte)(model, "3.0");
|
|
347
234
|
const max_tokens_limit = getGeminiMaxTokensLimit(model);
|
|
348
235
|
const excludeOptions = ["max_tokens", "presence_penalty", "frequency_penalty", "seed", "top_k"];
|
|
349
236
|
let commonOptions = fallback_js_1.textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
|
|
@@ -464,7 +351,7 @@ function getGeminiOptions(model, option) {
|
|
|
464
351
|
const seedOption = {
|
|
465
352
|
name: types_js_1.SharedOptions.seed, type: types_js_1.OptionType.numeric, integer: true, description: "The seed for the generation, useful for reproducibility"
|
|
466
353
|
};
|
|
467
|
-
if (isGeminiModelVersionGte(model, "3.0")) {
|
|
354
|
+
if ((0, version_parsing_js_1.isGeminiModelVersionGte)(model, "3.0")) {
|
|
468
355
|
const flexOptions = isFlexSupportedGeminiModel(model) ? [{
|
|
469
356
|
name: "flex",
|
|
470
357
|
type: types_js_1.OptionType.boolean,
|
|
@@ -550,76 +437,32 @@ function getGeminiOptions(model, option) {
|
|
|
550
437
|
};
|
|
551
438
|
}
|
|
552
439
|
function getClaudeOptions(model, option) {
|
|
553
|
-
const max_tokens_limit = getClaudeMaxTokensLimit(model);
|
|
440
|
+
const max_tokens_limit = (0, shared_parsing_js_1.getClaudeMaxTokensLimit)(model);
|
|
554
441
|
const excludeOptions = ["max_tokens", "presence_penalty", "frequency_penalty"];
|
|
555
|
-
|
|
442
|
+
let commonOptions = fallback_js_1.textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
|
|
443
|
+
// Opus 4.7+ models no longer support temperature, top_p, top_k (returns 400 error)
|
|
444
|
+
// Opus 4.6 and Sonnet 4.6 still support these parameters
|
|
445
|
+
const hasSamplingRestriction = (0, version_parsing_js_1.hasSamplingParameterRestriction)(model);
|
|
446
|
+
if (hasSamplingRestriction) {
|
|
447
|
+
commonOptions = commonOptions.filter((option) => option.name !== types_js_1.SharedOptions.temperature &&
|
|
448
|
+
option.name !== types_js_1.SharedOptions.top_p &&
|
|
449
|
+
option.name !== "top_k");
|
|
450
|
+
}
|
|
556
451
|
const max_tokens = [{
|
|
557
452
|
name: types_js_1.SharedOptions.max_tokens, type: types_js_1.OptionType.numeric, min: 1, max: max_tokens_limit,
|
|
558
453
|
integer: true, step: 200, description: "The maximum number of tokens to generate"
|
|
559
454
|
}];
|
|
560
|
-
const claudeCacheOptions = [
|
|
561
|
-
{
|
|
562
|
-
name: "cache_enabled",
|
|
563
|
-
type: types_js_1.OptionType.boolean,
|
|
564
|
-
default: false,
|
|
565
|
-
description: "Enable prompt caching. Injects cache breakpoints at the system prompt, tools, and conversation pivot.",
|
|
566
|
-
},
|
|
567
|
-
];
|
|
568
|
-
const claudeCacheTtlOptions = option?.cache_enabled ? [
|
|
569
|
-
{
|
|
570
|
-
name: "cache_ttl",
|
|
571
|
-
type: types_js_1.OptionType.enum,
|
|
572
|
-
enum: { "5 minutes (default)": "5m", "1 hour": "1h" },
|
|
573
|
-
default: "5m",
|
|
574
|
-
description: "TTL for cache breakpoints. '1h' requires extended caching to be enabled on your account.",
|
|
575
|
-
}
|
|
576
|
-
] : [];
|
|
577
|
-
if (model.includes("-3-7") || model.includes("-4")) {
|
|
578
|
-
const claudeModeOptions = [
|
|
579
|
-
{
|
|
580
|
-
name: "thinking_mode",
|
|
581
|
-
type: types_js_1.OptionType.boolean,
|
|
582
|
-
default: false,
|
|
583
|
-
description: "If true, use the extended reasoning mode"
|
|
584
|
-
},
|
|
585
|
-
];
|
|
586
|
-
const claudeThinkingOptions = option?.thinking_mode ? [
|
|
587
|
-
{
|
|
588
|
-
name: "thinking_budget_tokens",
|
|
589
|
-
type: types_js_1.OptionType.numeric,
|
|
590
|
-
min: 1024,
|
|
591
|
-
default: 1024,
|
|
592
|
-
integer: true,
|
|
593
|
-
step: 100,
|
|
594
|
-
description: "The target number of tokens to use for reasoning, not a hard limit."
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
name: "include_thoughts",
|
|
598
|
-
type: types_js_1.OptionType.boolean,
|
|
599
|
-
default: false,
|
|
600
|
-
description: "Include the model's reasoning process in the response"
|
|
601
|
-
}
|
|
602
|
-
] : [];
|
|
603
|
-
return {
|
|
604
|
-
_option_id: "vertexai-claude",
|
|
605
|
-
options: [
|
|
606
|
-
...max_tokens,
|
|
607
|
-
...commonOptions,
|
|
608
|
-
...claudeModeOptions,
|
|
609
|
-
...claudeThinkingOptions,
|
|
610
|
-
...claudeCacheOptions,
|
|
611
|
-
...claudeCacheTtlOptions,
|
|
612
|
-
]
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
455
|
return {
|
|
616
456
|
_option_id: "vertexai-claude",
|
|
617
457
|
options: [
|
|
618
458
|
...max_tokens,
|
|
619
459
|
...commonOptions,
|
|
620
|
-
...
|
|
621
|
-
...
|
|
622
|
-
|
|
460
|
+
...(0, shared_parsing_js_1.buildClaudeEffortOptions)(model),
|
|
461
|
+
...(0, shared_parsing_js_1.buildClaudeThinkingBudgetOption)(model),
|
|
462
|
+
...(0, shared_parsing_js_1.buildClaudeIncludeThoughtsOption)(model),
|
|
463
|
+
...(0, shared_parsing_js_1.buildClaudeCacheOptions)(),
|
|
464
|
+
...(0, shared_parsing_js_1.buildClaudeCacheTtlOptions)(option?.cache_enabled),
|
|
465
|
+
],
|
|
623
466
|
};
|
|
624
467
|
}
|
|
625
468
|
function getLlamaOptions(model) {
|
|
@@ -651,9 +494,9 @@ function getLlamaOptions(model) {
|
|
|
651
494
|
}
|
|
652
495
|
function getGeminiMaxTokensLimit(model) {
|
|
653
496
|
if (model.includes("image")) {
|
|
654
|
-
return isGeminiModelVersionGte(model, "2.5") ? 32768 : 8192;
|
|
497
|
+
return (0, version_parsing_js_1.isGeminiModelVersionGte)(model, "2.5") ? 32768 : 8192;
|
|
655
498
|
}
|
|
656
|
-
if (model.includes("thinking") || isGeminiModelVersionGte(model, "2.5")) {
|
|
499
|
+
if (model.includes("thinking") || (0, version_parsing_js_1.isGeminiModelVersionGte)(model, "2.5")) {
|
|
657
500
|
return 65535; // API upper bound is exclusive
|
|
658
501
|
}
|
|
659
502
|
if (model.includes("ultra") || model.includes("vision")) {
|
|
@@ -661,13 +504,6 @@ function getGeminiMaxTokensLimit(model) {
|
|
|
661
504
|
}
|
|
662
505
|
return 8192;
|
|
663
506
|
}
|
|
664
|
-
// Delegate to provider-agnostic limits,
|
|
665
|
-
// override only where VertexAI supports extended output (128K for 3.7)
|
|
666
|
-
function getClaudeMaxTokensLimit(model) {
|
|
667
|
-
if (model.includes('-3-7'))
|
|
668
|
-
return 128000;
|
|
669
|
-
return (0, context_windows_js_1.getMaxOutputTokens)(model);
|
|
670
|
-
}
|
|
671
507
|
function getLlamaMaxTokensLimit(_model) {
|
|
672
508
|
return 8192;
|
|
673
509
|
}
|
|
@@ -676,7 +512,7 @@ function getMaxTokensLimitVertexAi(model) {
|
|
|
676
512
|
return 0; // Imagen models do not have a max tokens limit in the same way as text models
|
|
677
513
|
}
|
|
678
514
|
else if (model.includes("claude")) {
|
|
679
|
-
return getClaudeMaxTokensLimit(model);
|
|
515
|
+
return (0, shared_parsing_js_1.getClaudeMaxTokensLimit)(model);
|
|
680
516
|
}
|
|
681
517
|
else if (model.includes("gemini")) {
|
|
682
518
|
return getGeminiMaxTokensLimit(model);
|