Cookbook/Dependencies: Pip/uv vs Docker variant toggle on recipe panel

Each recipe catalog entry now carries two variants:
  variants.pip    → uv pip install …
  variants.docker → docker pull <image>

A small 'Install via' pill row in the panel toggles between them
(default = Pip/uv per the user's preference). Switching variant or
changing the model re-renders the <pre> via _refreshRecipePre(); the
display text drops the 'source venv/bin/activate' prefix for Docker
since docker pull doesn't need a venv. Run honours the active variant
so picking Docker queues 'docker pull …' as the tmux task.
This commit is contained in:
pewdiepie-archdaemon
2026-06-14 22:47:26 +09:00
parent d70eb99a0d
commit 63b4ad2e9c
2 changed files with 94 additions and 44 deletions
+39 -24
View File
@@ -5,33 +5,37 @@
// Entries are matched first-hit; put the more specific patterns ABOVE the
// generic fallback for that backend.
// Recipes hold ONLY the install command(s). The renderer prepends a
// `source <venv>/bin/activate` line for context using the active server's
// configured envPath; the Run button reuses env_prefix to activate that
// same venv before executing, so the install lands in your existing
// environment rather than a fresh `.venv` in some random CWD.
// Recipes carry two variants per entry:
// variants.pip → install into the configured venv via uv/pip
// variants.docker → pull the official container image
//
// The renderer prepends a `source <venv>/bin/activate` for the pip variant
// (env_prefix handles activation for Run). The docker variant skips the
// activate line — `docker pull` doesn't need a venv.
const _RECIPES = [
// ── vllm ──────────────────────────────────────────────────────────────
// MiniMax M2/M2.7 — same generic vllm install for now; kept as its own
// entry so future model-specific patches (FP8 quants, custom kernels)
// land in one obvious place without touching the catch-all.
// MiniMax M2/M2.7 — same as the generic vllm install/image for now;
// kept as its own entry so future model-specific patches land in one
// obvious place without touching the catch-all.
{
backend: 'vllm',
label: 'MiniMax M2 / M2.7',
match: (m) => /minimax[-_]?m\s?2(\.7)?/i.test(m || ''),
commands: [
'uv pip install -U vllm --torch-backend auto',
],
variants: {
pip: { commands: ['uv pip install -U vllm --torch-backend auto'] },
docker: { commands: ['docker pull vllm/vllm-openai:latest'] },
},
},
// Generic vllm fallback — auto-resolves the right torch backend (CUDA
// 12.x / 12.4 / ROCm) at install time so users don't have to know.
// Generic vllm fallback.
{
backend: 'vllm',
label: 'Any vLLM model',
match: () => true,
commands: [
'uv pip install -U vllm --torch-backend auto',
],
variants: {
pip: { commands: ['uv pip install -U vllm --torch-backend auto'] },
docker: { commands: ['docker pull vllm/vllm-openai:latest'] },
},
},
// ── sglang ────────────────────────────────────────────────────────────
@@ -39,24 +43,35 @@ const _RECIPES = [
backend: 'sglang',
label: 'Any SGLang model',
match: () => true,
commands: [
'uv pip install -U "sglang[all]" --torch-backend auto',
],
variants: {
pip: { commands: ['uv pip install -U "sglang[all]" --torch-backend auto'] },
docker: { commands: ['docker pull lmsysorg/sglang:latest'] },
},
},
// ── llama.cpp ─────────────────────────────────────────────────────────
// The cookbook-side rebuild path covers this for users who already have
// the engine compiled — but for a fresh box, surface a sane install.
{
backend: 'llama_cpp',
label: 'Any GGUF model',
match: () => true,
commands: [
'CMAKE_ARGS="-DGGML_CUDA=on" uv pip install -U "llama-cpp-python[server]"',
],
variants: {
pip: { commands: ['CMAKE_ARGS="-DGGML_CUDA=on" uv pip install -U "llama-cpp-python[server]"'] },
docker: { commands: ['docker pull ghcr.io/ggerganov/llama.cpp:server-cuda'] },
},
},
];
export const RECIPE_VARIANTS = ['pip', 'docker'];
export const RECIPE_DEFAULT_VARIANT = 'pip';
// Get the commands array for a recipe + variant. Falls back to pip when
// the requested variant isn't defined for the recipe.
export function recipeCommands(recipe, variant) {
if (!recipe) return [];
const v = (recipe.variants || {})[variant] || (recipe.variants || {}).pip;
return (v && v.commands) || [];
}
// Backends we surface a recipe panel for. Other rows in the Dependencies
// list keep the existing flat Install/Reinstall button without an expand
// affordance.