Files
Kaname/src/lib/extra-args.ts
T
Pascal LinxweilerandClaude Opus 5.5 ea1f18cc74 Deployments: API keys, deploy from the library, reorganized form
- Settings → API keys (generate or paste, show again, delete). Deployments with
  "Require an API key" get them via LLAMA_API_KEY / VLLM_API_KEY (--api-key for
  several vLLM keys); values are masked in the stored/shown command and in logs.
  The chat proxy sends a key.
- "Deploy" in the library and on the model page preselects the model and a
  runtime that can serve it; library rows and the model page link to the
  model's deployments.
- Deployment form: grouped launch options with flags next to labels, command in
  its own step, extra arguments as flag/value rows (runtime form too).
- Native selects follow the dark theme (color-scheme), fixing unreadable options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 12:28:25 +02:00

25 lines
1018 B
TypeScript

// Extra command-line arguments as editable flag/value rows. Pure; shared by the runtime and
// deployment forms. The stored form stays a token list (one argv entry per item).
export type ArgRow = { flag: string; value: string };
const isFlag = (t: string) => t.startsWith("-") && !/^-\d/.test(t);
/** Tokens → rows: a flag takes the following non-flag token as its value. */
export function argsToRows(tokens: string[]): ArgRow[] {
const rows: ArgRow[] = [];
for (const t of tokens) {
const last = rows.at(-1);
// "--flag=value" stays one token, so it is shown (and passed) exactly as written.
if (!isFlag(t) && last && last.flag && !last.value && !last.flag.includes("=")) last.value = t;
else if (isFlag(t)) rows.push({ flag: t, value: "" });
else rows.push({ flag: "", value: t });
}
return rows;
}
/** Rows → tokens, skipping empty rows. */
export function rowsToArgs(rows: ArgRow[]): string[] {
return rows.flatMap((r) => [r.flag.trim(), r.value.trim()].filter(Boolean));
}