Новые модули: - 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>
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
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
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Ensure src/ is on path
|
|
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 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 Railway")
|
|
|
|
# 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")
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8102)
|