Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ MINERU_API_BASE_URL=https://mineru.net
MINERU_MODEL_VERSION=vlm

# --- 文件服务 URL(用于 MinerU 远程模式) ---
# 本地测试:http://localhost:8000
# 生产环境:https://download.myvibe.works
FILE_SERVICE_BASE_URL=http://localhost:8000
# ⚠️ 必须配置:此变量用于远程 MinerU API 访问本地文件
# 本地测试:http://localhost:8000(仅本地开发有效)
# Docker/生产环境:必须设置为服务器公网 IP 或域名,如 http://your-ip:8000
# 示例:http://192.168.1.100:8000 或 https://download.myvibe.works
FILE_SERVICE_BASE_URL=http://your-ip:8000

# --- 远程 MinerU 限流配置 ---
# 根据您的 API 套餐调整
Expand Down
13 changes: 10 additions & 3 deletions src/file_url_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
class FileURLService:
"""轻量级文件 URL 服务,在 8000 端口提供临时文件访问"""

def __init__(self, base_url: str = "http://localhost:8000",
def __init__(self, base_url: Optional[str] = None,
temp_dir: str = "/tmp/rag-files"):
# 从环境变量读取 base_url,移除硬编码默认值
base_url = base_url or os.getenv("FILE_SERVICE_BASE_URL")
if not base_url:
raise ValueError(
"FILE_SERVICE_BASE_URL 环境变量未设置。"
"请在 .env 文件中配置 FILE_SERVICE_BASE_URL=http://your-ip:8000"
)
Comment on lines -21 to +29
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有在 .env.example 中添加示例 @copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已更新 env.example,添加了 FILE_SERVICE_BASE_URL 的必须配置说明,并将默认值从 localhost 改为 your-ip 占位符,避免误用。(35e94f5)

self.base_url = base_url
self.temp_dir = temp_dir
os.makedirs(temp_dir, exist_ok=True)
Expand Down Expand Up @@ -138,6 +145,6 @@ def get_file_service():
"""获取文件服务实例"""
global global_file_service
if global_file_service is None:
base_url = os.getenv("FILE_SERVICE_BASE_URL", "http://localhost:8000")
global_file_service = FileURLService(base_url)
# 不再传递 base_url,让 FileURLService.__init__ 从环境变量读取
global_file_service = FileURLService()
return global_file_service