镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-08 07:26:48 +00:00
availavle version with async
这个提交包含在:
@@ -163,10 +163,7 @@ class ArxivRagWorker:
|
|||||||
try:
|
try:
|
||||||
text = (
|
text = (
|
||||||
f"Paper Title: {fragment.title}\n"
|
f"Paper Title: {fragment.title}\n"
|
||||||
f"Abstract: {fragment.abstract}\n"
|
|
||||||
f"ArXiv ID: {fragment.arxiv_id}\n"
|
|
||||||
f"Section: {fragment.current_section}\n"
|
f"Section: {fragment.current_section}\n"
|
||||||
f"Section Tree: {fragment.section_tree}\n"
|
|
||||||
f"Content: {fragment.content}\n"
|
f"Content: {fragment.content}\n"
|
||||||
f"Bibliography: {fragment.bibliography}\n"
|
f"Bibliography: {fragment.bibliography}\n"
|
||||||
f"Type: FRAGMENT"
|
f"Type: FRAGMENT"
|
||||||
@@ -179,24 +176,6 @@ class ArxivRagWorker:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error processing fragment {index}: {str(e)}")
|
logger.error(f"Error processing fragment {index}: {str(e)}")
|
||||||
raise """处理单个论文片段"""
|
raise """处理单个论文片段"""
|
||||||
try:
|
|
||||||
text = (
|
|
||||||
f"Paper Title: {fragment.title}\n"
|
|
||||||
f"Abstract: {fragment.abstract}\n"
|
|
||||||
f"ArXiv ID: {fragment.arxiv_id}\n"
|
|
||||||
f"Section: {fragment.current_section}\n"
|
|
||||||
f"Section Tree: {fragment.section_tree}\n"
|
|
||||||
f"Content: {fragment.content}\n"
|
|
||||||
f"Bibliography: {fragment.bibliography}\n"
|
|
||||||
f"Type: FRAGMENT"
|
|
||||||
)
|
|
||||||
logger.info(f"Processing fragment {index} for paper {fragment.arxiv_id}")
|
|
||||||
self.rag_worker.add_text_to_vector_store(text)
|
|
||||||
logger.info(f"Successfully added fragment {index} to vector store")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error processing fragment {index}: {str(e)}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
async def process_paper(self, arxiv_id: str) -> bool:
|
async def process_paper(self, arxiv_id: str) -> bool:
|
||||||
"""处理论文主函数"""
|
"""处理论文主函数"""
|
||||||
@@ -362,9 +341,9 @@ def Arxiv论文对话(txt: str, llm_kwargs: Dict, plugin_kwargs: Dict, chatbot:
|
|||||||
if success:
|
if success:
|
||||||
arxiv_id = worker._normalize_arxiv_id(txt)
|
arxiv_id = worker._normalize_arxiv_id(txt)
|
||||||
success = loop.run_until_complete(worker.wait_for_paper(arxiv_id))
|
success = loop.run_until_complete(worker.wait_for_paper(arxiv_id))
|
||||||
if success:
|
# if success:
|
||||||
# 执行自动分析
|
# # 执行自动分析
|
||||||
yield from worker.auto_analyze_paper(chatbot, history, system_prompt)
|
# yield from worker.auto_analyze_paper(chatbot, history, system_prompt)
|
||||||
finally:
|
finally:
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
@@ -379,11 +358,11 @@ def Arxiv论文对话(txt: str, llm_kwargs: Dict, plugin_kwargs: Dict, chatbot:
|
|||||||
# 处理用户询问的情况
|
# 处理用户询问的情况
|
||||||
# 获取用户询问指令
|
# 获取用户询问指令
|
||||||
user_query = plugin_kwargs.get("advanced_arg", "What is the main research question or problem addressed in this paper?")
|
user_query = plugin_kwargs.get("advanced_arg", "What is the main research question or problem addressed in this paper?")
|
||||||
user_query = "What is the main research question or problem addressed in this paper about graph attention network?"
|
if not user_query:
|
||||||
# if not user_query:
|
user_query = "What is the main research question or problem addressed in this paper about graph attention network?"
|
||||||
# chatbot.append((txt, "请提供您的问题。"))
|
# chatbot.append((txt, "请提供您的问题。"))
|
||||||
# yield from update_ui(chatbot=chatbot, history=history)
|
# yield from update_ui(chatbot=chatbot, history=history)
|
||||||
# return
|
# return
|
||||||
|
|
||||||
# 处理历史对话长度
|
# 处理历史对话长度
|
||||||
if len(history) > MAX_HISTORY_ROUND * 2:
|
if len(history) > MAX_HISTORY_ROUND * 2:
|
||||||
@@ -428,7 +407,7 @@ def Arxiv论文对话(txt: str, llm_kwargs: Dict, plugin_kwargs: Dict, chatbot:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 记忆问答对
|
# 记忆问答对
|
||||||
worker.remember_qa(query_to_remember, response)
|
# worker.remember_qa(query_to_remember, response)
|
||||||
history.extend([user_query, response])
|
history.extend([user_query, response])
|
||||||
|
|
||||||
yield from update_ui(chatbot=chatbot, history=history)
|
yield from update_ui(chatbot=chatbot, history=history)
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户