perf(hub-ai): reduce CPU load during trading coach chat

Cache chat context, parallelize exchange fetches, skip fund history writes, defer rolling summary to a background thread, and cache markdown rendering on the client.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-14 01:59:43 +08:00
parent 28a23008f3
commit 467d160f4d
5 changed files with 148 additions and 39 deletions
+3 -1
View File
@@ -1,6 +1,7 @@
"""中控 AI FastAPI 路由。"""
from __future__ import annotations
import asyncio
from typing import Callable
from fastapi import APIRouter, Body, File, Form, HTTPException, UploadFile
@@ -153,7 +154,8 @@ def create_hub_ai_router(*, load_all_exchanges: Callable[[], list]) -> APIRouter
"data": data,
}
)
result = send_chat_message(
result = await asyncio.to_thread(
send_chat_message,
exchanges,
message,
trading_day=_day(trading_day) if trading_day.strip() else None,