From df14f81b4d34b7aea88bb5e72cbdaba70f7d728f Mon Sep 17 00:00:00 2001
From: xuyonghao <898441624@qq.com>
Date: 星期三, 08 一月 2025 18:37:43 +0800
Subject: [PATCH] excel触发文件下载
---
main.py | 59 +++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/main.py b/main.py
index 2af3a01..9639f36 100644
--- a/main.py
+++ b/main.py
@@ -1,7 +1,8 @@
from contextlib import asynccontextmanager
-# from apscheduler.schedulers.background import BackgroundScheduler
+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
@@ -11,30 +12,44 @@
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.label import label_router
+from app.api.llm import llm_router
from app.api.organization import dept_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.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
+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, \
+ sync_resources_from_json
+from app.init_config.init_run_data import sync_default_data
+
+init_db()
# 浣跨敤 Lifespan 浜嬩欢澶勭悊绋嬪簭
@asynccontextmanager
async def lifespan(app: FastAPI):
# 鍒濆鍖栦唬鐞�
- initialize_agents()
- # 鍦ㄥ簲鐢ㄥ惎鍔ㄦ椂鍚屾浠g悊
- sync_agents()
+ # initialize_agents()
+ # # 鍦ㄥ簲鐢ㄥ惎鍔ㄦ椂鍚屾浠g悊
+ # sync_agents()
+
+
+ await sync_default_data()
+ sync_agents_v2()
+ sync_knowledge()
+ sync_resources_from_json()
yield
# 鍦ㄥ簲鐢ㄥ叧闂椂鎵ц娓呯悊鎿嶄綔锛堝鏋滈渶瑕侊級
pass
-init_db()
+
app = FastAPI(
title="basic_rag_gateway",
version="0.1",
@@ -43,18 +58,18 @@
)
# 璁剧疆 CORS 涓棿浠�
-app.add_middleware(
- CORSMiddleware,
- allow_origins=["*"], # 鍏佽鎵�鏈夊煙鍚嶈法鍩熻闂�
- allow_credentials=True,
- allow_methods=["*"], # 鍏佽鎵�鏈夋柟娉�
- allow_headers=["*"], # 鍏佽鎵�鏈夊ご閮�
-)
+# app.add_middleware(
+# CORSMiddleware,
+# allow_origins=["http://192.168.20.119:9303", "http://192.168.20.119:9301", "http://smartai.com:8293","http://localhost:9303", "http://127.0.0.1:9303","http://localhost:5173","http://192.168.20.158:5173"],
+# allow_credentials=True,
+# allow_methods=["*"], # 鍏佽鎵�鏈夋柟娉�
+# allow_headers=["*"], # 鍏佽鎵�鏈夊ご閮�
+# )
# 鍒涘缓璋冨害鍣�
-# scheduler = BackgroundScheduler()
-# scheduler.add_job(sync_resource, 'interval', minutes=1, id="sync_resource_data")
-# scheduler.start()
-
+scheduler = BackgroundScheduler()
+scheduler.add_job(sync_agents_v2, 'interval', minutes=60, id="sync_resource_data")
+# scheduler.add_job(delete_file_after_delay, 'interval', minutes=10, id="delete_file_after_delay")
+scheduler.start()
app.include_router(auth_router, prefix='/api/auth', tags=["auth"])
app.include_router(chat_router, prefix='/api/chat', tags=["chat"])
@@ -68,10 +83,14 @@
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(llm_router, prefix='/api/llm', tags=["llm"])
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"])
+app.include_router(label_router, prefix='/api/label', tags=["label"])
+app.include_router(public_api, prefix='/v1/api', tags=["public_api"])
+app.mount("/static", StaticFiles(directory="app/images"), name="static")
if __name__ == "__main__":
import uvicorn
+
uvicorn.run(app, host="0.0.0.0", port=9201)
--
Gitblit v1.8.0