From 0f20ffeff45d56cf83797e981708ffbf75c2de21 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Mon, 27 Mar 2023 11:29:11 +0800 Subject: [PATCH] localFileToRemote --- functional_crazy.py | 6 +++++- main.py | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/functional_crazy.py b/functional_crazy.py index 51e5652..5b63f34 100644 --- a/functional_crazy.py +++ b/functional_crazy.py @@ -33,4 +33,8 @@ def get_crazy_functionals(): }, } - +def on_file_uploaded(file): + with open(file[0].name,'r') as f: + print(f.read()) + print('uploaded') + pass diff --git a/main.py b/main.py index 0dd669f..8defd5a 100644 --- a/main.py +++ b/main.py @@ -25,7 +25,7 @@ from functional import get_functionals functional = get_functionals() # 对一些丧心病狂的实验性功能模块进行测试 -from functional_crazy import get_crazy_functionals +from functional_crazy import get_crazy_functionals, on_file_uploaded crazy_functional = get_crazy_functionals() # 处理markdown文本格式的转变 @@ -58,9 +58,17 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo: for k in functional: variant = functional[k]["Color"] if "Color" in functional[k] else "secondary" functional[k]["Button"] = gr.Button(k, variant=variant) + with gr.Row(): + gr.Markdown("Input Directory Functions.") + with gr.Row(): for k in crazy_functional: variant = crazy_functional[k]["Color"] if "Color" in crazy_functional[k] else "secondary" crazy_functional[k]["Button"] = gr.Button(k, variant=variant) + with gr.Row(): + gr.Markdown("Upload Files Functions.") + with gr.Row(): + file_upload = gr.Files(file_count="multiple") + from check_proxy import check_proxy statusDisplay = gr.Markdown(f"{check_proxy(proxies)}") systemPromptTxt = gr.Textbox(show_label=True, placeholder=f"System Prompt", label="System prompt", value=initial_prompt).style(container=True) @@ -77,7 +85,8 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo: for k in crazy_functional: crazy_functional[k]["Button"].click(crazy_functional[k]["Function"], [txt, top_p, temperature, chatbot, history, systemPromptTxt, gr.State(PORT)], [chatbot, history, statusDisplay]) - + file_upload.upload(on_file_uploaded, [file_upload]) + # 延迟函数,做一些准备工作,最后尝试打开浏览器 def auto_opentab_delay(): import threading, webbrowser, time