feat: harden and extend the CLI (security, UX, robustness, tests)
Sieben Verbesserungen; die Dateien überschneiden sich thematisch, daher ein Commit (jeder Commit bleibt grün: 115 Tests). - #1 --check ist scriptbar: Exit 0 wenn Container läuft und erreichbar, sonst 5 (check_exit_code / CheckResult). - #2 --force implementiert: Bypass eines belegten Locks mit Warnung (_container_lock) und stop_container(force=…) schluckt Inkonsistenzen. - #3 stille Trunkierung behoben: chat_completion_text liefert ChatReply (content + finish_reason); bei finish_reason=length Hinweis auf stderr, --chat gibt Exit 1 bei leerem Content zurück. - #4 keine vermeidbare Downtime: --change validiert den Modellpfad VOR dem Entfernen des laufenden Containers. - #5 Netzwerk dicht: Port-Publish standardmäßig nur auf 127.0.0.1 (--expose/expose für alle Interfaces), optionaler --api-key/api_key (Server --api-key + Bearer-Token auf allen Requests). - #6 --stream: Chat-Reply token-weise via SSE auf stdout (stream_chat). - #7 tests/test_actions.py: Orchestrierungs-Ebene (dry-run-Nebenwirkungen, Lock, validate-before-remove, chat/stream/exit-codes). Doku aktualisiert (Manpage, README, llama.cpp.config.example). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3158d16f9b
commit
24202feee6
14 changed files with 485 additions and 32 deletions
|
|
@ -116,7 +116,8 @@ def test_build_run_command_contains_key_flags():
|
|||
assert "--name" in cmd
|
||||
assert "test_llm" in cmd
|
||||
assert "-p" in cmd
|
||||
assert "8001:8000" in cmd
|
||||
# loopback-only by default (expose=False)
|
||||
assert "127.0.0.1:8001:8000" in cmd
|
||||
assert "--jinja" in cmd
|
||||
assert "--reasoning" in cmd
|
||||
assert "on" in cmd
|
||||
|
|
@ -125,6 +126,25 @@ def test_build_run_command_contains_key_flags():
|
|||
assert "--cont-batching" in cmd
|
||||
|
||||
|
||||
def test_build_run_command_expose_binds_all_interfaces():
|
||||
cfg = make_cfg(expose=True)
|
||||
cmd = build_run_command(cfg)
|
||||
assert "8001:8000" in cmd
|
||||
assert "127.0.0.1:8001:8000" not in cmd
|
||||
|
||||
|
||||
def test_build_run_command_api_key_passed_to_server():
|
||||
cfg = make_cfg(api_key="secret123")
|
||||
cmd = build_run_command(cfg)
|
||||
assert "--api-key" in cmd
|
||||
assert "secret123" in cmd
|
||||
|
||||
|
||||
def test_build_run_command_no_api_key_by_default():
|
||||
cfg = make_cfg()
|
||||
assert "--api-key" not in build_run_command(cfg)
|
||||
|
||||
|
||||
def test_build_run_command_respects_disabled_flags():
|
||||
cfg = make_cfg(jinja=False, kv_unified=False, cont_batching=False, no_context_shift=False, fa=False)
|
||||
cmd = build_run_command(cfg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue