refactor: Reimplement research workflow with dynamic expert configuration, multi-round discussion, and Mermaid diagram synthesis.

This commit is contained in:
xyz 2026-01-07 13:38:51 +08:00
parent 9dda930868
commit d26a7a36be
6 changed files with 16 additions and 7 deletions

Binary file not shown.

View File

@ -29,11 +29,11 @@ Be constructive but rigorous. Don't just agree; add value by challenging assumpt
Context: {context}""" Context: {context}"""
elif self.role == "expert_c": elif self.role == "expert_c":
return f"""You are Expert C, a Senior Strategist. return f"""You are Expert C, a Senior Strategist and Visual Thinker.
Your goal is to synthesize the final output. Your goal is to synthesize the final output.
Combine the structural strength of Expert A with the critical insights of Expert B. Combine the structural strength of Expert A with the critical insights of Expert B.
Produce a final, polished, comprehensive plan or report. Produce a final, polished, comprehensive plan or report.
Context: {context}""" CRITICAL: You MUST include a Mermaid.js diagram (using ```mermaid code block) to visualize the timeline, process, or architecture."""
else: else:
return "You are a helpful assistant." return "You are a helpful assistant."

4
app.py
View File

@ -205,8 +205,8 @@ with st.sidebar:
# ==================== 主界面逻辑 ==================== # ==================== 主界面逻辑 ====================
if mode == "Deep Research": if mode == "Deep Research":
st.title("🧪 Multi-Model Council") st.title("🧪 Multi-Model Council V2")
st.markdown("*多模型智囊团:分析 (Expert A) -> 批判 (Expert B) -> 决策 (Expert C)*") st.markdown("*多模型智囊团:分析 (Expert A) -> 批判 (Expert B) -> 改进 (Expert A) -> 决策 (Expert C)*")
# Input # Input
research_topic = st.text_area("研究/决策主题", placeholder="请输入你想深入研究或决策的主题...", height=100) research_topic = st.text_area("研究/决策主题", placeholder="请输入你想深入研究或决策的主题...", height=100)

View File

@ -61,10 +61,19 @@ class ResearchManager:
yield {"type": "content", "content": chunk} yield {"type": "content", "content": chunk}
yield {"type": "step_end", "output": findings_b} yield {"type": "step_end", "output": findings_b}
# Step 3: Expert C Synthesis # Step 3: Expert A Refinement (Innovative Optimization)
findings_a_refined = ""
yield {"type": "step_start", "step": "Expert A Refinement", "agent": self.agents["expert_a"].name, "model": self.agents["expert_a"].model_name}
prompt_a_refine = f"Expert B has critiqued your initial proposal.\nCritique: {findings_b}\n\nPlease refine your proposal to address these points. Strengthen your arguments and fix the gaps."
for chunk in self.agents["expert_a"].generate(prompt_a_refine, context):
findings_a_refined += chunk
yield {"type": "content", "content": chunk}
yield {"type": "step_end", "output": findings_a_refined}
# Step 4: Expert C Synthesis & Visualization
findings_c = "" findings_c = ""
yield {"type": "step_start", "step": "Expert C Synthesis", "agent": self.agents["expert_c"].name, "model": self.agents["expert_c"].model_name} yield {"type": "step_start", "step": "Expert C Synthesis & Visualization", "agent": self.agents["expert_c"].name, "model": self.agents["expert_c"].model_name}
prompt_c = f"Synthesize a final comprehensive plan for '{topic}' based on Expert A's proposal and Expert B's critique.\nExpert A:\n{findings_a}\nExpert B:\n{findings_b}" prompt_c = f"Synthesize a final comprehensive plan for '{topic}' based on the refined proposal.\nRefined Proposal:\n{findings_a_refined}\nCritique Reference:\n{findings_b}\n\nIMPORTANT: Include a Mermaid.js diagram (sequenceDiagram, gantt, or flowchart) to visualize the roadmap or process at the end of your report."
for chunk in self.agents["expert_c"].generate(prompt_c, context): for chunk in self.agents["expert_c"].generate(prompt_c, context):
findings_c += chunk findings_c += chunk
yield {"type": "content", "content": chunk} yield {"type": "content", "content": chunk}