|
import gradio as gr |
|
|
|
class UI: |
|
@staticmethod |
|
def feedback(data: gr.LikeData): |
|
if data.liked: |
|
print("You upvoted this response: " + data.value) |
|
else: |
|
print("You downvoted this response: " + data.value) |
|
|
|
@staticmethod |
|
def create_demo(): |
|
demo = gr.Blocks(title= "Chatbot", theme="Soft") |
|
with demo: |
|
with gr.Tab("Chat"): |
|
chatbot = gr.Chatbot(value=[], elem_id='chatbot') |
|
chatbot.like(UI.feedback, None, None) |
|
|
|
text_input = gr.Textbox( |
|
show_label=False, |
|
placeholder="Ask me anything!", |
|
container=False) |
|
|
|
clear_btn = gr.Button("🧹 Clear") |
|
with gr.Tab("Prompt"): |
|
ref_docs = gr.Textbox(label='References', lines=25) |
|
|
|
return demo, chatbot, ref_docs, text_input, clear_btn |