From 80a728682ca2ad45bbcf71501428559aae693239 Mon Sep 17 00:00:00 2001 From: Chen Xiao Date: Fri, 14 Aug 2026 09:54:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E4=BF=AE=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=AF=B9=E6=8A=97=E6=80=A7=E5=AE=A1=E6=9F=A5=E6=89=93?= =?UTF-8?q?=E5=88=86=E6=8C=89=E9=92=AE=E7=BC=BA=E5=B0=91UI=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E4=B8=8E=E7=8A=B6=E6=80=81=E5=8F=98=E9=87=8F=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=AF=BC=E8=87=B4=E6=97=A0=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/app.py | 103 ++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/frontend/app.py b/frontend/app.py index af9d5b2..ed9c5a6 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -855,58 +855,65 @@ with tab2: ) if review_btn: + rev_status_text = st.empty() + rev_status_text.info(f"⚙️ [AI Reviewer #2] 正在向阿里通义 Qwen ({selected_model}) 建立对抗性审查通道...") + with st.container(): + critic_console = st.empty() + full_rev_text = f"[System Log]: 正在向 Reviewer #2 提交假说并建立对抗性审查通道 (通过门槛: {pass_threshold}分)...\n[System Log]: 待审查假说 ID: [{st.session_state.current_hypo.get('id', 'H1')}]\n\n[Reviewer #2 Stream Output]: " + critic_console.markdown(f'
🔍 [Reviewer #2 Channel]: 阿里通义 Qwen ({selected_model}) 正在进行 5 维对抗性审查...
{full_rev_text}
', unsafe_allow_html=True) - if hasattr(critic_skill, 'review_stream'): - try: - rev_stream = critic_skill.review_stream(st.session_state.current_hypo, problem, pass_threshold=pass_threshold) - except TypeError: - rev_stream = critic_skill.review_stream(st.session_state.current_hypo, problem) - else: - try: - rev_res = critic_skill.review(st.session_state.current_hypo, problem, pass_threshold=pass_threshold) - except TypeError: - rev_res = critic_skill.review(st.session_state.current_hypo, problem) - rev_stream = [json.dumps(rev_res, ensure_ascii=False, indent=2)] - - raw_rev_accumulated = "" - for token_chunk in rev_stream: - raw_rev_accumulated += token_chunk - for char in token_chunk: - full_rev_text += char - if len(full_rev_text) % 2 == 0: - critic_console.markdown(f'
{full_rev_text}▋
', unsafe_allow_html=True) - time.sleep(0.003) - - # 健壮解析 5 维结构化判定 - parsed_rev = parse_json_robust(raw_rev_accumulated) - if not isinstance(parsed_rev, dict) or "scores" not in parsed_rev: - try: - parsed_rev = critic_skill.review(st.session_state.current_hypo, problem, pass_threshold=pass_threshold) - except TypeError: - parsed_rev = critic_skill.review(st.session_state.current_hypo, problem) - except Exception: - pass + if hasattr(critic_skill, 'review_stream'): + try: + rev_stream = critic_skill.review_stream(st.session_state.current_hypo, problem, pass_threshold=pass_threshold) + except TypeError: + rev_stream = critic_skill.review_stream(st.session_state.current_hypo, problem) + else: + try: + rev_res = critic_skill.review(st.session_state.current_hypo, problem, pass_threshold=pass_threshold) + except TypeError: + rev_res = critic_skill.review(st.session_state.current_hypo, problem) + rev_stream = [json.dumps(rev_res, ensure_ascii=False, indent=2)] + + raw_rev_accumulated = "" + for token_chunk in rev_stream: + raw_rev_accumulated += token_chunk + for char in token_chunk: + full_rev_text += char + if len(full_rev_text) % 2 == 0: + critic_console.markdown(f'
🔍 [Reviewer #2 Channel]: 阿里通义 Qwen ({selected_model}) 实时输出审查意见...
{full_rev_text}
', unsafe_allow_html=True) + time.sleep(0.003) + + # 健壮解析 5 维结构化判定 + parsed_rev = parse_json_robust(raw_rev_accumulated) + if not isinstance(parsed_rev, dict) or "scores" not in parsed_rev: + try: + parsed_rev = critic_skill.review(st.session_state.current_hypo, problem, pass_threshold=pass_threshold) + except TypeError: + parsed_rev = critic_skill.review(st.session_state.current_hypo, problem) + except Exception: + pass - if not isinstance(parsed_rev, dict): - parsed_rev = {} - if "scores" not in parsed_rev: - parsed_rev["scores"] = {"logical_consistency": 8, "literature_grounding": 9, "falsifiability": 9, "novelty": 8, "feasibility": 9} - if "total_score" not in parsed_rev: - parsed_rev["total_score"] = sum(parsed_rev["scores"].values()) - if "decision" not in parsed_rev: - parsed_rev["decision"] = "ACCEPT" if parsed_rev["total_score"] >= pass_threshold else ("REVISE" if parsed_rev["total_score"] >= pass_threshold - 10 else "REJECT") - if "detailed_comments" not in parsed_rev: - parsed_rev["detailed_comments"] = "审查判定完毕,假说具备良好的理论深度与可证伪性。" + if not isinstance(parsed_rev, dict): + parsed_rev = {} + if "scores" not in parsed_rev: + parsed_rev["scores"] = {"logical_consistency": 8, "literature_grounding": 9, "falsifiability": 9, "novelty": 8, "feasibility": 9} + if "total_score" not in parsed_rev: + parsed_rev["total_score"] = sum(parsed_rev["scores"].values()) + if "decision" not in parsed_rev: + parsed_rev["decision"] = "ACCEPT" if parsed_rev["total_score"] >= pass_threshold else ("REVISE" if parsed_rev["total_score"] >= pass_threshold - 10 else "REJECT") + if "detailed_comments" not in parsed_rev: + parsed_rev["detailed_comments"] = "审查判定完毕,假说具备良好的理论深度与可证伪性。" - full_rev_text += f"\n\n[System Log]: 审查判定解析成功!综合得分: {parsed_rev.get('total_score')}/50, 裁决结果: {parsed_rev.get('decision')}。" - critic_console.markdown(f'
{full_rev_text}
', unsafe_allow_html=True) - - # 持久化审查日志 - st.session_state.review_console_log = full_rev_text - st.session_state.review_result = parsed_rev + full_rev_text += f"\n\n[System Log]: 审查判定解析成功!综合得分: {parsed_rev.get('total_score')}/50, 裁决结果: {parsed_rev.get('decision')}。" + critic_console.markdown(f'
{full_rev_text}
', unsafe_allow_html=True) + + # 持久化审查日志 + st.session_state.review_console_log = full_rev_text + st.session_state.review_result = parsed_rev - st.session_state.current_state = "3_reviewed" - st.rerun() + rev_status_text.success("🎉 Reviewer #2 对抗性审查完毕!") + st.session_state.current_state = "3_reviewed" + st.rerun() # 常驻展示审查的控制台日志 (如果存在) if st.session_state.review_console_log: