feat(llm): direct Claude Haiku 4.5 backend with prompt caching
Adds a parallel LLM backend that bypasses OpenClaw and talks to Anthropic Messages API directly. Selected via LLM_BACKEND=claude in .env; default remains openclaw so nothing breaks for existing setup. Why: OpenClaw gateway adds 500-1000ms overhead on every turn (auth, memory fetch, routing). Direct Haiku 4.5 + prompt caching = faster first token and -90% cost on cached chunks. - satellite/llm_claude.py — Anthropic SDK streaming client, prompt caching on system prompt and all-but-last-2 history messages, per agent+date JSON history in HISTORY_DIR, reset_history() for the 'сбрось' command, per-agent system prompts (Cosmo / Люся), fallback to error event if SDK/key missing. - satellite/llm.py — dispatches to ask_claude_stream when backend=claude, exports LLM_BACKEND so modes.py can route reset too. - satellite/modes.py — _handle_reset calls reset_history when backend is claude, keeps /new POST for openclaw. - requirements.txt — anthropic >= 0.50.0 - .env.example — LLM_BACKEND, ANTHROPIC_API_KEY, ANTHROPIC_MODEL, HISTORY_DIR, MAX_HISTORY, HTTPS_PROXY block for non-RU egress. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
19
.env.example
19
.env.example
@@ -59,3 +59,22 @@ VOICE_API_KEY=your_voice_api_key_here
|
||||
# голос ассистента проигрывается на планшете через ElevenLabs proxy,
|
||||
# локальный mpv/speak пропускается. false = говорим локально как раньше.
|
||||
TABLET_TTS_ENABLED=true
|
||||
|
||||
# ——————————————————————————————————————————————
|
||||
# LLM backend
|
||||
# openclaw (дефолт) — существующий путь через gateway с памятью на сервере
|
||||
# claude — прямой вызов Anthropic Haiku 4.5 с локальной историей
|
||||
# и prompt caching (быстрее + дешевле, но без tools)
|
||||
LLM_BACKEND=openclaw
|
||||
|
||||
# Для LLM_BACKEND=claude:
|
||||
ANTHROPIC_API_KEY=your_anthropic_key_here
|
||||
ANTHROPIC_MODEL=claude-haiku-4-5
|
||||
HISTORY_DIR=data/history # куда сохранять JSON истории per-agent per-date
|
||||
MAX_HISTORY=40 # лимит сообщений в истории
|
||||
|
||||
# Egress proxy для non-RU сервисов (Anthropic, Groq, OpenAI).
|
||||
# httpx и requests подхватывают автоматически. Пусто = прямой выход.
|
||||
HTTPS_PROXY=http://192.168.31.103:8888
|
||||
HTTP_PROXY=http://192.168.31.103:8888
|
||||
NO_PROXY=localhost,127.0.0.1,192.168.31.0/24
|
||||
|
||||
Reference in New Issue
Block a user