修复对话背景信息配置

This commit is contained in:
zcr
2026-05-19 11:30:29 +08:00
parent a8f52dbdaa
commit 4ecc409ab5
3 changed files with 25 additions and 14 deletions

View File

@@ -146,6 +146,13 @@ async def chat_stream(request: DeepAgentChatRequest):
"Please strictly follow the above settings in subsequent conversations。" "Please strictly follow the above settings in subsequent conversations。"
) )
initial_messages.append(SystemMessage(content=system_prompt)) initial_messages.append(SystemMessage(content=system_prompt))
design_backend = f"""
<design_constraints>
Category: {cp.type or 'unspecified'}
region: {cp.region or 'unspecified'}
style: {cp.style or 'unspecified'}
</design_constraints>
"""
# 6. 分支处理 # 6. 分支处理
if is_branching: if is_branching:
@@ -195,6 +202,9 @@ async def chat_stream(request: DeepAgentChatRequest):
if input_image_content: if input_image_content:
content[0]["text"] += input_image_content content[0]["text"] += input_image_content
if design_backend:
content[0]["text"] += design_backend
message_list = [{"role": "user", "content": content}] message_list = [{"role": "user", "content": content}]
final_messages = {"messages": message_list, "files": files} final_messages = {"messages": message_list, "files": files}
logger.info(final_messages) logger.info(final_messages)

View File

@@ -106,6 +106,8 @@ def user_role_prompt(request: ModelRequest) -> str:
# ==================== 家具设计背景(加强版) ==================== # ==================== 家具设计背景(加强版) ====================
design_context = f""" design_context = f"""
当用户消息中首次出现 <design_constraints> 标签时,你必须将标签内的品类、区域、风格视为本次对话的**核心设计背景**,所有设计决策、图片生成、线稿、渲染图都必须严格符合该背景。
[Internal highest priority design background - only for thinking, not output to users] [Internal highest priority design background - only for thinking, not output to users]
Furniture design settings selected by the current user: Furniture design settings selected by the current user:
- Category: {ctx.type or 'unspecified'} - Category: {ctx.type or 'unspecified'}
@@ -150,7 +152,7 @@ def user_role_prompt(request: ModelRequest) -> str:
""" """
# ==================== 最终组合(设计背景放最前面) ==================== # ==================== 最终组合(设计背景放最前面) ====================
final_prompt = ( final_prompt = (
design_context + # design_context +
"\n\n" + "\n\n" +
language_prompt + language_prompt +
"\n\n" + "\n\n" +

View File

@@ -191,21 +191,20 @@ When generating new furniture sketches:
【2】When the user requests reports, research, analysis, or summaries: 【2】When the user requests reports, research, analysis, or summaries:
- First check if sufficient user profile information exists. - First check if sufficient user profile information exists.
- If information is missing (style, room type, theme, budget, etc.): Call `user_profile_subagent` to collect data. Do not generate the report directly. - If information is missing: Use the **task** tool to dispatch the **user_profile_subagent** subagent. Do NOT attempt to call user_profile_subagent as a standalone tool.
- If the user profile is already complete: Call `research_subagent` to generate the report. - If the user profile is already complete: Use the **task** tool to dispatch the **research_subagent** subagent.
【3】User Profile Priority Rules Example of correct invocation:
Whenever the user input involves: task(subagent_name="user_profile_subagent", input="收集用户的风格偏好、房间类型、预算等信息")
- Expressing design requirements
- Providing or modifying preferences (style, room type, budget, etc.) 【3】User Profile Priority Rules (Limited Scope)
- Supplementing report-related information - **This rule only applies to report/research/analysis/summary tasks.**
→ Prioritize calling `user_profile_subagent` to update or collect user profile data. - Furniture design, image generation and editing tasks are exempted from user profile collection and must not dispatch user_profile_subagent.
【4】Scheduling Principles 【4】Scheduling Principles
- `user_profile_subagent` is only responsible for **information collection**. - **user_profile_subagent** is a subagent (not a tool) — dispatch it via the **task** tool.
- `research_subagent` is only responsible for **report generation**. - **research_subagent** is a subagent (not a tool) — dispatch it via the **task** tool.
- `generate_furniture_sketch_prompts` is only responsible for **professional prompt generation for furniture sketches**. - Do NOT call them as direct tool calls.
Do not mix their responsibilities.
======================== ========================
Critical Prohibitions (Highest Priority) Critical Prohibitions (Highest Priority)