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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user