naman1102 commited on
Commit
2c45946
·
1 Parent(s): e410b86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -20
app.py CHANGED
@@ -393,42 +393,46 @@ def create_ui() -> gr.Blocks:
393
  )
394
 
395
  # Modified event handlers with status updates
396
- def process_repo_input_with_status(text: str, state: AppState) -> Tuple[pd.DataFrame, gr.update]:
397
  """Process repo input with status update."""
398
- return process_repo_input(text, state), gr.update(value="", visible=False)
 
399
 
400
- def keyword_search_with_status(keyword: str, state: AppState) -> Tuple[pd.DataFrame, gr.update]:
401
  """Search keywords with status update."""
402
- return keyword_search_and_update(keyword, state), gr.update(value="", visible=False)
 
403
 
404
- def analyze_with_status(state: AppState) -> Tuple[str, str, pd.DataFrame, gr.update]:
405
  """Analyze with status update."""
406
- return *show_combined_repo_and_llm(state), gr.update(value="", visible=False)
 
407
 
408
- def send_message_with_status(user_message: str, history: List[Dict[str, str]], state: AppState) -> Tuple[List[Dict[str, str]], str, gr.update]:
409
  """Send message with status update."""
410
  if not user_message:
411
- return history, "", gr.update(value="", visible=False)
412
  history.append({"role": "user", "content": user_message})
413
  response = chat_with_user(user_message, history, CHATBOT_SYSTEM_PROMPT)
414
  history.append({"role": "assistant", "content": response})
415
- return history, "", gr.update(value="", visible=False)
416
 
417
- def end_chat_with_status(history: List[Dict[str, str]], state: AppState) -> Tuple[List[str], gr.update, gr.update]:
418
  """End chat and extract keywords."""
419
  if not history:
420
- return [], gr.update(visible=True), gr.update(value="", visible=False)
421
  keywords = extract_keywords_from_conversation(history)
422
  state.generated_keywords = keywords
423
- return keywords, gr.update(visible=True), gr.update(value="", visible=False)
424
 
425
- def export_with_status(df: pd.DataFrame) -> Tuple[str, gr.update]:
426
  """Export with status update."""
427
- return export_results(df), gr.update(value="", visible=False)
 
428
 
429
  # Update event handlers with status updates
430
  submit_btn.click(
431
- fn=lambda: gr.update(value="Processing...", visible=True),
432
  inputs=[],
433
  outputs=[submit_status]
434
  ).then(
@@ -438,7 +442,7 @@ def create_ui() -> gr.Blocks:
438
  )
439
 
440
  search_btn.click(
441
- fn=lambda: gr.update(value="Searching...", visible=True),
442
  inputs=[],
443
  outputs=[search_status]
444
  ).then(
@@ -448,7 +452,7 @@ def create_ui() -> gr.Blocks:
448
  )
449
 
450
  next_btn.click(
451
- fn=lambda: gr.update(value="Analyzing...", visible=True),
452
  inputs=[],
453
  outputs=[next_status]
454
  ).then(
@@ -458,7 +462,7 @@ def create_ui() -> gr.Blocks:
458
  )
459
 
460
  send_btn.click(
461
- fn=lambda: gr.update(value="Sending...", visible=True),
462
  inputs=[],
463
  outputs=[send_status]
464
  ).then(
@@ -468,7 +472,7 @@ def create_ui() -> gr.Blocks:
468
  )
469
 
470
  end_chat_btn.click(
471
- fn=lambda: gr.update(value="Processing...", visible=True),
472
  inputs=[],
473
  outputs=[end_chat_status]
474
  ).then(
@@ -478,7 +482,7 @@ def create_ui() -> gr.Blocks:
478
  )
479
 
480
  export_btn.click(
481
- fn=lambda: gr.update(value="Exporting...", visible=True),
482
  inputs=[],
483
  outputs=[export_status]
484
  ).then(
 
393
  )
394
 
395
  # Modified event handlers with status updates
396
+ def process_repo_input_with_status(text: str, state: AppState) -> Tuple[pd.DataFrame, str]:
397
  """Process repo input with status update."""
398
+ df = process_repo_input(text, state)
399
+ return df, ""
400
 
401
+ def keyword_search_with_status(keyword: str, state: AppState) -> Tuple[pd.DataFrame, str]:
402
  """Search keywords with status update."""
403
+ df = keyword_search_and_update(keyword, state)
404
+ return df, ""
405
 
406
+ def analyze_with_status(state: AppState) -> Tuple[str, str, pd.DataFrame, str]:
407
  """Analyze with status update."""
408
+ content, summary, df = show_combined_repo_and_llm(state)
409
+ return content, summary, df, ""
410
 
411
+ def send_message_with_status(user_message: str, history: List[Dict[str, str]], state: AppState) -> Tuple[List[Dict[str, str]], str, str]:
412
  """Send message with status update."""
413
  if not user_message:
414
+ return history, "", ""
415
  history.append({"role": "user", "content": user_message})
416
  response = chat_with_user(user_message, history, CHATBOT_SYSTEM_PROMPT)
417
  history.append({"role": "assistant", "content": response})
418
+ return history, "", ""
419
 
420
+ def end_chat_with_status(history: List[Dict[str, str]], state: AppState) -> Tuple[List[str], gr.update, str]:
421
  """End chat and extract keywords."""
422
  if not history:
423
+ return [], gr.update(visible=True), ""
424
  keywords = extract_keywords_from_conversation(history)
425
  state.generated_keywords = keywords
426
+ return keywords, gr.update(visible=True), ""
427
 
428
+ def export_with_status(df: pd.DataFrame) -> Tuple[str, str]:
429
  """Export with status update."""
430
+ result = export_results(df)
431
+ return result, ""
432
 
433
  # Update event handlers with status updates
434
  submit_btn.click(
435
+ fn=lambda: "Processing...",
436
  inputs=[],
437
  outputs=[submit_status]
438
  ).then(
 
442
  )
443
 
444
  search_btn.click(
445
+ fn=lambda: "Searching...",
446
  inputs=[],
447
  outputs=[search_status]
448
  ).then(
 
452
  )
453
 
454
  next_btn.click(
455
+ fn=lambda: "Analyzing...",
456
  inputs=[],
457
  outputs=[next_status]
458
  ).then(
 
462
  )
463
 
464
  send_btn.click(
465
+ fn=lambda: "Sending...",
466
  inputs=[],
467
  outputs=[send_status]
468
  ).then(
 
472
  )
473
 
474
  end_chat_btn.click(
475
+ fn=lambda: "Processing...",
476
  inputs=[],
477
  outputs=[end_chat_status]
478
  ).then(
 
482
  )
483
 
484
  export_btn.click(
485
+ fn=lambda: "Exporting...",
486
  inputs=[],
487
  outputs=[export_status]
488
  ).then(