File size: 743 Bytes
ca891cb
 
 
 
39118f8
ca891cb
2ff30a9
ca891cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
from gradio_client import Client
import gradio as gr
import random
import time
import os

client = Client("ShynBui/Vector_db_v3")

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

    def respond(message, chat_history):
        if len(chat_history) == 0:
            chat_history.append(("", ""))
        result = client.predict(
            quote= message,
            history= [chat_history[-1]],
            api_name="/predict"
        )
        bot_message = result[1]
        chat_history.append((result[0], bot_message))
        return "", chat_history

    msg.submit(respond, [msg, chatbot], [msg, chatbot])


if __name__ == "__main__":
    demo.launch(debug=True)