From f0d9098df525535c53fb05c24789ef60303fde44 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 29 Mar 2023 16:47:15 +0800 Subject: [PATCH] dev --- main.py | 12 +++++++++++- toolbox.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6359d36..50ccf30 100644 --- a/main.py +++ b/main.py @@ -93,6 +93,16 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo: try: click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot]) except: pass +# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数 +def auto_opentab_delay(): + import threading, webbrowser, time + print(f"URL http://localhost:{PORT}") + def open(): + time.sleep(2) + webbrowser.open_new_tab(f'http://localhost:{PORT}') + t = threading.Thread(target=open) + t.daemon = True; t.start() +auto_opentab_delay() demo.title = "ChatGPT 学术优化" -demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=True, server_port=PORT, inbrowser=True, auth=AUTHENTICATION) +demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=True, server_port=PORT, auth=AUTHENTICATION) diff --git a/toolbox.py b/toolbox.py index 2aaa82e..9705b9a 100644 --- a/toolbox.py +++ b/toolbox.py @@ -207,7 +207,7 @@ def on_file_uploaded(files, chatbot, txt): 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}\n\n调用路径参数已自动修正到: \n\n{txt}\n\n现在您可以直接选择任意实现性功能']) + f'[Local Message] 收到以下文件: \n\n{moved_files_str}\n\n调用路径参数已自动修正到: \n\n{txt}\n\n现在您点击任意实验功能时,以上文件将被作为输入参数']) return chatbot, txt