Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -295,13 +295,12 @@ if st.session_state.start_pipeline or st.session_state.resume_pipeline:
|
|
| 295 |
if global_lock.locked():
|
| 296 |
try: global_lock.release()
|
| 297 |
except: pass
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
st.stop()
|
| 305 |
|
| 306 |
if not global_lock.acquire(blocking=False):
|
| 307 |
st.warning("⏳ 有小伙伴正在创作,您在15-20 分钟后就能正常使用啦")
|
|
@@ -465,11 +464,10 @@ if st.session_state.start_pipeline or st.session_state.resume_pipeline:
|
|
| 465 |
|
| 466 |
original_anchor_dir = APP_CONFIG.get('anchor_generation_directive', '')
|
| 467 |
|
| 468 |
-
# 【修复 2:针对克隆模式的摘要长度进行强硬扩写要求】
|
| 469 |
if st.session_state.run_mode == "clone":
|
| 470 |
-
length_mandate = "\n[LENGTH MANDATE] The Abstract MUST be extremely comprehensive and detailed. It MUST be at least
|
| 471 |
else:
|
| 472 |
-
length_mandate = "\n[LENGTH MANDATE] The Abstract MUST be comprehensive and detailed, containing at least
|
| 473 |
|
| 474 |
APP_CONFIG['anchor_generation_directive'] = original_anchor_dir + length_mandate
|
| 475 |
|
|
@@ -594,7 +592,6 @@ if st.session_state.start_pipeline or st.session_state.resume_pipeline:
|
|
| 594 |
remaining_sections -= 1
|
| 595 |
continue
|
| 596 |
|
| 597 |
-
# 【修复 1:断点状态同步原子化】
|
| 598 |
if previous_task:
|
| 599 |
with st.spinner(f"⏳ 正在同步保存上一节【{previous_task['name']}】的翻译状态..."):
|
| 600 |
try:
|
|
@@ -762,7 +759,6 @@ if st.session_state.start_pipeline or st.session_state.resume_pipeline:
|
|
| 762 |
|
| 763 |
future = translation_executor.submit(thread_wrapper, agent, en_draft_clean, trans_ph, target_lang, is_quarantined)
|
| 764 |
|
| 765 |
-
# 将任务打包暂存,待下一节循环开始时强制原子化同步保存,确保断点无损
|
| 766 |
previous_task = {
|
| 767 |
"name": display_name,
|
| 768 |
"future": future,
|
|
@@ -776,7 +772,6 @@ if st.session_state.start_pipeline or st.session_state.resume_pipeline:
|
|
| 776 |
generation_aborted = True
|
| 777 |
break
|
| 778 |
|
| 779 |
-
# 循环结束后的收尾:处理最后一条挂起的翻译同步任务
|
| 780 |
if not generation_aborted and previous_task:
|
| 781 |
with st.spinner(f"⏳ 正在同步保存最后一节【{previous_task['name']}】的翻译状态..."):
|
| 782 |
try:
|
|
|
|
| 295 |
if global_lock.locked():
|
| 296 |
try: global_lock.release()
|
| 297 |
except: pass
|
| 298 |
+
# 【修改点:无感自动恢复,移除按钮拦截,直接重置状态并重跑】
|
| 299 |
+
st.toast("🔄 检测到页面刷新或网络抖动,系统正在自动恢复进度...", icon="⚡")
|
| 300 |
+
st.session_state.is_running = False
|
| 301 |
+
st.session_state.start_pipeline = False
|
| 302 |
+
st.session_state.resume_pipeline = True
|
| 303 |
+
st.rerun()
|
|
|
|
| 304 |
|
| 305 |
if not global_lock.acquire(blocking=False):
|
| 306 |
st.warning("⏳ 有小伙伴正在创作,您在15-20 分钟后就能正常使用啦")
|
|
|
|
| 464 |
|
| 465 |
original_anchor_dir = APP_CONFIG.get('anchor_generation_directive', '')
|
| 466 |
|
|
|
|
| 467 |
if st.session_state.run_mode == "clone":
|
| 468 |
+
length_mandate = "\n[LENGTH MANDATE] The Abstract MUST be extremely comprehensive and detailed. It MUST be at least 80-100 words LONGER than the reference paper's abstract. Aim for 350-500 words. Thoroughly cover the research background, specific methodology, main empirical findings, and theoretical/practical implications."
|
| 469 |
else:
|
| 470 |
+
length_mandate = "\n[LENGTH MANDATE] The Abstract MUST be comprehensive and detailed, containing at least 250-350 words. Thoroughly cover the research background, specific methodology, main empirical findings, and theoretical/practical implications."
|
| 471 |
|
| 472 |
APP_CONFIG['anchor_generation_directive'] = original_anchor_dir + length_mandate
|
| 473 |
|
|
|
|
| 592 |
remaining_sections -= 1
|
| 593 |
continue
|
| 594 |
|
|
|
|
| 595 |
if previous_task:
|
| 596 |
with st.spinner(f"⏳ 正在同步保存上一节【{previous_task['name']}】的翻译状态..."):
|
| 597 |
try:
|
|
|
|
| 759 |
|
| 760 |
future = translation_executor.submit(thread_wrapper, agent, en_draft_clean, trans_ph, target_lang, is_quarantined)
|
| 761 |
|
|
|
|
| 762 |
previous_task = {
|
| 763 |
"name": display_name,
|
| 764 |
"future": future,
|
|
|
|
| 772 |
generation_aborted = True
|
| 773 |
break
|
| 774 |
|
|
|
|
| 775 |
if not generation_aborted and previous_task:
|
| 776 |
with st.spinner(f"⏳ 正在同步保存最后一节【{previous_task['name']}】的翻译状态..."):
|
| 777 |
try:
|