代码修改
This commit is contained in:
1 parent
f0c85c4795
commit
93243298e1
2 files changed
+27
-15
No files matched your search
@@ -60,5 +60,6 @@ ELEMENT_STATE_FILE=/app/backend/.deer-flow/element-bot-token
|
||||
# PYTHON_TRUSTED_HOST=your-python-mirror
|
||||
MYSQL_DATABASE_URL=mysql+asyncmy://deerflow:deerflow123@192.168.0.123:3306/deerflow?charset=utf8mb4
|
||||
DEER_FLOW_NOTEBOOK_API_BASE=http://127.0.0.1:8003
|
||||
# 圆桌后台作业网关:inprocess=进程内驱动真模型;simulated=模拟(默认)
|
||||
# 圆桌后台作业网关:缺省即 inprocess(进程内驱动真模型,后台挂起开箱即用);
|
||||
# 仅前端联调时显式设 simulated(真实进度但不调真模型)。本行可删,留作文档。
|
||||
ROUNDTABLE_JOB_GATEWAY=inprocess
|
||||
@@ -38,6 +38,17 @@ if TYPE_CHECKING:
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def resolve_roundtable_gateway_mode(raw: str | None) -> str:
|
||||
"""解析 ``ROUNDTABLE_JOB_GATEWAY``:**默认 ``inprocess``(真模型后台挂起)**。
|
||||
|
||||
只有显式写 ``simulated`` 才用模拟网关(前端联调用:真实进度、不调真模型);
|
||||
缺省 / 空串 / 其它值一律落到 ``inprocess`` —— 部署时无需在 .env 里配置任何值,
|
||||
后台挂起开箱即用(Phase 3b 已在 Windows 本地与内网 Docker 验证)。
|
||||
"""
|
||||
mode = (raw or "").strip().lower()
|
||||
return "simulated" if mode == "simulated" else "inprocess"
|
||||
|
||||
|
||||
def get_config(request: Request) -> AppConfig:
|
||||
"""Return the app-scoped ``AppConfig`` stored on ``app.state``."""
|
||||
config = getattr(request.app.state, "config", None)
|
||||
@@ -225,25 +236,17 @@ async def langgraph_runtime(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
_register_roundtable_job_default_store(app.state.roundtable_job_store)
|
||||
|
||||
# 圆桌后台作业执行器:把编排引擎作为后台任务跑。
|
||||
# 网关由环境变量 ``ROUNDTABLE_JOB_GATEWAY`` 选择:
|
||||
# - "inprocess"(Phase 3b):进程内驱动真模型(leader/seat/report);
|
||||
# - 其它/缺省(Phase 3a):模拟网关,产生真实进度但不调真模型,供前端联调。
|
||||
# 默认 simulated —— 真网关需在能起完整后端栈 + 真模型的环境验证后再开。
|
||||
# 网关由环境变量 ``ROUNDTABLE_JOB_GATEWAY`` 选择(见 resolve_roundtable_gateway_mode):
|
||||
# - 缺省 / "inprocess"(Phase 3b):进程内驱动真模型(leader/seat/report)——**默认**,
|
||||
# 部署时无需任何配置即可用后台挂起;
|
||||
# - 显式 "simulated"(Phase 3a):模拟网关,产生真实进度但不调真模型,供前端联调。
|
||||
if app.state.roundtable_job_store is not None:
|
||||
import os
|
||||
|
||||
from app.gateway.roundtable_job_executor import RoundtableJobExecutor
|
||||
|
||||
gateway_mode = (os.getenv("ROUNDTABLE_JOB_GATEWAY") or "simulated").strip().lower()
|
||||
if gateway_mode == "inprocess":
|
||||
from app.gateway.roundtable_inprocess_gateway import InProcessRoundtableGateway
|
||||
|
||||
_app = app # 闭包捕获 app,供网关访问 app.state(checkpointer/thread_store)
|
||||
gateway_factory = lambda p: InProcessRoundtableGateway( # noqa: E731
|
||||
_app, user_id=p.user_id, agents=p.agents, model=p.model
|
||||
)
|
||||
logger.info("[roundtable-jobs] gateway = inprocess (real models)")
|
||||
else:
|
||||
gateway_mode = resolve_roundtable_gateway_mode(os.getenv("ROUNDTABLE_JOB_GATEWAY"))
|
||||
if gateway_mode == "simulated":
|
||||
from deerflow.agents.roundtable_orchestrator import SimulatedRoundtableGateway
|
||||
|
||||
# delay=3s/步:让模拟后台任务有可观察的进行中时长(切页/重连仍在跑)。
|
||||
@@ -251,6 +254,14 @@ async def langgraph_runtime(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
p.agents, mode=p.mode, delay=3.0
|
||||
)
|
||||
logger.info("[roundtable-jobs] gateway = simulated")
|
||||
else:
|
||||
from app.gateway.roundtable_inprocess_gateway import InProcessRoundtableGateway
|
||||
|
||||
_app = app # 闭包捕获 app,供网关访问 app.state(checkpointer/thread_store)
|
||||
gateway_factory = lambda p: InProcessRoundtableGateway( # noqa: E731
|
||||
_app, user_id=p.user_id, agents=p.agents, model=p.model
|
||||
)
|
||||
logger.info("[roundtable-jobs] gateway = inprocess (real models, default)")
|
||||
|
||||
app.state.roundtable_job_executor = RoundtableJobExecutor(
|
||||
app.state.roundtable_job_store,
|
||||
|
||||
Reference in new issue
Block a user