From afc68af3a67b2f936429feb3a68c1f09e03ce930 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期五, 11 四月 2025 10:07:24 +0800
Subject: [PATCH] 智能体中心不显示自研智能体
---
main.py | 33 ++++++++++-----------------------
1 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/main.py b/main.py
index baad0e8..ccaefda 100644
--- a/main.py
+++ b/main.py
@@ -1,9 +1,7 @@
from contextlib import asynccontextmanager
from apscheduler.schedulers.background import BackgroundScheduler
from fastapi import FastAPI
-from fastapi.middleware.cors import CORSMiddleware
from starlette.staticfiles import StaticFiles
-
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
@@ -17,20 +15,19 @@
from app.api.organization import dept_router
from app.api.system import system_router
from app.api.v2.chat import chat_router_v2
+from app.api.v2.mindmap import mind_map_router
from app.api.v2.public_api import public_api
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.delete_execl_file import delete_file_after_delay
-# from app.models.base_model import init_db
-from app.task.fetch_agent import sync_agents, initialize_agents, sync_agents_v2, sync_knowledge, \
+from app.task.fetch_agent import sync_agents_v2, sync_knowledge, \
sync_resources_from_json
from app.init_config.init_run_data import sync_default_data
-from app.task.sync_account_token import start_sync_token_task, sync_token
+from app.task.sync_account_token import start_sync_token_task
+from app.task.sync_system import sync_resource
init_db()
@@ -38,13 +35,8 @@
# 浣跨敤 Lifespan 浜嬩欢澶勭悊绋嬪簭
@asynccontextmanager
async def lifespan(app: FastAPI):
- # 鍒濆鍖栦唬鐞�
- # initialize_agents()
- # # 鍦ㄥ簲鐢ㄥ惎鍔ㄦ椂鍚屾浠g悊
- # sync_agents()
-
- # await sync_default_data() # Todo
+ await sync_default_data() # Todo
sync_agents_v2() # 鏅鸿兘浣�
sync_knowledge() # 鐭ヨ瘑搴�
sync_resources_from_json()
@@ -60,19 +52,13 @@
lifespan=lifespan
)
-# 璁剧疆 CORS 涓棿浠�
-# app.add_middleware(
-# CORSMiddleware,
-# allow_origins=["*"],
-# allow_credentials=True,
-# allow_methods=["*"], # 鍏佽鎵�鏈夋柟娉�
-# allow_headers=["*"], # 鍏佽鎵�鏈夊ご閮�
-# )
+
# 鍒涘缓璋冨害鍣�
scheduler = BackgroundScheduler()
scheduler.add_job(sync_agents_v2, 'interval', minutes=60, id="sync_resource_data")
scheduler.add_job(start_sync_token_task, 'interval', minutes=5, id="sync_token_1")
-# scheduler.add_job(delete_file_after_delay, 'interval', minutes=10, id="delete_file_after_delay")
+scheduler.add_job(sync_resource, 'interval', minutes=30, id="sync_resource_1")
+
scheduler.start()
app.include_router(auth_router, prefix='/api/auth', tags=["auth"])
@@ -91,9 +77,10 @@
app.include_router(dialog_router, prefix='/api/dialog', tags=["dialog"])
app.include_router(canvas_router, prefix='/api/canvas', tags=["canvas"])
app.include_router(label_router, prefix='/api/label', tags=["label"])
-app.include_router(public_api, prefix='/v1/api', tags=["public_api"])
+app.include_router(public_api, prefix='/v1', tags=["public_api"])
app.include_router(chat_router_v2, prefix='/api/v1', tags=["chat1"])
app.include_router(system_router, prefix='/api/system', tags=["system"])
+app.include_router(mind_map_router, prefix='/api/mindmap', tags=["mindmap"])
app.mount("/static", StaticFiles(directory="app/images"), name="static")
if __name__ == "__main__":
--
Gitblit v1.8.0