Spaces:
Running
Running
Update core/pipeline_agent.py
Browse files- core/pipeline_agent.py +1 -4
core/pipeline_agent.py
CHANGED
|
@@ -245,7 +245,6 @@ class SSciPipelineAgent:
|
|
| 245 |
return full
|
| 246 |
|
| 247 |
def call_deepseek(self, system_prompt, user_prompt, max_tokens=8000, temp=0.3, model_name="deepseek-reasoner"):
|
| 248 |
-
logging.info(f"🚀 [DeepSeek API] 准备调用 {model_name}, 提示词预计 Tokens: {self._count_tokens(user_prompt)}")
|
| 249 |
for attempt in range(3):
|
| 250 |
with self.lock:
|
| 251 |
self.ds_calls += 1
|
|
@@ -446,7 +445,7 @@ class SSciPipelineAgent:
|
|
| 446 |
|
| 447 |
def generate_outline(self, topic, keywords, synthesis_result):
|
| 448 |
sys_prompt = "You are a senior academic journal reviewer. Design a strict empirical research paper outline."
|
| 449 |
-
user_prompt = f
|
| 450 |
for attempt in range(3):
|
| 451 |
plan = self._extract_json_from_text(self.call_deepseek(sys_prompt, user_prompt, temp=0.2))
|
| 452 |
if plan and isinstance(plan, dict) and "structure" in plan:
|
|
@@ -470,7 +469,6 @@ class SSciPipelineAgent:
|
|
| 470 |
|
| 471 |
def _fetch_s2_page(self, search_term, offset=0, limit=50):
|
| 472 |
time.sleep(random.uniform(0.5, 2.0))
|
| 473 |
-
logging.info(f"🔍 [S2 串行检索] 关键词: '{search_term}', Offset: {offset}")
|
| 474 |
headers = {"x-api-key": str(self.s2_key).strip()} if self.s2_key else {}
|
| 475 |
resp = self._requests_get_with_retry(
|
| 476 |
f"{self.s2_api_url}/paper/search",
|
|
@@ -483,7 +481,6 @@ class SSciPipelineAgent:
|
|
| 483 |
|
| 484 |
def _fetch_openalex_page(self, search_term, page, filter_str):
|
| 485 |
time.sleep(random.uniform(1.0, 3.0))
|
| 486 |
-
logging.info(f"🔍 [OpenAlex 串行检索] 关键词: '{search_term}', 页码: {page}")
|
| 487 |
headers = {"User-Agent": f"mailto:ssci_researcher_{random.randint(10000, 99999)}@gmail.com"}
|
| 488 |
if self.openalex_key:
|
| 489 |
headers["Authorization"] = f"Bearer {self.openalex_key}"
|
|
|
|
| 245 |
return full
|
| 246 |
|
| 247 |
def call_deepseek(self, system_prompt, user_prompt, max_tokens=8000, temp=0.3, model_name="deepseek-reasoner"):
|
|
|
|
| 248 |
for attempt in range(3):
|
| 249 |
with self.lock:
|
| 250 |
self.ds_calls += 1
|
|
|
|
| 445 |
|
| 446 |
def generate_outline(self, topic, keywords, synthesis_result):
|
| 447 |
sys_prompt = "You are a senior academic journal reviewer. Design a strict empirical research paper outline."
|
| 448 |
+
user_prompt = f"Topic: {topic}\nKeywords: {keywords}\nSynthesis:\n{synthesis_result}\nReturn ONLY a JSON: {{\"en_topic\": \"...\", \"en_keywords\": \"...\", \"structure\": [{{"section\": \"...\", \"weight\": 0.15, \"is_method_or_result\": false}}]}}"
|
| 449 |
for attempt in range(3):
|
| 450 |
plan = self._extract_json_from_text(self.call_deepseek(sys_prompt, user_prompt, temp=0.2))
|
| 451 |
if plan and isinstance(plan, dict) and "structure" in plan:
|
|
|
|
| 469 |
|
| 470 |
def _fetch_s2_page(self, search_term, offset=0, limit=50):
|
| 471 |
time.sleep(random.uniform(0.5, 2.0))
|
|
|
|
| 472 |
headers = {"x-api-key": str(self.s2_key).strip()} if self.s2_key else {}
|
| 473 |
resp = self._requests_get_with_retry(
|
| 474 |
f"{self.s2_api_url}/paper/search",
|
|
|
|
| 481 |
|
| 482 |
def _fetch_openalex_page(self, search_term, page, filter_str):
|
| 483 |
time.sleep(random.uniform(1.0, 3.0))
|
|
|
|
| 484 |
headers = {"User-Agent": f"mailto:ssci_researcher_{random.randint(10000, 99999)}@gmail.com"}
|
| 485 |
if self.openalex_key:
|
| 486 |
headers["Authorization"] = f"Bearer {self.openalex_key}"
|