KvrParaskevi commited on
Commit
93c9f45
1 Parent(s): f99b5fc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ with gr.Blocks() as demo:
4
+ chatbot = gr.Chatbot()
5
+ msg = gr.Textbox()
6
+ clear = gr.Button("Clear")
7
+ llm_chain, llm = init_chain(model, tokenizer)
8
+
9
+ def user(user_message, history):
10
+ return "", history + [[user_message, None]]
11
+
12
+ def bot(history):
13
+ print("Question: ", history[-1][0])
14
+ llm_chain.run(question=history[-1][0])
15
+ history[-1][1] = ""
16
+ for character in llm.streamer:
17
+ print(character)
18
+ history[-1][1] += character
19
+ yield history
20
+
21
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)
22
+ clear.click(lambda: None, None, chatbot, queue=False)
23
+
24
+ demo.queue()
25
+ demo.launch()