Skip to content

Commit edbe98a

Browse files
committed
Merge branch 'GHSA-3jw4-f3wg-xr4c'
2 parents eac5191 + fac52ed commit edbe98a

File tree

2 files changed

+29
-39
lines changed

2 files changed

+29
-39
lines changed

crazy_functions/Latex输出PDF.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def is_float(s):
107107
except ValueError:
108108
return False
109109

110+
if txt.startswith('https://arxiv.org/pdf/'):
111+
arxiv_id = txt.split('/')[-1] # 2402.14207v2.pdf
112+
txt = arxiv_id.split('v')[0] # 2402.14207
113+
110114
if ('.' in txt) and ('/' not in txt) and is_float(txt): # is arxiv ID
111115
txt = 'https://arxiv.org/abs/' + txt.strip()
112116
if ('.' in txt) and ('/' not in txt) and is_float(txt[:10]): # is arxiv ID
@@ -121,6 +125,7 @@ def is_float(s):
121125
time.sleep(1) # 刷新界面
122126

123127
url_ = txt # https://arxiv.org/abs/1707.06690
128+
124129
if not txt.startswith('https://arxiv.org/abs/'):
125130
msg = f"解析arxiv网址失败, 期望格式例如: https://arxiv.org/abs/1707.06690。实际得到格式: {url_}。"
126131
yield from update_ui_lastest_msg(msg, chatbot=chatbot, history=history) # 刷新界面
@@ -458,23 +463,23 @@ def PDF翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, h
458463
promote_file_to_downloadzone(translate_pdf, rename_file=None, chatbot=chatbot)
459464

460465
comparison_pdf = [f for f in glob.glob(f'{project_folder}/**/comparison.pdf', recursive=True)][0]
461-
promote_file_to_downloadzone(comparison_pdf, rename_file=None, chatbot=chatbot)
466+
promote_file_to_downloadzone(comparison_pdf, rename_file=None, chatbot=chatbot)
462467

463468
zip_res = zip_result(project_folder)
464469
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
465470

466471
return True
467-
472+
468473
except:
469474
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"发现重复上传,但是无法找到相关文件")
470475
yield from update_ui(chatbot=chatbot, history=history)
471-
476+
472477
chatbot.append([f"没有相关文件", '尝试重新翻译PDF...'])
473478
yield from update_ui(chatbot=chatbot, history=history)
474479

475480
except_flag = True
476-
477-
481+
482+
478483
elif not repeat or except_flag:
479484
yield from update_ui_lastest_msg(f"未发现重复上传", chatbot=chatbot, history=history)
480485

crazy_functions/latex_fns/latex_actions.py

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -259,40 +259,25 @@ def Latex精细分解与转化(file_manifest, project_folder, llm_kwargs, plugin
259259
inputs_array, sys_prompt_array = switch_prompt(pfg, mode)
260260
inputs_show_user_array = [f"{mode} {f}" for f in pfg.sp_file_tag]
261261

262-
if os.path.exists(pj(project_folder,'temp.pkl')):
263-
264-
# <-------- 【仅调试】如果存在调试缓存文件,则跳过GPT请求环节 ---------->
265-
pfg = objload(file=pj(project_folder,'temp.pkl'))
266-
267-
else:
268-
# <-------- gpt 多线程请求 ---------->
269-
history_array = [[""] for _ in range(n_split)]
270-
# LATEX_EXPERIMENTAL, = get_conf('LATEX_EXPERIMENTAL')
271-
# if LATEX_EXPERIMENTAL:
272-
# paper_meta = f"The paper you processing is `{lps.title}`, a part of the abstraction is `{lps.abstract}`"
273-
# paper_meta_max_len = 888
274-
# history_array = [[ paper_meta[:paper_meta_max_len] + '...', "Understand, what should I do?"] for _ in range(n_split)]
275-
276-
gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
277-
inputs_array=inputs_array,
278-
inputs_show_user_array=inputs_show_user_array,
279-
llm_kwargs=llm_kwargs,
280-
chatbot=chatbot,
281-
history_array=history_array,
282-
sys_prompt_array=sys_prompt_array,
283-
# max_workers=5, # 并行任务数量限制, 最多同时执行5个, 其他的排队等待
284-
scroller_max_len = 40
285-
)
286-
287-
# <-------- 文本碎片重组为完整的tex片段 ---------->
288-
pfg.sp_file_result = []
289-
for i_say, gpt_say, orig_content in zip(gpt_response_collection[0::2], gpt_response_collection[1::2], pfg.sp_file_contents):
290-
pfg.sp_file_result.append(gpt_say)
291-
pfg.merge_result()
292-
293-
# <-------- 临时存储用于调试 ---------->
294-
pfg.get_token_num = None
295-
objdump(pfg, file=pj(project_folder,'temp.pkl'))
262+
# <-------- gpt 多线程请求 ---------->
263+
history_array = [[""] for _ in range(n_split)]
264+
265+
gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
266+
inputs_array=inputs_array,
267+
inputs_show_user_array=inputs_show_user_array,
268+
llm_kwargs=llm_kwargs,
269+
chatbot=chatbot,
270+
history_array=history_array,
271+
sys_prompt_array=sys_prompt_array,
272+
# max_workers=5, # 并行任务数量限制, 最多同时执行5个, 其他的排队等待
273+
scroller_max_len = 40
274+
)
275+
276+
# <-------- 文本碎片重组为完整的tex片段 ---------->
277+
pfg.sp_file_result = []
278+
for i_say, gpt_say, orig_content in zip(gpt_response_collection[0::2], gpt_response_collection[1::2], pfg.sp_file_contents):
279+
pfg.sp_file_result.append(gpt_say)
280+
pfg.merge_result()
296281

297282
write_html(pfg.sp_file_contents, pfg.sp_file_result, chatbot=chatbot, project_folder=project_folder)
298283

0 commit comments

Comments
 (0)