DocUA commited on
Commit
8e09424
Β·
1 Parent(s): dfe11ec

feat: Update refresh button text and enhance provider summary display in the simplified interface

Browse files
src/interface/simplified_gradio_app.py CHANGED
@@ -171,7 +171,7 @@ def create_simplified_interface():
171
  label="πŸ“Š Status"
172
  )
173
 
174
- refresh_btn = gr.Button("πŸ”„ Refresh Status", size="sm")
175
 
176
  # Conversation statistics
177
  gr.Markdown("### πŸ“ˆ Conversation Stats")
@@ -180,8 +180,6 @@ def create_simplified_interface():
180
  label="Statistics"
181
  )
182
 
183
- refresh_stats_btn = gr.Button("πŸ”„ Refresh Stats", size="sm")
184
-
185
  # Debug info (only in debug mode)
186
  if debug_mode:
187
  gr.Markdown("### πŸ”§ Debug Info")
@@ -197,6 +195,8 @@ def create_simplified_interface():
197
  value="**Provider Summary Generated**\n\nA detailed summary has been generated for the spiritual care team. Use the Download button below to access the full summary."
198
  )
199
 
 
 
200
  with gr.Row():
201
  download_summary_btn = gr.DownloadButton(
202
  "πŸ“₯ Download Summary",
@@ -720,6 +720,7 @@ CSV note:
720
  # Use gr.update for both visibility and value
721
  if not provider_summary_text:
722
  provider_summary_text = ""
 
723
 
724
  # Generate status message for provider summary
725
  if show_provider_panel and provider_summary_text:
@@ -741,7 +742,8 @@ Use the **Download Summary** button below to access the complete provider summar
741
  "",
742
  stats,
743
  gr.update(visible=show_provider_panel), # provider_summary_content visibility
744
- status_msg # provider_summary_status content
 
745
  )
746
 
747
  def handle_clear(session: SimplifiedSessionData):
@@ -752,15 +754,51 @@ Use the **Download Summary** button below to access the complete provider summar
752
  session.update_activity()
753
  new_history, status = session.app_instance.reset_session()
754
  # Also hide provider summary content
755
- return new_history, status, session, gr.update(visible=False), "No provider summary available"
756
 
757
  def get_status(session: SimplifiedSessionData):
758
- """Get current status."""
759
  if session is None:
760
- return "❌ Session not initialized"
761
 
762
  session.update_activity()
763
- return session.app_instance._get_status_info()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
 
765
  def send_example(example_text: str, history, session: SimplifiedSessionData):
766
  """Send example message."""
@@ -1964,27 +2002,27 @@ To revert, use "Reset to Default" button.
1964
  send_btn.click(
1965
  handle_message,
1966
  inputs=[msg, chatbot, session_data],
1967
- outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status]
1968
  )
1969
 
1970
  msg.submit(
1971
  handle_message,
1972
  inputs=[msg, chatbot, session_data],
1973
- outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status]
1974
  )
1975
 
1976
  # Clear chat
1977
  clear_btn.click(
1978
  handle_clear,
1979
  inputs=[session_data],
1980
- outputs=[chatbot, status_box, session_data, provider_summary_content, provider_summary_status]
1981
  )
1982
 
1983
  # Refresh status
1984
  refresh_btn.click(
1985
  get_status,
1986
  inputs=[session_data],
1987
- outputs=[status_box]
1988
  )
1989
 
1990
  # Example buttons
@@ -1995,19 +2033,19 @@ To revert, use "Reset to Default" button.
1995
  example_medical.click(
1996
  lambda h, s: send_example_with_stats("I have a headache and feel tired", h, s),
1997
  inputs=[chatbot, session_data],
1998
- outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status]
1999
  )
2000
 
2001
  example_wellness.click(
2002
  lambda h, s: send_example_with_stats("I'm feeling stressed and overwhelmed lately", h, s),
2003
  inputs=[chatbot, session_data],
2004
- outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status]
2005
  )
2006
 
