ShynBui commited on
Commit
ca891cb
·
verified ·
1 Parent(s): 5b9c908

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from gradio_client import Client
2
+ import gradio as gr
3
+ import random
4
+ import time
5
+
6
+ client = Client("ShynBui/Vector_db_v2")
7
+
8
+ with gr.Blocks() as demo:
9
+ chatbot = gr.Chatbot()
10
+ msg = gr.Textbox()
11
+ clear = gr.ClearButton([msg, chatbot])
12
+
13
+ def respond(message, chat_history):
14
+ if len(chat_history) == 0:
15
+ chat_history.append(("", ""))
16
+ result = client.predict(
17
+ quote= message,
18
+ history= [chat_history[-1]],
19
+ api_name="/predict"
20
+ )
21
+ bot_message = result[1]
22
+ chat_history.append((result[0], bot_message))
23
+ return "", chat_history
24
+
25
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
26
+
27
+
28
+ if __name__ == "__main__":
29
+ demo.launch(debug=True)