增加prompt 检索和编辑器|增加prompt 展示
This commit is contained in:
48
test.py
48
test.py
@ -39,45 +39,31 @@ class ChatBotFrame:
|
||||
self.description = """代码开源和更新[地址🚀](https://github.com/binary-husky/chatgpt_academic),感谢热情的[开发者们❤️](https://github.com/binary-husky/chatgpt_academic/graphs/contributors)"""
|
||||
|
||||
|
||||
class ChatBot():
|
||||
class ChatBot:
|
||||
def __init__(self):
|
||||
self.demo = gr.Blocks()
|
||||
|
||||
def draw_test(self):
|
||||
with self.demo:
|
||||
# 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})
|
||||
dic = func_box.YamlHandle().load()
|
||||
gr.EventData
|
||||
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
|
||||
|
||||
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()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import gradio as gr
|
||||
|
||||
|
||||
def highlight_text(text, highlights):
|
||||
for h in highlights:
|
||||
text = text.replace(h, f"<span class='highlight' onclick='alert(\"{h}\")'>{h}</span>")
|
||||
return text
|
||||
|
||||
|
||||
app = gr.Interface(
|
||||
fn=highlight_text,
|
||||
inputs=["text", "highlighted_text"],
|
||||
outputs="html",
|
||||
interpretation="default",
|
||||
examples=[["The quick brown fox jumps over the lazy dog.", ["quick", "brown", "fox", "lazy"]]],
|
||||
layout="unaligned",
|
||||
capture_session=True
|
||||
)
|
||||
|
||||
app.launch()
|
||||
ChatBot().draw_test()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user