GuXiaopeng commited on
Commit
33e9cec
·
verified ·
1 Parent(s): 5fd44b0

Update core/pipeline_agent.py

Browse files
Files changed (1) hide show
  1. core/pipeline_agent.py +23 -5
core/pipeline_agent.py CHANGED
@@ -461,11 +461,29 @@ class SSciPipelineAgent:
461
 
462
  def generate_anchors(self, topic, keywords, synthesis_result, refs_text):
463
  sys_prompt = "You are a senior scholar conceptualizing a high-impact empirical paper."
464
- user_prompt = f"Topic: {topic}\nKeywords: {keywords}\nLiterature Synthesis:\n{synthesis_result}\nCitation Context:\n{refs_text[:3000]}\n{APP_CONFIG['anchor_generation_directive']}"
465
- response = self.call_deepseek(sys_prompt, user_prompt, max_tokens=1500, temp=0.3)
466
- abstract_match = re.search(r'---ABSTRACT---\s*(.*?)\s*---CONCLUSION---', response, re.DOTALL | re.IGNORECASE)
467
- conclusion_match = re.search(r'---CONCLUSION---\s*(.*?)$', response, re.DOTALL | re.IGNORECASE)
468
- return (abstract_match.group(1).strip() if abstract_match else ""), (conclusion_match.group(1).strip() if conclusion_match else "")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
 
470
  def generate_outline(self, topic, keywords, synthesis_result):
471
  sys_prompt = "You are a senior academic journal reviewer. Design a strict empirical research paper outline."
 
461
 
462
  def generate_anchors(self, topic, keywords, synthesis_result, refs_text):
463
  sys_prompt = "You are a senior scholar conceptualizing a high-impact empirical paper."
464
+
465
+ # [核心修复 1] 强制格式指令:无视前端选择的风格,底层强制规定分隔符
466
+ format_mandate = """\n\n[CRITICAL FORMAT MANDATE]
467
+ You MUST output your response EXACTLY using the following two delimiters. Do not add Markdown headings like ## before them:
468
+ ---ABSTRACT---
469
+ (Write the comprehensive abstract here)
470
+ ---CONCLUSION---
471
+ (Write the expected conclusion here)"""
472
+
473
+ base_directive = APP_CONFIG.get('anchor_generation_directive', '')
474
+ user_prompt = f"Topic: {topic}\nKeywords: {keywords}\nLiterature Synthesis:\n{synthesis_result}\nCitation Context:\n{refs_text[:3000]}\n{base_directive}{format_mandate}"
475
+
476
+ response = self.call_deepseek(sys_prompt, user_prompt, max_tokens=1500, temp=0.3, model_name="deepseek-reasoner")
477
+
478
+ # [核心修复 2] 增强正则提取的容错率(允许破折号数量和空格变化)
479
+ abstract_match = re.search(r'-+\s*ABSTRACT\s*-+\s*(.*?)(?=\s*-+\s*CONCLUSION\s*-+|$)', response, re.DOTALL | re.IGNORECASE)
480
+ conclusion_match = re.search(r'-+\s*CONCLUSION\s*-+\s*(.*?)$', response, re.DOTALL | re.IGNORECASE)
481
+
482
+ # [核心修复 3] 终极兜底:如果全盘失效,强制将所有返回文本当作摘要,绝不留白
483
+ final_abstract = abstract_match.group(1).strip() if abstract_match else response.strip()
484
+ final_conclusion = conclusion_match.group(1).strip() if conclusion_match else ""
485
+
486
+ return final_abstract, final_conclusion
487
 
488
  def generate_outline(self, topic, keywords, synthesis_result):
489
  sys_prompt = "You are a senior academic journal reviewer. Design a strict empirical research paper outline."