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>
This commit is contained in:
1 parent
66e6a8c4f7
commit
ea1f18cc74
32 files changed
+2478
-183
No files matched your search
@@ -14,8 +14,13 @@ export type CommandInput = {
|
||||
options: DeploymentOptions;
|
||||
model: { repoId: string; localPath: string };
|
||||
runtime: { env: Record<string, string>; extraArgs: string[] };
|
||||
/** Keys from Settings → API keys; used when `options.requireApiKey` is set. */
|
||||
apiKeys?: string[];
|
||||
};
|
||||
|
||||
/** Stands in for key values in everything Kaname shows or stores. */
|
||||
export const API_KEY_PLACEHOLDER = "<api-key>";
|
||||
|
||||
export type ContainerCommand = { args: string[]; env: Record<string, string>; port: number };
|
||||
|
||||
const inModels = (localPath: string, file?: string | null) =>
|
||||
@@ -34,8 +39,9 @@ function withoutFlag(args: string[], flag: string): string[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
export function buildCommand({ engine, options: o, model, runtime }: CommandInput): ContainerCommand {
|
||||
export function buildCommand({ engine, options: o, model, runtime, apiKeys = [] }: CommandInput): ContainerCommand {
|
||||
const port = ENGINE_PORT[engine];
|
||||
const keys = o.requireApiKey ? apiKeys : [];
|
||||
if (engine === "llama.cpp") {
|
||||
// The image's entrypoint is llama-server, so these are its arguments.
|
||||
const args = [
|
||||
@@ -63,12 +69,16 @@ export function buildCommand({ engine, options: o, model, runtime }: CommandInpu
|
||||
...runtime.extraArgs,
|
||||
...o.extraArgs,
|
||||
];
|
||||
return { args, env: { ...runtime.env }, port };
|
||||
// Via the environment, not the command line; several keys as one comma-separated list.
|
||||
const env = { ...runtime.env, ...(keys.length ? { LLAMA_API_KEY: keys.join(",") } : {}) };
|
||||
return { args, env, port };
|
||||
}
|
||||
|
||||
// vLLM: the image's entrypoint is `vllm serve`; the model is the repo folder.
|
||||
const env = { ...runtime.env };
|
||||
if (o.kvCacheGb != null) env.VLLM_CPU_KVCACHE_SPACE = String(o.kvCacheGb);
|
||||
// VLLM_API_KEY holds a single key; more than one needs --api-key.
|
||||
if (keys.length === 1) env.VLLM_API_KEY = keys[0];
|
||||
const args = [
|
||||
inModels(model.localPath, o.modelFile || null),
|
||||
"--host",
|
||||
@@ -79,6 +89,7 @@ export function buildCommand({ engine, options: o, model, runtime }: CommandInpu
|
||||
model.repoId,
|
||||
...num("--max-model-len", o.contextSize),
|
||||
...num("--max-num-seqs", o.maxNumSeqs),
|
||||
...(keys.length > 1 ? ["--api-key", ...keys] : []),
|
||||
// A deployment's dtype replaces the runtime's default instead of repeating the flag.
|
||||
...(o.dtype ? withoutFlag(runtime.extraArgs, "--dtype") : runtime.extraArgs),
|
||||
...str("--dtype", o.dtype),
|
||||
@@ -87,6 +98,12 @@ export function buildCommand({ engine, options: o, model, runtime }: CommandInpu
|
||||
return { args, env, port };
|
||||
}
|
||||
|
||||
/** The command with every key replaced by {@link API_KEY_PLACEHOLDER}. */
|
||||
export function redactCommand(cmd: ContainerCommand, keys: string[]): ContainerCommand {
|
||||
const hide = (v: string) => keys.filter(Boolean).reduce((acc, k) => acc.split(k).join(API_KEY_PLACEHOLDER), v);
|
||||
return { ...cmd, args: cmd.args.map(hide), env: Object.fromEntries(Object.entries(cmd.env).map(([k, v]) => [k, hide(v)])) };
|
||||
}
|
||||
|
||||
/** Shell-style rendering for display ("docker run … image args"). */
|
||||
export function renderCommand(image: string, cmd: ContainerCommand): string {
|
||||
const q = (s: string) => (/^[\w@%+=:,./-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`);
|
||||
|
||||
Reference in new issue
Block a user