feat(hub): enrich AI coach with fund history, closed trades, and chat uploads
- Add 15-day fund snapshot store and /api/hub/account on all instances - Summary includes yesterday/today trades, fund columns, and section 5 操作建议 - Chat context distinguishes empty positions from local monitors - Support image/document attachments in AI chat Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -163,7 +163,13 @@ def ensure_active_session(*, trading_day: str) -> dict:
|
||||
return create_new_session(trading_day=trading_day)
|
||||
|
||||
|
||||
def append_chat_message(session_id: str, role: str, content: str) -> dict:
|
||||
def append_chat_message(
|
||||
session_id: str,
|
||||
role: str,
|
||||
content: str,
|
||||
*,
|
||||
attachments: Optional[list] = None,
|
||||
) -> dict:
|
||||
store = load_chat_store()
|
||||
sessions = store.get("sessions") or []
|
||||
target = None
|
||||
@@ -174,6 +180,8 @@ def append_chat_message(session_id: str, role: str, content: str) -> dict:
|
||||
if not target:
|
||||
raise KeyError("session_not_found")
|
||||
msg = {"role": role, "content": content.strip(), "at": _now_str()}
|
||||
if attachments:
|
||||
msg["attachments"] = list(attachments)
|
||||
target.setdefault("messages", []).append(msg)
|
||||
target["updated_at"] = _now_str()
|
||||
if role == "user" and (target.get("title") in (None, "", "新对话")):
|
||||
|
||||
Reference in New Issue
Block a user