rahul7star commited on
Commit
208666e
·
verified ·
1 Parent(s): 98fe4bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -19
app.py CHANGED
@@ -232,33 +232,84 @@ def reset_chat():
232
 
233
  # ---------------------------
234
  # Gradio UI with working Send button
 
 
 
235
  # ---------------------------
236
  def build_ui():
237
- custom_css = """
238
- #chatbot { background-color:#11121a; color:#e6eef8;
239
- border-radius:10px; padding:10px; }
240
- """
241
- with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
242
- gr.Markdown("## 🤖 Aerelyth — Dialectical Agentic CrossSphere AI")
243
- chatbot = gr.Chatbot(height=520, elem_id="chatbot", type="tuples")
244
-
245
- with gr.Row():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  msg = gr.Textbox(
247
- placeholder="Type message (press Enter or click Send)…",
248
- lines=3,
249
  scale=8,
250
- show_label=False
251
  )
252
- send = gr.Button("Send", variant="primary", scale=1)
253
-
254
- with gr.Row():
255
- clear = gr.Button("Clear")
256
 
257
- send.click(chat_with_model, inputs=[msg, chatbot], outputs=[chatbot, msg])
258
- msg.submit(chat_with_model, inputs=[msg, chatbot], outputs=[chatbot, msg])
259
- clear.click(reset_chat, outputs=chatbot)
 
260
 
261
  demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
 
 
262
 
263
  # ---------------------------
264
  # Entrypoint
 
232
 
233
  # ---------------------------
234
  # Gradio UI with working Send button
235
+ # ---------------------------
236
+ ---------------------------
237
+ # Gradio UI
238
  # ---------------------------
239
  def build_ui():
240
+ with gr.Blocks(
241
+ theme=gr.themes.Soft(),
242
+ css="""
243
+ #chatbot {
244
+ background-color: #f9f9fb;
245
+ border-radius: 12px;
246
+ padding: 10px;
247
+ overflow-y: auto;
248
+ }
249
+ .user-bubble {
250
+ background: #4a90e2;
251
+ color: white;
252
+ border-radius: 14px;
253
+ padding: 8px 12px;
254
+ margin: 6px;
255
+ max-width: 75%;
256
+ align-self: flex-end;
257
+ font-size: 14px;
258
+ }
259
+ .bot-bubble {
260
+ background: #e6e6e6;
261
+ color: #333;
262
+ border-radius: 14px;
263
+ padding: 8px 12px;
264
+ margin: 6px;
265
+ max-width: 75%;
266
+ align-self: flex-start;
267
+ font-size: 14px;
268
+ }
269
+ #controls {
270
+ display: flex;
271
+ gap: 8px;
272
+ align-items: center;
273
+ margin-top: 6px;
274
+ }
275
+ #topbar {
276
+ display: flex;
277
+ justify-content: flex-end;
278
+ gap: 8px;
279
+ margin-bottom: 6px;
280
+ }
281
+ """
282
+ ) as demo:
283
+ # Top bar with close + clear
284
+ with gr.Row(elem_id="topbar"):
285
+ close_btn = gr.Button("❌", size="sm")
286
+ clear_btn = gr.Button("🧹 Clear", size="sm")
287
+
288
+ chatbot = gr.Chatbot(
289
+ label="",
290
+ height=350, # reduced height so input is visible
291
+ elem_id="chatbot",
292
+ type="tuples",
293
+ bubble_full_width=False,
294
+ avatar_images=("👤", "🤖"),
295
+ )
296
+
297
+ with gr.Row(elem_id="controls"):
298
  msg = gr.Textbox(
299
+ placeholder="Type your message here...",
300
+ lines=2,
301
  scale=8,
 
302
  )
303
+ submit_btn = gr.Button("🚀 Send", variant="primary", scale=2)
 
 
 
304
 
305
+ # Wire buttons
306
+ submit_btn.click(chat_with_model, inputs=[msg, chatbot], outputs=[msg, chatbot])
307
+ msg.submit(chat_with_model, inputs=[msg, chatbot], outputs=[msg, chatbot])
308
+ clear_btn.click(reset_chat, inputs=None, outputs=chatbot)
309
 
310
  demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
311
+ return demo
312
+
313
 
314
  # ---------------------------
315
  # Entrypoint