修改配置
This commit is contained in:
@@ -6,13 +6,24 @@ import asyncio
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 加载 .env 文件
|
||||
load_dotenv()
|
||||
|
||||
# 添加项目根目录和 backend 目录到 Python 路径
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "backend"))
|
||||
|
||||
from .index_builder import IndexBuilder, IndexBuilderConfig
|
||||
from .splitters import SplitterType
|
||||
# 导入方式:条件导入,支持作为脚本运行和作为包导入
|
||||
if __name__ == "__main__":
|
||||
# 作为脚本直接运行时使用绝对导入
|
||||
from rag_indexer.index_builder import IndexBuilder, IndexBuilderConfig
|
||||
from rag_indexer.splitters import SplitterType
|
||||
else:
|
||||
# 作为包导入时使用相对导入
|
||||
from .index_builder import IndexBuilder, IndexBuilderConfig
|
||||
from .splitters import SplitterType
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
|
||||
Reference in New Issue
Block a user