2007
  example_help.click(
2008
  lambda h, s: send_example_with_stats("I am currently experiencing an emotional crisis", h, s),
2009
  inputs=[chatbot, session_data],
2010
- outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status]
2011
  )
2012
 
2013
  # Conversation logging buttons
@@ -2054,7 +2092,7 @@ To revert, use "Reset to Default" button.
2054
 
2055
  def clear_provider_summary():
2056
  """Clear provider summary panel."""
2057
- return gr.update(visible=False), "No provider summary available"
2058
 
2059
  download_summary_btn.click(
2060
  download_provider_summary,
@@ -2065,7 +2103,7 @@ To revert, use "Reset to Default" button.
2065
  clear_summary_btn.click(
2066
  clear_provider_summary,
2067
  inputs=[],
2068
- outputs=[provider_summary_content, provider_summary_status]
2069
  )
2070
 
2071
  # Download helper (used by embedded Conversation Verification tab)
@@ -2486,13 +2524,6 @@ To revert, use "Reset to Default" button.
2486
  outputs=[conv_verify_index, conv_verify_exchange, conv_position, conv_stats, conv_incorrect_comment_row, conv_incorrect_comment, conv_correct_classification]
2487
  )
2488
 
2489
- # Refresh conversation stats
2490
- refresh_stats_btn.click(
2491
- get_conversation_stats,
2492
- inputs=[session_data],
2493
- outputs=[conversation_stats]
2494
- )
2495
-
2496
  # Prompt editing events
2497
  load_prompt_btn.click(
2498
  load_prompt,
 
171
  label="πŸ“Š Status"
172
  )
173
 
174
+ refresh_btn = gr.Button("πŸ”„ Check Status & Summary", size="sm")
175
 
176
  # Conversation statistics
177
  gr.Markdown("### πŸ“ˆ Conversation Stats")
 
180
  label="Statistics"
181
  )
182
 
 
 
183
  # Debug info (only in debug mode)
184
  if debug_mode:
185
  gr.Markdown("### πŸ”§ Debug Info")
 
195
  value="**Provider Summary Generated**\n\nA detailed summary has been generated for the spiritual care team. Use the Download button below to access the full summary."
196
  )
197
 
198
+ provider_summary_display = gr.HTML(value="")
199
+
200
  with gr.Row():
201
  download_summary_btn = gr.DownloadButton(
202
  "πŸ“₯ Download Summary",
 
720
  # Use gr.update for both visibility and value
721
  if not provider_summary_text:
722
  provider_summary_text = ""
723
+ html_content = ""
724
 
725
  # Generate status message for provider summary
726
  if show_provider_panel and provider_summary_text:
 
742
  "",
743
  stats,
744
  gr.update(visible=show_provider_panel), # provider_summary_content visibility
745
+ status_msg, # provider_summary_status content
746
+ gr.update(value=html_content, visible=True) if show_provider_panel else gr.update(visible=False) # provider_summary_display content
747
  )
748
 
749
  def handle_clear(session: SimplifiedSessionData):
 
754
  session.update_activity()
755
  new_history, status = session.app_instance.reset_session()
756
  # Also hide provider summary content
757
+ return new_history, status, session, gr.update(visible=False), "No provider summary available", ""
758
 
759
  def get_status(session: SimplifiedSessionData):
760
+ """Get current status and stats."""
761
  if session is None:
762
+ return "❌ Session not initialized", "No stats", gr.update(visible=False), "No provider summary available", ""
763
 
764
  session.update_activity()
