naman1102 commited on
Commit
6a5d12d
Β·
1 Parent(s): 269a57d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -317,7 +317,6 @@ def create_ui() -> gr.Blocks:
317
  gr.Markdown("### πŸ’¬ Intelligent Repository Discovery")
318
 
319
  chatbot = gr.Chatbot(
320
- value=[{"role": "assistant", "content": CHATBOT_INITIAL_MESSAGE}],
321
  label="πŸ€– AI Assistant",
322
  height=450,
323
  type="messages",
@@ -417,6 +416,10 @@ def create_ui() -> gr.Blocks:
417
 
418
  def handle_user_message(user_message: str, history: List[Dict[str, str]]) -> Tuple[List[Dict[str, str]], str]:
419
  """Appends the user's message to the history, preparing for the bot's response."""
 
 
 
 
420
  if user_message:
421
  history.append({"role": "user", "content": user_message})
422
  return history, ""
@@ -465,6 +468,12 @@ def create_ui() -> gr.Blocks:
465
 
466
  # --- Component Event Wiring ---
467
 
 
 
 
 
 
 
468
  # Input Tab
469
  submit_repo_btn.click(
470
  fn=handle_repo_id_submission,
 
317
  gr.Markdown("### πŸ’¬ Intelligent Repository Discovery")
318
 
319
  chatbot = gr.Chatbot(
 
320
  label="πŸ€– AI Assistant",
321
  height=450,
322
  type="messages",
 
416
 
417
  def handle_user_message(user_message: str, history: List[Dict[str, str]]) -> Tuple[List[Dict[str, str]], str]:
418
  """Appends the user's message to the history, preparing for the bot's response."""
419
+ # Initialize chatbot with welcome message if empty
420
+ if not history:
421
+ history = [{"role": "assistant", "content": CHATBOT_INITIAL_MESSAGE}]
422
+
423
  if user_message:
424
  history.append({"role": "user", "content": user_message})
425
  return history, ""
 
468
 
469
  # --- Component Event Wiring ---
470
 
471
+ # Initialize chatbot with welcome message on app load
472
+ app.load(
473
+ fn=lambda: [{"role": "assistant", "content": CHATBOT_INITIAL_MESSAGE}],
474
+ outputs=[chatbot]
475
+ )
476
+
477
  # Input Tab
478
  submit_repo_btn.click(
479
  fn=handle_repo_id_submission,