This commit is contained in:
Timothy Jaeryang Baek committed 2026-05-09 03:45:56 +09:00
1 parent cdfcbc4af6
commit 7c398a625a
2 files changed
+17 -12

No files matched your search

+11
View File
@@ -1829,6 +1829,7 @@ async def chat_completion(
]
if user_message_id
else [],
'files': metadata.get('files') or [],
'tags': [],
'timestamp': int(time.time() * 1000),
},
@@ -1861,6 +1862,16 @@ async def chat_completion(
detail=ERROR_MESSAGES.DEFAULT(),
)
# Persist chat-level files (knowledge collections, docs, etc.)
# The old frontend saveChatHandler did this on every message;
# now the backend owns persistence.
chat_files = metadata.get('files')
if chat_files is not None:
existing_chat = await Chats.get_chat_by_id(chat_id)
if existing_chat:
updated = {**existing_chat.chat, 'files': chat_files}
await Chats.update_chat_by_id(chat_id, updated)
# Save user message to DB
user_message = metadata.get('user_message') or {}
if user_message and user_message.get('id'):