From b841d58a26c22195fd3660e5c5bb29e2d3132f2f Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Tue, 11 Apr 2023 18:36:38 +0800 Subject: [PATCH] renew all --- crazy_functions/Latex全文润色.py | 2 +- crazy_functions/Latex全文翻译.py | 2 +- crazy_functions/下载arxiv论文翻译摘要.py | 3 +-- crazy_functions/总结word文档.py | 25 ++++++++++++++++------ crazy_functions/批量总结PDF文档.py | 22 ++++++++++++++++--- crazy_functions/批量总结PDF文档pdfminer.py | 23 +++++++++++++++----- crazy_functions/理解PDF文档内容.py | 9 ++++---- crazy_functions/生成函数注释.py | 9 ++++---- crazy_functions/解析项目源代码.py | 4 ++-- crazy_functions/读文章写摘要.py | 7 +++--- 10 files changed, 75 insertions(+), 31 deletions(-) diff --git a/crazy_functions/Latex全文润色.py b/crazy_functions/Latex全文润色.py index 09d84e4..cee3547 100644 --- a/crazy_functions/Latex全文润色.py +++ b/crazy_functions/Latex全文润色.py @@ -1,5 +1,5 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file fast_debug = False class PaperFileGroup(): diff --git a/crazy_functions/Latex全文翻译.py b/crazy_functions/Latex全文翻译.py index 8d2fdb7..c1684b3 100644 --- a/crazy_functions/Latex全文翻译.py +++ b/crazy_functions/Latex全文翻译.py @@ -1,5 +1,5 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file fast_debug = False class PaperFileGroup(): diff --git a/crazy_functions/下载arxiv论文翻译摘要.py b/crazy_functions/下载arxiv论文翻译摘要.py index 7ae1ace..56ec400 100644 --- a/crazy_functions/下载arxiv论文翻译摘要.py +++ b/crazy_functions/下载arxiv论文翻译摘要.py @@ -1,5 +1,5 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down, get_conf +from toolbox import CatchException, report_execption, write_results_to_file, 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): @@ -181,7 +181,6 @@ def 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, hi 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, 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 2c6cbc0..4a3f7c9 100644 --- a/crazy_functions/总结word文档.py +++ b/crazy_functions/总结word文档.py @@ -1,5 +1,6 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file +from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive fast_debug = False @@ -40,9 +41,16 @@ 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, history=[]) # 带超时倒计时 + 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="总结文章。" + ) # 带超时倒计时 chatbot[-1] = (i_say_show_user, gpt_say) - history.append(i_say_show_user); + history.append(i_say_show_user) history.append(gpt_say) yield from update_ui(chatbot=chatbot, history=chatbot, msg=msg) # 刷新界面 if not fast_debug: time.sleep(2) @@ -65,9 +73,14 @@ 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, chatbot, llm_kwargs, - history=history) # 带超时倒计时 - + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive( + inputs=i_say, + inputs_show_user=i_say, + llm_kwargs=llm_kwargs, + chatbot=chatbot, + history=history, + sys_prompt="总结文章。" + ) # 带超时倒计时 chatbot[-1] = (i_say, gpt_say) history.append(i_say) history.append(gpt_say) diff --git a/crazy_functions/批量总结PDF文档.py b/crazy_functions/批量总结PDF文档.py index 9c6b71a..9f5b0d4 100644 --- a/crazy_functions/批量总结PDF文档.py +++ b/crazy_functions/批量总结PDF文档.py @@ -1,8 +1,9 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file import re import unicodedata fast_debug = False +from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive def is_paragraph_break(match): """ @@ -77,7 +78,15 @@ def 解析PDF(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, history=[]) # 带超时倒计时 + 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="总结文章。" + ) # 带超时倒计时 + chatbot[-1] = (i_say_show_user, gpt_say) history.append(i_say_show_user); history.append(gpt_say) @@ -92,7 +101,14 @@ def 解析PDF(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, chatbot, llm_kwargs, history=history) # 带超时倒计时 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive( + inputs=i_say, + inputs_show_user=i_say, + llm_kwargs=llm_kwargs, + chatbot=chatbot, + history=history, + sys_prompt="总结文章。" + ) # 带超时倒计时 chatbot[-1] = (i_say, gpt_say) history.append(i_say); history.append(gpt_say) diff --git a/crazy_functions/批量总结PDF文档pdfminer.py b/crazy_functions/批量总结PDF文档pdfminer.py index ea79017..b6a1ad1 100644 --- a/crazy_functions/批量总结PDF文档pdfminer.py +++ b/crazy_functions/批量总结PDF文档pdfminer.py @@ -1,5 +1,6 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file +from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive fast_debug = False @@ -82,8 +83,14 @@ def 解析Paper(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo 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, history=[]) # 带超时倒计时 - + 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="总结文章。" + ) # 带超时倒计时 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) # 刷新界面 @@ -97,8 +104,14 @@ def 解析Paper(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo if not fast_debug: msg = '正常' # ** gpt request ** - gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, llm_kwargs, history=history) # 带超时倒计时 - + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive( + inputs=i_say, + inputs_show_user=i_say, + llm_kwargs=llm_kwargs, + chatbot=chatbot, + history=history, + sys_prompt="总结文章。" + ) # 带超时倒计时 chatbot[-1] = (i_say, gpt_say) history.append(i_say); history.append(gpt_say) yield from update_ui(chatbot=chatbot, history=chatbot, msg=msg) # 刷新界面 diff --git a/crazy_functions/理解PDF文档内容.py b/crazy_functions/理解PDF文档内容.py index b7d83ce..a9278e8 100644 --- a/crazy_functions/理解PDF文档内容.py +++ b/crazy_functions/理解PDF文档内容.py @@ -1,7 +1,8 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption import re import unicodedata +from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive fast_debug = False def is_paragraph_break(match): @@ -81,11 +82,11 @@ def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_pro i_say = f'你只需要回答“接受完成”。文章内容第{i+1}/{split_group}部分是 ```{file_content[i*split_number:(i+1)*split_number]}```' i_say_show_user = f'当前发送{i+1}/{split_group}部分' chatbot.append((i_say_show_user, "[Local Message] waiting gpt response.")) - gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, llm_kwargs, history=[]) # 带超时倒计时 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(i_say, i_say_show_user, llm_kwargs, chatbot, history=[], sys_prompt="") # 带超时倒计时 while "完成" not in gpt_say: i_say = f'你只需要回答“接受完成”。文章内容第{i+1}/{split_group}部分是 ```{file_content[i*split_number:(i+1)*split_number]}```' i_say_show_user = f'出现error,重新发送{i+1}/{split_group}部分' - gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, llm_kwargs, history=[]) # 带超时倒计时 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(i_say, i_say_show_user, llm_kwargs, chatbot, history=[], sys_prompt="") # 带超时倒计时 time.sleep(1) chatbot[-1] = (i_say_show_user, gpt_say) history.append(i_say_show_user); history.append(gpt_say) @@ -97,7 +98,7 @@ def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_pro yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # ** gpt request ** - gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, llm_kwargs, history=history) # 带超时倒计时 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(i_say, i_say, llm_kwargs, chatbot, history=history, sys_prompt="") # 带超时倒计时 chatbot[-1] = (i_say, gpt_say) history.append(i_say); history.append(gpt_say) yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 diff --git a/crazy_functions/生成函数注释.py b/crazy_functions/生成函数注释.py index 00f5937..852fef8 100644 --- a/crazy_functions/生成函数注释.py +++ b/crazy_functions/生成函数注释.py @@ -1,10 +1,10 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file +from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive fast_debug = False - def 生成函数注释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt): - import time, glob, os + import time, os print('begin analysis on:', file_manifest) for index, fp in enumerate(file_manifest): with open(fp, 'r', encoding='utf-8') as f: @@ -18,7 +18,8 @@ def 生成函数注释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, 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, history=[]) # 带超时倒计时 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive( + i_say, i_say_show_user, llm_kwargs, chatbot, history=[], sys_prompt=system_prompt) # 带超时倒计时 chatbot[-1] = (i_say_show_user, gpt_say) history.append(i_say_show_user); history.append(gpt_say) diff --git a/crazy_functions/解析项目源代码.py b/crazy_functions/解析项目源代码.py index 6e4b128..a35cd8c 100644 --- a/crazy_functions/解析项目源代码.py +++ b/crazy_functions/解析项目源代码.py @@ -1,10 +1,10 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt): import os, copy from .crazy_utils import request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency - from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive, WithRetry + from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive msg = '正常' inputs_array = [] inputs_show_user_array = [] diff --git a/crazy_functions/读文章写摘要.py b/crazy_functions/读文章写摘要.py index 721f8b1..d1e4ee3 100644 --- a/crazy_functions/读文章写摘要.py +++ b/crazy_functions/读文章写摘要.py @@ -1,5 +1,6 @@ from toolbox import update_ui -from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down +from toolbox import CatchException, report_execption, write_results_to_file +from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive fast_debug = False @@ -19,7 +20,7 @@ def 解析Paper(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo 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, history=[]) # 带超时倒计时 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(i_say, i_say_show_user, llm_kwargs, chatbot, history=[], sys_prompt=system_prompt) # 带超时倒计时 chatbot[-1] = (i_say_show_user, gpt_say) history.append(i_say_show_user); history.append(gpt_say) @@ -34,7 +35,7 @@ def 解析Paper(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo if not fast_debug: msg = '正常' # ** gpt request ** - gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, llm_kwargs, history=history) # 带超时倒计时 + gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(i_say, i_say, llm_kwargs, chatbot, history=history, sys_prompt=system_prompt) # 带超时倒计时 chatbot[-1] = (i_say, gpt_say) history.append(i_say); history.append(gpt_say)