From 87524b8bf9fc48cf7992cb06eac95306eeee2540 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期五, 22 十一月 2024 11:38:36 +0800
Subject: [PATCH] 自研智能体会话列表排序

---
 main.py |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/main.py b/main.py
index 5826d6f..2af3a01 100644
--- a/main.py
+++ b/main.py
@@ -1,18 +1,26 @@
 from contextlib import asynccontextmanager
+# from apscheduler.schedulers.background import BackgroundScheduler
 from fastapi import FastAPI
+from fastapi.middleware.cors import CORSMiddleware
 
-from app.Log import init_log
 from app.api.auth import router as auth_router
+from app.api.canvas import canvas_router
 from app.api.chat import router as chat_router
 from app.api.agent import router as agent_router
+from app.api.dialog import dialog_router
 from app.api.excel import router as excel_router
 from app.api.files import router as files_router
+from app.api.knowledge import knowledge_router
+from app.api.organization import dept_router
 from app.api.report import router as report_router
+from app.api.resource import menu_router
+from app.api.sync_data import sync_router
 from app.api.user import user_router
 from app.api.group import group_router
 from app.api.role import role_router
 from app.models.base_model import init_db
 from app.task.fetch_agent import sync_agents, initialize_agents
+from app.task.sync_resources import sync_resource
 
 
 # 浣跨敤 Lifespan 浜嬩欢澶勭悊绋嬪簭
@@ -34,6 +42,19 @@
     lifespan=lifespan
 )
 
+# 璁剧疆 CORS 涓棿浠�
+app.add_middleware(
+    CORSMiddleware,
+    allow_origins=["*"],  # 鍏佽鎵�鏈夊煙鍚嶈法鍩熻闂�
+    allow_credentials=True,
+    allow_methods=["*"],  # 鍏佽鎵�鏈夋柟娉�
+    allow_headers=["*"],  # 鍏佽鎵�鏈夊ご閮�
+)
+# 鍒涘缓璋冨害鍣�
+# scheduler = BackgroundScheduler()
+# scheduler.add_job(sync_resource, 'interval', minutes=1, id="sync_resource_data")
+# scheduler.start()
+
 
 app.include_router(auth_router, prefix='/api/auth', tags=["auth"])
 app.include_router(chat_router, prefix='/api/chat', tags=["chat"])
@@ -44,6 +65,12 @@
 app.include_router(user_router, prefix='/api/user', tags=["user"])
 app.include_router(group_router, prefix='/api/group', tags=["group"])
 app.include_router(role_router, prefix='/api/role', tags=["role"])
+app.include_router(dept_router, prefix='/api/dept', tags=["dept"])
+app.include_router(menu_router, prefix='/api/menu', tags=["menu"])
+app.include_router(knowledge_router, prefix='/api/knowledge', tags=["knowledge"])
+app.include_router(dialog_router, prefix='/api/dialog', tags=["dialog"])
+app.include_router(canvas_router, prefix='/api/canvas', tags=["canvas"])
+app.include_router(sync_router, prefix='/api/sync', tags=["sync"])
 
 if __name__ == "__main__":
     import uvicorn

--
Gitblit v1.8.0