From 7cd7c2edd21e0b51e481d5d3937cecd3c1c29bef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:35:14 +0000 Subject: [PATCH 1/3] Initial plan From 986ceb6636e57a13d00b9240d58fe598ca981252 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:41:55 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=20URL=20=E7=A1=AC=E7=BC=96=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E7=A7=BB=E9=99=A4=20localhost=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com> --- src/file_url_service.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/file_url_service.py b/src/file_url_service.py index 4f07baa..863128d 100644 --- a/src/file_url_service.py +++ b/src/file_url_service.py @@ -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" + ) self.base_url = base_url self.temp_dir = temp_dir os.makedirs(temp_dir, exist_ok=True) @@ -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 From 35e94f5b927985384d818595ac90601a599dae05 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:59:55 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20env.example=20?= =?UTF-8?q?=E4=B8=AD=20FILE=5FSERVICE=5FBASE=5FURL=20=E7=9A=84=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E5=92=8C=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com> --- env.example | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/env.example b/env.example index db7a4f2..f0cd5a3 100644 --- a/env.example +++ b/env.example @@ -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 套餐调整