GuglielmoTor commited on
Commit
794a271
·
verified ·
1 Parent(s): 81af3e7

Update run_agentic_pipeline.py

Browse files
Files changed (1) hide show
  1. run_agentic_pipeline.py +17 -12
run_agentic_pipeline.py CHANGED
@@ -25,8 +25,6 @@ except ImportError as e:
25
  return {'header_html': '<h1>Agentic modules not loaded.</h1>', 'body_markdown': 'Report display unavailable.'}
26
  # These functions are now used by app.py directly for placeholder returns if modules are not loaded,
27
  # but their definitions might still be expected in some contexts, so providing minimal ones.
28
- # We still need placeholders for the *return values* if the import fails, even if they're not called
29
- # directly within this file, to maintain the correct function signature for load_and_display_agentic_results.
30
  def extract_key_results_for_selection(okrs_dict): return []
31
  def format_single_okr_for_display(okr_data, **kwargs): return "Agentic modules not loaded."
32
  # Placeholder for the new OKR UI display
@@ -68,10 +66,11 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
68
  session_cache: The session-specific cache for reconstructed data.
69
 
70
  Returns:
71
- A tuple of Gradio updates, including the updated cache and the new enhanced OKR HTML.
72
- This function now returns 11 values to match the expected outputs in app.py.
 
73
  """
74
- # Define placeholder content for empty or error states to match 11 outputs
75
  empty_header_html = """
76
  <div class="report-title">📊 Comprehensive Analysis Report</div>
77
  <div class="report-subtitle">AI-Generated Insights from Your LinkedIn Data</div>
@@ -87,7 +86,7 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
87
  </div>
88
  """
89
 
90
- # Default initial updates for 11 outputs
91
  initial_updates = (
92
  gr.update(value="Status: No agentic analysis data found."), # 0: agentic_pipeline_status_md
93
  gr.update(choices=[], value=None, interactive=False), # 1: report_selector_dd
@@ -99,12 +98,13 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
99
  gr.update(value=empty_header_html), # 7: report_header_html_display
100
  gr.update(value=empty_body_markdown_no_selection), # 8: report_body_markdown_display
101
  gr.update(value=session_cache), # 9: reconstruction_cache_st
102
- gr.update(value=get_initial_okr_display()) # 10: enhanced_okr_display_html
 
103
  )
104
 
105
  if not AGENTIC_MODULES_LOADED:
106
  logger.error("Agentic modules not loaded, returning placeholder updates.")
107
- # Ensure error updates match the 11-item signature
108
  error_header_html = '<div class="report-title">Error Loading Report</div><div class="report-subtitle">Agentic modules not loaded.</div><div class="status-badge">Error</div>'
109
  error_body_markdown = '<div class="empty-state"><div class="empty-state-icon">❌</div><div class="empty-state-title">Module Error</div><div class="empty-state-description">Agentic analysis modules could not be loaded. Report display unavailable.</div></div>'
110
  return (
@@ -118,7 +118,8 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
118
  gr.update(value=error_header_html), # 7
119
  gr.update(value=error_body_markdown), # 8
120
  gr.update(value=session_cache), # 9
121
- gr.update(value=get_initial_okr_display()) # 10: Placeholder for enhanced OKR display
 
122
  )
123
 
124
  agentic_df = token_state.get("bubble_agentic_analysis_data")
@@ -165,6 +166,7 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
165
  raw_results_state = None
166
  okr_details_md = "No OKRs found in the latest report." # This is for the old, hidden component
167
  enhanced_okr_html_content = get_initial_okr_display() # Default to loading state or empty
 
168
  key_results_cbg_update = gr.update(choices=[], value=[], interactive=False)
169
  all_krs_state = []
170
 
@@ -174,6 +176,7 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
174
 
175
  # Refined check for actionable_okrs_dict content
176
  if actionable_okrs_dict and isinstance(actionable_okrs_dict, dict) and actionable_okrs_dict.get("okrs"):
 
177
  # Format for the new enhanced HTML display
178
  enhanced_okr_html_content = format_okrs_for_enhanced_display(raw_results_state)
179
  else:
@@ -198,12 +201,13 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
198
  gr.update(value=report_header_content), # 7: report_header_html_display
199
  gr.update(value=report_body_content), # 8: report_body_markdown_display
200
  gr.update(value=updated_cache), # 9: reconstruction_cache_st
201
- gr.update(value=enhanced_okr_html_content) # 10: NEW: The enhanced HTML display for OKRs
 
202
  )
203
 
204
  except Exception as e:
205
  logger.error(f"Failed to process and display agentic results: {e}", exc_info=True)
206
- # Ensure error returns match the 11-item signature
207
  error_header_html = """
208
  <div class="report-title">⚠️ Error Loading Report</div>
209
  <div class="report-subtitle">An error occurred during data processing.</div>
@@ -230,5 +234,6 @@ def load_and_display_agentic_results(token_state: dict, session_cache: dict):
230
  gr.update(value=error_header_html), # 7
231
  gr.update(value=error_body_markdown), # 8
232
  gr.update(value=session_cache), # 9
