@llumiverse/common 1.2.0 → 1.4.0-dev.20260629.090753Z
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/capability/anthropic.d.ts +3 -0
- package/lib/capability/anthropic.d.ts.map +1 -0
- package/lib/capability/anthropic.js +92 -0
- package/lib/capability/anthropic.js.map +1 -0
- package/lib/{types/capability → capability}/azure_foundry.d.ts +1 -1
- package/lib/capability/azure_foundry.d.ts.map +1 -0
- package/lib/capability/azure_foundry.js +394 -0
- package/lib/capability/azure_foundry.js.map +1 -0
- package/lib/{types/capability → capability}/bedrock.d.ts +1 -1
- package/lib/capability/bedrock.d.ts.map +1 -0
- package/lib/capability/bedrock.js +300 -0
- package/lib/capability/bedrock.js.map +1 -0
- package/lib/{types/capability → capability}/openai.d.ts +1 -1
- package/lib/capability/openai.d.ts.map +1 -0
- package/lib/capability/openai.js +179 -0
- package/lib/capability/openai.js.map +1 -0
- package/lib/{types/capability → capability}/vertexai.d.ts +1 -1
- package/lib/capability/vertexai.d.ts.map +1 -0
- package/lib/capability/vertexai.js +137 -0
- package/lib/capability/vertexai.js.map +1 -0
- package/lib/{types/capability.d.ts → capability.d.ts} +1 -1
- package/lib/capability.d.ts.map +1 -0
- package/lib/{esm/capability.js → capability.js} +21 -15
- package/lib/capability.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -0
- package/lib/options/anthropic.d.ts +16 -0
- package/lib/options/anthropic.d.ts.map +1 -0
- package/lib/options/anthropic.js +34 -0
- package/lib/options/anthropic.js.map +1 -0
- package/lib/{types/options → options}/azure_foundry.d.ts +14 -14
- package/lib/options/azure_foundry.d.ts.map +1 -0
- package/lib/{esm/options → options}/azure_foundry.js +126 -126
- package/lib/options/azure_foundry.js.map +1 -0
- package/lib/options/bedrock.d.ts +61 -0
- package/lib/options/bedrock.d.ts.map +1 -0
- package/lib/options/bedrock.js +489 -0
- package/lib/options/bedrock.js.map +1 -0
- package/lib/options/context-windows.d.ts.map +1 -0
- package/lib/options/context-windows.js.map +1 -0
- package/lib/options/embedding.d.ts +38 -0
- package/lib/options/embedding.d.ts.map +1 -0
- package/lib/options/embedding.js +77 -0
- package/lib/options/embedding.js.map +1 -0
- package/lib/{types/options → options}/fallback.d.ts +2 -2
- package/lib/options/fallback.d.ts.map +1 -0
- package/lib/options/fallback.js +65 -0
- package/lib/options/fallback.js.map +1 -0
- package/lib/{types/options → options}/groq.d.ts +2 -2
- package/lib/options/groq.d.ts.map +1 -0
- package/lib/options/groq.js +54 -0
- package/lib/options/groq.js.map +1 -0
- package/lib/options/openai.d.ts +40 -0
- package/lib/options/openai.d.ts.map +1 -0
- package/lib/options/openai.js +284 -0
- package/lib/options/openai.js.map +1 -0
- package/lib/{types/options → options}/shared-parsing.d.ts +1 -1
- package/lib/options/shared-parsing.d.ts.map +1 -0
- package/lib/{esm/options → options}/shared-parsing.js +14 -17
- package/lib/options/shared-parsing.js.map +1 -0
- package/lib/options/version-parsing.d.ts.map +1 -0
- package/lib/{esm/options → options}/version-parsing.js +15 -15
- package/lib/options/version-parsing.js.map +1 -0
- package/lib/{types/options → options}/vertexai.d.ts +18 -15
- package/lib/options/vertexai.d.ts.map +1 -0
- package/lib/options/vertexai.js +606 -0
- package/lib/options/vertexai.js.map +1 -0
- package/lib/{types/options.d.ts → options.d.ts} +1 -1
- package/lib/options.d.ts.map +1 -0
- package/lib/{esm/options.js → options.js} +10 -7
- package/lib/options.js.map +1 -0
- package/lib/{types/types.d.ts → types.d.ts} +161 -42
- package/lib/types.d.ts.map +1 -0
- package/lib/{esm/types.js → types.js} +28 -22
- package/lib/types.js.map +1 -0
- package/package.json +12 -34
- package/src/LlumiverseError.test.ts +18 -72
- package/src/capability/anthropic.ts +99 -0
- package/src/capability/azure_foundry.ts +303 -65
- package/src/capability/bedrock.ts +201 -56
- package/src/capability/openai.ts +135 -41
- package/src/capability/vertexai.ts +105 -35
- package/src/capability.ts +21 -16
- package/src/index.ts +13 -11
- package/src/options/anthropic.ts +59 -0
- package/src/options/azure_foundry.ts +157 -143
- package/src/options/bedrock.ts +266 -187
- package/src/options/context-windows.ts +2 -2
- package/src/options/embedding.ts +92 -0
- package/src/options/fallback.ts +50 -17
- package/src/options/groq.ts +48 -21
- package/src/options/openai.ts +231 -183
- package/src/options/shared-parsing.ts +16 -21
- package/src/options/version-parsing.ts +17 -17
- package/src/options/vertexai.ts +385 -288
- package/src/options.ts +11 -8
- package/src/types.ts +284 -160
- package/lib/cjs/capability/azure_foundry.js +0 -160
- package/lib/cjs/capability/azure_foundry.js.map +0 -1
- package/lib/cjs/capability/bedrock.js +0 -158
- package/lib/cjs/capability/bedrock.js.map +0 -1
- package/lib/cjs/capability/openai.js +0 -98
- package/lib/cjs/capability/openai.js.map +0 -1
- package/lib/cjs/capability/vertexai.js +0 -80
- package/lib/cjs/capability/vertexai.js.map +0 -1
- package/lib/cjs/capability.js +0 -109
- package/lib/cjs/capability.js.map +0 -1
- package/lib/cjs/index.js +0 -27
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/options/azure_foundry.js +0 -423
- package/lib/cjs/options/azure_foundry.js.map +0 -1
- package/lib/cjs/options/bedrock.js +0 -427
- package/lib/cjs/options/bedrock.js.map +0 -1
- package/lib/cjs/options/context-windows.js +0 -138
- package/lib/cjs/options/context-windows.js.map +0 -1
- package/lib/cjs/options/fallback.js +0 -35
- package/lib/cjs/options/fallback.js.map +0 -1
- package/lib/cjs/options/groq.js +0 -37
- package/lib/cjs/options/groq.js.map +0 -1
- package/lib/cjs/options/openai.js +0 -246
- package/lib/cjs/options/openai.js.map +0 -1
- package/lib/cjs/options/shared-parsing.js +0 -144
- package/lib/cjs/options/shared-parsing.js.map +0 -1
- package/lib/cjs/options/version-parsing.js +0 -326
- package/lib/cjs/options/version-parsing.js.map +0 -1
- package/lib/cjs/options/vertexai.js +0 -525
- package/lib/cjs/options/vertexai.js.map +0 -1
- package/lib/cjs/options.js +0 -30
- package/lib/cjs/options.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/types.js +0 -299
- package/lib/cjs/types.js.map +0 -1
- package/lib/esm/capability/azure_foundry.js +0 -157
- package/lib/esm/capability/azure_foundry.js.map +0 -1
- package/lib/esm/capability/bedrock.js +0 -155
- package/lib/esm/capability/bedrock.js.map +0 -1
- package/lib/esm/capability/openai.js +0 -95
- package/lib/esm/capability/openai.js.map +0 -1
- package/lib/esm/capability/vertexai.js +0 -77
- package/lib/esm/capability/vertexai.js.map +0 -1
- package/lib/esm/capability.js.map +0 -1
- package/lib/esm/index.js +0 -11
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/options/azure_foundry.js.map +0 -1
- package/lib/esm/options/bedrock.js +0 -423
- package/lib/esm/options/bedrock.js.map +0 -1
- package/lib/esm/options/context-windows.js.map +0 -1
- package/lib/esm/options/fallback.js +0 -32
- package/lib/esm/options/fallback.js.map +0 -1
- package/lib/esm/options/groq.js +0 -34
- package/lib/esm/options/groq.js.map +0 -1
- package/lib/esm/options/openai.js +0 -243
- package/lib/esm/options/openai.js.map +0 -1
- package/lib/esm/options/shared-parsing.js.map +0 -1
- package/lib/esm/options/version-parsing.js.map +0 -1
- package/lib/esm/options/vertexai.js +0 -519
- package/lib/esm/options/vertexai.js.map +0 -1
- package/lib/esm/options.js.map +0 -1
- package/lib/esm/types.js.map +0 -1
- package/lib/types/capability/azure_foundry.d.ts.map +0 -1
- package/lib/types/capability/bedrock.d.ts.map +0 -1
- package/lib/types/capability/openai.d.ts.map +0 -1
- package/lib/types/capability/vertexai.d.ts.map +0 -1
- package/lib/types/capability.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -11
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/options/azure_foundry.d.ts.map +0 -1
- package/lib/types/options/bedrock.d.ts +0 -54
- package/lib/types/options/bedrock.d.ts.map +0 -1
- package/lib/types/options/context-windows.d.ts.map +0 -1
- package/lib/types/options/fallback.d.ts.map +0 -1
- package/lib/types/options/groq.d.ts.map +0 -1
- package/lib/types/options/openai.d.ts +0 -37
- package/lib/types/options/openai.d.ts.map +0 -1
- package/lib/types/options/shared-parsing.d.ts.map +0 -1
- package/lib/types/options/version-parsing.d.ts.map +0 -1
- package/lib/types/options/vertexai.d.ts.map +0 -1
- package/lib/types/options.d.ts.map +0 -1
- package/lib/types/types.d.ts.map +0 -1
- /package/lib/{types/options → options}/context-windows.d.ts +0 -0
- /package/lib/{esm/options → options}/context-windows.js +0 -0
- /package/lib/{types/options → options}/version-parsing.d.ts +0 -0
package/src/options/vertexai.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ModelOptionInfoItem,
|
|
3
|
+
type ModelOptions,
|
|
4
|
+
type ModelOptionsInfo,
|
|
5
|
+
OptionType,
|
|
6
|
+
SharedOptions,
|
|
7
|
+
} from '../types.js';
|
|
8
|
+
import { textOptionsFallback } from './fallback.js';
|
|
3
9
|
import {
|
|
4
10
|
buildClaudeCacheOptions,
|
|
5
11
|
buildClaudeCacheTtlOptions,
|
|
@@ -7,58 +13,58 @@ import {
|
|
|
7
13
|
buildClaudeIncludeThoughtsOption,
|
|
8
14
|
buildClaudeThinkingBudgetOption,
|
|
9
15
|
getClaudeMaxTokensLimit,
|
|
10
|
-
} from
|
|
11
|
-
import {
|
|
12
|
-
hasSamplingParameterRestriction,
|
|
13
|
-
isGeminiModelVersionGte,
|
|
14
|
-
} from "./version-parsing.js";
|
|
16
|
+
} from './shared-parsing.js';
|
|
17
|
+
import { hasSamplingParameterRestriction, isGeminiModelVersionGte } from './version-parsing.js';
|
|
15
18
|
|
|
16
19
|
// Union type of all VertexAI options
|
|
20
|
+
/**
|
|
21
|
+
* @discriminator _option_id
|
|
22
|
+
*/
|
|
17
23
|
export type VertexAIOptions = ImagenOptions | VertexAIClaudeOptions | VertexAIGeminiOptions;
|
|
18
24
|
|
|
19
25
|
export enum ImagenTaskType {
|
|
20
|
-
TEXT_IMAGE =
|
|
21
|
-
EDIT_MODE_INPAINT_REMOVAL =
|
|
22
|
-
EDIT_MODE_INPAINT_INSERTION =
|
|
23
|
-
EDIT_MODE_BGSWAP =
|
|
24
|
-
EDIT_MODE_OUTPAINT =
|
|
25
|
-
CUSTOMIZATION_SUBJECT =
|
|
26
|
-
CUSTOMIZATION_STYLE =
|
|
27
|
-
CUSTOMIZATION_CONTROLLED =
|
|
28
|
-
CUSTOMIZATION_INSTRUCT =
|
|
26
|
+
TEXT_IMAGE = 'TEXT_IMAGE',
|
|
27
|
+
EDIT_MODE_INPAINT_REMOVAL = 'EDIT_MODE_INPAINT_REMOVAL',
|
|
28
|
+
EDIT_MODE_INPAINT_INSERTION = 'EDIT_MODE_INPAINT_INSERTION',
|
|
29
|
+
EDIT_MODE_BGSWAP = 'EDIT_MODE_BGSWAP',
|
|
30
|
+
EDIT_MODE_OUTPAINT = 'EDIT_MODE_OUTPAINT',
|
|
31
|
+
CUSTOMIZATION_SUBJECT = 'CUSTOMIZATION_SUBJECT',
|
|
32
|
+
CUSTOMIZATION_STYLE = 'CUSTOMIZATION_STYLE',
|
|
33
|
+
CUSTOMIZATION_CONTROLLED = 'CUSTOMIZATION_CONTROLLED',
|
|
34
|
+
CUSTOMIZATION_INSTRUCT = 'CUSTOMIZATION_INSTRUCT',
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
export enum ImagenMaskMode {
|
|
32
|
-
MASK_MODE_USER_PROVIDED =
|
|
33
|
-
MASK_MODE_BACKGROUND =
|
|
34
|
-
MASK_MODE_FOREGROUND =
|
|
35
|
-
MASK_MODE_SEMANTIC =
|
|
38
|
+
MASK_MODE_USER_PROVIDED = 'MASK_MODE_USER_PROVIDED',
|
|
39
|
+
MASK_MODE_BACKGROUND = 'MASK_MODE_BACKGROUND',
|
|
40
|
+
MASK_MODE_FOREGROUND = 'MASK_MODE_FOREGROUND',
|
|
41
|
+
MASK_MODE_SEMANTIC = 'MASK_MODE_SEMANTIC',
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export enum ThinkingLevel {
|
|
39
|
-
HIGH =
|
|
40
|
-
MEDIUM =
|
|
41
|
-
LOW =
|
|
42
|
-
MINIMAL =
|
|
43
|
-
THINKING_LEVEL_UNSPECIFIED =
|
|
45
|
+
HIGH = 'HIGH',
|
|
46
|
+
MEDIUM = 'MEDIUM',
|
|
47
|
+
LOW = 'LOW',
|
|
48
|
+
MINIMAL = 'MINIMAL',
|
|
49
|
+
THINKING_LEVEL_UNSPECIFIED = 'THINKING_LEVEL_UNSPECIFIED',
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
export interface ImagenOptions {
|
|
47
|
-
_option_id:
|
|
53
|
+
_option_id: 'vertexai-imagen';
|
|
48
54
|
|
|
49
55
|
//General and generate options
|
|
50
56
|
number_of_images?: number;
|
|
51
57
|
seed?: number;
|
|
52
|
-
person_generation?:
|
|
53
|
-
safety_setting?:
|
|
54
|
-
image_file_type?:
|
|
58
|
+
person_generation?: 'dont_allow' | 'allow_adults' | 'allow_all';
|
|
59
|
+
safety_setting?: 'block_none' | 'block_only_high' | 'block_medium_and_above' | 'block_low_and_above'; //The "off" option does not seem to work for Imagen 3, might be only for text models
|
|
60
|
+
image_file_type?: 'image/jpeg' | 'image/png';
|
|
55
61
|
jpeg_compression_quality?: number;
|
|
56
|
-
aspect_ratio?:
|
|
62
|
+
aspect_ratio?: '1:1' | '4:3' | '3:4' | '16:9' | '9:16';
|
|
57
63
|
add_watermark?: boolean;
|
|
58
64
|
enhance_prompt?: boolean;
|
|
59
65
|
|
|
60
66
|
//Capability options
|
|
61
|
-
edit_mode?: ImagenTaskType
|
|
67
|
+
edit_mode?: ImagenTaskType;
|
|
62
68
|
guidance_scale?: number;
|
|
63
69
|
edit_steps?: number;
|
|
64
70
|
mask_mode?: ImagenMaskMode;
|
|
@@ -66,13 +72,13 @@ export interface ImagenOptions {
|
|
|
66
72
|
mask_class?: number[];
|
|
67
73
|
|
|
68
74
|
//Customization options
|
|
69
|
-
controlType?:
|
|
75
|
+
controlType?: 'CONTROL_TYPE_FACE_MESH' | 'CONTROL_TYPE_CANNY' | 'CONTROL_TYPE_SCRIBBLE';
|
|
70
76
|
controlImageComputation?: boolean;
|
|
71
|
-
subjectType?:
|
|
77
|
+
subjectType?: 'SUBJECT_TYPE_PERSON' | 'SUBJECT_TYPE_ANIMAL' | 'SUBJECT_TYPE_PRODUCT' | 'SUBJECT_TYPE_DEFAULT';
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
export interface VertexAIClaudeOptions {
|
|
75
|
-
_option_id:
|
|
81
|
+
_option_id: 'vertexai-claude';
|
|
76
82
|
max_tokens?: number;
|
|
77
83
|
temperature?: number;
|
|
78
84
|
top_p?: number;
|
|
@@ -86,7 +92,7 @@ export interface VertexAIClaudeOptions {
|
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
export interface VertexAIGeminiOptions {
|
|
89
|
-
_option_id:
|
|
95
|
+
_option_id: 'vertexai-gemini';
|
|
90
96
|
max_tokens?: number;
|
|
91
97
|
temperature?: number;
|
|
92
98
|
top_p?: number;
|
|
@@ -101,36 +107,36 @@ export interface VertexAIGeminiOptions {
|
|
|
101
107
|
thinking_level?: ThinkingLevel;
|
|
102
108
|
flex?: boolean;
|
|
103
109
|
// ImageConfig properties
|
|
104
|
-
image_aspect_ratio?:
|
|
105
|
-
image_size?:
|
|
106
|
-
person_generation?:
|
|
107
|
-
prominent_people?:
|
|
108
|
-
output_mime_type?:
|
|
110
|
+
image_aspect_ratio?: '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '9:16' | '16:9' | '21:9';
|
|
111
|
+
image_size?: '1K' | '2K' | '4K';
|
|
112
|
+
person_generation?: 'ALLOW_ALL' | 'ALLOW_ADULT' | 'ALLOW_NONE';
|
|
113
|
+
prominent_people?: 'PROMINENT_PEOPLE_UNSPECIFIED' | 'ALLOW_PROMINENT_PEOPLE' | 'BLOCK_PROMINENT_PEOPLE';
|
|
114
|
+
output_mime_type?: 'image/png' | 'image/jpeg';
|
|
109
115
|
output_compression_quality?: number;
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
/** Models that support Flex processing (shared, cost-efficient tier). */
|
|
113
119
|
const FLEX_SUPPORTED_GEMINI_MODELS = [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
'gemini-3.1-flash-lite-preview',
|
|
121
|
+
'gemini-3.1-flash-image-preview',
|
|
122
|
+
'gemini-3.1-pro-preview',
|
|
123
|
+
'gemini-3-flash-preview',
|
|
124
|
+
'gemini-3-pro-image-preview',
|
|
119
125
|
] as const;
|
|
120
126
|
|
|
121
127
|
export function isFlexSupportedGeminiModel(model: string): boolean {
|
|
122
128
|
const modelName = model.split('/').pop() ?? model;
|
|
123
|
-
return FLEX_SUPPORTED_GEMINI_MODELS.some(m => modelName.includes(m));
|
|
129
|
+
return FLEX_SUPPORTED_GEMINI_MODELS.some((m) => modelName.includes(m));
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
export function getVertexAiOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
|
|
127
|
-
if (model.includes(
|
|
133
|
+
if (model.includes('imagen-')) {
|
|
128
134
|
return getImagenOptions(model, option);
|
|
129
|
-
} else if (model.includes(
|
|
135
|
+
} else if (model.includes('gemini')) {
|
|
130
136
|
return getGeminiOptions(model, option);
|
|
131
|
-
} else if (model.includes(
|
|
137
|
+
} else if (model.includes('claude')) {
|
|
132
138
|
return getClaudeOptions(model, option);
|
|
133
|
-
} else if (model.includes(
|
|
139
|
+
} else if (model.includes('llama')) {
|
|
134
140
|
return getLlamaOptions(model);
|
|
135
141
|
}
|
|
136
142
|
return textOptionsFallback;
|
|
@@ -139,70 +145,109 @@ export function getVertexAiOptions(model: string, option?: ModelOptions): ModelO
|
|
|
139
145
|
function getImagenOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
|
|
140
146
|
const commonOptions: ModelOptionInfoItem[] = [
|
|
141
147
|
{
|
|
142
|
-
name: SharedOptions.number_of_images,
|
|
143
|
-
|
|
148
|
+
name: SharedOptions.number_of_images,
|
|
149
|
+
type: OptionType.numeric,
|
|
150
|
+
min: 1,
|
|
151
|
+
max: 4,
|
|
152
|
+
default: 1,
|
|
153
|
+
integer: true,
|
|
154
|
+
description: 'Number of Images to generate',
|
|
144
155
|
},
|
|
145
156
|
{
|
|
146
|
-
name: SharedOptions.seed,
|
|
147
|
-
|
|
157
|
+
name: SharedOptions.seed,
|
|
158
|
+
type: OptionType.numeric,
|
|
159
|
+
min: 0,
|
|
160
|
+
max: 4294967295,
|
|
161
|
+
default: 12,
|
|
162
|
+
integer: true,
|
|
163
|
+
description: 'The seed of the generated image',
|
|
148
164
|
},
|
|
149
165
|
{
|
|
150
|
-
name:
|
|
151
|
-
|
|
166
|
+
name: 'person_generation',
|
|
167
|
+
type: OptionType.enum,
|
|
168
|
+
enum: {
|
|
169
|
+
'Disallow the inclusion of people or faces in images': 'dont_allow',
|
|
170
|
+
'Allow generation of adults only': 'allow_adult',
|
|
171
|
+
'Allow generation of people of all ages': 'allow_all',
|
|
172
|
+
},
|
|
173
|
+
default: 'allow_adult',
|
|
174
|
+
description: 'The safety setting for allowing the generation of people in the image',
|
|
152
175
|
},
|
|
153
176
|
{
|
|
154
|
-
name:
|
|
155
|
-
|
|
177
|
+
name: 'safety_setting',
|
|
178
|
+
type: OptionType.enum,
|
|
179
|
+
enum: {
|
|
180
|
+
'Block very few problematic prompts and responses': 'block_none',
|
|
181
|
+
'Block only few problematic prompts and responses': 'block_only_high',
|
|
182
|
+
'Block some problematic prompts and responses': 'block_medium_and_above',
|
|
183
|
+
'Strictest filtering': 'block_low_and_above',
|
|
184
|
+
},
|
|
185
|
+
default: 'block_medium_and_above',
|
|
186
|
+
description: 'The overall safety setting',
|
|
156
187
|
},
|
|
157
188
|
];
|
|
158
189
|
|
|
159
190
|
const outputOptions: ModelOptionInfoItem[] = [
|
|
160
191
|
{
|
|
161
|
-
name:
|
|
162
|
-
|
|
192
|
+
name: 'image_file_type',
|
|
193
|
+
type: OptionType.enum,
|
|
194
|
+
enum: { JPEG: 'image/jpeg', PNG: 'image/png' },
|
|
195
|
+
default: 'image/png',
|
|
196
|
+
description: 'The file type of the generated image',
|
|
163
197
|
refresh: true,
|
|
164
198
|
},
|
|
165
|
-
]
|
|
199
|
+
];
|
|
166
200
|
|
|
167
201
|
const jpegQuality: ModelOptionInfoItem = {
|
|
168
|
-
name:
|
|
169
|
-
|
|
170
|
-
|
|
202
|
+
name: 'jpeg_compression_quality',
|
|
203
|
+
type: OptionType.numeric,
|
|
204
|
+
min: 0,
|
|
205
|
+
max: 100,
|
|
206
|
+
default: 75,
|
|
207
|
+
integer: true,
|
|
208
|
+
description: 'The compression quality of the JPEG image',
|
|
209
|
+
};
|
|
171
210
|
|
|
172
|
-
if ((option as ImagenOptions)?.image_file_type ===
|
|
211
|
+
if ((option as ImagenOptions)?.image_file_type === 'image/jpeg') {
|
|
173
212
|
outputOptions.push(jpegQuality);
|
|
174
213
|
}
|
|
175
214
|
|
|
176
|
-
if (model.includes(
|
|
215
|
+
if (model.includes('generate')) {
|
|
177
216
|
// Generate models
|
|
178
217
|
const modeOptions: ModelOptionInfoItem[] = [
|
|
179
218
|
{
|
|
180
|
-
name:
|
|
181
|
-
|
|
219
|
+
name: 'aspect_ratio',
|
|
220
|
+
type: OptionType.enum,
|
|
221
|
+
enum: { '1:1': '1:1', '4:3': '4:3', '3:4': '3:4', '16:9': '16:9', '9:16': '9:16' },
|
|
222
|
+
default: '1:1',
|
|
223
|
+
description: 'The aspect ratio of the generated image',
|
|
182
224
|
},
|
|
183
225
|
{
|
|
184
|
-
name:
|
|
226
|
+
name: 'add_watermark',
|
|
227
|
+
type: OptionType.boolean,
|
|
228
|
+
default: false,
|
|
229
|
+
description: 'Add an invisible watermark to the generated image, useful for detection of AI images',
|
|
185
230
|
},
|
|
186
231
|
];
|
|
187
232
|
|
|
188
|
-
const enhanceOptions: ModelOptionInfoItem[] = !model.includes(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
233
|
+
const enhanceOptions: ModelOptionInfoItem[] = !model.includes('generate-001')
|
|
234
|
+
? [
|
|
235
|
+
{
|
|
236
|
+
name: 'enhance_prompt',
|
|
237
|
+
type: OptionType.boolean,
|
|
238
|
+
default: true,
|
|
239
|
+
description: "VertexAI automatically rewrites the prompt to better reflect the prompt's intent.",
|
|
240
|
+
},
|
|
241
|
+
]
|
|
242
|
+
: [];
|
|
193
243
|
|
|
194
244
|
return {
|
|
195
|
-
_option_id:
|
|
196
|
-
options: [
|
|
197
|
-
...commonOptions,
|
|
198
|
-
...modeOptions,
|
|
199
|
-
...outputOptions,
|
|
200
|
-
...enhanceOptions,
|
|
201
|
-
]
|
|
245
|
+
_option_id: 'vertexai-imagen',
|
|
246
|
+
options: [...commonOptions, ...modeOptions, ...outputOptions, ...enhanceOptions],
|
|
202
247
|
};
|
|
203
248
|
}
|
|
204
249
|
|
|
205
|
-
if (model.includes(
|
|
250
|
+
if (model.includes('capability')) {
|
|
206
251
|
// Edit models
|
|
207
252
|
let guidanceScaleDefault = 75;
|
|
208
253
|
if ((option as ImagenOptions)?.edit_mode === ImagenTaskType.EDIT_MODE_INPAINT_INSERTION) {
|
|
@@ -211,70 +256,110 @@ function getImagenOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
211
256
|
|
|
212
257
|
const modeOptions: ModelOptionInfoItem[] = [
|
|
213
258
|
{
|
|
214
|
-
name:
|
|
215
|
-
|
|
216
|
-
"EDIT_MODE_INPAINT_REMOVAL": "EDIT_MODE_INPAINT_REMOVAL",
|
|
217
|
-
"EDIT_MODE_INPAINT_INSERTION": "EDIT_MODE_INPAINT_INSERTION",
|
|
218
|
-
"EDIT_MODE_BGSWAP": "EDIT_MODE_BGSWAP",
|
|
219
|
-
"EDIT_MODE_OUTPAINT": "EDIT_MODE_OUTPAINT",
|
|
220
|
-
"CUSTOMIZATION_SUBJECT": "CUSTOMIZATION_SUBJECT",
|
|
221
|
-
"CUSTOMIZATION_STYLE": "CUSTOMIZATION_STYLE",
|
|
222
|
-
"CUSTOMIZATION_CONTROLLED": "CUSTOMIZATION_CONTROLLED",
|
|
223
|
-
"CUSTOMIZATION_INSTRUCT": "CUSTOMIZATION_INSTRUCT",
|
|
224
|
-
},
|
|
225
|
-
description: "The editing mode. CUSTOMIZATION options use few-shot learning to generate images based on a few examples."
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
name: "guidance_scale", type: OptionType.numeric, min: 0, max: 500, default: guidanceScaleDefault,
|
|
229
|
-
integer: true, description: "How closely the generation follows the prompt"
|
|
230
|
-
}
|
|
231
|
-
];
|
|
232
|
-
|
|
233
|
-
const maskOptions: ModelOptionInfoItem[] = ((option as ImagenOptions)?.edit_mode?.includes("EDIT")) ? [
|
|
234
|
-
{
|
|
235
|
-
name: "mask_mode", type: OptionType.enum,
|
|
259
|
+
name: 'edit_mode',
|
|
260
|
+
type: OptionType.enum,
|
|
236
261
|
enum: {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
262
|
+
EDIT_MODE_INPAINT_REMOVAL: 'EDIT_MODE_INPAINT_REMOVAL',
|
|
263
|
+
EDIT_MODE_INPAINT_INSERTION: 'EDIT_MODE_INPAINT_INSERTION',
|
|
264
|
+
EDIT_MODE_BGSWAP: 'EDIT_MODE_BGSWAP',
|
|
265
|
+
EDIT_MODE_OUTPAINT: 'EDIT_MODE_OUTPAINT',
|
|
266
|
+
CUSTOMIZATION_SUBJECT: 'CUSTOMIZATION_SUBJECT',
|
|
267
|
+
CUSTOMIZATION_STYLE: 'CUSTOMIZATION_STYLE',
|
|
268
|
+
CUSTOMIZATION_CONTROLLED: 'CUSTOMIZATION_CONTROLLED',
|
|
269
|
+
CUSTOMIZATION_INSTRUCT: 'CUSTOMIZATION_INSTRUCT',
|
|
241
270
|
},
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
name: "mask_dilation", type: OptionType.numeric, min: 0, max: 1,
|
|
247
|
-
integer: true, description: "The mask dilation, grows the mask by a percentage of image width to compensate for imprecise masks."
|
|
271
|
+
description:
|
|
272
|
+
'The editing mode. CUSTOMIZATION options use few-shot learning to generate images based on a few examples.',
|
|
248
273
|
},
|
|
249
|
-
] : [];
|
|
250
|
-
|
|
251
|
-
const maskClassOptions: ModelOptionInfoItem[] = ((option as ImagenOptions)?.mask_mode === ImagenMaskMode.MASK_MODE_SEMANTIC) ? [
|
|
252
|
-
{
|
|
253
|
-
name: "mask_class", type: OptionType.string_list, default: [],
|
|
254
|
-
description: "Input Class IDs. Create a mask based on image class, based on https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api-customization#segment-ids"
|
|
255
|
-
}
|
|
256
|
-
] : [];
|
|
257
|
-
|
|
258
|
-
const editOptions: ModelOptionInfoItem[] = (option as ImagenOptions)?.edit_mode?.includes("EDIT") ? [
|
|
259
274
|
{
|
|
260
|
-
name:
|
|
261
|
-
|
|
275
|
+
name: 'guidance_scale',
|
|
276
|
+
type: OptionType.numeric,
|
|
277
|
+
min: 0,
|
|
278
|
+
max: 500,
|
|
279
|
+
default: guidanceScaleDefault,
|
|
280
|
+
integer: true,
|
|
281
|
+
description: 'How closely the generation follows the prompt',
|
|
262
282
|
},
|
|
263
|
-
]
|
|
283
|
+
];
|
|
264
284
|
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
285
|
+
const maskOptions: ModelOptionInfoItem[] = (option as ImagenOptions)?.edit_mode?.includes('EDIT')
|
|
286
|
+
? [
|
|
287
|
+
{
|
|
288
|
+
name: 'mask_mode',
|
|
289
|
+
type: OptionType.enum,
|
|
290
|
+
enum: {
|
|
291
|
+
MASK_MODE_USER_PROVIDED: 'MASK_MODE_USER_PROVIDED',
|
|
292
|
+
MASK_MODE_BACKGROUND: 'MASK_MODE_BACKGROUND',
|
|
293
|
+
MASK_MODE_FOREGROUND: 'MASK_MODE_FOREGROUND',
|
|
294
|
+
MASK_MODE_SEMANTIC: 'MASK_MODE_SEMANTIC',
|
|
295
|
+
},
|
|
296
|
+
default: 'MASK_MODE_USER_PROVIDED',
|
|
297
|
+
description: 'How should the mask for the generation be provided',
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'mask_dilation',
|
|
301
|
+
type: OptionType.numeric,
|
|
302
|
+
min: 0,
|
|
303
|
+
max: 1,
|
|
304
|
+
integer: true,
|
|
305
|
+
description:
|
|
306
|
+
'The mask dilation, grows the mask by a percentage of image width to compensate for imprecise masks.',
|
|
307
|
+
},
|
|
308
|
+
]
|
|
309
|
+
: [];
|
|
310
|
+
|
|
311
|
+
const maskClassOptions: ModelOptionInfoItem[] =
|
|
312
|
+
(option as ImagenOptions)?.mask_mode === ImagenMaskMode.MASK_MODE_SEMANTIC
|
|
313
|
+
? [
|
|
314
|
+
{
|
|
315
|
+
name: 'mask_class',
|
|
316
|
+
type: OptionType.string_list,
|
|
317
|
+
default: [],
|
|
318
|
+
description:
|
|
319
|
+
'Input Class IDs. Create a mask based on image class, based on https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api-customization#segment-ids',
|
|
320
|
+
},
|
|
321
|
+
]
|
|
322
|
+
: [];
|
|
323
|
+
|
|
324
|
+
const editOptions: ModelOptionInfoItem[] = (option as ImagenOptions)?.edit_mode?.includes('EDIT')
|
|
325
|
+
? [
|
|
326
|
+
{
|
|
327
|
+
name: 'edit_steps',
|
|
328
|
+
type: OptionType.numeric,
|
|
329
|
+
default: 75,
|
|
330
|
+
integer: true,
|
|
331
|
+
description:
|
|
332
|
+
'The number of steps for the base image generation, more steps means more time and better quality',
|
|
333
|
+
},
|
|
334
|
+
]
|
|
335
|
+
: [];
|
|
336
|
+
|
|
337
|
+
const customizationOptions: ModelOptionInfoItem[] =
|
|
338
|
+
(option as ImagenOptions)?.edit_mode === ImagenTaskType.CUSTOMIZATION_CONTROLLED ||
|
|
339
|
+
(option as ImagenOptions)?.edit_mode === ImagenTaskType.CUSTOMIZATION_SUBJECT
|
|
340
|
+
? [
|
|
341
|
+
{
|
|
342
|
+
name: 'controlType',
|
|
343
|
+
type: OptionType.enum,
|
|
344
|
+
enum: {
|
|
345
|
+
'Face Mesh': 'CONTROL_TYPE_FACE_MESH',
|
|
346
|
+
Canny: 'CONTROL_TYPE_CANNY',
|
|
347
|
+
Scribble: 'CONTROL_TYPE_SCRIBBLE',
|
|
348
|
+
},
|
|
349
|
+
default: 'CONTROL_TYPE_CANNY',
|
|
350
|
+
description: 'Method used to generate the control image',
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: 'controlImageComputation',
|
|
354
|
+
type: OptionType.boolean,
|
|
355
|
+
default: true,
|
|
356
|
+
description: 'Should the control image be computed from the input image, or is it provided',
|
|
357
|
+
},
|
|
358
|
+
]
|
|
359
|
+
: [];
|
|
275
360
|
|
|
276
361
|
return {
|
|
277
|
-
_option_id:
|
|
362
|
+
_option_id: 'vertexai-imagen',
|
|
278
363
|
options: [
|
|
279
364
|
...modeOptions,
|
|
280
365
|
...commonOptions,
|
|
@@ -283,7 +368,7 @@ function getImagenOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
283
368
|
...editOptions,
|
|
284
369
|
...customizationOptions,
|
|
285
370
|
...outputOptions,
|
|
286
|
-
]
|
|
371
|
+
],
|
|
287
372
|
};
|
|
288
373
|
}
|
|
289
374
|
|
|
@@ -291,48 +376,45 @@ function getImagenOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
291
376
|
}
|
|
292
377
|
|
|
293
378
|
function getGeminiEffortOptions(model: string): Record<string, string> {
|
|
294
|
-
if (model.includes(
|
|
295
|
-
return {
|
|
379
|
+
if (model.includes('gemini-3-pro-image')) {
|
|
380
|
+
return { High: 'high' };
|
|
296
381
|
}
|
|
297
|
-
if (model.includes(
|
|
298
|
-
return {
|
|
382
|
+
if (model.includes('gemini-3.1-flash-image')) {
|
|
383
|
+
return { Low: 'low', High: 'high' };
|
|
299
384
|
}
|
|
300
|
-
return {
|
|
385
|
+
return { Low: 'low', Medium: 'medium', High: 'high' };
|
|
301
386
|
}
|
|
302
387
|
|
|
303
388
|
function getGeminiThinkingOptionItems(model: string): ModelOptionInfoItem[] {
|
|
304
389
|
return [
|
|
305
390
|
{
|
|
306
|
-
name:
|
|
391
|
+
name: 'include_thoughts',
|
|
307
392
|
type: OptionType.boolean,
|
|
308
393
|
default: false,
|
|
309
|
-
description: "Include the model's reasoning process in the response"
|
|
394
|
+
description: "Include the model's reasoning process in the response",
|
|
310
395
|
},
|
|
311
396
|
{
|
|
312
397
|
name: SharedOptions.effort,
|
|
313
398
|
type: OptionType.enum,
|
|
314
399
|
enum: getGeminiEffortOptions(model),
|
|
315
|
-
description:
|
|
316
|
-
}
|
|
400
|
+
description: 'Higher thinking levels may improve quality, but increase response times and token costs',
|
|
401
|
+
},
|
|
317
402
|
];
|
|
318
403
|
}
|
|
319
404
|
|
|
320
405
|
function getGeminiOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
|
|
321
406
|
// Special handling for gemini image / nano banana models
|
|
322
|
-
if (model.includes(
|
|
323
|
-
const isGemini25OrLater = isGeminiModelVersionGte(model,
|
|
324
|
-
const isGemini3OrLater = isGeminiModelVersionGte(model,
|
|
407
|
+
if (model.includes('image')) {
|
|
408
|
+
const isGemini25OrLater = isGeminiModelVersionGte(model, '2.5');
|
|
409
|
+
const isGemini3OrLater = isGeminiModelVersionGte(model, '3.0');
|
|
325
410
|
|
|
326
411
|
const max_tokens_limit = getGeminiMaxTokensLimit(model);
|
|
327
|
-
const excludeOptions = [
|
|
412
|
+
const excludeOptions = ['max_tokens', 'presence_penalty', 'frequency_penalty', 'seed', 'top_k'];
|
|
328
413
|
let commonOptions = textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
|
|
329
414
|
|
|
330
415
|
// Set max temperature to 2.0
|
|
331
416
|
commonOptions = commonOptions.map((option) => {
|
|
332
|
-
if (
|
|
333
|
-
option.name === SharedOptions.temperature &&
|
|
334
|
-
option.type === OptionType.numeric
|
|
335
|
-
) {
|
|
417
|
+
if (option.name === SharedOptions.temperature && option.type === OptionType.numeric) {
|
|
336
418
|
return {
|
|
337
419
|
...option,
|
|
338
420
|
max: 2.0,
|
|
@@ -341,15 +423,17 @@ function getGeminiOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
341
423
|
return option;
|
|
342
424
|
});
|
|
343
425
|
|
|
344
|
-
const max_tokens: ModelOptionInfoItem[] = [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
426
|
+
const max_tokens: ModelOptionInfoItem[] = [
|
|
427
|
+
{
|
|
428
|
+
name: SharedOptions.max_tokens,
|
|
429
|
+
type: OptionType.numeric,
|
|
430
|
+
min: 1,
|
|
431
|
+
max: max_tokens_limit,
|
|
432
|
+
integer: true,
|
|
433
|
+
step: 200,
|
|
434
|
+
description: 'Maximum output tokens',
|
|
435
|
+
},
|
|
436
|
+
];
|
|
353
437
|
|
|
354
438
|
const imageOptions: ModelOptionInfoItem[] = [];
|
|
355
439
|
|
|
@@ -357,40 +441,40 @@ function getGeminiOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
357
441
|
if (isGemini25OrLater) {
|
|
358
442
|
imageOptions.push(
|
|
359
443
|
{
|
|
360
|
-
name:
|
|
444
|
+
name: 'image_aspect_ratio',
|
|
361
445
|
type: OptionType.enum,
|
|
362
446
|
enum: {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
447
|
+
'1:1': '1:1',
|
|
448
|
+
'2:3': '2:3',
|
|
449
|
+
'3:2': '3:2',
|
|
450
|
+
'3:4': '3:4',
|
|
451
|
+
'4:3': '4:3',
|
|
452
|
+
'9:16': '9:16',
|
|
453
|
+
'16:9': '16:9',
|
|
454
|
+
'21:9': '21:9',
|
|
371
455
|
},
|
|
372
|
-
default:
|
|
373
|
-
description:
|
|
456
|
+
default: '1:1',
|
|
457
|
+
description: 'Aspect ratio of the generated images',
|
|
374
458
|
},
|
|
375
459
|
{
|
|
376
|
-
name:
|
|
460
|
+
name: 'person_generation',
|
|
377
461
|
type: OptionType.enum,
|
|
378
462
|
enum: {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
463
|
+
'Allow all people': 'ALLOW_ALL',
|
|
464
|
+
'Allow adults only': 'ALLOW_ADULT',
|
|
465
|
+
'Do not generate people': 'ALLOW_NONE',
|
|
382
466
|
},
|
|
383
|
-
default:
|
|
384
|
-
description:
|
|
467
|
+
default: 'ALLOW_ALL',
|
|
468
|
+
description: 'Controls the generation of people in images',
|
|
385
469
|
},
|
|
386
470
|
{
|
|
387
|
-
name:
|
|
471
|
+
name: 'prominent_people',
|
|
388
472
|
type: OptionType.enum,
|
|
389
473
|
enum: {
|
|
390
|
-
|
|
391
|
-
|
|
474
|
+
'Allow prominent people': 'ALLOW_PROMINENT_PEOPLE',
|
|
475
|
+
'Block prominent people': 'BLOCK_PROMINENT_PEOPLE',
|
|
392
476
|
},
|
|
393
|
-
description:
|
|
477
|
+
description: 'Controls whether prominent people (celebrities) can be generated',
|
|
394
478
|
},
|
|
395
479
|
);
|
|
396
480
|
}
|
|
@@ -398,40 +482,40 @@ function getGeminiOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
398
482
|
// Resolution settings: 3.0+
|
|
399
483
|
if (isGemini3OrLater) {
|
|
400
484
|
imageOptions.push({
|
|
401
|
-
name:
|
|
485
|
+
name: 'image_size',
|
|
402
486
|
type: OptionType.enum,
|
|
403
487
|
enum: {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
488
|
+
'1K': '1K',
|
|
489
|
+
'2K': '2K',
|
|
490
|
+
'4K': '4K',
|
|
407
491
|
},
|
|
408
|
-
default:
|
|
409
|
-
description:
|
|
492
|
+
default: '1K',
|
|
493
|
+
description: 'Size of generated images',
|
|
410
494
|
});
|
|
411
495
|
}
|
|
412
496
|
|
|
413
497
|
// Output format: all image models
|
|
414
498
|
imageOptions.push({
|
|
415
|
-
name:
|
|
499
|
+
name: 'output_mime_type',
|
|
416
500
|
type: OptionType.enum,
|
|
417
501
|
enum: {
|
|
418
|
-
|
|
419
|
-
|
|
502
|
+
PNG: 'image/png',
|
|
503
|
+
JPEG: 'image/jpeg',
|
|
420
504
|
},
|
|
421
|
-
default:
|
|
422
|
-
description:
|
|
505
|
+
default: 'image/png',
|
|
506
|
+
description: 'MIME type of the generated image',
|
|
423
507
|
refresh: true,
|
|
424
508
|
});
|
|
425
509
|
|
|
426
|
-
if ((option as VertexAIGeminiOptions)?.output_mime_type ===
|
|
510
|
+
if ((option as VertexAIGeminiOptions)?.output_mime_type === 'image/jpeg') {
|
|
427
511
|
imageOptions.push({
|
|
428
|
-
name:
|
|
512
|
+
name: 'output_compression_quality',
|
|
429
513
|
type: OptionType.numeric,
|
|
430
514
|
min: 0,
|
|
431
515
|
max: 100,
|
|
432
516
|
default: 90,
|
|
433
517
|
integer: true,
|
|
434
|
-
description:
|
|
518
|
+
description: 'Compression quality for JPEG images (0-100)',
|
|
435
519
|
});
|
|
436
520
|
}
|
|
437
521
|
|
|
@@ -439,86 +523,99 @@ function getGeminiOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
439
523
|
const thinkingOptions = isGemini3OrLater ? getGeminiThinkingOptionItems(model) : [];
|
|
440
524
|
|
|
441
525
|
return {
|
|
442
|
-
_option_id:
|
|
443
|
-
options: [
|
|
444
|
-
...max_tokens,
|
|
445
|
-
...commonOptions,
|
|
446
|
-
...imageOptions,
|
|
447
|
-
...thinkingOptions,
|
|
448
|
-
]
|
|
526
|
+
_option_id: 'vertexai-gemini',
|
|
527
|
+
options: [...max_tokens, ...commonOptions, ...imageOptions, ...thinkingOptions],
|
|
449
528
|
};
|
|
450
529
|
}
|
|
451
530
|
const max_tokens_limit = getGeminiMaxTokensLimit(model);
|
|
452
|
-
const excludeOptions = [
|
|
531
|
+
const excludeOptions = ['max_tokens'];
|
|
453
532
|
const commonOptions = textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
|
|
454
533
|
|
|
455
|
-
const max_tokens: ModelOptionInfoItem[] = [
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
534
|
+
const max_tokens: ModelOptionInfoItem[] = [
|
|
535
|
+
{
|
|
536
|
+
name: SharedOptions.max_tokens,
|
|
537
|
+
type: OptionType.numeric,
|
|
538
|
+
min: 1,
|
|
539
|
+
max: max_tokens_limit,
|
|
540
|
+
integer: true,
|
|
541
|
+
step: 200,
|
|
542
|
+
description: 'The maximum number of tokens to generate',
|
|
543
|
+
},
|
|
544
|
+
];
|
|
459
545
|
|
|
460
546
|
const seedOption: ModelOptionInfoItem = {
|
|
461
|
-
name: SharedOptions.seed,
|
|
547
|
+
name: SharedOptions.seed,
|
|
548
|
+
type: OptionType.numeric,
|
|
549
|
+
integer: true,
|
|
550
|
+
description: 'The seed for the generation, useful for reproducibility',
|
|
462
551
|
};
|
|
463
552
|
|
|
464
|
-
if (isGeminiModelVersionGte(model,
|
|
465
|
-
const flexOptions: ModelOptionInfoItem[] = isFlexSupportedGeminiModel(model)
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
553
|
+
if (isGeminiModelVersionGte(model, '3.0')) {
|
|
554
|
+
const flexOptions: ModelOptionInfoItem[] = isFlexSupportedGeminiModel(model)
|
|
555
|
+
? [
|
|
556
|
+
{
|
|
557
|
+
name: 'flex',
|
|
558
|
+
type: OptionType.boolean,
|
|
559
|
+
default: false,
|
|
560
|
+
description:
|
|
561
|
+
'Use Flex processing tier for cost-efficient, batch-style execution with relaxed latency.',
|
|
562
|
+
},
|
|
563
|
+
]
|
|
564
|
+
: [];
|
|
471
565
|
return {
|
|
472
|
-
_option_id:
|
|
566
|
+
_option_id: 'vertexai-gemini',
|
|
473
567
|
options: [
|
|
474
568
|
...max_tokens,
|
|
475
569
|
...commonOptions,
|
|
476
570
|
seedOption,
|
|
477
571
|
...getGeminiThinkingOptionItems(model),
|
|
478
572
|
...flexOptions,
|
|
479
|
-
]
|
|
573
|
+
],
|
|
480
574
|
};
|
|
481
575
|
}
|
|
482
576
|
|
|
483
|
-
if (model.includes(
|
|
577
|
+
if (model.includes('-2.5-')) {
|
|
484
578
|
// Gemini 2.5 thinking models
|
|
485
579
|
|
|
486
580
|
// Set budget token ranges based on model variant
|
|
487
581
|
let budgetMin = -1;
|
|
488
582
|
let budgetMax = 24576;
|
|
489
|
-
let budgetDescription =
|
|
490
|
-
if (model.includes(
|
|
583
|
+
let budgetDescription = '';
|
|
584
|
+
if (model.includes('flash-lite')) {
|
|
491
585
|
budgetMin = -1;
|
|
492
586
|
budgetMax = 24576;
|
|
493
|
-
budgetDescription =
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
587
|
+
budgetDescription =
|
|
588
|
+
'The target number of tokens to use for reasoning. ' +
|
|
589
|
+
'Flash Lite default: Model does not think. ' +
|
|
590
|
+
'Range: 512-24576 tokens. ' +
|
|
591
|
+
'Set to 0 to disable thinking, -1 for dynamic thinking.';
|
|
592
|
+
} else if (model.includes('flash')) {
|
|
498
593
|
budgetMin = -1;
|
|
499
594
|
budgetMax = 24576;
|
|
500
|
-
budgetDescription =
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
595
|
+
budgetDescription =
|
|
596
|
+
'The target number of tokens to use for reasoning. ' +
|
|
597
|
+
'Flash default: Dynamic thinking (model decides when and how much to think). ' +
|
|
598
|
+
'Range: 0-24576 tokens. ' +
|
|
599
|
+
'Set to 0 to disable thinking, -1 for dynamic thinking.';
|
|
600
|
+
} else if (model.includes('pro')) {
|
|
505
601
|
budgetMin = -1;
|
|
506
602
|
budgetMax = 32768;
|
|
507
|
-
budgetDescription =
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
603
|
+
budgetDescription =
|
|
604
|
+
'The target number of tokens to use for reasoning. ' +
|
|
605
|
+
'Pro default: Dynamic thinking (model decides when and how much to think). ' +
|
|
606
|
+
'Range: 128-32768 tokens. ' +
|
|
607
|
+
'Cannot disable thinking - minimum 128 tokens. Set to -1 for dynamic thinking.';
|
|
511
608
|
}
|
|
512
609
|
|
|
513
610
|
const geminiThinkingOptions: ModelOptionInfoItem[] = [
|
|
514
611
|
{
|
|
515
|
-
name:
|
|
612
|
+
name: 'include_thoughts',
|
|
516
613
|
type: OptionType.boolean,
|
|
517
614
|
default: false,
|
|
518
|
-
description: "Include the model's reasoning process in the response"
|
|
615
|
+
description: "Include the model's reasoning process in the response",
|
|
519
616
|
},
|
|
520
617
|
{
|
|
521
|
-
name:
|
|
618
|
+
name: 'thinking_budget_tokens',
|
|
522
619
|
type: OptionType.numeric,
|
|
523
620
|
min: budgetMin,
|
|
524
621
|
max: budgetMax,
|
|
@@ -526,53 +623,52 @@ function getGeminiOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
526
623
|
integer: true,
|
|
527
624
|
step: 100,
|
|
528
625
|
description: budgetDescription,
|
|
529
|
-
}
|
|
626
|
+
},
|
|
530
627
|
];
|
|
531
628
|
|
|
532
629
|
return {
|
|
533
|
-
_option_id:
|
|
534
|
-
options: [
|
|
535
|
-
...max_tokens,
|
|
536
|
-
...commonOptions,
|
|
537
|
-
seedOption,
|
|
538
|
-
...geminiThinkingOptions,
|
|
539
|
-
]
|
|
630
|
+
_option_id: 'vertexai-gemini',
|
|
631
|
+
options: [...max_tokens, ...commonOptions, seedOption, ...geminiThinkingOptions],
|
|
540
632
|
};
|
|
541
633
|
}
|
|
542
634
|
|
|
543
635
|
return {
|
|
544
|
-
_option_id:
|
|
545
|
-
options: [
|
|
546
|
-
...max_tokens,
|
|
547
|
-
...commonOptions,
|
|
548
|
-
seedOption,
|
|
549
|
-
]
|
|
636
|
+
_option_id: 'vertexai-gemini',
|
|
637
|
+
options: [...max_tokens, ...commonOptions, seedOption],
|
|
550
638
|
};
|
|
551
639
|
}
|
|
552
640
|
|
|
553
641
|
function getClaudeOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
|
|
554
642
|
const max_tokens_limit = getClaudeMaxTokensLimit(model);
|
|
555
|
-
const excludeOptions = [
|
|
643
|
+
const excludeOptions = ['max_tokens', 'presence_penalty', 'frequency_penalty'];
|
|
556
644
|
let commonOptions = textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
|
|
557
645
|
|
|
558
646
|
// Opus 4.7+ models no longer support temperature, top_p, top_k (returns 400 error)
|
|
559
647
|
// Opus 4.6 and Sonnet 4.6 still support these parameters
|
|
560
648
|
const hasSamplingRestriction = hasSamplingParameterRestriction(model);
|
|
561
649
|
if (hasSamplingRestriction) {
|
|
562
|
-
commonOptions = commonOptions.filter(
|
|
563
|
-
option
|
|
564
|
-
|
|
565
|
-
|
|
650
|
+
commonOptions = commonOptions.filter(
|
|
651
|
+
(option) =>
|
|
652
|
+
option.name !== SharedOptions.temperature &&
|
|
653
|
+
option.name !== SharedOptions.top_p &&
|
|
654
|
+
option.name !== 'top_k',
|
|
566
655
|
);
|
|
567
656
|
}
|
|
568
657
|
|
|
569
|
-
const max_tokens: ModelOptionInfoItem[] = [
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
658
|
+
const max_tokens: ModelOptionInfoItem[] = [
|
|
659
|
+
{
|
|
660
|
+
name: SharedOptions.max_tokens,
|
|
661
|
+
type: OptionType.numeric,
|
|
662
|
+
min: 1,
|
|
663
|
+
max: max_tokens_limit,
|
|
664
|
+
integer: true,
|
|
665
|
+
step: 200,
|
|
666
|
+
description: 'The maximum number of tokens to generate',
|
|
667
|
+
},
|
|
668
|
+
];
|
|
573
669
|
|
|
574
670
|
return {
|
|
575
|
-
_option_id:
|
|
671
|
+
_option_id: 'vertexai-claude',
|
|
576
672
|
options: [
|
|
577
673
|
...max_tokens,
|
|
578
674
|
...commonOptions,
|
|
@@ -587,19 +683,23 @@ function getClaudeOptions(model: string, option?: ModelOptions): ModelOptionsInf
|
|
|
587
683
|
|
|
588
684
|
function getLlamaOptions(model: string): ModelOptionsInfo {
|
|
589
685
|
const max_tokens_limit = getLlamaMaxTokensLimit(model);
|
|
590
|
-
const excludeOptions = [
|
|
686
|
+
const excludeOptions = ['max_tokens', 'presence_penalty', 'frequency_penalty', 'stop_sequence'];
|
|
591
687
|
let commonOptions = textOptionsFallback.options.filter((option) => !excludeOptions.includes(option.name));
|
|
592
|
-
const max_tokens: ModelOptionInfoItem[] = [
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
688
|
+
const max_tokens: ModelOptionInfoItem[] = [
|
|
689
|
+
{
|
|
690
|
+
name: SharedOptions.max_tokens,
|
|
691
|
+
type: OptionType.numeric,
|
|
692
|
+
min: 1,
|
|
693
|
+
max: max_tokens_limit,
|
|
694
|
+
integer: true,
|
|
695
|
+
step: 200,
|
|
696
|
+
description: 'The maximum number of tokens to generate',
|
|
697
|
+
},
|
|
698
|
+
];
|
|
596
699
|
|
|
597
700
|
// Set max temperature to 1.0 for Llama models
|
|
598
701
|
commonOptions = commonOptions.map((option) => {
|
|
599
|
-
if (
|
|
600
|
-
option.name === SharedOptions.temperature &&
|
|
601
|
-
option.type === OptionType.numeric
|
|
602
|
-
) {
|
|
702
|
+
if (option.name === SharedOptions.temperature && option.type === OptionType.numeric) {
|
|
603
703
|
return {
|
|
604
704
|
...option,
|
|
605
705
|
max: 1.0,
|
|
@@ -609,22 +709,19 @@ function getLlamaOptions(model: string): ModelOptionsInfo {
|
|
|
609
709
|
});
|
|
610
710
|
|
|
611
711
|
return {
|
|
612
|
-
_option_id:
|
|
613
|
-
options: [
|
|
614
|
-
...max_tokens,
|
|
615
|
-
...commonOptions,
|
|
616
|
-
]
|
|
712
|
+
_option_id: 'text-fallback',
|
|
713
|
+
options: [...max_tokens, ...commonOptions],
|
|
617
714
|
};
|
|
618
715
|
}
|
|
619
716
|
|
|
620
717
|
function getGeminiMaxTokensLimit(model: string): number {
|
|
621
|
-
if (model.includes(
|
|
622
|
-
return isGeminiModelVersionGte(model,
|
|
718
|
+
if (model.includes('image')) {
|
|
719
|
+
return isGeminiModelVersionGte(model, '2.5') ? 32768 : 8192;
|
|
623
720
|
}
|
|
624
|
-
if (model.includes(
|
|
721
|
+
if (model.includes('thinking') || isGeminiModelVersionGte(model, '2.5')) {
|
|
625
722
|
return 65535; // API upper bound is exclusive
|
|
626
723
|
}
|
|
627
|
-
if (model.includes(
|
|
724
|
+
if (model.includes('ultra') || model.includes('vision')) {
|
|
628
725
|
return 2048;
|
|
629
726
|
}
|
|
630
727
|
return 8192;
|
|
@@ -635,13 +732,13 @@ function getLlamaMaxTokensLimit(_model: string): number {
|
|
|
635
732
|
}
|
|
636
733
|
|
|
637
734
|
export function getMaxTokensLimitVertexAi(model: string): number {
|
|
638
|
-
if (model.includes(
|
|
735
|
+
if (model.includes('imagen-')) {
|
|
639
736
|
return 0; // Imagen models do not have a max tokens limit in the same way as text models
|
|
640
|
-
} else if (model.includes(
|
|
737
|
+
} else if (model.includes('claude')) {
|
|
641
738
|
return getClaudeMaxTokensLimit(model);
|
|
642
|
-
} else if (model.includes(
|
|
739
|
+
} else if (model.includes('gemini')) {
|
|
643
740
|
return getGeminiMaxTokensLimit(model);
|
|
644
|
-
} else if (model.includes(
|
|
741
|
+
} else if (model.includes('llama')) {
|
|
645
742
|
return getLlamaMaxTokensLimit(model);
|
|
646
743
|
}
|
|
647
744
|
return 8192; // Default fallback limit
|