feat(hub): add AI coach page with daily summary and chat

Aggregate four-account trades via hub_ai module and /api/hub/trades/today; store sessions in JSON; default OpenAI config matches instances.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-06 23:51:36 +08:00
parent 4fad5696df
commit cee641ba5d
23 changed files with 1557 additions and 14 deletions
+12 -1
View File
@@ -77,7 +77,7 @@ _allow_pub_raw = (os.getenv("HUB_ALLOW_PUBLIC") or "").strip().lower()
# 云服务器 + 域名反代时设为 true:不做 IP 限制,仅靠 HUB_PASSWORD / 登录页保护
HUB_ALLOW_PUBLIC = _allow_pub_raw in ("1", "true", "yes", "on")
DIR = Path(__file__).resolve().parent
HUB_BUILD = "20260603-hub-board-sse"
HUB_BUILD = "20260606-hub-ai"
HUB_AGENT_TIMEOUT = float(os.getenv("HUB_AGENT_TIMEOUT", "8"))
HUB_FLASK_TIMEOUT = float(os.getenv("HUB_FLASK_TIMEOUT", "10"))
HUB_BOARD_TIMEOUT = float(os.getenv("HUB_BOARD_TIMEOUT", "45"))
@@ -362,11 +362,22 @@ def root_redirect():
@app.get("/monitor")
@app.get("/market")
@app.get("/ai")
@app.get("/settings")
def shell_pages():
return _shell_page()
def _all_exchanges_for_ai() -> list:
"""AI 聚合用:含未启用账户(标记未监控)。"""
return list(load_settings().get("exchanges") or [])
from hub_ai.routes import create_hub_ai_router
app.include_router(create_hub_ai_router(load_all_exchanges=_all_exchanges_for_ai))
@app.get("/trade")
def trade_removed_redirect():
from fastapi.responses import RedirectResponse