@@ -20,6 +20,7 @@ import { useValidateServiceName } from '../hooks/useValidateServiceName';
2020import EnvVarFormList , {
2121 sanitizeSensitiveEnv ,
2222 EnvVarFormListValue ,
23+ EnvVarConfig ,
2324} from './EnvVarFormList' ;
2425import ImageEnvironmentSelectFormItems , {
2526 ImageEnvironmentFormInput ,
@@ -175,6 +176,126 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
175176
176177 const { getErrorMessage } = useErrorMessageResolver ( ) ;
177178
179+ // Runtime variant environment variable configurations
180+ const RUNTIME_ENV_VAR_CONFIGS : Record <
181+ string ,
182+ {
183+ requiredEnvVars ?: EnvVarConfig [ ] ;
184+ optionalEnvVars ?: EnvVarConfig [ ] ;
185+ }
186+ > = {
187+ vllm : {
188+ requiredEnvVars : [
189+ {
190+ variable : 'BACKEND_MODEL_NAME' ,
191+ placeholder : 'Enter model name (e.g., meta-llama/Llama-2-7b-chat-hf)' ,
192+ description : "Corresponds to vLLM's --model-name argument" ,
193+ } ,
194+ ] ,
195+ optionalEnvVars : [
196+ {
197+ variable : 'VLLM_QUANTIZATION' ,
198+ placeholder : 'e.g., awq, gptq, fp8' ,
199+ description : "Corresponds to vLLM's --quantization argument" ,
200+ } ,
201+ {
202+ variable : 'VLLM_TP_SIZE' ,
203+ placeholder : 'Tensor parallel size (e.g., 2, 4, 8)' ,
204+ description : "Corresponds to vLLM's --tensor-parallel-size argument" ,
205+ } ,
206+ {
207+ variable : 'VLLM_PP_SIZE' ,
208+ placeholder : 'Pipeline parallel size (e.g., 2, 4)' ,
209+ description :
210+ "Corresponds to vLLM's --pipeline-parallel-size argument" ,
211+ } ,
212+ {
213+ variable : 'VLLM_EXTRA_ARGS' ,
214+ placeholder :
215+ 'Additional vLLM arguments (e.g., --tokenizer=/models/custom-tokenizer --dtype=half)' ,
216+ description :
217+ 'Used to pass additional vLLM arguments not mentioned above' ,
218+ } ,
219+ ] ,
220+ } ,
221+ sglang : {
222+ requiredEnvVars : [
223+ {
224+ variable : 'BACKEND_MODEL_NAME' ,
225+ placeholder :
226+ 'Enter model name (e.g., gpt-oss-20b, qwen3-8b-Gemini-3-2.5-Pro-Distill)' ,
227+ description : 'Model name for sglang' ,
228+ } ,
229+ ] ,
230+ optionalEnvVars : [
231+ {
232+ variable : 'SGLANG_QUANTIZATION' ,
233+ placeholder : 'e.g., awq, awq_marlin, gptq, int4, fp8' ,
234+ description : 'Quantization method' ,
235+ } ,
236+ {
237+ variable : 'SGLANG_TP_SIZE' ,
238+ placeholder : 'Tensor parallel size (e.g., 1(default), 2, ...)' ,
239+ description : 'Tensor parallel size' ,
240+ } ,
241+ {
242+ variable : 'SGLANG_PP_SIZE' ,
243+ placeholder : 'Pipeline parallel size (e.g., 1(default), 2, ...)' ,
244+ description : 'Pipeline parallel size' ,
245+ } ,
246+ {
247+ variable : 'SGLANG_EXTRA_ARGS' ,
248+ placeholder :
249+ 'Extra arguments (e.g., --dtype bfloat16 --max-running-requests 100)' ,
250+ description : 'Extra arguments used for sglang cmd' ,
251+ } ,
252+ ] ,
253+ } ,
254+ nim : {
255+ requiredEnvVars : [
256+ {
257+ variable : 'NGC_API_KEY' ,
258+ placeholder : 'Enter your NGC API key' ,
259+ description : 'NGC API key with NIM Model Registry access' ,
260+ } ,
261+ ] ,
262+ optionalEnvVars : [ ] ,
263+ } ,
264+ } ;
265+
266+ // Helper function to set environment variables based on runtime variant
267+ const setEnvironmentVariablesForRuntimeVariant = ( runtimeVariant : string ) => {
268+ const runtimeConfig = RUNTIME_ENV_VAR_CONFIGS [ runtimeVariant ] ;
269+ if ( ! runtimeConfig ) return ;
270+
271+ const currentEnvVars = form . getFieldValue ( 'envvars' ) || [ ] ;
272+ const existingVariables = currentEnvVars
273+ . filter ( ( env : EnvVarFormListValue ) => env && env . variable )
274+ . map ( ( env : EnvVarFormListValue ) => env . variable ) ;
275+
276+ // Add required environment variables that don't exist
277+ const newRequiredEnvVars = ( runtimeConfig . requiredEnvVars || [ ] )
278+ . filter ( ( envVar ) => ! existingVariables . includes ( envVar . variable ) )
279+ . map ( ( envVar ) => ( {
280+ variable : envVar . variable ,
281+ value : '' ,
282+ } ) ) ;
283+
284+ if ( newRequiredEnvVars . length > 0 ) {
285+ const updatedEnvVars = [ ...currentEnvVars , ...newRequiredEnvVars ] ;
286+ form . setFieldValue ( 'envvars' , updatedEnvVars ) ;
287+ }
288+ } ;
289+
290+ // Handler for form values change
291+ const handleFormValuesChange = (
292+ changedValues : Partial < ServiceLauncherInput > ,
293+ ) => {
294+ if ( changedValues . runtimeVariant && ! endpoint ) {
295+ setEnvironmentVariablesForRuntimeVariant ( changedValues . runtimeVariant ) ;
296+ }
297+ } ;
298+
178299 const endpoint = useFragment (
179300 graphql `
180301 fragment ServiceLauncherPageContentFragment on Endpoint {
@@ -766,6 +887,7 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
766887 layout = "vertical"
767888 labelCol = { { span : 12 } }
768889 initialValues = { mergedInitialValues }
890+ onValuesChange = { handleFormValuesChange }
769891 >
770892 < BAIFlex direction = "column" gap = { 'md' } align = "stretch" >
771893 < Card >
@@ -780,7 +902,9 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
780902 < Input disabled = { ! ! endpoint } />
781903 </ Form . Item >
782904 < Form . Item name = "openToPublic" valuePropName = "checked" >
783- < Checkbox disabled = { ! ! endpoint } > { t ( 'modelService.OpenToPublic' ) } </ Checkbox >
905+ < Checkbox disabled = { ! ! endpoint } >
906+ { t ( 'modelService.OpenToPublic' ) }
907+ </ Checkbox >
784908 </ Form . Item >
785909 { ! endpoint ? (
786910 < Form . Item
@@ -1013,15 +1137,35 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
10131137 >
10141138 < ResourceAllocationFormItems enableResourcePresets />
10151139 </ div >
1016- < Form . Item
1017- label = { t ( 'session.launcher.EnvironmentVariable' ) }
1018- >
1019- < EnvVarFormList
1020- name = { 'envvars' }
1021- formItemProps = { {
1022- validateTrigger : [ 'onChange' , 'onBlur' ] ,
1023- } }
1024- />
1140+ < Form . Item dependencies = { [ 'runtimeVariant' ] } noStyle >
1141+ { ( { getFieldValue } ) => {
1142+ const runtimeVariant =
1143+ getFieldValue ( 'runtimeVariant' ) ;
1144+ const runtimeVariantConfig = runtimeVariant
1145+ ? RUNTIME_ENV_VAR_CONFIGS [ runtimeVariant ]
1146+ : null ;
1147+
1148+ return (
1149+ < Form . Item
1150+ label = { t (
1151+ 'session.launcher.EnvironmentVariable' ,
1152+ ) }
1153+ >
1154+ < EnvVarFormList
1155+ name = { 'envvars' }
1156+ requiredEnvVars = {
1157+ runtimeVariantConfig ?. requiredEnvVars
1158+ }
1159+ optionalEnvVars = {
1160+ runtimeVariantConfig ?. optionalEnvVars
1161+ }
1162+ formItemProps = { {
1163+ validateTrigger : [ 'onChange' , 'onBlur' ] ,
1164+ } }
1165+ />
1166+ </ Form . Item >
1167+ ) ;
1168+ } }
10251169 </ Form . Item >
10261170 </ >
10271171 ) }
0 commit comments