From fc010cda0668f182419a3cf89593bf3c0bfdfb48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=88=AA=E5=AE=87?= <3364451258@qq.com> Date: Fri, 10 Jul 2026 15:23:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CLI=20serve=20=E4=BD=BF=E7=94=A8=20load?= =?UTF-8?q?=5Fconfig=20=E9=81=BF=E5=85=8D=E4=B8=BB=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=8F=8C=E9=87=8D=E5=8A=A0=E8=BD=BD=E5=B5=8C=E5=85=A5=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 用 load_config(config) 替代 get_state().config - 避免 CLI 主进程加载嵌入模型后 uvicorn 子进程再次加载 - 移除对 get_state 的隐式依赖(已有 DEFAULT_CONFIG_PATH 导入) Co-Authored-By: Claude --- src/cli/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cli/main.py b/src/cli/main.py index a1a823c..4ab0fa3 100644 --- a/src/cli/main.py +++ b/src/cli/main.py @@ -168,10 +168,12 @@ def serve( ): # 传递 config 给 uvicorn 子进程 (通过环境变量) os.environ["MD_VECTOR_CONFIG"] = config + # 使用 load_config 而非 get_state(),避免在 CLI 主进程加载嵌入模型 + from src.core.config import load_config + + cfg = load_config(config) typer.echo(f"启动服务: http://localhost:{port}") typer.echo(f"API 文档: http://localhost:{port}/docs") - # 加载配置以获取 SSL 设置 - cfg = get_state().config ssl_kwargs = {} if cfg.server.ssl_keyfile and cfg.server.ssl_certfile: ssl_kwargs["ssl_keyfile"] = cfg.server.ssl_keyfile