增加auto-gpt0.5版本
This commit is contained in:
89
test.py
89
test.py
@ -3,69 +3,56 @@
|
||||
# @Time : 2023/4/19
|
||||
# @Author : Spike
|
||||
# @Descr :
|
||||
|
||||
|
||||
import gradio as gr
|
||||
|
||||
|
||||
def sentence_builder(quantity, xixi):
|
||||
return f"{quantity}_{xixi}"
|
||||
|
||||
class my_class():
|
||||
|
||||
def __init__(self):
|
||||
self.numb = 0
|
||||
|
||||
def coun_up(self):
|
||||
self.numb += 1
|
||||
|
||||
|
||||
with gr.Blocks() as demo:
|
||||
def set_obj(sts):
|
||||
btn = sts['btn'].update(visible=False)
|
||||
btn2 = sts['btn2'].update(visible=True)
|
||||
sts['obj'] = my_class()
|
||||
return sts, btn, btn2
|
||||
|
||||
txt = gr.Textbox(label="Input", lines=2)
|
||||
txt_2 = gr.CheckboxGroup(['USA', "Japan"], value=['USA'], label='你好呀')
|
||||
txt_3 = gr.Textbox(value="", label="Output")
|
||||
btn = gr.Button(value="Submit")
|
||||
btn.click(sentence_builder, inputs=[txt, txt_2], outputs=[txt_3])
|
||||
|
||||
class ChatGPTForTester:
|
||||
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"<h1 align=\"center\">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 book(self):
|
||||
def draw_test(self):
|
||||
with self.demo:
|
||||
txt = gr.Textbox(label="Input", lines=2)
|
||||
txt_2 = gr.CheckboxGroup(['USA', "Japan"], value=['USA'], label='你好呀')
|
||||
txt_3 = gr.Textbox(value="", label="Output")
|
||||
btn = gr.Button(value="Submit")
|
||||
btn.click(sentence_builder, inputs=[txt, txt_2], outputs=[txt_3])
|
||||
|
||||
def book2(self):
|
||||
with self.demo:
|
||||
txt = gr.Textbox(label="Input", lines=2)
|
||||
txt_2 = gr.CheckboxGroup(['USA', "Japan"], value=['USA'], label='我好呀')
|
||||
txt_3 = gr.Textbox(value="", label="Output")
|
||||
btn = gr.Button(value="Submit")
|
||||
btn.click(sentence_builder, inputs=[txt, txt_2], outputs=[txt_3])
|
||||
|
||||
def main(self):
|
||||
self.book2()
|
||||
self.book()
|
||||
# self.temp = gr.Markdown('')
|
||||
self.txt = gr.Textbox(label="Input", lines=2)
|
||||
self.btn = gr.Button(value="Submit1")
|
||||
self.btn2 = gr.Button(value="Submit2", visible=False)
|
||||
self.obj = gr.State({'obj': None, 'btn': self.btn, 'btn2': self.btn2})
|
||||
self.btn.click(set_obj, inputs=[self.obj], outputs=[self.obj, self.btn, self.btn2])
|
||||
self.btn2.click(print_obj, inputs=[self.obj], outputs=[self.txt])
|
||||
self.demo.launch()
|
||||
|
||||
|
||||
|
||||
class MyClass:
|
||||
|
||||
def __init__(self):
|
||||
self.my_attribute1 = ''
|
||||
|
||||
def __getattribute__(self, name):
|
||||
try:
|
||||
return object.__getattribute__(self, name)
|
||||
except AttributeError:
|
||||
return []
|
||||
|
||||
def my_method(self):
|
||||
self.test = '12312312312'
|
||||
print("This is my method.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
__url = gr.State(f'https://')
|
||||
print(__url)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ChatBot().draw_test()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user