From e6c4bf1881ae6113c7168013209377eae1973ef1 Mon Sep 17 00:00:00 2001 From: w_xiaolizu Date: Tue, 16 May 2023 11:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E7=BA=A7=E7=94=A8=E6=B3=95=E7=9A=84?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=8A=A0=E5=85=A5=E4=B8=8B=E6=8B=89=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + __main__.py | 10 +++-- test.py | 115 ---------------------------------------------------- 3 files changed, 8 insertions(+), 118 deletions(-) delete mode 100644 test.py diff --git a/.gitignore b/.gitignore index 93b0c51..34af516 100644 --- a/.gitignore +++ b/.gitignore @@ -151,3 +151,4 @@ crazy_functions/test_samples request_llm/jittorllms !prompt_users/.keep prompt_users/* +.__test.py diff --git a/__main__.py b/__main__.py index 8f30ed7..03668af 100644 --- a/__main__.py +++ b/__main__.py @@ -187,8 +187,12 @@ class ChatBot(ChatBotFrame): crazy_fns[k]["Button"] = gr.Button(k, variant=self.variant) crazy_fns[k]["Button"].style(size="sm") with gr.Accordion("更多函数插件/高级用法", open=False): - dropdown_fn_list = [k for k in crazy_fns.keys() if - not crazy_fns[k].get("AsButton", True)] + dropdown_fn_list = [] + for k in crazy_fns.keys(): + if not crazy_fns[k].get("AsButton", True): + dropdown_fn_list.append(k) + elif crazy_fns[k].get('AdvancedArgs', False): + dropdown_fn_list.append(k) self.dropdown = gr.Dropdown(dropdown_fn_list, value=r"打开插件列表", label="").style( container=False) self.plugin_advanced_arg = gr.Textbox(show_label=True, label="高级参数输入区", visible=False, @@ -217,7 +221,7 @@ class ChatBot(ChatBotFrame): # temp = gr.Markdown(self.description) def draw_goals_auto(self): - with gr.Tab('Ai Prompt--未完成的作品--敬请期待---'): + with gr.Tab('Ai Prompt--未完成--敬请期待'): with gr.Row(): self.ai_name = gr.Textbox(show_label=False, placeholder="给Ai一个名字").style(container=False) with gr.Row(): diff --git a/test.py b/test.py deleted file mode 100644 index 3594dea..0000000 --- a/test.py +++ /dev/null @@ -1,115 +0,0 @@ -#! .\venv\ -# encoding: utf-8 -# @Time : 2023/4/19 -# @Author : Spike -# @Descr : -import gradio as gr - -import func_box - - -class my_class(): - - def __init__(self): - self.numb = 0 - - def coun_up(self): - self.numb += 1 - - -def set_obj(sts): - btn = sts['btn'].update(visible=False) - btn2 = sts['btn2'].update(visible=True) - sts['obj'] = my_class() - return sts, btn, btn2 - - -def print_obj(sts): - print(sts) - print(sts['btn'], type(sts['btn'])) - sts['obj'].coun_up() - print(sts['obj'].numb) - -class ChatBotFrame: - - def __init__(self): - self.cancel_handles = [] - self.initial_prompt = "Serve me as a writing and programming assistant." - self.title_html = f"

ChatGPT For Tester" - self.description = """代码开源和更新[地址🚀](https://github.com/binary-husky/chatgpt_academic),感谢热情的[开发者们❤️](https://github.com/binary-husky/chatgpt_academic/graphs/contributors)""" - - -class ChatBot: - def __init__(self): - self.demo = gr.Blocks() - - def draw_test(self): - with self.demo: - with gr.Tab('122121', id='add_') as self.tab1: - self.txt = gr.Textbox(label="Input", lines=2) - self.btn = gr.Button(value="Submit1") - self.pro_prompt_list = gr.Dataset(components=[gr.HTML(visible=False)], samples_per_page=10,label="Prompt usage frequency", - samples=[['None'],['None'],['None'],['None'],['None'],['None'],['None'],['None'],['None'],['None'],['None'],], type='index') - self.list_staus = gr.State(self.pro_prompt_list) - self.tab_state = gr.State(self.tab1) - self.btn.click(fn=self.on_button_click, inputs=[self.tab_state], outputs=[self.tab1]) - self.demo.launch() - - # Add a new input textbox when self.btn is clicked - def on_button_click(self, tab): - tab.children.append(gr.Button(value="Submit2")) - return tab - - -if __name__ == '__main__': - from flask import Flask, render_template - import gradio as gr - - app = Flask(__name__) - - - # 第一个 Gradio 实例,用于页面1 - def greet(name): - return f"Hello, {name}!" - - - gr_interface1 = gr.Interface(fn=greet, inputs="text", outputs="text") - - - # 第二个 Gradio 实例,用于页面2 - def square(x): - return x * x - - - gr_interface2 = gr.Interface(fn=square, inputs="number", outputs="number") - - - @app.route('/') - def index(): - return render_template('index.html') - - - @app.route('/page1') - def page1(): - return gr_interface1.launch() - - - @app.route('/page2') - def page2(): - return gr_interface2.launch() - - - if __name__ == '__main__': - app.run() - - - - - - - - - - - -