Ryan commited on
Commit
aefef4e
·
1 Parent(s): e0032f7
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -9,6 +9,22 @@ import logging
9
  import sys
10
  import traceback
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # Set up logging
13
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
14
  logger = logging.getLogger('gradio_app')
@@ -506,10 +522,11 @@ def create_app():
506
  # Add visualization handling for Bias Detection
507
  elif selected_analysis == "Bias Detection" and "bias_detection" in analyses:
508
  models = analyses["bias_detection"].get("models", ["Model 1", "Model 2"])
509
- # Use the bias visualization function to create components
510
- visualization_components = process_and_visualize_bias_analysis(analysis_results)
511
 
512
- # Set up visibility and components for display
 
 
 
513
  return (
514
  analysis_results, # analysis_results_state
515
  False, # analysis_output visibility
@@ -517,15 +534,15 @@ def create_app():
517
  gr.update(visible=True), # analysis_title
518
  gr.update(visible=True, value=f"## Analysis of Prompt: \"{prompt[:100]}...\""), # prompt_title
519
  gr.update(visible=True, value=f"### Comparing responses from {models[0]} and {models[1]}"), # models_compared
520
- gr.update(visible=False), # model1_title
521
- gr.update(visible=False), # model1_words
522
  gr.update(visible=False), # model2_title
523
  gr.update(visible=False), # model2_words
524
  gr.update(visible=False), # similarity_metrics_title
525
  gr.update(visible=False), # similarity_metrics
526
  False, # status_message_visible
527
  gr.update(visible=False) # status_message
528
- )
529
 
530
  # If we don't have visualization data from any analysis
531
  if not visualization_area_visible:
 
9
  import sys
10
  import traceback
11
 
12
+ def create_bias_visualization_tab(analysis_results):
13
+ """
14
+ Create a specialized tab for bias visualization
15
+
16
+ Args:
17
+ analysis_results (dict): The analysis results
18
+
19
+ Returns:
20
+ gradio.Tab: A tab containing the bias visualization
21
+ """
22
+ with gr.Tab("Bias Analysis") as tab:
23
+ # Let the bias visualizer create all needed components
24
+ components = process_and_visualize_bias_analysis(analysis_results)
25
+
26
+ return tab
27
+
28
  # Set up logging
29
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
30
  logger = logging.getLogger('gradio_app')
 
522
  # Add visualization handling for Bias Detection
523
  elif selected_analysis == "Bias Detection" and "bias_detection" in analyses:
524
  models = analyses["bias_detection"].get("models", ["Model 1", "Model 2"])
 
 
525
 
526
+ # Set up minimal visibility for the main tab
527
+ # Instead of trying to create visualizations here, we'll flag that we need
528
+ # to show the bias visualization on another tab
529
+
530
  return (
531
  analysis_results, # analysis_results_state
532
  False, # analysis_output visibility
 
534
  gr.update(visible=True), # analysis_title
535
  gr.update(visible=True, value=f"## Analysis of Prompt: \"{prompt[:100]}...\""), # prompt_title
536
  gr.update(visible=True, value=f"### Comparing responses from {models[0]} and {models[1]}"), # models_compared
537
+ gr.update(visible=True, value="#### Bias detection visualization is available below"), # model1_title
538
+ gr.update(visible=True, value="The detailed bias analysis includes sentiment analysis, partisan term detection, and framing analysis. Scroll down to see the visualizations."), # model1_words
539
  gr.update(visible=False), # model2_title
540
  gr.update(visible=False), # model2_words
541
  gr.update(visible=False), # similarity_metrics_title
542
  gr.update(visible=False), # similarity_metrics
543
  False, # status_message_visible
544
  gr.update(visible=False) # status_message
545
+ )
546
 
547
  # If we don't have visualization data from any analysis
548
  if not visualization_area_visible: