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