aymnsk commited on
Commit
bf19c1f
·
verified ·
1 Parent(s): cef70b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -13
app.py CHANGED
@@ -12,7 +12,7 @@ zaid = DebuggerAgent()
12
  # In-memory chat
13
  chat_memory = []
14
 
15
- # Load greeting shortcut mappings (optional JSON file)
16
  GREETING_RESPONSES = {
17
  "hi": "Hey there! 👋",
18
  "hello": "Hello! How can I help?",
@@ -31,7 +31,7 @@ def chat(user_input):
31
  return chat_memory
32
 
33
  is_greeting, shortcut = fast_greeting_handler(user_input)
34
-
35
  if is_greeting:
36
  response_aymaan = shortcut + " (Aymaan)"
37
  response_zaid = shortcut + " (Zaid)"
@@ -42,13 +42,11 @@ def chat(user_input):
42
  user_msg = ACPMessage(sender="User", receiver="Zaid", performative="inform", content=user_input)
43
  response_zaid = zaid.receive_message(user_msg).content
44
 
45
- chat_memory.append({"role": "user", "content": user_input})
46
  chat_memory.append({"role": "Aymaan", "content": response_aymaan})
47
  chat_memory.append({"role": "Zaid", "content": response_zaid})
48
 
49
- formatted = []
50
- for item in chat_memory:
51
- formatted.append((item["role"], item["content"]))
52
  return formatted
53
 
54
  def reset_memory():
@@ -56,20 +54,50 @@ def reset_memory():
56
  chat_memory = []
57
  return []
58
 
59
- with gr.Blocks(css="footer {margin-top: 2em; text-align: center;}") as demo:
60
- gr.Markdown("## 🤖 BotTalks (Groq Edition) — Chat with Aymaan & Zaid")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- chatbot = gr.Chatbot(label="Group Chat", height=300)
63
- msg = gr.Textbox(label="Type your message...")
64
- send_btn = gr.Button("Send")
65
- clear_btn = gr.Button("🧹 Clear Chat")
 
 
 
 
 
 
 
 
 
66
 
67
  send_btn.click(chat, inputs=msg, outputs=chatbot)
68
  clear_btn.click(reset_memory, outputs=chatbot)
69
 
70
  gr.HTML("""
71
  <footer>
72
- 👨‍💻 Made by <a href="https://github.com/aymnsk" target="_blank">aymnsk</a> • Powered by <a href="https://groq.com/" target="_blank">Groq API</a>
73
  </footer>
74
  """)
75
 
 
12
  # In-memory chat
13
  chat_memory = []
14
 
15
+ # Greeting shortcuts
16
  GREETING_RESPONSES = {
17
  "hi": "Hey there! 👋",
18
  "hello": "Hello! How can I help?",
 
31
  return chat_memory
32
 
33
  is_greeting, shortcut = fast_greeting_handler(user_input)
34
+
35
  if is_greeting:
36
  response_aymaan = shortcut + " (Aymaan)"
37
  response_zaid = shortcut + " (Zaid)"
 
42
  user_msg = ACPMessage(sender="User", receiver="Zaid", performative="inform", content=user_input)
43
  response_zaid = zaid.receive_message(user_msg).content
44
 
45
+ chat_memory.append({"role": "You", "content": user_input})
46
  chat_memory.append({"role": "Aymaan", "content": response_aymaan})
47
  chat_memory.append({"role": "Zaid", "content": response_zaid})
48
 
49
+ formatted = [(item["role"], item["content"]) for item in chat_memory]
 
 
50
  return formatted
51
 
52
  def reset_memory():
 
54
  chat_memory = []
55
  return []
56
 
57
+ custom_css = """
58
+ footer {
59
+ margin-top: 2em;
60
+ text-align: center;
61
+ color: #999;
62
+ font-size: 0.9em;
63
+ }
64
+
65
+ .gradio-container {
66
+ background: linear-gradient(to bottom right, #f0f2f5, #dbe6f3);
67
+ font-family: 'Segoe UI', sans-serif;
68
+ }
69
+
70
+ textarea, .gr-button {
71
+ border-radius: 12px !important;
72
+ }
73
+
74
+ .gr-button {
75
+ background-color: #007bff !important;
76
+ color: white !important;
77
+ font-weight: bold;
78
+ transition: background-color 0.3s ease;
79
+ }
80
 
81
+ .gr-button:hover {
82
+ background-color: #0056b3 !important;
83
+ }
84
+ """
85
+
86
+ with gr.Blocks(css=custom_css) as demo:
87
+ gr.Markdown("### 💬 ChatLoop — Your Dual AI Chat")
88
+
89
+ chatbot = gr.Chatbot(label="Chat", height=400, bubble_full_width=False)
90
+ with gr.Row():
91
+ msg = gr.Textbox(placeholder="Type your message here...", show_label=False, lines=1, max_lines=4, scale=4)
92
+ send_btn = gr.Button("📨 Send", scale=1)
93
+ clear_btn = gr.Button("🧹 Clear Chat", variant="secondary")
94
 
95
  send_btn.click(chat, inputs=msg, outputs=chatbot)
96
  clear_btn.click(reset_memory, outputs=chatbot)
97
 
98
  gr.HTML("""
99
  <footer>
100
+ Built with ❤️ by <a href="https://github.com/aymnsk" target="_blank">aymnsk</a>
101
  </footer>
102
  """)
103