diff --git a/backend/apps/webui/models/auths.py b/backend/apps/webui/models/auths.py index 7698359f9..9f6bd59e8 100644 --- a/backend/apps/webui/models/auths.py +++ b/backend/apps/webui/models/auths.py @@ -195,6 +195,7 @@ class AuthsTable: if result: db.query(Auth).filter_by(id=id).delete() + db.commit() return True else: diff --git a/backend/apps/webui/models/chats.py b/backend/apps/webui/models/chats.py index 8d2e6b104..ae63999a2 100644 --- a/backend/apps/webui/models/chats.py +++ b/backend/apps/webui/models/chats.py @@ -171,6 +171,8 @@ class ChatTable: with get_db() as db: db.query(Chat).filter_by(user_id=f"shared-{chat_id}").delete() + db.commit() + return True except: return False @@ -323,6 +325,7 @@ class ChatTable: with get_db() as db: db.query(Chat).filter_by(id=id).delete() + db.commit() return True and self.delete_shared_chat_by_chat_id(id) except: @@ -333,6 +336,7 @@ class ChatTable: with get_db() as db: db.query(Chat).filter_by(id=id, user_id=user_id).delete() + db.commit() return True and self.delete_shared_chat_by_chat_id(id) except: @@ -346,6 +350,8 @@ class ChatTable: self.delete_shared_chats_by_user_id(user_id) db.query(Chat).filter_by(user_id=user_id).delete() + db.commit() + return True except: return False @@ -359,6 +365,7 @@ class ChatTable: shared_chat_ids = [f"shared-{chat.id}" for chat in chats_by_user] db.query(Chat).filter(Chat.user_id.in_(shared_chat_ids)).delete() + db.commit() return True except: diff --git a/backend/apps/webui/models/files.py b/backend/apps/webui/models/files.py index 58058e907..16272f24a 100644 --- a/backend/apps/webui/models/files.py +++ b/backend/apps/webui/models/files.py @@ -104,6 +104,8 @@ class FilesTable: try: db.query(File).filter_by(id=id).delete() + db.commit() + return True except: return False @@ -114,6 +116,8 @@ class FilesTable: try: db.query(File).delete() + db.commit() + return True except: return False diff --git a/backend/apps/webui/models/functions.py b/backend/apps/webui/models/functions.py index cdc1bd334..907576b80 100644 --- a/backend/apps/webui/models/functions.py +++ b/backend/apps/webui/models/functions.py @@ -267,9 +267,10 @@ class FunctionsTable: def delete_function_by_id(self, id: str) -> bool: with get_db() as db: - try: db.query(Function).filter_by(id=id).delete() + db.commit() + return True except: return False diff --git a/backend/apps/webui/models/memories.py b/backend/apps/webui/models/memories.py index 662bbedfe..02d4b6924 100644 --- a/backend/apps/webui/models/memories.py +++ b/backend/apps/webui/models/memories.py @@ -115,6 +115,8 @@ class MemoriesTable: try: db.query(Memory).filter_by(id=id).delete() + db.commit() + return True except: @@ -125,6 +127,8 @@ class MemoriesTable: try: db.query(Memory).filter_by(user_id=user_id).delete() + db.commit() + return True except: return False @@ -134,6 +138,8 @@ class MemoriesTable: try: db.query(Memory).filter_by(id=id, user_id=user_id).delete() + db.commit() + return True except: return False diff --git a/backend/apps/webui/models/models.py b/backend/apps/webui/models/models.py index c95c36c7d..0aeac3e24 100644 --- a/backend/apps/webui/models/models.py +++ b/backend/apps/webui/models/models.py @@ -176,6 +176,8 @@ class ModelsTable: with get_db() as db: db.query(Model).filter_by(id=id).delete() + db.commit() + return True except: return False diff --git a/backend/apps/webui/models/prompts.py b/backend/apps/webui/models/prompts.py index 2af2ce22c..b8467b631 100644 --- a/backend/apps/webui/models/prompts.py +++ b/backend/apps/webui/models/prompts.py @@ -109,6 +109,8 @@ class PromptsTable: with get_db() as db: db.query(Prompt).filter_by(command=command).delete() + db.commit() + return True except: return False diff --git a/backend/apps/webui/models/tags.py b/backend/apps/webui/models/tags.py index bbbc95ed2..bb98d3a38 100644 --- a/backend/apps/webui/models/tags.py +++ b/backend/apps/webui/models/tags.py @@ -225,6 +225,7 @@ class TagTable: if tag_count == 0: # Remove tag item from Tag col as well db.query(Tag).filter_by(name=tag_name, user_id=user_id).delete() + db.commit() return True except Exception as e: log.error(f"delete_tag: {e}") @@ -250,6 +251,7 @@ class TagTable: if tag_count == 0: # Remove tag item from Tag col as well db.query(Tag).filter_by(name=tag_name, user_id=user_id).delete() + db.commit() return True except Exception as e: diff --git a/backend/apps/webui/models/tools.py b/backend/apps/webui/models/tools.py index b3964a9b8..a6fbe120f 100644 --- a/backend/apps/webui/models/tools.py +++ b/backend/apps/webui/models/tools.py @@ -201,6 +201,8 @@ class ToolsTable: try: with get_db() as db: db.query(Tool).filter_by(id=id).delete() + db.commit() + return True except: return False diff --git a/backend/apps/webui/routers/functions.py b/backend/apps/webui/routers/functions.py index f01133a35..eb5216b20 100644 --- a/backend/apps/webui/routers/functions.py +++ b/backend/apps/webui/routers/functions.py @@ -233,7 +233,10 @@ async def delete_function_by_id( # delete the function file function_path = os.path.join(FUNCTIONS_DIR, f"{id}.py") - os.remove(function_path) + try: + os.remove(function_path) + except: + pass return result