Ryan commited on
Commit
a109ed5
·
1 Parent(s): 0276c39
.idea/workspace.xml CHANGED
@@ -62,7 +62,7 @@
62
  <option name="presentableId" value="Default" />
63
  <updated>1745170754325</updated>
64
  <workItem from="1745170755404" duration="245000" />
65
- <workItem from="1745172030020" duration="18134000" />
66
  </task>
67
  <servers />
68
  </component>
 
62
  <option name="presentableId" value="Default" />
63
  <updated>1745170754325</updated>
64
  <workItem from="1745170755404" duration="245000" />
65
+ <workItem from="1745172030020" duration="18429000" />
66
  </task>
67
  <servers />
68
  </component>
processors/bias_processor.py CHANGED
@@ -25,10 +25,42 @@ def process_bias_detection(analysis_results, prompt, analyses):
25
 
26
  try:
27
  # Create bias visualization components
28
- from visualization.bias_visualizer import process_and_visualize_bias_analysis
29
- bias_components = process_and_visualize_bias_analysis(analysis_results)
30
 
31
- logger.info(f"Created {len(bias_components)} bias visualization components")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  return (
34
  analysis_results, # analysis_results_state
@@ -42,13 +74,14 @@ def process_bias_detection(analysis_results, prompt, analyses):
42
  gr.update(visible=True,
43
  value="The detailed bias analysis includes sentiment analysis, partisan term detection, and framing analysis."),
44
  # model1_words
45
- gr.update(visible=True), # model2_title
46
- gr.update(visible=True), # model2_words
47
- gr.update(visible=True), # similarity_metrics_title
48
- gr.update(visible=True), # similarity_metrics
49
  False, # status_message_visible
50
- gr.update(visible=True), # status_message
51
- gr.update(visible=True, value=bias_components) # bias_visualizations - Update with components
 
52
  )
53
  except Exception as e:
54
  logger.error(f"Error generating bias visualization: {str(e)}\n{traceback.format_exc()}")
 
25
 
26
  try:
27
  # Create bias visualization components
28
+ from visualization.bias_visualizer import create_bias_visualization
 
29
 
30
+ # Get the bias detection results
31
+ bias_results = analyses["bias_detection"]
32
+
33
+ # Create markdown components directly rather than trying to return them
34
+ results_markdown = f"""
35
+ ## Bias Analysis Results
36
+
37
+ ### Sentiment Analysis
38
+ - {models[0]}: {bias_results[models[0]]['sentiment']['bias_direction']} (strength: {bias_results[models[0]]['sentiment']['bias_strength']:.2f})
39
+ - {models[1]}: {bias_results[models[1]]['sentiment']['bias_direction']} (strength: {bias_results[models[1]]['sentiment']['bias_strength']:.2f})
40
+ - Difference: {bias_results['comparative']['sentiment']['difference']:.2f}
41
+
42
+ ### Partisan Leaning
43
+ - {models[0]}: {bias_results[models[0]]['partisan']['leaning']} (score: {bias_results[models[0]]['partisan']['lean_score']:.2f})
44
+ - {models[1]}: {bias_results[models[1]]['partisan']['leaning']} (score: {bias_results[models[1]]['partisan']['lean_score']:.2f})
45
+ - Difference: {bias_results['comparative']['partisan']['difference']:.2f}
46
+
47
+ ### Framing Analysis
48
+ - {models[0]} dominant frame: {bias_results[models[0]]['framing']['dominant_frame']}
49
+ - {models[1]} dominant frame: {bias_results[models[1]]['framing']['dominant_frame']}
50
+ - Different frames: {'Yes' if bias_results['comparative']['framing']['different_frames'] else 'No'}
51
+
52
+ ### Liberal Terms Found
53
+ - {models[0]}: {', '.join(bias_results[models[0]]['partisan']['liberal_terms'][:10])}
54
+ - {models[1]}: {', '.join(bias_results[models[1]]['partisan']['liberal_terms'][:10])}
55
+
56
+ ### Conservative Terms Found
57
+ - {models[0]}: {', '.join(bias_results[models[0]]['partisan']['conservative_terms'][:10])}
58
+ - {models[1]}: {', '.join(bias_results[models[1]]['partisan']['conservative_terms'][:10])}
59
+
60
+ ### Overall Comparison
61
+ The overall bias difference is {bias_results['comparative']['overall']['difference']:.2f}, which is
62
+ {'significant' if bias_results['comparative']['overall']['significant_bias_difference'] else 'not significant'}.
63
+ """
64
 
65
  return (
66
  analysis_results, # analysis_results_state
 
74
  gr.update(visible=True,
75
  value="The detailed bias analysis includes sentiment analysis, partisan term detection, and framing analysis."),
76
  # model1_words
77
+ gr.update(visible=False), # model2_title
78
+ gr.update(visible=False), # model2_words
79
+ gr.update(visible=False), # similarity_metrics_title
80
+ gr.update(visible=False), # similarity_metrics
81
  False, # status_message_visible
82
+ gr.update(visible=False), # status_message
83
+ gr.update(visible=True, value=results_markdown)
84
+ # bias_visualizations - Update with text instead of components
85
  )
86
  except Exception as e:
87
  logger.error(f"Error generating bias visualization: {str(e)}\n{traceback.format_exc()}")