DDDDEvvvvv commited on
Commit
a1dce44
·
verified ·
1 Parent(s): 31868a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -16,7 +16,12 @@ def respond(message, chat_history):
16
  outputs = model.generate(inputs, max_length=200, pad_token_id=tokenizer.eos_token_id)
17
  response_text = tokenizer.decode(outputs[:, inputs.shape[-1]:][0], skip_special_tokens=True)
18
  history.append({"role": "assistant", "content": response_text})
19
- return history, "" # reset input box
 
 
 
 
 
20
 
21
  with gr.Blocks(css="""
22
  body {background-color: #000 !important; color: #fff !important;}
@@ -25,12 +30,13 @@ body {background-color: #000 !important; color: #fff !important;}
25
  .gr-chatbot .message.bot {border-color: #aaa; background-color: transparent !important;}
26
  .gr-textbox textarea {background-color: transparent !important; color: #fff !important; border: 1px solid #555 !important;}
27
  .gr-textbox textarea::selection {background-color: #0ff !important; color: #000 !important;}
28
- .gr-button {display: none !important;}
29
  footer {display: none !important;}
30
  """) as demo:
31
- chatbot = gr.Chatbot(label="DevMegaBlack AI Chat")
32
  msg = gr.Textbox(placeholder="Say something...")
 
33
  msg.submit(respond, [msg, chatbot], [chatbot, msg])
 
34
 
35
  demo.launch()
36
-
 
16
  outputs = model.generate(inputs, max_length=200, pad_token_id=tokenizer.eos_token_id)
17
  response_text = tokenizer.decode(outputs[:, inputs.shape[-1]:][0], skip_special_tokens=True)
18
  history.append({"role": "assistant", "content": response_text})
19
+ return history, ""
20
+
21
+ def reset_chat():
22
+ global history
23
+ history = []
24
+ return [], "" # clears chatbox and input
25
 
26
  with gr.Blocks(css="""
27
  body {background-color: #000 !important; color: #fff !important;}
 
30
  .gr-chatbot .message.bot {border-color: #aaa; background-color: transparent !important;}
31
  .gr-textbox textarea {background-color: transparent !important; color: #fff !important; border: 1px solid #555 !important;}
32
  .gr-textbox textarea::selection {background-color: #0ff !important; color: #000 !important;}
33
+ .gr-button {background-color: #0ff !important; color: #000 !important; border-radius: 8px;}
34
  footer {display: none !important;}
35
  """) as demo:
36
+ chatbot = gr.Chatbot(label="DevMegaBlack")
37
  msg = gr.Textbox(placeholder="Say something...")
38
+ reset_btn = gr.Button("Reset Chat")
39
  msg.submit(respond, [msg, chatbot], [chatbot, msg])
40
+ reset_btn.click(reset_chat, [], [chatbot, msg])
41
 
42
  demo.launch()