From bd570b7e2ea6c6a964370b9626a69b198ce3e2d1 Mon Sep 17 00:00:00 2001 From: silentoplayz Date: Mon, 4 Aug 2025 16:52:45 -0400 Subject: [PATCH 1/2] fix: chat metadata wasn't being taken into consideration when cloning a chat fix: chat metadata wasn't being taken into consideration when cloning a chat --- backend/open_webui/routers/chats.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index 628f9176b8..bd7044bee4 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -617,7 +617,18 @@ async def clone_chat_by_id( "title": form_data.title if form_data.title else f"Clone of {chat.title}", } - chat = Chats.insert_new_chat(user.id, ChatForm(**{"chat": updated_chat})) + chat = Chats.import_chat( + user.id, + ChatImportForm( + **{ + "chat": updated_chat, + "meta": chat.meta, + "pinned": chat.pinned, + "folder_id": chat.folder_id, + } + ), + ) + return ChatResponse(**chat.model_dump()) else: raise HTTPException( From 7c4550fa9229a81cb49f646e1641c66ef2ff750e Mon Sep 17 00:00:00 2001 From: silentoplayz Date: Tue, 5 Aug 2025 16:21:03 -0400 Subject: [PATCH 2/2] fix: cloned chat metadata not taken into consideration --- backend/open_webui/models/chats.py | 7 ++++++- backend/open_webui/routers/chats.py | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index b9de2e5a4e..47b559f504 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -296,6 +296,9 @@ class ChatTable: "user_id": f"shared-{chat_id}", "title": chat.title, "chat": chat.chat, + "meta": chat.meta, + "pinned": chat.pinned, + "folder_id": chat.folder_id, "created_at": chat.created_at, "updated_at": int(time.time()), } @@ -327,7 +330,9 @@ class ChatTable: shared_chat.title = chat.title shared_chat.chat = chat.chat - + shared_chat.meta = chat.meta + shared_chat.pinned = chat.pinned + shared_chat.folder_id = chat.folder_id shared_chat.updated_at = int(time.time()) db.commit() db.refresh(shared_chat) diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index bd7044bee4..ba16b506f7 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -657,7 +657,17 @@ async def clone_shared_chat_by_id(id: str, user=Depends(get_verified_user)): "title": f"Clone of {chat.title}", } - chat = Chats.insert_new_chat(user.id, ChatForm(**{"chat": updated_chat})) + chat = Chats.import_chat( + user.id, + ChatImportForm( + **{ + "chat": updated_chat, + "meta": chat.meta, + "pinned": chat.pinned, + "folder_id": chat.folder_id, + } + ), + ) return ChatResponse(**chat.model_dump()) else: raise HTTPException(