Implement prompt caching, speculative decoding config, parallel slots, and dynamic pricing metrics

This commit is contained in:
Hitonabi
2026-06-26 14:00:32 +02:00
parent 2c60caf790
commit 35dcc69ba5
12 changed files with 216 additions and 35 deletions
+21
View File
@@ -57,6 +57,15 @@ def _parse_model(name: str, spec: dict) -> dict:
aliases = [str(a) for a in aliases]
role = aliases[0].lower() if aliases else (name.lower() if name.lower() in ROLE_IDS else None)
prompt_cache = "--prompt-cache " in cmd or cmd.endswith("--prompt-cache") or "--prompt-cache-all" in cmd
spec_draft = None
if "--spec-draft-model" in cmd:
m_draft = re.search(r"--spec-draft-model\s+([^\s]+)", cmd)
if m_draft:
spec_draft = os.path.basename(m_draft.group(1).replace("'", "").replace('"', ""))
parallel_match = re.search(r"--parallel\s+(\d+)", cmd)
parallel_slots = int(parallel_match.group(1)) if parallel_match else 1
from services.caps import capabilities
return {
"name": name,
@@ -71,6 +80,9 @@ def _parse_model(name: str, spec: dict) -> dict:
"quant": quant,
"size_bytes": size_bytes,
"incomplete": not path,
"prompt_cache": prompt_cache,
"spec_draft_model": spec_draft,
"parallel_slots": parallel_slots,
"capabilities": capabilities(
name=filename or name, cmd=cmd,
gguf_path=(path if (path and os.path.exists(path)) else ""),
@@ -171,6 +183,15 @@ def register_model(model_path: str, role: str | None = None, ctx: int = 8192,
cmd = _augment_vision(cmd, model_path, mmproj_path)
if jinja and "--jinja" not in cmd:
cmd += " --jinja"
role_lower = (role or "").strip().lower()
if role_lower in ("fast", "coder"):
if "--parallel" not in cmd:
cmd += " --parallel 2"
draft_path = "/srv/models/drafts/qwen2.5-1.5b-instruct-q4_k_m.gguf"
if os.path.exists(draft_path) and "--spec-draft-model" not in cmd:
cmd += f" --spec-draft-model {draft_path}"
cfg.setdefault("models", {})[model_id] = {
"cmd": LiteralScalarString(cmd + "\n"),
"ttl": ttl if ttl is not None else DEFAULT_TTL,