feat: двойной бэкенд — Claude Code + GLM (переключаемый)

- AI_BACKEND=claude|glm в .env для переключения
- claude_bridge_glm.py: GLM-5 + CAG context (НР/СП/коэффициенты в промпте)
  + text search по resources.json для расценок
  + streaming SSE, история диалогов
- main.py: динамический импорт бэкенда по AI_BACKEND
- GLM-бэкенд не требует Docker/sandbox — чистый Python
- Нужен действующий ZAI_API_KEY (текущий — закончился баланс)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-24 21:23:42 +10:00
co-authored by Claude Opus 4.6
parent c4d45b94f9
commit a623ae7794
2 changed files with 223 additions and 8 deletions
+15 -8
View File
@@ -1,4 +1,4 @@
"""smeta-web: AI assistant for estimators — FastAPI + Claude Code."""
"""smeta-web: AI assistant for estimators — FastAPI + Claude Code or GLM-5."""
import os
import shutil
@@ -9,15 +9,22 @@ from fastapi.responses import FileResponse, HTMLResponse, StreamingResponse
from fastapi.staticfiles import StaticFiles
from auth import authenticate, verify_token
from claude_bridge import (
clear_session,
get_work_dir,
is_allowed_file,
list_user_files,
stream_claude,
)
from db import get_history, init_db, list_sessions, save_message
# Backend selection: "claude" (Docker sandbox) or "glm" (GLM-5 + CAG/RAG)
AI_BACKEND = os.environ.get("AI_BACKEND", "claude")
if AI_BACKEND == "glm":
from claude_bridge_glm import (
clear_session, get_work_dir, is_allowed_file,
list_user_files, stream_claude,
)
else:
from claude_bridge import (
clear_session, get_work_dir, is_allowed_file,
list_user_files, stream_claude,
)
app = FastAPI(title="smeta-web")
app.mount("/static", StaticFiles(directory="static"), name="static")