From 6bbc10f5b9628d05d6d08d281d507145127f3cef Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 11 Apr 2023 18:12:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A7=E6=80=A5bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/下载arxiv论文翻译摘要.py | 13 +++++++++++-- crazy_functions/总结word文档.py | 3 +-- toolbox.py | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crazy_functions/下载arxiv论文翻译摘要.py b/crazy_functions/下载arxiv论文翻译摘要.py index 566d4c9..f43b897 100644 --- a/crazy_functions/下载arxiv论文翻译摘要.py +++ b/crazy_functions/下载arxiv论文翻译摘要.py @@ -1,7 +1,7 @@ from toolbox import update_ui from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down, get_conf import re, requests, unicodedata, os - +from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive def download_arxiv_(url_pdf): if 'arxiv.org' not in url_pdf: if ('.' in url_pdf) and ('/' not in url_pdf): @@ -172,7 +172,16 @@ def 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, hi yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 msg = '正常' # ** gpt request ** - gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, llm_kwargs, plugin_kwargs, history=[]) # 带超时倒计时 + # 单线,获取文章meta信息 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive( + inputs=i_say, + inputs_show_user=i_say_show_user, + llm_kwargs=llm_kwargs, + chatbot=chatbot, history=[], + sys_prompt="Your job is to collect information from materials and translate to Chinese。", + ) + + # gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, llm_kwargs, plugin_kwargs, history=[]) # 带超时倒计时 chatbot[-1] = (i_say_show_user, gpt_say) history.append(i_say_show_user); history.append(gpt_say) yield from update_ui(chatbot=chatbot, history=chatbot, msg=msg) # 刷新界面 diff --git a/crazy_functions/总结word文档.py b/crazy_functions/总结word文档.py index abf78b8..2c00fbe 100644 --- a/crazy_functions/总结word文档.py +++ b/crazy_functions/总结word文档.py @@ -40,8 +40,7 @@ def 解析docx(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot if not fast_debug: msg = '正常' # ** gpt request ** - gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, llm_kwargs, plugin_kwargs, - history=[]) # 带超时倒计时 + gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, llm_kwargs, plugin_kwargs, history=[]) # 带超时倒计时 chatbot[-1] = (i_say_show_user, gpt_say) history.append(i_say_show_user); history.append(gpt_say) diff --git a/toolbox.py b/toolbox.py index b96fbac..43abdbc 100644 --- a/toolbox.py +++ b/toolbox.py @@ -76,7 +76,7 @@ def get_reduce_token_percent(text): return 0.5, '不详' -def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[], sys_prompt='', long_connection=True): +def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, llm_kwargs, history=[], sys_prompt='', long_connection=True): """ * 此函数未来将被弃用(替代函数 request_gpt_model_in_new_thread_with_ui_alive 文件 chatgpt_academic/crazy_functions/crazy_utils) @@ -102,7 +102,7 @@ def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temp while True: try: mutable[0] = predict_no_ui_long_connection( - inputs=i_say, top_p=top_p, temperature=temperature, history=history, sys_prompt=sys_prompt) + inputs=i_say, llm_kwargs=llm_kwargs, history=history, sys_prompt=sys_prompt) except ConnectionAbortedError as token_exceeded_error: # 尝试计算比例,尽可能多地保留文本