padmanabhbosamia commited on
Commit
2e73311
·
verified ·
1 Parent(s): 908f93a

Cosmetic Changes

Browse files
Files changed (1) hide show
  1. app.py +47 -17
app.py CHANGED
@@ -187,6 +187,33 @@ custom_css = """
187
  color: #34495e;
188
  margin: 10px 0;
189
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  """
191
 
192
  # Create the Gradio interface with enhanced UI
@@ -276,6 +303,12 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
276
  output = gr.Markdown(
277
  label="Generated Response(s)",
278
  show_label=True,
 
 
 
 
 
 
279
  )
280
 
281
  gr.Markdown(
@@ -307,26 +340,23 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
307
  elem_classes="description"
308
  )
309
 
310
- # Add examples
311
- gr.Examples(
312
- examples=[
313
- ["What is machine learning?"],
314
- ["Write a short story about a robot learning to paint."],
315
- ["Explain quantum computing in simple terms."],
316
- ["Write a poem about artificial intelligence."],
317
- ["What is deep learning?"],
318
- ["Write a story about a time-traveling smartphone."],
319
- ["How does neural network training work?"],
320
- ["Write a fairy tale about a computer learning to dream."],
321
- ["What is the difference between supervised and unsupervised learning?"],
322
- ["Create a story about an AI becoming an artist."]
323
- ],
324
- inputs=prompt
325
- )
326
 
327
  # Connect the interface
328
  generate_btn.click(
329
- fn=generate_response,
330
  inputs=[
331
  prompt,
332
  max_length,
 
187
  color: #34495e;
188
  margin: 10px 0;
189
  }
190
+ .loading {
191
+ display: flex;
192
+ align-items: center;
193
+ justify-content: center;
194
+ padding: 20px;
195
+ background-color: #f8f9fa;
196
+ border-radius: 8px;
197
+ margin: 10px 0;
198
+ }
199
+ .loading-spinner {
200
+ width: 40px;
201
+ height: 40px;
202
+ border: 4px solid #f3f3f3;
203
+ border-top: 4px solid #3498db;
204
+ border-radius: 50%;
205
+ animation: spin 1s linear infinite;
206
+ margin-right: 15px;
207
+ }
208
+ @keyframes spin {
209
+ 0% { transform: rotate(0deg); }
210
+ 100% { transform: rotate(360deg); }
211
+ }
212
+ .loading-text {
213
+ color: #2c3e50;
214
+ font-size: 1.1em;
215
+ font-weight: 500;
216
+ }
217
  """
218
 
219
  # Create the Gradio interface with enhanced UI
 
303
  output = gr.Markdown(
304
  label="Generated Response(s)",
305
  show_label=True,
306
+ value="Your generated responses will appear here...", # Add default value
307
+ )
308
+ loading_status = gr.Markdown(
309
+ value="",
310
+ show_label=False,
311
+ elem_classes="loading"
312
  )
313
 
314
  gr.Markdown(
 
340
  elem_classes="description"
341
  )
342
 
343
+ def generate_with_status(*args):
344
+ # Show loading status
345
+ loading_status.value = """
346
+ <div class="loading">
347
+ <div class="loading-spinner"></div>
348
+ <div class="loading-text">Generating responses... Please wait...</div>
349
+ </div>
350
+ """
351
+ # Generate response
352
+ result = generate_response(*args)
353
+ # Clear loading status
354
+ loading_status.value = ""
355
+ return result
 
 
 
356
 
357
  # Connect the interface
358
  generate_btn.click(
359
+ fn=generate_with_status,
360
  inputs=[
361
  prompt,
362
  max_length,