feat: local LLM multi-model, session search, cron proactive types, notifications, docs overhaul
Local LLM:
- user_settings.py: per-user hosts/models config (local_llm.json)
- routers/local_llm.py + static/local_llm.html: dedicated settings page
- llm_client.py: local OpenAI-compatible backend via httpx
- config.py: LOCAL_API_URL/KEY/MODEL + per-backend timeouts
- Active model shown near backend toggle (amber hint text)
Memory distillation:
- memory_distiller.py: DISTILL_BACKEND_MID/LONG .env overrides
- scheduler.py + notification.py: notify NC Talk after mid/long distill
- notification.py: outbound channel abstraction (NC Talk, extensible)
Session search:
- routers/files.py: GET /sessions/search?q= with excerpts grouped by date
- static/index.html + app.js: search UI in file sidebar with highlight
- _esc() helper to prevent XSS in search results
Proactive cron:
- cron_runner.py: new job types — message (send directly) and brief (LLM + send)
- Both support optional per-job channel override
Channels:
- routers/nextcloud_talk.py: consolidated using notification._send_nct_message()
- routers/auth.py: local backend status in /auth/status
- routers/chat.py: /backend returns {primary, fallback, local_model} object
UI / UX:
- Copy button for user messages (matching assistant)
- Autocomplete disabled on sensitive form fields
- settings.html: local model section replaced with link to /settings/local
Docs overhaul:
- MASTER.md hub + ARCH__SYSTEM/BACKENDS/PERSONA/CHANNELS/FUTURE.md
- ARCH__Intelligence_Layer.md replaced with redirect table
- CORTEX.md trimmed to vision only; README updated
- OPEN_WEBUI_API.md added to docs/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -77,15 +77,22 @@ def distill_short(username: str | None = None, persona: str | None = None) -> di
|
||||
async def distill_mid(username: str | None = None, persona: str | None = None) -> dict:
|
||||
"""
|
||||
Ask the LLM to summarize MEMORY_SHORT.md → MEMORY_MID.md.
|
||||
Uses DISTILL_BACKEND_MID if set (e.g. "local"), otherwise primary_backend.
|
||||
"""
|
||||
from llm_client import complete
|
||||
from persona import set_context
|
||||
|
||||
inara_dir = _persona_path(username, persona)
|
||||
u = username or settings.user_name.lower()
|
||||
p = persona or settings.agent_name.lower()
|
||||
set_context(u, p)
|
||||
|
||||
inara_dir = _persona_path(u, p)
|
||||
short_content = _read(inara_dir / "MEMORY_SHORT.md")
|
||||
|
||||
if not short_content.strip() or "Not yet populated" in short_content:
|
||||
return {"error": "MEMORY_SHORT.md is empty — run distill/short first"}
|
||||
|
||||
backend_override = settings.distill_backend_mid or None
|
||||
budget_tokens = settings.memory_budget_mid
|
||||
system_prompt = (
|
||||
f"You are {settings.agent_name}'s memory distillation system. "
|
||||
@@ -100,6 +107,7 @@ async def distill_mid(username: str | None = None, persona: str | None = None) -
|
||||
response_text, backend = await complete(
|
||||
system_prompt=system_prompt,
|
||||
messages=[{"role": "user", "content": short_content}],
|
||||
model=backend_override,
|
||||
)
|
||||
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M")
|
||||
@@ -112,6 +120,7 @@ async def distill_mid(username: str | None = None, persona: str | None = None) -
|
||||
logger.info("distill_mid: wrote %d chars via %s", len(header) + len(response_text), backend)
|
||||
|
||||
return {
|
||||
"username": u,
|
||||
"backend": backend,
|
||||
"chars_written": len(header) + len(response_text),
|
||||
"budget_tokens": budget_tokens,
|
||||
@@ -121,16 +130,23 @@ async def distill_mid(username: str | None = None, persona: str | None = None) -
|
||||
async def distill_long(username: str | None = None, persona: str | None = None) -> dict:
|
||||
"""
|
||||
Ask the LLM to integrate MEMORY_MID.md into MEMORY_LONG.md.
|
||||
Uses DISTILL_BACKEND_LONG if set, otherwise primary_backend.
|
||||
"""
|
||||
from llm_client import complete
|
||||
from persona import set_context
|
||||
|
||||
inara_dir = _persona_path(username, persona)
|
||||
u = username or settings.user_name.lower()
|
||||
p = persona or settings.agent_name.lower()
|
||||
set_context(u, p)
|
||||
|
||||
inara_dir = _persona_path(u, p)
|
||||
long_content = _read(inara_dir / "MEMORY_LONG.md")
|
||||
mid_content = _read(inara_dir / "MEMORY_MID.md")
|
||||
|
||||
if not mid_content.strip() or "Not yet populated" in mid_content:
|
||||
return {"error": "MEMORY_MID.md is empty — run distill/mid first"}
|
||||
|
||||
backend_override = settings.distill_backend_long or None
|
||||
budget_tokens = settings.memory_budget_long
|
||||
system_prompt = (
|
||||
f"You are {settings.agent_name}'s long-term memory curator. "
|
||||
@@ -149,6 +165,7 @@ async def distill_long(username: str | None = None, persona: str | None = None)
|
||||
response_text, backend = await complete(
|
||||
system_prompt=system_prompt,
|
||||
messages=[{"role": "user", "content": user_content}],
|
||||
model=backend_override,
|
||||
)
|
||||
|
||||
# Ensure the file has the right header if the LLM dropped it
|
||||
@@ -165,6 +182,7 @@ async def distill_long(username: str | None = None, persona: str | None = None)
|
||||
logger.info("distill_long: wrote %d chars via %s", len(response_text), backend)
|
||||
|
||||
return {
|
||||
"username": u,
|
||||
"backend": backend,
|
||||
"chars_written": len(response_text),
|
||||
"budget_tokens": budget_tokens,
|
||||
|
||||
Reference in New Issue
Block a user