修复 use_report 按钮无效问题

This commit is contained in:
zcr
2026-04-02 16:43:58 +08:00
parent d27fbc969d
commit 63b4b932c7
5 changed files with 476 additions and 439 deletions

View File

@@ -11,7 +11,7 @@ from fastapi.responses import StreamingResponse
from langchain_core.messages import SystemMessage, AIMessageChunk, ToolMessage, AIMessage, ToolMessageChunk
from src.core.config import PROJECT_ROOT, settings
from src.server.deep_agent.agents.main_agent import build_main_agent
from src.server.deep_agent.agents.main_agent import build_main_agent, Context
from src.server.deep_agent.tools.conversation_title_tool import conversation_title
from src.schemas.deep_agent_chat import DeepAgentChatRequest, HistoryResponse, HistoryItem
from src.server.deep_agent.tools.extract_suggested_questions import generate_suggested_questions
@@ -104,7 +104,7 @@ async def chat_stream(request: DeepAgentChatRequest):
# 构建主agent
workspace_dir = os.path.join(PROJECT_ROOT, f"agent_workspace/{target_thread_id}")
logger.info(f"chat request data: {request} | target_thread_id : workspace_dir: {workspace_dir}")
main_agent = build_main_agent(request.use_report, workspace_dir, request.enable_thinking)
main_agent = build_main_agent(workspace_dir, request.enable_thinking)
# 2. 配置參數
temp = request.config_params.temperature if request.config_params else 0.7
@@ -195,7 +195,8 @@ async def chat_stream(request: DeepAgentChatRequest):
final_messages,
config=current_config,
stream_mode=["updates", "messages", "custom"],
subgraphs=True
subgraphs=True,
context=Context(use_report=request.use_report),
):
_, mode, chunks = stream
if is_first:
@@ -387,7 +388,7 @@ async def get_chat_history(thread_id: str):
history_data = []
workspace_dir = os.path.join(PROJECT_ROOT, f"agent_workspace/{thread_id}")
main_agent = build_main_agent(False, workspace_dir, enable_thinking=False)
main_agent = build_main_agent(workspace_dir, enable_thinking=False)
async for state in main_agent.aget_state_history(config):
msg_content = "Initial"
if state.values and "messages" in state.values: