refactor: 统一导入方式,移除 sys.path 操作
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m22s
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m22s
- 重构所有模块导入,移除 sys.path.insert - 统一使用 from backend.xxx 的绝对导入方式 - rag_core 包内使用相对导入(from .xxx) - 移动 visualize_graph.py 到 tools/ 目录 - 添加必要的 __init__.py 文件 - 清理废弃文档和脚本
This commit is contained in:
@@ -6,14 +6,11 @@ import numpy as np
|
||||
from dotenv import load_dotenv
|
||||
from qdrant_client import QdrantClient
|
||||
|
||||
# 添加项目根目录和 backend 目录到 Python 路径
|
||||
# 加载环境变量
|
||||
project_root = os.path.join(os.path.dirname(__file__), "..")
|
||||
backend_dir = os.path.join(project_root, "backend")
|
||||
sys.path.insert(0, project_root)
|
||||
sys.path.insert(0, backend_dir)
|
||||
load_dotenv()
|
||||
load_dotenv(os.path.join(project_root, ".env"))
|
||||
|
||||
from rag_core import LlamaCppEmbedder
|
||||
from backend.rag_core import LlamaCppEmbedder
|
||||
|
||||
QDRANT_URL = os.getenv("QDRANT_URL", "http://127.0.0.1:6333")
|
||||
QDRANT_API_KEY = os.getenv("QDRANT_API_KEY")
|
||||
|
||||
Reference in New Issue
Block a user