Corianas commited on
Commit
562d3e8
1 Parent(s): 89ca527

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -104,28 +104,27 @@ def gen(input):
104
  out = remove_caseifer(generated_text)
105
  return input + out
106
 
107
-
 
 
 
 
 
 
 
 
108
  with gr.Blocks() as demo:
109
  chatbot = gr.Chatbot()
110
  msg = gr.Textbox()
111
  clear = gr.Button("Clear")
112
 
113
- def user(user_message, history):
114
- return gr.update(value="", interactive=False), history + [[user_message, None]]
115
-
116
- def bot(history):
117
- bot_message = gen(history)
118
- history[-1][1] = ""
119
- for character in bot_message:
120
- history[-1][1] += character
121
- time.sleep(0.05)
122
- yield history
123
-
124
- response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
125
- bot, chatbot, chatbot
126
- )
127
- response.then(lambda: gr.update(interactive=True), None, [msg], queue=False)
128
  clear.click(lambda: None, None, chatbot, queue=False)
129
 
130
- demo.queue()
131
- demo.launch()
 
104
  out = remove_caseifer(generated_text)
105
  return input + out
106
 
107
+ md = """This is some code:
108
+
109
+ hello
110
+
111
+ ```py
112
+ def fn(x, y, z):
113
+ print(x, y, z)
114
+ """
115
+
116
  with gr.Blocks() as demo:
117
  chatbot = gr.Chatbot()
118
  msg = gr.Textbox()
119
  clear = gr.Button("Clear")
120
 
121
+ def respond(message, chat_history):
122
+ bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
123
+ chat_history.append((message, md))
124
+ time.sleep(1)
125
+ return "", chat_history
126
+
127
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
 
 
 
 
 
 
 
 
128
  clear.click(lambda: None, None, chatbot, queue=False)
129
 
130
+ demo.launch()