233
- gr.update(value=get_initial_okr_display()) # 10: Placeholder for enhanced OKR display on error
 
234
  )
 
25
  return {'header_html': '<h1>Agentic modules not loaded.</h1>', 'body_markdown': 'Report display unavailable.'}
26
  # These functions are now used by app.py directly for placeholder returns if modules are not loaded,
27
  # but their definitions might still be expected in some contexts, so providing minimal ones.
 
 
28
  def extract_key_results_for_selection(okrs_dict): return []
29
  def format_single_okr_for_display(okr_data, **kwargs): return "Agentic modules not loaded."
30
  # Placeholder for the new OKR UI display
 
66
  session_cache: The session-specific cache for reconstructed data.
67
 
68
  Returns:
69
+ A tuple of Gradio updates, including the updated cache, the new enhanced OKR HTML,
70
+ and the extracted actionable_okrs_dict.
71
+ This function now returns 12 values to match the expected outputs in app.py.
72
  """
73
+ # Define placeholder content for empty or error states to match 12 outputs
74
  empty_header_html = """
75
  <div class="report-title">📊 Comprehensive Analysis Report</div>
76
  <div class="report-subtitle">AI-Generated Insights from Your LinkedIn Data</div>
 
86
  </div>
87
  """
88
 
89
+ # Default initial updates for 12 outputs
90
  initial_updates = (
91
  gr.update(value="Status: No agentic analysis data found."), # 0: agentic_pipeline_status_md
92
  gr.update(choices=[], value=None, interactive=False), # 1: report_selector_dd
 
98
  gr.update(value=empty_header_html), # 7: report_header_html_display
99
  gr.update(value=empty_body_markdown_no_selection), # 8: report_body_markdown_display
100
  gr.update(value=session_cache), # 9: reconstruction_cache_st
101
+ gr.update(value=get_initial_okr_display()), # 10: enhanced_okr_display_html
102
+ gr.update(value={}) # 11: actionable_okrs_data_st (NEW)
103
  )
104
 
105
  if not AGENTIC_MODULES_LOADED:
106
  logger.error("Agentic modules not loaded, returning placeholder updates.")
107
+ # Ensure error updates match the 12-item signature
108
  error_header_html = '<div class="report-title">Error Loading Report</div><div class="report-subtitle">Agentic modules not loaded.</div><div class="status-badge">Error</div>'
109
  error_body_markdown = '<div class="empty-state"><div class="empty-state-icon">❌</div><div class="empty-state-title">Module Error</div><div class="empty-state-description">Agentic analysis modules could not be loaded. Report display unavailable.</div></div>'
110
  return (
 
118
  gr.update(value=error_header_html), # 7
119
  gr.update(value=error_body_markdown), # 8
120
  gr.update(value=session_cache), # 9
121
+ gr.update(value=get_initial_okr_display()), # 10: Placeholder for enhanced OKR display
122
+ gr.update(value={}) # 11: Placeholder for actionable_okrs_data_st (NEW)
123
  )
124
 
125
  agentic_df = token_state.get("bubble_agentic_analysis_data")
 
166
  raw_results_state = None
167
  okr_details_md = "No OKRs found in the latest report." # This is for the old, hidden component
168
  enhanced_okr_html_content = get_initial_okr_display() # Default to loading state or empty
169
+ actionable_okrs_dict_for_state = {} # NEW: Initialize the new state variable
170
  key_results_cbg_update = gr.update(choices=[], value=[], interactive=False)
171
  all_krs_state = []
172
 
 
176
 
177
  # Refined check for actionable_okrs_dict content
178
  if actionable_okrs_dict and isinstance(actionable_okrs_dict, dict) and actionable_okrs_dict.get("okrs"):
179
+ actionable_okrs_dict_for_state = actionable_okrs_dict # Store for the new state
180
  # Format for the new enhanced HTML display
181
  enhanced_okr_html_content = format_okrs_for_enhanced_display(raw_results_state)
182
  else:
 
201
  gr.update(value=report_header_content), # 7: report_header_html_display
202
  gr.update(value=report_body_content), # 8: report_body_markdown_display
203
  gr.update(value=updated_cache), # 9: reconstruction_cache_st
204
+ gr.update(value=enhanced_okr_html_content), # 10: NEW: The enhanced HTML display for OKRs
205
+ gr.update(value=actionable_okrs_dict_for_state) # 11: NEW: Explicit actionable_okrs_data_st
206
  )
207
 
208
  except Exception as e:
209
  logger.error(f"Failed to process and display agentic results: {e}", exc_info=True)
210
+ # Ensure error returns match the 12-item signature
211
  error_header_html = """
212
  <div class="report-title">⚠️ Error Loading Report</div>
213
  <div class="report-subtitle">An error occurred during data processing.</div>
 
234
  gr.update(value=error_header_html), # 7
235
  gr.update(value=error_body_markdown), # 8
236
  gr.update(value=session_cache), # 9
237
+ gr.update(value=get_initial_okr_display()), # 10: Placeholder for enhanced OKR display on error
238
+ gr.update(value={}) # 11: Placeholder for actionable_okrs_data_st on error
239
  )