镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 06:26:47 +00:00
pre
这个提交包含在:
@@ -364,6 +364,24 @@ def Latex翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot,
|
|||||||
chatbot=chatbot, history=history)
|
chatbot=chatbot, history=history)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# allow_cloud_io = True
|
||||||
|
# arxiv_id = "2203.01927"
|
||||||
|
# if allow_cloud_io and arxiv_id:
|
||||||
|
# # 如果用户允许,我们将arxiv论文PDF上传到云端
|
||||||
|
# for file_path in chatbot._cookies.get("files_to_promote", []):
|
||||||
|
# if file_path.endswith('comparison.pdf'):
|
||||||
|
# def compute_hash(file_path):
|
||||||
|
# return map_file_to_sha256(file_path)
|
||||||
|
# with open(file_path, 'rb') as f:
|
||||||
|
# import requests
|
||||||
|
# url = 'https://cloud-2.agent-matrix.com/upload'
|
||||||
|
# files = {'file': (file_path, f, 'application/octet-stream')}
|
||||||
|
# data = {
|
||||||
|
# 'arxiv_id': arxiv_id,
|
||||||
|
# 'file_hash': compute_hash(file_path),
|
||||||
|
# }
|
||||||
|
# resp = requests.get(url=url, files=files, data=data, timeout=10)
|
||||||
|
|
||||||
if txt.endswith('.pdf'):
|
if txt.endswith('.pdf'):
|
||||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"发现已经存在翻译好的PDF文档")
|
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"发现已经存在翻译好的PDF文档")
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
@@ -406,14 +424,34 @@ def Latex翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot,
|
|||||||
# <-------------- zip PDF ------------->
|
# <-------------- zip PDF ------------->
|
||||||
zip_res = zip_result(project_folder)
|
zip_res = zip_result(project_folder)
|
||||||
if success:
|
if success:
|
||||||
|
allow_cloud_io = True
|
||||||
|
arxiv_id = "2203.01927"
|
||||||
|
if allow_cloud_io and arxiv_id:
|
||||||
|
# 如果用户允许,我们将arxiv论文PDF上传到云端
|
||||||
|
for file_path in chatbot._cookies.get("files_to_promote", []):
|
||||||
|
if file_path.endswith('translate_zh.pdf') or file_path.endswith('comparison.pdf'):
|
||||||
|
def compute_hash(file_path):
|
||||||
|
return map_file_to_sha256(file_path)
|
||||||
|
with open(file_path, 'rb') as f:
|
||||||
|
import requests
|
||||||
|
url = 'https://cloud-2.agent-matrix.com/upload'
|
||||||
|
files = {'file': (file_path, f, 'application/octet-stream')}
|
||||||
|
data = {
|
||||||
|
'arxiv_id': arxiv_id,
|
||||||
|
'file_hash': compute_hash(file_path),
|
||||||
|
}
|
||||||
|
resp = requests.post(url=url, files=files, data=data, timeout=10)
|
||||||
|
|
||||||
|
|
||||||
chatbot.append((f"成功啦", '请查收结果(压缩包)...'))
|
chatbot.append((f"成功啦", '请查收结果(压缩包)...'))
|
||||||
yield from update_ui(chatbot=chatbot, history=history);
|
yield from update_ui(chatbot=chatbot, history=history)
|
||||||
time.sleep(1) # 刷新界面
|
time.sleep(1) # 刷新界面
|
||||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
chatbot.append((f"失败了",
|
chatbot.append((f"失败了",
|
||||||
'虽然PDF生成失败了, 但请查收结果(压缩包), 内含已经翻译的Tex文档, 您可以到Github Issue区, 用该压缩包进行反馈。如系统是Linux,请检查系统字体(见Github wiki) ...'))
|
'虽然PDF生成失败了, 但请查收结果(压缩包), 内含已经翻译的Tex文档, 您可以到Github Issue区, 用该压缩包进行反馈。如系统是Linux,请检查系统字体(见Github wiki) ...'))
|
||||||
yield from update_ui(chatbot=chatbot, history=history);
|
yield from update_ui(chatbot=chatbot, history=history)
|
||||||
time.sleep(1) # 刷新界面
|
time.sleep(1) # 刷新界面
|
||||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||||
|
|
||||||
|
|||||||
@@ -423,6 +423,9 @@ def 编译Latex(chatbot, history, main_file_original, main_file_modified, work_f
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return True # 成功啦
|
return True # 成功啦
|
||||||
else:
|
else:
|
||||||
if n_fix>=max_try: break
|
if n_fix>=max_try: break
|
||||||
|
|||||||
@@ -19,4 +19,5 @@ if __name__ == "__main__":
|
|||||||
plugin_test = importlib.import_module('test_utils').plugin_test
|
plugin_test = importlib.import_module('test_utils').plugin_test
|
||||||
|
|
||||||
|
|
||||||
plugin_test(plugin='crazy_functions.Latex_Function->Latex翻译中文并重新编译PDF', main_input="2203.01927")
|
# plugin_test(plugin='crazy_functions.Latex_Function->Latex翻译中文并重新编译PDF', main_input="2203.01927")
|
||||||
|
plugin_test(plugin='crazy_functions.Latex_Function->Latex翻译中文并重新编译PDF', main_input="gpt_log/arxiv_cache/2203.01927/workfolder")
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户