feat: web API модули + структурированные ошибки + few-shot промпты

Новые модули:
- errors.py — классификация ошибок (transient/validation/business)
- web/chat_api.py — поиск ГЭСН, НР/СП lookup
- web/generator_api.py — 3-шаговая генерация сметы
- .claude/rules/ — конвенции для calc/ai/output/web

Улучшения:
- generator.py: few-shot примеры, retry при невалидном JSON, предусловия
- bot.py: структурированные ошибки вместо голых Exception
- wizard_api.py: структурированные ошибки в HTTP-ответах

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-31 07:23:00 +10:00
co-authored by Claude Opus 4.6
parent 35e04a2f0c
commit f7b9400163
11 changed files with 453 additions and 35 deletions
+18 -6
View File
@@ -1,10 +1,16 @@
#!/usr/bin/env python3
"""
Wizard-aggregator web server.
Smeta Railway — unified web server.
Serves:
- /api/wizard/* — xlsx aggregation wizard
- /api/chat/* — GESN search, questions, NR/SP lookup
- /api/gen/* — estimate generation pipeline
- /* — static files (index.html with tabs)
Usage:
python scripts/wizard_server.py
# Open http://localhost:8102/wizard.html
# Open http://localhost:8102
"""
import sys
@@ -16,12 +22,18 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from smeta_railway.web.wizard_api import router
from smeta_railway.web.wizard_api import router as wizard_router
from smeta_railway.web.chat_api import router as chat_router
from smeta_railway.web.generator_api import router as gen_router
app = FastAPI(title="Smeta Wizard Aggregator")
app.include_router(router, prefix="/api/wizard")
app = FastAPI(title="Smeta Railway")
# Serve static files (wizard.html)
# API routers
app.include_router(wizard_router, prefix="/api/wizard")
app.include_router(chat_router, prefix="/api/chat")
app.include_router(gen_router, prefix="/api/gen")
# Serve static files (index.html, wizard.html)
static_dir = Path(__file__).resolve().parent.parent / "static"
app.mount("/", StaticFiles(directory=str(static_dir), html=True), name="static")