We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1e9eac4 commit 31111a6Copy full SHA for 31111a6
1 file changed
backend/open_webui/main.py
@@ -1891,6 +1891,13 @@ async def chat_completion(
1891
# Save user message to DB
1892
user_message = metadata.get('user_message') or {}
1893
if user_message and user_message.get('id'):
1894
+ # Guard: infer parentId from chat's currentId when frontend sends null
1895
+ if not user_message.get('parentId'):
1896
+ _existing = locals().get('existing_chat') or await Chats.get_chat_by_id(chat_id)
1897
+ _current_id = (_existing.chat or {}).get('history', {}).get('currentId') if _existing else None
1898
+ if _current_id and _current_id != user_message['id']:
1899
+ user_message['parentId'] = _current_id
1900
+
1901
await Chats.upsert_message_to_chat_by_id_and_message_id(
1902
chat_id,
1903
user_message['id'],
0 commit comments