Steuert einen llama.cpp-Server als Docker-Container: --start/--check/--stop/
--change/--chat, INI-Konfiguration (builtin defaults -> [default] ->
[model.<profile>] -> CLI), SSRF-gehärtete Prompt-Eingabe (Datei/HTTPS-URL),
File-Locking für --start/--change und ein OpenAI-kompatibler HTTP-Layer.
Enthält u. a.:
- Env-Var-Expansion in hf_home (hf_home = ${HF_HOME})
- konfigurierbares Chat-Antwortbudget (max_tokens/chat_temperature,
CLI: --max-tokens/--chat-temp); temperature defer an Server-Default
- DNS-Pinning gegen DNS-Rebinding bei URL-Quellen
- dry-run als nebenwirkungsfreie Vorschau (kein Lock/Removal/Modell-Check)
- 98 Tests (pytest)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
792 B
Python
28 lines
792 B
Python
from llamacppctl.prompt_io import PromptSource, PromptSourceError, resolve_source
|
|
|
|
|
|
def test_resolve_literal_source():
|
|
src = resolve_source("hello", None, None)
|
|
assert src == PromptSource("literal", "hello")
|
|
|
|
|
|
def test_resolve_file_source():
|
|
src = resolve_source(None, "/tmp/foo.txt", None)
|
|
assert src == PromptSource("file", "/tmp/foo.txt")
|
|
|
|
|
|
def test_resolve_url_source():
|
|
src = resolve_source(None, None, "https://example.org/x.txt")
|
|
assert src == PromptSource("url", "https://example.org/x.txt")
|
|
|
|
|
|
def test_resolve_none():
|
|
assert resolve_source(None, None, None) is None
|
|
|
|
|
|
def test_resolve_rejects_multiple_sources():
|
|
try:
|
|
resolve_source("a", "b", None)
|
|
assert False, "expected PromptSourceError"
|
|
except PromptSourceError:
|
|
pass
|