重构代码,统一config配置
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 47m14s

This commit is contained in:
2026-04-21 11:02:16 +08:00
parent 726236eaff
commit 8b354b7ccc
50 changed files with 4025 additions and 6 deletions

View File

@@ -0,0 +1,27 @@
# rag_core/client.py
import os
from .config import QDRANT_URL, QDRANT_API_KEY
from typing import Optional
from qdrant_client import QdrantClient
def create_qdrant_client(
url: Optional[str] = None,
api_key: Optional[str] = None,
timeout: int = 300, # 索引构建需要较长超时
) -> QdrantClient:
effective_url = url or QDRANT_URL
effective_api_key = api_key or QDRANT_API_KEY
if not effective_url:
raise ValueError("Qdrant URL 未配置")
client_kwargs = {
"url": effective_url,
"timeout": timeout,
}
if effective_api_key:
client_kwargs["api_key"] = effective_api_key
return QdrantClient(**client_kwargs)