bhanuTeja8 commited on
Commit
49a1567
·
verified ·
1 Parent(s): 8b5fa62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -9
app.py CHANGED
@@ -43,36 +43,47 @@ def chat_bot_response(user_message, history):
43
  history.append((user_message, response))
44
  return "", history
45
 
 
 
 
 
 
 
 
46
  # Gradio ChatGPT-like interface
47
  with gr.Blocks(css="""
48
  body {
49
- background-color: #f7f7f8;
50
  font-family: 'Segoe UI', sans-serif;
 
51
  }
52
  .chatbox {
53
- background-color: #ffffff;
54
- border: 1px solid #ddd;
55
- border-radius: 10px;
56
  padding: 10px;
57
  max-height: 500px;
58
  overflow-y: auto;
59
  }
60
  .message.user {
61
- background-color: #e8f0fe;
62
- color: #000;
63
  padding: 8px 12px;
64
  border-radius: 10px;
65
  margin: 5px 0;
66
  align-self: flex-end;
67
  }
68
  .message.bot {
69
- background-color: #f1f1f1;
70
- color: #000;
71
  padding: 8px 12px;
72
  border-radius: 10px;
73
  margin: 5px 0;
74
  align-self: flex-start;
75
  }
 
 
 
76
  """) as demo:
77
 
78
  gr.HTML("<h1 style='text-align: center;'>🤖 Ultron - ChatGPT Style Assistant</h1>")
@@ -80,8 +91,14 @@ body {
80
  chatbot = gr.Chatbot(elem_classes="chatbox", value=[])
81
  msg = gr.Textbox(placeholder="Ask Ultron anything...", show_label=False)
82
 
 
 
 
 
83
  msg.submit(chat_bot_response, inputs=[msg, chatbot], outputs=[msg, chatbot])
 
 
84
 
85
  # Run the app
86
  if __name__ == "__main__":
87
- demo.launch(debug=True)
 
43
  history.append((user_message, response))
44
  return "", history
45
 
46
+ def clear_chat():
47
+ return "", []
48
+
49
+ def clear_history_fn():
50
+ memory.clear()
51
+ return "", []
52
+
53
  # Gradio ChatGPT-like interface
54
  with gr.Blocks(css="""
55
  body {
56
+ background-color: #0f172a;
57
  font-family: 'Segoe UI', sans-serif;
58
+ color: #e5e7eb;
59
  }
60
  .chatbox {
61
+ background-color: #1f2937;
62
+ border: 1px solid #334155;
63
+ border-radius: 12px;
64
  padding: 10px;
65
  max-height: 500px;
66
  overflow-y: auto;
67
  }
68
  .message.user {
69
+ background-color: #2563eb;
70
+ color: #fff;
71
  padding: 8px 12px;
72
  border-radius: 10px;
73
  margin: 5px 0;
74
  align-self: flex-end;
75
  }
76
  .message.bot {
77
+ background-color: #374151;
78
+ color: #fff;
79
  padding: 8px 12px;
80
  border-radius: 10px;
81
  margin: 5px 0;
82
  align-self: flex-start;
83
  }
84
+ button {
85
+ margin-top: 10px;
86
+ }
87
  """) as demo:
88
 
89
  gr.HTML("<h1 style='text-align: center;'>🤖 Ultron - ChatGPT Style Assistant</h1>")
 
91
  chatbot = gr.Chatbot(elem_classes="chatbox", value=[])
92
  msg = gr.Textbox(placeholder="Ask Ultron anything...", show_label=False)
93
 
94
+ with gr.Row():
95
+ clear_btn = gr.Button("Clear Chat")
96
+ reset_memory_btn = gr.Button("Clear History")
97
+
98
  msg.submit(chat_bot_response, inputs=[msg, chatbot], outputs=[msg, chatbot])
99
+ clear_btn.click(clear_chat, outputs=[msg, chatbot])
100
+ reset_memory_btn.click(clear_history_fn, outputs=[msg, chatbot])
101
 
102
  # Run the app
103
  if __name__ == "__main__":
104
+ demo.launch(debug=True)