From d26a7a36bed05fd2af4b62730dfdd79ea1ce7e84 Mon Sep 17 00:00:00 2001 From: xyz <123456@gmail.com> Date: Wed, 7 Jan 2026 13:38:51 +0800 Subject: [PATCH] refactor: Reimplement research workflow with dynamic expert configuration, multi-round discussion, and Mermaid diagram synthesis. --- __pycache__/app.cpython-313.pyc | Bin 22130 -> 22154 bytes .../research_agent.cpython-313.pyc | Bin 2940 -> 3059 bytes agents/research_agent.py | 4 ++-- app.py | 4 ++-- .../research_manager.cpython-313.pyc | Bin 4779 -> 5581 bytes orchestrator/research_manager.py | 15 ++++++++++++--- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/__pycache__/app.cpython-313.pyc b/__pycache__/app.cpython-313.pyc index e2ee526d6d0e925abca61c95b5b7c03231781633..675f8045f5c50c89d9a0477fc23b36b1687e6ef0 100644 GIT binary patch delta 107 zcmeyghOuicBkyNkUM>b8So|_J(`6%Xo1vmKkoRH!@>L4Hr8y;;y1w}-sW}SH`K5Wu znK=q!My2VKHySz%Je#uf#s1j}8m<)usYN9Uj+@^b){6;hU18C_!NS(=-Q;~ipz;b! K)#iGS&%6L8uqcNB delta 87 zcmeBL%lK&xBkyNkUM>b8Pn9(wve^UElna)Eoup{L;MS p%$(Ao$y*GaH}e=(i3zG-VbQq3!q)EH(+t9*Y0~ diff --git a/agents/__pycache__/research_agent.cpython-313.pyc b/agents/__pycache__/research_agent.cpython-313.pyc index 57fab3a2eba3e2b4be1e9581f74aa01f1cd6cd39..fcaafbd0fbc7d943c3bf5ec81dc8f990ec1b6f08 100644 GIT binary patch delta 227 zcmew(_F0_wGcPX}0}#x38JoF!BQFmNW7XsYX6ebMEYYlt3=HXPo9D8eWMoY&2XZE7 zu&D|wB<7_kgk=_&Cgv!FWMt-Lrxs1_W!qODT zs*tGQn_85cn3sTAZ1eu8@$BkPDGiNX`eUP0Gnn&el{Y$yX=? zTaj6ns!);v#F@FNIhlE>Itm3v`N^rp#X1W4MGA>U$r+g?smUd!MNFxBlY`kS7!xO- QVUJ=lfKlY=>8geAB>a4>KSbx3~TWDybjz`(*Q Kws{kWBQpT^W*q1M diff --git a/agents/research_agent.py b/agents/research_agent.py index d68d79b..5244528 100644 --- a/agents/research_agent.py +++ b/agents/research_agent.py @@ -29,11 +29,11 @@ Be constructive but rigorous. Don't just agree; add value by challenging assumpt Context: {context}""" 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. Combine the structural strength of Expert A with the critical insights of Expert B. 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: return "You are a helpful assistant." diff --git a/app.py b/app.py index 3f5f2d5..a7070fc 100644 --- a/app.py +++ b/app.py @@ -205,8 +205,8 @@ with st.sidebar: # ==================== 主界面逻辑 ==================== if mode == "Deep Research": - st.title("🧪 Multi-Model Council") - st.markdown("*多模型智囊团:分析 (Expert A) -> 批判 (Expert B) -> 决策 (Expert C)*") + st.title("🧪 Multi-Model Council V2") + st.markdown("*多模型智囊团:分析 (Expert A) -> 批判 (Expert B) -> 改进 (Expert A) -> 决策 (Expert C)*") # Input research_topic = st.text_area("研究/决策主题", placeholder="请输入你想深入研究或决策的主题...", height=100) diff --git a/orchestrator/__pycache__/research_manager.cpython-313.pyc b/orchestrator/__pycache__/research_manager.cpython-313.pyc index 03e900cad896a94fde0bc97ce885bb5c3ec18e39..7c0fd17a75b35c42d30acc77e7fa7425199824b0 100644 GIT binary patch delta 1155 zcmZ`%O>7%Q6y6=#G9Ae=N+b?Y2{>Q=)px+7G!I9#z2v-tX>EVnuGtmHE#q#Qluf0$=(i`jZgntfswds1XAkr0B z(OPZ+R8hl9wx$1gq51{kz7S4IqMGN#=tZ7{2558qlTNtCMLU6LZp9# z*$j+|HyIN*43i}3!|-W7ME?q}rbpSsDVnZY*U+^=j|WkvP;ZbU=0H43k`IKzrEG=R zKLa5xM&9I~?0*%(d}j*U!bI=*j6J{d^Y(A02POMm*~u#1tmb4jo3y&55J0s2}hdi zN(+v(aL4#v%I&RpdZ8&NbjA)%^-i3+BRQjsk3);k{M=ZcKRm{bPuufvIg#au!ZM4- z#`na&(@nd4y<1kDvT9dNr)+i0EvMXK-&zA3uDLakbIrNH$UJz@i%Q;I#f$n7T~Yha zRnU``?@RZG?93;uKW1A2F4l0Qd(9id{5y#UX)wM0J{O-0i@fBre=p5_E&{|4~d BVD|t3 delta 458 zcmX@By;_y;GcPX}0}yaNkIfX~-N={3!OaHbDg*K7M@*ZmIoO#P1t;fo>jTO8+{(g2 zp^SVC!NQ@;KvE=>jgP^YZSs9CNucaUZpq0)+_oI)qUOwLjGAJb{dsOP3JbYb6r>iF zC^#zwSLT&uq!wouPvSQYa8g%DN-R!IQOM6zfU0m*FIFfh$}h+-PRvnA%u9iZI|0R$ zi!w_x3rkb=xL}H{xT?5e949NT$@~JUj9imV1)Qb0(lYZ>GV{`lnA|OD%xl4D`H2BY6iETa0O@Fi8UO$Q diff --git a/orchestrator/research_manager.py b/orchestrator/research_manager.py index 5fe3f3c..79f3c67 100644 --- a/orchestrator/research_manager.py +++ b/orchestrator/research_manager.py @@ -61,10 +61,19 @@ class ResearchManager: yield {"type": "content", "content": chunk} 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 = "" - yield {"type": "step_start", "step": "Expert C Synthesis", "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}" + 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 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): findings_c += chunk yield {"type": "content", "content": chunk}