wrolpi/modules/ai
Roland 84883c36f6
ai: the /api/chat agent loop — SSE streaming, modes, tool execution
Tool definitions are generated in-process from the /api/ai blueprint's
own OpenAPI operations (operationId = tool name, description = tool
description, dataclass bodies + declared parameters = one flat JSON
schema) — the spec IS the catalog, nothing to drift.  Manage endpoints
never become tools.  A mode is a server-enforced system prompt + tool
allowlist (Help / Research / System per ai.md); the executor can only
reach allowlisted /api/ai endpoints, path parameters are encoded and
traversal-rejected so a crafted argument cannot escape an endpoint.

POST /api/chat streams SSE (status/token/tool_call/tool_result/done/
error), starts llama-server on demand, validates tool args server-side
with instructive errors the model can retry on, caps tool results with
a paging hint, and bounds the loop by ai.yaml max_tool_calls plus a
hard timeout.  Caddy passes the stream unbuffered (flush_interval -1)
in both deployments.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-13 20:10:16 -06:00
..
test ai: the /api/chat agent loop — SSE streaming, modes, tool execution 2026-09-13 20:10:16 -06:00
__init__.py ai: package llama-server for all three deployments, with idle unload 2026-09-13 20:10:16 -06:00
agent.py ai: the /api/chat agent loop — SSE streaming, modes, tool execution 2026-09-13 20:10:16 -06:00
api.py ai: the /api/chat agent loop — SSE streaming, modes, tool execution 2026-09-13 20:10:16 -06:00
catalog.py ai: ai.yaml config, model catalog, and the GGUF downloader 2026-09-13 20:10:15 -06:00
chat.py ai: the /api/chat agent loop — SSE streaming, modes, tool execution 2026-09-13 20:10:16 -06:00
config.py ai: ai.yaml config, model catalog, and the GGUF downloader 2026-09-13 20:10:15 -06:00
conftest.py ai: ai.yaml config, model catalog, and the GGUF downloader 2026-09-13 20:10:15 -06:00
controller_client.py ai: package llama-server for all three deployments, with idle unload 2026-09-13 20:10:16 -06:00
downloader.py ai: ai.yaml config, model catalog, and the GGUF downloader 2026-09-13 20:10:15 -06:00
errors.py ai: system endpoints — aggregate status, services, logs, disks 2026-09-13 20:10:15 -06:00
help_docs.py ai: help-docs search — Help mode tools 2026-09-13 20:10:15 -06:00
lib.py ai: add the /api/ai blueprint, the read-only LLM tool catalog 2026-09-13 20:10:15 -06:00
modes.py ai: the /api/chat agent loop — SSE streaming, modes, tool execution 2026-09-13 20:10:16 -06:00
schema.py ai: the /api/chat agent loop — SSE streaming, modes, tool execution 2026-09-13 20:10:16 -06:00
service.py ai: package llama-server for all three deployments, with idle unload 2026-09-13 20:10:16 -06:00