This commit is contained in:
2025-08-19 10:52:03 +08:00
parent f33c6ac544
commit a6b2cd8c2b

View File

@@ -21,7 +21,7 @@ logger.setLevel(logging.INFO)
# 初始化异步 OpenAI 客户端
client = AsyncOpenAI(
api_key=Config.ALY_LLM_API_KEY,
base_url=Config.ALY_LLM_MODEL_NAME,
base_url=Config.ALY_LLM_BASE_URL,
)
# 初始化 ElasticSearch 工具
@@ -29,14 +29,11 @@ search_util = EsSearchUtil(Config.ES_CONFIG)
async def lifespan(app: FastAPI):
# 抑制 HTTPS 相关警告
warnings.filterwarnings('ignore', message='Connecting to .* using TLS with verify_certs=False is insecure')
warnings.filterwarnings('ignore', message='Unverified HTTPS request is being made to host')
yield
app = FastAPI(lifespan=lifespan)
@app.post("/api/chat", dependencies=[Depends(verify_api_key)])
@app.post("/api/chat")
async def chat(request: fastapi.Request):
"""
根据用户输入的语句,通过关键字和向量两种方式查询相关信息