File size: 662 Bytes
8677815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Application file for Gradio App

import gradio as gr
import time
from hay.pipeline import rs_pipeline

with gr.Blocks() as chat:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.ClearButton([msg, chatbot])

    def user(user_message, history):
        return "", history + [[user_message, None]]

    def respond(message, chat_history):
        question = str(message)
        answer = rs_pipeline(question)
        bot_message = answer
        chat_history.append((message, bot_message))
        time.sleep(2)
        return " ", chat_history
    
    msg.submit(respond, [msg, chatbot], [msg, chatbot])

def application():
    chat.launch()