File size: 903 Bytes
af8db98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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