增加prompt收集统计
This commit is contained in:
34
test.py
34
test.py
@ -5,6 +5,7 @@
|
||||
# @Descr :
|
||||
import gradio as gr
|
||||
|
||||
import func_box
|
||||
|
||||
|
||||
class my_class():
|
||||
@ -49,10 +50,41 @@ class ChatBot():
|
||||
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
|
||||
|
||||
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__':
|
||||
ChatBot().draw_test()
|
||||
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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user