修复 title 总结失败bug,新增enable_thinking参数
This commit is contained in:
@@ -39,6 +39,7 @@ async def chat_stream(request: DeepAgentChatRequest):
|
||||
|
||||
#### 2. 请求参数
|
||||
* `message`: 用户的设计意图(如:'我想设计一个极简风格的橡木办公桌')。
|
||||
* `enable_thinking`: 是否开启思考模式。
|
||||
* `quote_image_path`: 用户引用图片地址 如:"fida-test/furniture/sketches/8a1804d1-5ac9-4d02-bf17-e65fa7272f65.png"。
|
||||
* `input_image_paths`: 用户上传图片地址集合如:["fida-test/furniture/sketches/8a1804d1-5ac9-4d02-bf17-e65fa7272f65.png"]。
|
||||
* `thread_id`: (可选) 现有项目的唯一标识。若不传,系统将自动分配并返回。
|
||||
@@ -106,7 +107,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)
|
||||
main_agent = build_main_agent(request.use_report, workspace_dir, request.enable_thinking)
|
||||
# 2. 配置參數
|
||||
temp = request.config_params.temperature if request.config_params else 0.7
|
||||
|
||||
@@ -318,7 +319,7 @@ async def chat_stream(request: DeepAgentChatRequest):
|
||||
# 获取标题
|
||||
if need_title:
|
||||
title = await conversation_title(agent=main_agent, config=current_config)
|
||||
logger.info(f"[need_title] {title}")
|
||||
logger.info(f"[title] {title}")
|
||||
yield f"data: {json.dumps({'title': title}, ensure_ascii=False)}\n\n"
|
||||
|
||||
yield f"data: {json.dumps({'status': 'end'}, ensure_ascii=False)}\n\n"
|
||||
|
||||
@@ -11,6 +11,7 @@ class AgentConfig(BaseModel):
|
||||
|
||||
class DeepAgentChatRequest(BaseModel):
|
||||
message: str = Field(..., description="用户的输入指令")
|
||||
enable_thinking: Optional[bool] = Field(default=False, description="是否开启思考模式")
|
||||
quote_image_path: Optional[str] = Field(None, description="引用图片地址") # ✅ 新增
|
||||
input_image_paths: Optional[list[str]] = Field(None, description="上传图片地址集合") # ✅ 新增
|
||||
thread_id: Optional[str] = Field(None, description="会话线程ID,不传则开启新会话")
|
||||
|
||||
@@ -9,7 +9,7 @@ from src.core.config import MONGO_URI
|
||||
from src.server.deep_agent.agents.painter import build_painter_subagent
|
||||
from src.server.deep_agent.agents.researcher import build_researcher_subagent
|
||||
from src.server.deep_agent.agents.user_profile import user_profile_subagent
|
||||
from src.server.deep_agent.init_llm import main_llm
|
||||
from src.server.deep_agent.init_llm import build_main_llm
|
||||
from src.server.deep_agent.init_prompt import build_system_prompt
|
||||
|
||||
client = MongoClient(MONGO_URI)
|
||||
@@ -39,7 +39,7 @@ class CanvasMiddleware:
|
||||
return state, agent_input
|
||||
|
||||
|
||||
def build_main_agent(use_report, workspace_dir):
|
||||
def build_main_agent(use_report, workspace_dir, enable_thinking):
|
||||
research_subagent = build_researcher_subagent(workspace_dir)
|
||||
painter_subagent = build_painter_subagent(workspace_dir)
|
||||
subagents = [
|
||||
@@ -48,7 +48,7 @@ def build_main_agent(use_report, workspace_dir):
|
||||
user_profile_subagent
|
||||
]
|
||||
main_agent = create_deep_agent(
|
||||
model=main_llm,
|
||||
model=build_main_llm(enable_thinking=enable_thinking),
|
||||
system_prompt=build_system_prompt(use_report=use_report),
|
||||
subagents=subagents,
|
||||
checkpointer=checkpointer,
|
||||
@@ -58,7 +58,7 @@ def build_main_agent(use_report, workspace_dir):
|
||||
),
|
||||
middleware=[
|
||||
SummarizationMiddleware(
|
||||
model=main_llm,
|
||||
model=build_main_llm(enable_thinking=enable_thinking),
|
||||
trigger=("tokens", 3000),
|
||||
keep=("messages", 100),
|
||||
),
|
||||
|
||||
@@ -22,13 +22,18 @@ title_llm = ChatQwen(
|
||||
api_key=settings.QWEN_API_KEY
|
||||
)
|
||||
|
||||
main_llm = ChatQwen(
|
||||
model="qwen3.5-flash",
|
||||
temperature=0.2,
|
||||
max_tokens=3_000,
|
||||
timeout=None,
|
||||
max_retries=2,
|
||||
api_key=settings.QWEN_API_KEY)
|
||||
|
||||
def build_main_llm(enable_thinking):
|
||||
main_llm = ChatQwen(
|
||||
enable_thinking=enable_thinking,
|
||||
model="qwen3.5-flash",
|
||||
temperature=0.2,
|
||||
max_tokens=3_000,
|
||||
timeout=None,
|
||||
max_retries=2,
|
||||
api_key=settings.QWEN_API_KEY)
|
||||
return main_llm
|
||||
|
||||
|
||||
suggested_llm = ChatQwen(
|
||||
model="qwen-plus",
|
||||
|
||||
@@ -22,8 +22,6 @@ async def conversation_title(agent, config):
|
||||
|
||||
if user_msg and ai_msg:
|
||||
break
|
||||
if not user_msg or not ai_msg:
|
||||
return None
|
||||
|
||||
prompt = f"""
|
||||
请根据以下首次对话内容,生成一个简洁、精准的标题(2-15个字):
|
||||
|
||||
Reference in New Issue
Block a user