From 2d0c7b15898e16ab4bdc22bd95c23b13e3455c0a Mon Sep 17 00:00:00 2001
From: xuyonghao <898441624@qq.com>
Date: 星期三, 25 十二月 2024 14:24:12 +0800
Subject: [PATCH] 合并webSocket修改

---
 app/task/fetch_agent.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/task/fetch_agent.py b/app/task/fetch_agent.py
index 303d8f6..00d2cc6 100644
--- a/app/task/fetch_agent.py
+++ b/app/task/fetch_agent.py
@@ -228,9 +228,9 @@
     try:
         if names:
             query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id) \
-                .filter( Dialog.name.in_(names))
+                .filter( Dialog.name.in_(names), Dialog.status == "1")
         else:
-            query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id)
+            query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id).filter( Dialog.status == "1")
 
         results = query.all()
         formatted_results = [
@@ -271,7 +271,7 @@
             if existing_agent:
                 existing_agent.name = row["name"]
                 existing_agent.description = row["description"]
-                existing_agent.status = row["status"]
+                # existing_agent.status = row["status"]
                 existing_agent.mode = row["mode"]
                 # existing_agent.tenant_id = get_rag_user_id(db, row["user_id"], type_dict[dialog_type])
             else:
@@ -324,6 +324,8 @@
         print("v2 Agents synchronized successfully")
     except Exception as e:
         print(f"v2 Failed to sync agents: {str(e)}")
+    finally:
+        db.close()
 
 def update_ids_in_local_knowledge(data, klg_type):
     type_dict = {"1": RAGFLOW, "2": BISHENG, "4": DIFY}
@@ -386,6 +388,8 @@
         print("sync knowledge successfully")
     except Exception as e:
         print(f"Failed to sync knowledge: {str(e)}")
+    finally:
+        db.close()
 
 
 if __name__ == "__main__":

--
Gitblit v1.8.0