diff --git a/frontend/src/api/k8s/inferenceServices.ts b/frontend/src/api/k8s/inferenceServices.ts index fded27ccbc..3fbff23997 100644 --- a/frontend/src/api/k8s/inferenceServices.ts +++ b/frontend/src/api/k8s/inferenceServices.ts @@ -45,6 +45,13 @@ export const assembleInferenceService = ( const dataConnectionKey = secretKey || dataConnection; const nonEmptyArgs = servingRuntimeArgs?.filter(Boolean) || []; + // If we have nonEmptyArgs, ensure that we properly handle separating args + let splitArgs: string[] = []; + if (nonEmptyArgs.length > 0) { + for (let i = 0; i < nonEmptyArgs.length; i++) { + splitArgs = splitArgs.concat(parseCommandLine(nonEmptyArgs[i])); + } + } const nonEmptyEnvVars = servingRuntimeEnvVars?.filter((ev) => ev.name) || []; const updateInferenceService: InferenceServiceKind = inferenceService @@ -87,7 +94,7 @@ export const assembleInferenceService = ( path, }, }), - args: nonEmptyArgs, + args: splitArgs, env: nonEmptyEnvVars, }, }, @@ -135,7 +142,7 @@ export const assembleInferenceService = ( path, }, }), - args: nonEmptyArgs, + args: splitArgs, env: nonEmptyEnvVars, }, }, @@ -325,3 +332,25 @@ export const deleteInferenceService = ( opts, ), ); + + +function parseCommandLine(input: string): string[] { + const args: string[] = []; + const regex = /(?:[^\s"']+|"[^"]*"|'[^']*')+/g; + let match: RegExpExecArray | null; + + while ((match = regex.exec(input)) !== null) { + let arg: string = match[0]; + + // Remove surrounding quotes if any + if (arg.startsWith('"') && arg.endsWith('"')) { + arg = arg.slice(1, -1).replace(/\\"/g, '"'); // Unescape double quotes + } else if (arg.startsWith("'") && arg.endsWith("'")) { + arg = arg.slice(1, -1); // Remove single quotes + } + + args.push(arg); + } + + return args; +} \ No newline at end of file