xllama-remote 0.11.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xllama_remote/__init__.py +10 -0
- xllama_remote/__main__.py +6 -0
- xllama_remote/api/__init__.py +2 -0
- xllama_remote/api/atomic.py +29 -0
- xllama_remote/api/backend.py +71 -0
- xllama_remote/api/catalog.py +130 -0
- xllama_remote/api/client.py +632 -0
- xllama_remote/api/config.py +392 -0
- xllama_remote/api/discovery.py +178 -0
- xllama_remote/api/errors.py +196 -0
- xllama_remote/api/network.py +49 -0
- xllama_remote/api/sampling.py +51 -0
- xllama_remote/api/sse.py +58 -0
- xllama_remote/api/wire.py +263 -0
- xllama_remote/cli/__init__.py +106 -0
- xllama_remote/cli/agent.py +263 -0
- xllama_remote/cli/daemon.py +228 -0
- xllama_remote/cli/mcp.py +65 -0
- xllama_remote/cli/media.py +177 -0
- xllama_remote/cli/model.py +369 -0
- xllama_remote/cli/repl_launch.py +475 -0
- xllama_remote/cli/run.py +631 -0
- xllama_remote/cli/sessions.py +136 -0
- xllama_remote/cli/state.py +298 -0
- xllama_remote/cli/system.py +236 -0
- xllama_remote/cli/trust.py +85 -0
- xllama_remote/daemon/__init__.py +15 -0
- xllama_remote/daemon/app.py +449 -0
- xllama_remote/daemon/auth.py +111 -0
- xllama_remote/daemon/client.py +182 -0
- xllama_remote/daemon/codes.py +27 -0
- xllama_remote/daemon/folder_grant.py +57 -0
- xllama_remote/daemon/gate.py +70 -0
- xllama_remote/daemon/remote.py +385 -0
- xllama_remote/daemon/server.py +281 -0
- xllama_remote/daemon/service.py +1013 -0
- xllama_remote/daemon/state.py +122 -0
- xllama_remote/daemon/static/app.css +66 -0
- xllama_remote/daemon/static/app.js +851 -0
- xllama_remote/daemon/static/index.html +86 -0
- xllama_remote/daemon/turn_end.py +73 -0
- xllama_remote/daemon/turnlog.py +140 -0
- xllama_remote/harness/__init__.py +2 -0
- xllama_remote/harness/agent.py +759 -0
- xllama_remote/harness/agent_types.py +187 -0
- xllama_remote/harness/bm25.py +41 -0
- xllama_remote/harness/cancel.py +35 -0
- xllama_remote/harness/compaction.py +153 -0
- xllama_remote/harness/context.py +244 -0
- xllama_remote/harness/environment.py +87 -0
- xllama_remote/harness/evals/__init__.py +74 -0
- xllama_remote/harness/evals/cases/persona/brevity.jsonl +8 -0
- xllama_remote/harness/evals/cases/persona/identity.jsonl +8 -0
- xllama_remote/harness/evals/cases/persona/register.jsonl +8 -0
- xllama_remote/harness/evals/cases/recall/recall.jsonl +8 -0
- xllama_remote/harness/evals/cases/task/change.jsonl +2 -0
- xllama_remote/harness/evals/cases/task/fix.jsonl +3 -0
- xllama_remote/harness/evals/cases/task/inspect.jsonl +2 -0
- xllama_remote/harness/evals/cases/v1/abstention.jsonl +21 -0
- xllama_remote/harness/evals/cases/v1/chat.jsonl +10 -0
- xllama_remote/harness/evals/cases/v1/environment.jsonl +10 -0
- xllama_remote/harness/evals/cases/v1/irrelevance.jsonl +26 -0
- xllama_remote/harness/evals/cases/v1/missing_param.jsonl +6 -0
- xllama_remote/harness/evals/cases/v1/multiturn.jsonl +15 -0
- xllama_remote/harness/evals/cases/v1/retrieval.jsonl +37 -0
- xllama_remote/harness/evals/cases/v1/single.jsonl +23 -0
- xllama_remote/harness/evals/cases/v1/web.jsonl +12 -0
- xllama_remote/harness/evals/cases.py +165 -0
- xllama_remote/harness/evals/checks.py +273 -0
- xllama_remote/harness/evals/extra_tools.py +116 -0
- xllama_remote/harness/evals/fixtures/README.md +18 -0
- xllama_remote/harness/evals/fixtures/greeter/README.md +3 -0
- xllama_remote/harness/evals/fixtures/greeter/app.py +18 -0
- xllama_remote/harness/evals/fixtures/greeter/users.json +4 -0
- xllama_remote/harness/evals/fixtures/receipt/README.md +5 -0
- xllama_remote/harness/evals/fixtures/receipt/calc.py +22 -0
- xllama_remote/harness/evals/fixtures/receipt/test_calc.py +18 -0
- xllama_remote/harness/evals/fixtures/shapes/README.md +5 -0
- xllama_remote/harness/evals/fixtures/shapes/geometry.py +9 -0
- xllama_remote/harness/evals/fixtures/shapes/report.py +15 -0
- xllama_remote/harness/evals/fixtures/shapes/test_shapes.py +19 -0
- xllama_remote/harness/evals/report.py +308 -0
- xllama_remote/harness/evals/runner.py +694 -0
- xllama_remote/harness/evals/stats.py +43 -0
- xllama_remote/harness/hooks.py +89 -0
- xllama_remote/harness/language.py +91 -0
- xllama_remote/harness/mcp.py +474 -0
- xllama_remote/harness/model_choice.py +273 -0
- xllama_remote/harness/models.py +535 -0
- xllama_remote/harness/permissions.py +351 -0
- xllama_remote/harness/procs.py +97 -0
- xllama_remote/harness/reasoning.py +55 -0
- xllama_remote/harness/runtime.py +603 -0
- xllama_remote/harness/sandbox.py +251 -0
- xllama_remote/harness/sessions.py +454 -0
- xllama_remote/harness/tool_retrieval.py +55 -0
- xllama_remote/harness/tools/__init__.py +6 -0
- xllama_remote/harness/tools/builtin.py +322 -0
- xllama_remote/harness/tools/control.py +56 -0
- xllama_remote/harness/tools/keywords.py +93 -0
- xllama_remote/harness/tools/registry.py +165 -0
- xllama_remote/harness/trust.py +28 -0
- xllama_remote/harness/turn.py +94 -0
- xllama_remote/harness/web/__init__.py +49 -0
- xllama_remote/harness/web/extract.py +65 -0
- xllama_remote/harness/web/fetch.py +230 -0
- xllama_remote/harness/web/passages.py +81 -0
- xllama_remote/harness/web/provenance.py +82 -0
- xllama_remote/harness/web/search.py +139 -0
- xllama_remote/harness/web/settings.py +77 -0
- xllama_remote/harness/web/tools.py +75 -0
- xllama_remote/py.typed +0 -0
- xllama_remote/ui/__init__.py +2 -0
- xllama_remote/ui/clipboard.py +17 -0
- xllama_remote/ui/command_panel.py +36 -0
- xllama_remote/ui/commands.py +85 -0
- xllama_remote/ui/dialogs.py +210 -0
- xllama_remote/ui/doctor.py +170 -0
- xllama_remote/ui/fullscreen.py +731 -0
- xllama_remote/ui/fullscreen_render.py +115 -0
- xllama_remote/ui/fullscreen_session.py +117 -0
- xllama_remote/ui/history.py +69 -0
- xllama_remote/ui/logfile.py +62 -0
- xllama_remote/ui/model_picker.py +170 -0
- xllama_remote/ui/output.py +92 -0
- xllama_remote/ui/picker.py +284 -0
- xllama_remote/ui/prompt.py +115 -0
- xllama_remote/ui/render.py +395 -0
- xllama_remote/ui/repl.py +853 -0
- xllama_remote/ui/session_picker.py +64 -0
- xllama_remote/ui/tool_picker.py +76 -0
- xllama_remote/ui/transcript.py +411 -0
- xllama_remote-0.11.2.dist-info/METADATA +191 -0
- xllama_remote-0.11.2.dist-info/RECORD +138 -0
- xllama_remote-0.11.2.dist-info/WHEEL +4 -0
- xllama_remote-0.11.2.dist-info/entry_points.txt +2 -0
- xllama_remote-0.11.2.dist-info/licenses/LICENSE +21 -0
- xllama_remote-0.11.2.dist-info/licenses/NOTICE +26 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Thin remote CLI for the xllama LAN API."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("xllama-remote")
|
|
7
|
+
except PackageNotFoundError: # pragma: no cover - editable/uninstalled fallback
|
|
8
|
+
__version__ = "0.11.2"
|
|
9
|
+
|
|
10
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
"""Replace a file in one step, so a reader never sees half of it."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import stat
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from tempfile import NamedTemporaryFile
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def replace_file(path: Path, data: bytes, *, mode: int = 0o600) -> None:
|
|
13
|
+
"""Write ``data`` to a temporary file in ``path``'s folder, flush it to
|
|
14
|
+
disk and rename it over ``path``. The new file keeps the old one's
|
|
15
|
+
permission bits; a new file gets ``mode``. Two writers never share the
|
|
16
|
+
temporary file (each gets its own name); the last rename wins."""
|
|
17
|
+
temp: Path | None = None
|
|
18
|
+
try:
|
|
19
|
+
with NamedTemporaryFile(dir=path.parent, delete=False) as stream:
|
|
20
|
+
temp = Path(stream.name)
|
|
21
|
+
stream.write(data)
|
|
22
|
+
stream.flush()
|
|
23
|
+
os.fsync(stream.fileno())
|
|
24
|
+
os.chmod(temp, stat.S_IMODE(path.stat().st_mode) if path.exists() else mode)
|
|
25
|
+
os.replace(temp, path)
|
|
26
|
+
temp = None
|
|
27
|
+
finally:
|
|
28
|
+
if temp is not None:
|
|
29
|
+
temp.unlink(missing_ok=True)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
"""What the server behind the base URL can do.
|
|
3
|
+
|
|
4
|
+
The harness speaks OpenAI ``/v1/chat/completions`` and ``/v1/models`` to any
|
|
5
|
+
backend (xllama, Ollama, llama.cpp server, LM Studio, vLLM, OpenAI,
|
|
6
|
+
OpenRouter…). Everything else is a capability: xllama adds ``/health``,
|
|
7
|
+
``/api/pull``, images, training and preferences, and a single-slot ``503
|
|
8
|
+
busy`` worth retrying. ``backend = "auto"`` asks ``/health`` once.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from typing import Literal
|
|
14
|
+
|
|
15
|
+
from xllama_remote.api.errors import EXIT_USAGE, XlrError
|
|
16
|
+
|
|
17
|
+
Kind = Literal["xllama", "openai"]
|
|
18
|
+
Capability = Literal["health", "pull", "image", "train", "prefs", "embeddings"]
|
|
19
|
+
|
|
20
|
+
CAPABILITIES: dict[str, frozenset[str]] = {
|
|
21
|
+
"xllama": frozenset({"health", "pull", "image", "train", "prefs", "embeddings"}),
|
|
22
|
+
"openai": frozenset({"embeddings"}),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class UnsupportedError(XlrError):
|
|
27
|
+
"""The configured backend does not offer this feature."""
|
|
28
|
+
|
|
29
|
+
exit_code = EXIT_USAGE
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def supports(kind: str, capability: Capability) -> bool:
|
|
33
|
+
return capability in CAPABILITIES.get(kind, frozenset())
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def require(kind: str, capability: Capability, command: str) -> None:
|
|
37
|
+
if not supports(kind, capability):
|
|
38
|
+
raise UnsupportedError(
|
|
39
|
+
f"`{command}` needs an xllama console; this profile's backend is {kind!r}."
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# /health capability names (xllama #572) mapped to xlr's capability names.
|
|
44
|
+
HEALTH_CAPABILITIES = {
|
|
45
|
+
"pull": "pull",
|
|
46
|
+
"images": "image",
|
|
47
|
+
"training_status": "train",
|
|
48
|
+
"preferences": "prefs",
|
|
49
|
+
"embeddings": "embeddings",
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def from_health(body: dict[str, object]) -> frozenset[str] | None:
|
|
54
|
+
"""Capabilities the server reports, or None for servers that predate them."""
|
|
55
|
+
caps = body.get("capabilities")
|
|
56
|
+
if not isinstance(caps, dict):
|
|
57
|
+
return None
|
|
58
|
+
found = {ours for theirs, ours in HEALTH_CAPABILITIES.items() if caps.get(theirs) is True}
|
|
59
|
+
return frozenset(found | {"health"})
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def require_in(
|
|
63
|
+
capabilities: frozenset[str], kind: str, capability: Capability, command: str
|
|
64
|
+
) -> None:
|
|
65
|
+
if capability not in capabilities:
|
|
66
|
+
if kind != "xllama":
|
|
67
|
+
require(kind, capability, command)
|
|
68
|
+
raise UnsupportedError(
|
|
69
|
+
f"`{command}` is not available on this backend ({kind}); the server does not "
|
|
70
|
+
f"report the {capability!r} capability."
|
|
71
|
+
)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
"""xllama catalogue adapter: model facts for xllama servers that do not report them.
|
|
3
|
+
|
|
4
|
+
Used by ``harness/models.py`` only when ``backend = xllama``, as one layer
|
|
5
|
+
below user overrides and backend reports. Since xllama #572, ``/v1/models``
|
|
6
|
+
carries ``n_ctx``, ``kind``, ``role``, display name and capabilities, and the
|
|
7
|
+
backend layer wins; this table covers older servers (1.7/1.8 builds that
|
|
8
|
+
return only ids). Context sizes and display names come from xllama's
|
|
9
|
+
``uwp/models/manifest.json``; entries without ``n_ctx`` use ``kDefaultNCtx``
|
|
10
|
+
(2048, ``include/xllama/inference_params.h``).
|
|
11
|
+
|
|
12
|
+
Models to download are never suggested from this table: they come from the
|
|
13
|
+
console's own ``GET /api/catalog`` (``harness/model_choice``).
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from dataclasses import dataclass, replace
|
|
19
|
+
from typing import Any, Literal
|
|
20
|
+
|
|
21
|
+
DEFAULT_N_CTX = 2048
|
|
22
|
+
|
|
23
|
+
Kind = Literal["ort-genai", "gguf", "diffusion"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class CatalogEntry:
|
|
28
|
+
display: str
|
|
29
|
+
kind: Kind
|
|
30
|
+
role: str = ""
|
|
31
|
+
n_ctx: int = DEFAULT_N_CTX
|
|
32
|
+
tools: bool = False # tested for tool proposals
|
|
33
|
+
reasoning: bool = False # emits <think>…</think> before answering
|
|
34
|
+
languages: tuple[str, ...] | None = None # from the model card
|
|
35
|
+
# Model card sampling recommendations; None = the server's default.
|
|
36
|
+
temperature: float | None = None
|
|
37
|
+
top_p: float | None = None
|
|
38
|
+
top_k: int | None = None
|
|
39
|
+
repetition_penalty: float | None = None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
CATALOG: dict[str, CatalogEntry] = {
|
|
43
|
+
"smollm2-360m-cpu-int4": CatalogEntry("SmolLM2 360M (CPU int4)", "ort-genai"),
|
|
44
|
+
"smollm2-360m-dml-fp16-v2": CatalogEntry("SmolLM2 360M (GPU fp16)", "ort-genai"),
|
|
45
|
+
"smollm2-1.7b-cpu-int4": CatalogEntry("SmolLM2 1.7B (CPU int4)", "ort-genai"),
|
|
46
|
+
"qwen35-0.8b": CatalogEntry("Qwen3.5 0.8B", "gguf"),
|
|
47
|
+
"gemma3-270m": CatalogEntry("Gemma 3 270M", "gguf"),
|
|
48
|
+
"gemma4-e2b": CatalogEntry("Gemma 4 E2B", "gguf"),
|
|
49
|
+
"lfm25-230m": CatalogEntry("LFM2.5 230M", "gguf", tools=True),
|
|
50
|
+
"lfm25-350m": CatalogEntry("LFM2.5 350M", "gguf", tools=True),
|
|
51
|
+
"lfm25-1.2b-instruct": CatalogEntry("LFM2.5 1.2B Instruct", "gguf", tools=True),
|
|
52
|
+
"lfm2-2.6b": CatalogEntry("LFM2 2.6B", "gguf", tools=True),
|
|
53
|
+
"llama32-3b": CatalogEntry("Llama 3.2 3B", "gguf", tools=True),
|
|
54
|
+
"qwen25-coder-0.5b": CatalogEntry("Qwen2.5 Coder 0.5B", "gguf", "coding", 4096),
|
|
55
|
+
"qwen25-coder-1.5b": CatalogEntry("Qwen2.5 Coder 1.5B", "gguf", "coding", 4096),
|
|
56
|
+
"phi4-mini": CatalogEntry("Phi-4 mini", "gguf", n_ctx=4096),
|
|
57
|
+
"qwen3-1.7b": CatalogEntry("Qwen3 1.7B", "gguf"),
|
|
58
|
+
"lfm25-1.2b-thinking": CatalogEntry("LFM2.5 1.2B Thinking", "gguf", tools=True, reasoning=True),
|
|
59
|
+
"embed-bge-m3": CatalogEntry("BGE-M3", "gguf", "embedding", 8192),
|
|
60
|
+
"embed-nomic-v2-moe": CatalogEntry("Nomic Embed Text v2 MoE", "gguf", "embedding", 512),
|
|
61
|
+
"sd-turbo-fp16": CatalogEntry("SD-Turbo", "diffusion"),
|
|
62
|
+
# Tools measured by xlr on a Series S (2026-11-25): 4/4 correct calls
|
|
63
|
+
# (list_dir, read_file), ~140 reasoning tokens, 10–15 s per turn.
|
|
64
|
+
"lfm25-8b-a1b": CatalogEntry("LFM2.5 8B-A1B MoE", "gguf", tools=True, reasoning=True),
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# Model-card facts. LFM2.5: "English, Arabic, Chinese, French, German, Japanese,
|
|
68
|
+
# Korean, Spanish", temperature 0.1 (huggingface.co/LiquidAI/LFM2.5-1.2B-Instruct).
|
|
69
|
+
# The sampling here only serves consoles before xllama v1.11: from v1.11 the
|
|
70
|
+
# server applies each model's values itself (model_sampling, ADR 0002), and a
|
|
71
|
+
# request carries only the user's overrides.
|
|
72
|
+
# Llama 3.2: English, German, French, Italian, Portuguese, Hindi, Spanish, Thai.
|
|
73
|
+
LFM_LANGS = ("en", "ar", "zh", "fr", "de", "ja", "ko", "es")
|
|
74
|
+
LLAMA32_LANGS = ("en", "de", "fr", "it", "pt", "hi", "es", "th")
|
|
75
|
+
for _id, _entry in list(CATALOG.items()):
|
|
76
|
+
if _id.startswith(("lfm25-", "lfm2-")):
|
|
77
|
+
CATALOG[_id] = replace(_entry, languages=LFM_LANGS, temperature=0.1)
|
|
78
|
+
CATALOG["llama32-3b"] = replace(CATALOG["llama32-3b"], languages=LLAMA32_LANGS)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def entry(model_id: str | None) -> CatalogEntry | None:
|
|
82
|
+
return CATALOG.get(model_id or "")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def n_ctx(model_id: str | None) -> int:
|
|
86
|
+
found = entry(model_id)
|
|
87
|
+
return found.n_ctx if found else DEFAULT_N_CTX
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def display(model_id: str | None) -> str | None:
|
|
91
|
+
found = entry(model_id)
|
|
92
|
+
return found.display if found else None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def reasoning(model_id: str | None) -> bool:
|
|
96
|
+
found = entry(model_id)
|
|
97
|
+
return bool(found and found.reasoning)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def tools_validated(model_id: str | None) -> bool:
|
|
101
|
+
found = entry(model_id)
|
|
102
|
+
return bool(found and found.tools)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def facts(model_id: str, reported: dict[str, Any] | None = None) -> dict[str, str | None]:
|
|
106
|
+
"""Display name, kind and role: what ``/v1/models`` reports (xllama #572)
|
|
107
|
+
first, this table for servers that report only ids."""
|
|
108
|
+
raw = reported or {}
|
|
109
|
+
known = entry(model_id)
|
|
110
|
+
|
|
111
|
+
def pick(key: str, fallback: str | None) -> str | None:
|
|
112
|
+
value = raw.get(key)
|
|
113
|
+
return value if isinstance(value, str) and value else fallback
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
"display": pick("display", known.display if known else None),
|
|
117
|
+
"kind": pick("kind", known.kind if known else None),
|
|
118
|
+
"role": pick("role", (known.role or None) if known else None),
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def is_chat(model_id: str, reported: dict[str, Any] | None = None) -> bool:
|
|
123
|
+
"""False for embedding and image models, which must not be picked for chat:
|
|
124
|
+
on xllama they share the single resident session, so after ``xlr embed`` the
|
|
125
|
+
active model is the embedder."""
|
|
126
|
+
caps = (reported or {}).get("capabilities")
|
|
127
|
+
if isinstance(caps, dict) and caps.get("embedding") is True:
|
|
128
|
+
return False
|
|
129
|
+
found = facts(model_id, reported)
|
|
130
|
+
return found["role"] != "embedding" and found["kind"] != "diffusion"
|