HAMMALE commited on
Commit
dd13db1
·
verified ·
1 Parent(s): 2eed108

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -24
app.py CHANGED
@@ -264,6 +264,7 @@ with gr.Blocks(title="SaulLM Chat", theme=gr.themes.Soft()) as demo:
264
  uploaded_docs_state = gr.State([])
265
 
266
  gr.Markdown("# SaulLM Chat")
 
267
 
268
  with gr.Row():
269
  # Left Sidebar
@@ -323,27 +324,7 @@ with gr.Blocks(title="SaulLM Chat", theme=gr.themes.Soft()) as demo:
323
  lines=1
324
  )
325
 
326
- gr.Markdown("### 📄 Document Upload")
327
- file_upload = gr.File(
328
- label="Upload Documents (PDF, DOCX, TXT, CSV)",
329
- file_count="multiple",
330
- file_types=[".pdf", ".docx", ".txt", ".csv"]
331
- )
332
-
333
- upload_status = gr.Textbox(
334
- label="Upload Status",
335
- interactive=False,
336
- lines=3
337
- )
338
-
339
- uploaded_docs_display = gr.Textbox(
340
- label="Uploaded Documents",
341
- interactive=False,
342
- lines=5,
343
- value="No documents uploaded yet"
344
- )
345
-
346
- clear_btn = gr.Button("Clear Chat & Memory", variant="stop")
347
 
348
  # Main Chat Area
349
  with gr.Column(scale=3):
@@ -366,6 +347,27 @@ with gr.Blocks(title="SaulLM Chat", theme=gr.themes.Soft()) as demo:
366
  with gr.Row():
367
  regenerate_btn = gr.Button("Regenerate Response")
368
  clear_input_btn = gr.Button("Clear Input")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
 
370
  # Event Handlers
371
  def user_submit(message, history):
@@ -408,12 +410,12 @@ with gr.Blocks(title="SaulLM Chat", theme=gr.themes.Soft()) as demo:
408
  def clear_chat(memory_agent):
409
  """Clear chat and memory"""
410
  memory_agent.clear()
411
- return [], "No documents uploaded yet", "Chat and memory cleared"
412
 
413
  def update_uploaded_docs_display(docs):
414
  """Update the uploaded documents display"""
415
  if not docs:
416
- return "No documents uploaded yet"
417
  return "\n".join([f"✓ {doc}" for doc in docs])
418
 
419
  def load_model_handler(model_name):
@@ -422,7 +424,7 @@ with gr.Blocks(title="SaulLM Chat", theme=gr.themes.Soft()) as demo:
422
  load_model(model_name)
423
  return f"✓ Model '{model_name}' loaded successfully!"
424
  except Exception as e:
425
- return f"Error loading model: {str(e)}"
426
 
427
  def update_system_prompt_handler(prompt):
428
  """Handle system prompt update"""
 
264
  uploaded_docs_state = gr.State([])
265
 
266
  gr.Markdown("# SaulLM Chat")
267
+
268
 
269
  with gr.Row():
270
  # Left Sidebar
 
324
  lines=1
325
  )
326
 
327
+ clear_btn = gr.Button("🗑️ Clear Chat & Memory", variant="stop")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
 
329
  # Main Chat Area
330
  with gr.Column(scale=3):
 
347
  with gr.Row():
348
  regenerate_btn = gr.Button("Regenerate Response")
349
  clear_input_btn = gr.Button("Clear Input")
350
+
351
+ gr.Markdown("### Document Upload")
352
+ file_upload = gr.File(
353
+ label="Upload Documents (PDF, DOCX, TXT, CSV)",
354
+ file_count="multiple",
355
+ file_types=[".pdf", ".docx", ".txt", ".csv"]
356
+ )
357
+
358
+ with gr.Row():
359
+ upload_status = gr.Textbox(
360
+ label="Upload Status",
361
+ interactive=False,
362
+ lines=2,
363
+ scale=1
364
+ )
365
+ uploaded_docs_display = gr.Textbox(
366
+ label="Uploaded Documents",
367
+ interactive=False,
368
+ lines=2,
369
+ scale=1
370
+ )
371
 
372
  # Event Handlers
373
  def user_submit(message, history):
 
410
  def clear_chat(memory_agent):
411
  """Clear chat and memory"""
412
  memory_agent.clear()
413
+ return [], "", "Chat and memory cleared"
414
 
415
  def update_uploaded_docs_display(docs):
416
  """Update the uploaded documents display"""
417
  if not docs:
418
+ return ""
419
  return "\n".join([f"✓ {doc}" for doc in docs])
420
 
421
  def load_model_handler(model_name):
 
424
  load_model(model_name)
425
  return f"✓ Model '{model_name}' loaded successfully!"
426
  except Exception as e:
427
+ return f" Error loading model: {str(e)}"
428
 
429
  def update_system_prompt_handler(prompt):
430
  """Handle system prompt update"""