fix: harden image handling and update docs
This commit is contained in:
@@ -18,7 +18,16 @@ class DataRepository:
|
||||
|
||||
# --- 聊天记录 (异步化) ---
|
||||
|
||||
async def save_chat(self, platform: str, user_id: str, content: str, direction: str, acc_id: str = "", image_urls: list = None):
|
||||
async def save_chat(
|
||||
self,
|
||||
platform: str,
|
||||
user_id: str,
|
||||
content: str,
|
||||
direction: str,
|
||||
acc_id: str = "",
|
||||
image_urls: list = None,
|
||||
msg_type: int = 0,
|
||||
):
|
||||
"""异步持久化存储聊天记录"""
|
||||
# 将图片URL列表转为\n分隔的字符串
|
||||
urls_str = "\n".join(image_urls) if image_urls else ""
|
||||
@@ -29,6 +38,7 @@ class DataRepository:
|
||||
direction=direction,
|
||||
platform=platform,
|
||||
acc_id=acc_id,
|
||||
msg_type=msg_type,
|
||||
image_urls=urls_str
|
||||
)
|
||||
|
||||
@@ -42,6 +52,8 @@ class DataRepository:
|
||||
{
|
||||
"role": role,
|
||||
"content": r["message"],
|
||||
"msg_type": r.get("msg_type", 0),
|
||||
"image_urls": r.get("image_urls", ""),
|
||||
"timestamp": r.get("timestamp", ""),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user