765
+ status_info = session.app_instance._get_status_info()
766
+
767
+ # Get stats
768
+ stats_text = get_conversation_stats(session)
769
+
770
+ # Check for provider summary
771
+ last_summary = session.app_instance.get_last_provider_summary()
772
+ show_provider_panel = last_summary is not None
773
+
774
+ provider_summary_text = ""
775
+ if last_summary:
776
+ provider_summary_text = session.app_instance.provider_summary_generator.format_for_display(last_summary)
777
+
778
+ if provider_summary_text:
779
+ import html
780
+ escaped_text = html.escape(provider_summary_text)
781
+ html_content = f"<pre style='white-space: pre-wrap; font-family: monospace; font-size: 11px; background: #fffbeb; padding: 10px; border-radius: 8px; max-height: 400px; overflow-y: auto;'>{escaped_text}</pre>"
782
+
783
+ status_msg = f"""**πŸ”΄ Provider Summary Generated**
784
+
785
+ **Patient:** {session.app_instance.patient_info.get('name', 'Test Patient')}
786
+ **Classification:** RED FLAG
787
+ **Indicators:** {len(last_summary.indicators)} distress indicators detected
788
+ **Summary Length:** {len(provider_summary_text)} characters
789
+
790
+ Use the **Download Summary** button below to access the complete provider summary for the spiritual care team."""
791
+ else:
792
+ html_content = ""
793
+ status_msg = "No provider summary available"
794
+
795
+ return (
796
+ status_info,
797
+ stats_text,
798
+ gr.update(visible=show_provider_panel),
799
+ status_msg,
800
+ html_content
801
+ )
802
 
803
  def send_example(example_text: str, history, session: SimplifiedSessionData):
804
  """Send example message."""
 
2002
  send_btn.click(
2003
  handle_message,
2004
  inputs=[msg, chatbot, session_data],
2005
+ outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status, provider_summary_display]
2006
  )
2007
 
2008
  msg.submit(
2009
  handle_message,
2010
  inputs=[msg, chatbot, session_data],
2011
+ outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status, provider_summary_display]
2012
  )
2013
 
2014
  # Clear chat
2015
  clear_btn.click(
2016
  handle_clear,
2017
  inputs=[session_data],
2018
+ outputs=[chatbot, status_box, session_data, provider_summary_content, provider_summary_status, provider_summary_display]
2019
  )
2020
 
2021
  # Refresh status
2022
  refresh_btn.click(
2023
  get_status,
2024
  inputs=[session_data],
2025
+ outputs=[status_box, conversation_stats, provider_summary_content, provider_summary_status, provider_summary_display]
2026
  )
2027
 
2028
  # Example buttons
 
2033
  example_medical.click(
2034
  lambda h, s: send_example_with_stats("I have a headache and feel tired", h, s),
2035
  inputs=[chatbot, session_data],
2036
+ outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status, provider_summary_display]
2037
  )
2038
 
2039
  example_wellness.click(
2040
  lambda h, s: send_example_with_stats("I'm feeling stressed and overwhelmed lately", h, s),
2041
  inputs=[chatbot, session_data],
2042
+ outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status, provider_summary_display]
2043
  )
2044
 
2045
  example_help.click(
2046
  lambda h, s: send_example_with_stats("I am currently experiencing an emotional crisis", h, s),
2047
  inputs=[chatbot, session_data],
2048
+ outputs=[chatbot, status_box, session_data, msg, conversation_stats, provider_summary_content, provider_summary_status, provider_summary_display]
2049
  )
2050
 
2051
  # Conversation logging buttons
 
2092
 
2093
  def clear_provider_summary():
2094
  """Clear provider summary panel."""
2095
+ return gr.update(visible=False), "No provider summary available", ""
2096
 
2097
  download_summary_btn.click(
2098
  download_provider_summary,
 
2103
  clear_summary_btn.click(
2104
  clear_provider_summary,
2105
  inputs=[],
2106
+ outputs=[provider_summary_content, provider_summary_status, provider_summary_display]
2107
  )
2108
 
2109
  # Download helper (used by embedded Conversation Verification tab)
 
2524
  outputs=[conv_verify_index, conv_verify_exchange, conv_position, conv_stats, conv_incorrect_comment_row, conv_incorrect_comment, conv_correct_classification]
2525
  )
2526
 
 
 
 
 
 
 
 
2527
  # Prompt editing events
2528
  load_prompt_btn.click(
2529
  load_prompt,