rahul7star commited on
Commit
2d56f37
·
verified ·
1 Parent(s): 1a32b0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -11
app.py CHANGED
@@ -178,27 +178,83 @@ def chat_with_model(user_message, chat_history):
178
  def reset_chat():
179
  return []
180
 
 
 
181
  def build_ui():
182
- custom_css = """
183
- #chatbot { background-color:#10121a; color:#e6eef8; border-radius:10px; padding:10px; }
184
- """
185
- with gr.Blocks(theme=gr.themes.Soft(), ) as demo:
186
-
187
- chatbot = gr.Chatbot(height=540, elem_id="chatbot", type="tuples")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
  with gr.Row():
190
  msg = gr.Textbox(
191
- placeholder="Type a message", lines=3, scale=8, show_label=False
 
 
 
 
192
  )
193
- send = gr.Button("Send", variant="primary", scale=1)
194
- with gr.Row():
195
- clear = gr.Button("Clear")
196
 
 
 
 
 
 
197
  send.click(chat_with_model, inputs=[msg, chatbot], outputs=[chatbot, msg])
198
  msg.submit(chat_with_model, inputs=[msg, chatbot], outputs=[chatbot, msg])
199
  clear.click(reset_chat, outputs=chatbot)
200
 
201
- demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
202
 
203
  # ---------------------------
204
  # Entrypoint
 
178
  def reset_chat():
179
  return []
180
 
181
+ import gradio as gr
182
+
183
  def build_ui():
184
+ with gr.Blocks(
185
+ theme=gr.themes.Soft(primary_hue="indigo"),
186
+ css="""
187
+ #ohamlab {
188
+ height: 550px !important;
189
+ border-radius: 14px;
190
+ box-shadow: 0 2px 12px rgba(0,0,0,0.1);
191
+ background: white;
192
+ }
193
+ .gradio-container {
194
+ max-width: 900px !important;
195
+ margin: auto;
196
+ padding-top: 1.5rem;
197
+ }
198
+ textarea {
199
+ resize: none !important;
200
+ border-radius: 12px !important;
201
+ border: 1px solid #d1d5db !important;
202
+ box-shadow: 0 1px 3px rgba(0,0,0,0.08);
203
+ }
204
+ button.primary {
205
+ background-color: #4f46e5 !important;
206
+ color: white !important;
207
+ border-radius: 10px !important;
208
+ padding: 0.6rem 1.4rem !important;
209
+ font-weight: 600;
210
+ transition: all 0.2s ease-in-out;
211
+ }
212
+ button.primary:hover {
213
+ background-color: #4338ca !important;
214
+ }
215
+ button.secondary {
216
+ background-color: #f3f4f6 !important;
217
+ border-radius: 10px !important;
218
+ color: #374151 !important;
219
+ font-weight: 500;
220
+ transition: all 0.2s ease-in-out;
221
+ }
222
+ button.secondary:hover {
223
+ background-color: #e5e7eb !important;
224
+ }
225
+ """
226
+ ) as demo:
227
+
228
+ gr.Markdown(
229
+ """
230
+ <div style="text-align:center; margin-bottom: 1rem;">
231
+ <h2 style="font-weight:700; font-size:1.8rem;">💠 OhamLab AI Assistant</h2>
232
+ <p style="color:#6b7280; font-size:0.95rem;">Your intelligent R&D and engineering companion powered by contextual knowledge.</p>
233
+ </div>
234
+ """
235
+ )
236
+
237
+ chatbot = gr.Chatbot(height=520, elem_id="ohamlab", type="tuples")
238
 
239
  with gr.Row():
240
  msg = gr.Textbox(
241
+ placeholder="Type your message here...",
242
+ lines=3,
243
+ scale=12,
244
+ show_label=False,
245
+ container=False,
246
  )
 
 
 
247
 
248
+ with gr.Row(equal_height=True):
249
+ send = gr.Button("Send", variant="primary", elem_classes=["primary"])
250
+ clear = gr.Button("Clear", variant="secondary", elem_classes=["secondary"])
251
+
252
+ # Wire events
253
  send.click(chat_with_model, inputs=[msg, chatbot], outputs=[chatbot, msg])
254
  msg.submit(chat_with_model, inputs=[msg, chatbot], outputs=[chatbot, msg])
255
  clear.click(reset_chat, outputs=chatbot)
256
 
257
+ return demo
258
 
259
  # ---------------------------
260
  # Entrypoint