sync update from LAN repo (source master @ ca48c4ec)
This commit is contained in:
1 parent
8bc8b0e082
commit
ea9dcff9c0
873 files changed
+107866
-14011
No files matched your search
@@ -51,6 +51,7 @@ from pydantic import BaseModel, Field
|
||||
|
||||
from deerflow.agents.lead_agent.agent import make_lead_agent
|
||||
from deerflow.config.agents_config import list_custom_agents, validate_agent_id
|
||||
from deerflow.runtime.runs.worker import build_agent_with_timing
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -81,7 +82,7 @@ class OpenChatRequest(BaseModel):
|
||||
thinking_enabled: bool = Field(default=False, description="是否开启思考;默认 False = 关闭思考(内网模型也会被强制关闭)")
|
||||
strip_think: bool = Field(default=True, description="关闭思考时,从答案里剥离残留的 <think>…</think> 块")
|
||||
thread_id: str | None = Field(default=None, description="可选;仅用于文件隔离,留空自动生成")
|
||||
recursion_limit: int = Field(default=100, ge=1, le=300, description="智能体单次问答的最大步数")
|
||||
recursion_limit: int = Field(default=100, ge=1, le=300, description="兼容旧客户端保留;实际步数上限统一使用管理员的问答步骤设置", deprecated=True)
|
||||
include_files: bool = Field(default=True, description="是否随结果回传智能体在 outputs 目录生成的文件(名称+内容)")
|
||||
|
||||
|
||||
@@ -279,7 +280,13 @@ def _build_run_context(body: OpenChatRequest) -> tuple[dict[str, Any], str | Non
|
||||
}
|
||||
if agent_id:
|
||||
configurable["agent_id"] = agent_id
|
||||
config: dict[str, Any] = {"configurable": configurable, "recursion_limit": body.recursion_limit}
|
||||
from deerflow.config.system_settings import get_conversation_context_settings
|
||||
|
||||
# Match browser chat: external callers cannot override the server budget.
|
||||
config: dict[str, Any] = {
|
||||
"configurable": configurable,
|
||||
"recursion_limit": get_conversation_context_settings().max_run_steps,
|
||||
}
|
||||
return config, agent_id, thread_id
|
||||
|
||||
|
||||
@@ -301,7 +308,7 @@ async def open_chat(body: OpenChatRequest) -> OpenChatResponse:
|
||||
config, agent_id, thread_id = _build_run_context(body)
|
||||
|
||||
try:
|
||||
agent = make_lead_agent(config)
|
||||
agent = await build_agent_with_timing(make_lead_agent, config, None, thread_id)
|
||||
result = await agent.ainvoke({"messages": lc_messages}, config=config)
|
||||
except Exception as exc: # noqa: BLE001 — 开放接口需把内部错误归一成 502
|
||||
logger.exception("open_chat 调用智能体失败 (model=%s, agent=%s)", body.model_name, agent_id)
|
||||
@@ -345,7 +352,7 @@ async def _open_chat_event_stream(body: OpenChatRequest) -> AsyncIterator[str]:
|
||||
async def produce() -> None:
|
||||
nonlocal final_state
|
||||
try:
|
||||
agent = make_lead_agent(config)
|
||||
agent = await build_agent_with_timing(make_lead_agent, config, None, thread_id)
|
||||
async for mode, chunk in agent.astream({"messages": lc_messages}, config=config, stream_mode=["values", "messages"]):
|
||||
if mode == "values" and isinstance(chunk, dict):
|
||||
final_state = chunk
|
||||
|
||||
Reference in new issue
Block a user