From 1a5ff2f926ab0334749c3ebc6fd3cbc1865363e1 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 30 十月 2024 20:19:15 +0800
Subject: [PATCH] 配置ip取环境变量的
---
main.py | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/main.py b/main.py
index d5a8c5d..e629cbf 100644
--- a/main.py
+++ b/main.py
@@ -1,19 +1,41 @@
+from contextlib import asynccontextmanager
+
from fastapi import FastAPI
from app.api.auth import router as auth_router
from app.api.chat import router as chat_router
from app.api.agent import router as agent_router
+from app.api.excel import router as excel_router
+from app.api.files import router as files_router
+from app.api.report import router as report_router
from app.models.base_model import init_db
+from app.task.fetch_agent import sync_agents, initialize_agents
+
+
+# 浣跨敤 Lifespan 浜嬩欢澶勭悊绋嬪簭
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+ # 鍒濆鍖栦唬鐞�
+ initialize_agents()
+ # 鍦ㄥ簲鐢ㄥ惎鍔ㄦ椂鍚屾浠g悊
+ sync_agents()
+ yield
+ # 鍦ㄥ簲鐢ㄥ叧闂椂鎵ц娓呯悊鎿嶄綔锛堝鏋滈渶瑕侊級
+ pass
init_db()
app = FastAPI(
- title="basic_rag_gateway",
- version="0.1",
- description="",
+ title="basic_rag_gateway",
+ version="0.1",
+ description="",
+ lifespan=lifespan
)
-app.include_router(auth_router, prefix='/auth', tags=["auth"])
-app.include_router(chat_router, prefix='/chat', tags=["chat"])
-app.include_router(agent_router, prefix='/agent', tags=["agent"])
+app.include_router(auth_router, prefix='/api/auth', tags=["auth"])
+app.include_router(chat_router, prefix='/api/chat', tags=["chat"])
+app.include_router(agent_router, prefix='/api/agent', tags=["agent"])
+app.include_router(excel_router, prefix='/api/document', tags=["document"])
+app.include_router(files_router, prefix='/api/files', tags=["files"])
+app.include_router(report_router, prefix='/api/report', tags=["report"])
if __name__ == "__main__":
import uvicorn
--
Gitblit v1.8.0