From c6942060e49b3540eb415541060fd1fde0390fd3 Mon Sep 17 00:00:00 2001 From: w_xiaolizu Date: Wed, 19 Apr 2023 21:50:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=98=BE=E7=A4=BA=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E5=8A=9F=E8=83=BD=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __main__.py | 19 ++----------------- toolbox.py | 13 ++++--------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/__main__.py b/__main__.py index 09d0b8d..b0ef843 100644 --- a/__main__.py +++ b/__main__.py @@ -17,7 +17,7 @@ if not AUTHENTICATION: AUTHENTICATION = None from check_proxy import get_current_version initial_prompt = "Serve me as a writing and programming assistant." -title_html = f"

ChatGPT 学术优化 {get_current_version()}

" +title_html = f"

ChatGPT For Tester {get_current_version()}

" description = """代码开源和更新[地址🚀](https://github.com/binary-husky/chatgpt_academic),感谢热情的[开发者们❤️](https://github.com/binary-husky/chatgpt_academic/graphs/contributors)""" # 问询记录, python 版本建议3.9+(越新越好) @@ -128,27 +128,12 @@ with gr.Blocks(title="ChatGPT 学术优化", theme=set_theme, analytics_enabled= models_box = gr.CheckboxGroup(["input加密"], value=["input加密"], label="对话模式") - checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区"], - value=["基础功能区", "函数插件区"], label="显示/隐藏功能区") md_dropdown = gr.Dropdown(AVAIL_LLM_MODELS, value=LLM_MODEL, label="更换LLM模型/请求源").style( container=False) gr.Markdown(description) - # 功能区显示开关与功能区的互动 - def fn_area_visibility(a): - ret = {} - ret.update({area_basic_fn: gr.update(visible=("基础功能区" in a))}) - ret.update({area_crazy_fn: gr.update(visible=("函数插件区" in a))}) - ret.update({area_input_primary: gr.update(visible=("底部输入区" not in a))}) - # ret.update({area_input_secondary: gr.update(visible=("底部输入区" in a))}) - if "底部输入区" in a: ret.update({txt: gr.update(value="")}) - return ret - - - checkboxes.select(fn_area_visibility, [checkboxes], - [area_basic_fn, area_crazy_fn, area_input_primary, txt]) # 整理反复出现的控件句柄组合 # submitBtn.info input_combo = [cookies, max_length_sl, md_dropdown, txt, top_p, temperature, chatbot, history, system_prompt, models_box] @@ -165,7 +150,7 @@ with gr.Blocks(title="ChatGPT 学术优化", theme=set_theme, analytics_enabled= outputs=output_combo) cancel_handles.append(click_handle) # 文件上传区,接收文件后与chatbot的互动 - file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt, checkboxes], [chatbot, txt]) + file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt], [chatbot, txt]) # 函数插件-固定按钮区 for k in crazy_fns: if not crazy_fns[k].get("AsButton", True): continue diff --git a/toolbox.py b/toolbox.py index 08dec2d..1fda556 100644 --- a/toolbox.py +++ b/toolbox.py @@ -378,7 +378,7 @@ def find_recent_files(directory): return recent_files -def on_file_uploaded(files, chatbot, txt, checkboxes): +def on_file_uploaded(files, chatbot, txt): if len(files) == 0: return chatbot, txt import shutil @@ -400,18 +400,13 @@ def on_file_uploaded(files, chatbot, txt, checkboxes): dest_dir=f'private_upload/{time_tag}/{file_origin_name}.extract') moved_files = [fp for fp in glob.glob( 'private_upload/**/*', recursive=True)] - if "底部输入区" in checkboxes: - txt = "" - txt2 = f'private_upload/{time_tag}' - else: - txt = f'private_upload/{time_tag}' - txt2 = "" + txt = f'private_upload/{time_tag}' moved_files_str = '\t\n\n'.join(moved_files) chatbot.append(['我上传了文件,请查收', f'[Local Message] 收到以下文件: \n\n{moved_files_str}' + f'\n\n调用路径参数已自动修正到: \n\n{txt}' + - f'\n\n现在您点击任意“红颜色”标识的函数插件时,以上文件将被作为输入参数'+err_msg]) - return chatbot, txt, txt2 + f'\n\n现在您点击任意“高亮”标识的函数插件时,以上文件将被作为输入参数'+err_msg]) + return chatbot, txt def on_report_generated(files, chatbot):