Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -76,15 +76,15 @@ except ImportError as e:
|
|
76 |
# matching the `outputs` in the .then() call later.
|
77 |
return (
|
78 |
gr.update(value="Modules not loaded."), # agentic_pipeline_status_md (0)
|
79 |
-
gr.update(choices=[], value=None),
|
80 |
-
gr.update(choices=[], value=[]),
|
81 |
gr.update(value="Modules not loaded."), # okr_detail_display_md (3) - KEPT HIDDEN for compatibility
|
82 |
-
None,
|
83 |
-
[],
|
84 |
-
[],
|
85 |
-
gr.update(value=empty_header_html),
|
86 |
gr.update(value=empty_body_markdown), # report_body_markdown_display (8)
|
87 |
-
{},
|
88 |
gr.update(value=get_initial_okr_display()), # NEW: enhanced_okr_display_html (10)
|
89 |
gr.update(value={}) # NEW: actionable_okrs_data_st (11)
|
90 |
)
|
@@ -96,7 +96,7 @@ except ImportError as e:
|
|
96 |
|
97 |
|
98 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
99 |
-
|
100 |
# --- STATE MANAGEMENT ---
|
101 |
token_state = gr.State(value={
|
102 |
"token": None, "client_id": None, "org_urn": None,
|
@@ -130,17 +130,28 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
|
130 |
gr.Markdown("# 🚀 LinkedIn Organization Dashboard")
|
131 |
url_user_token_display = gr.Textbox(label="User Token (Hidden)", interactive=False, visible=False)
|
132 |
org_urn_display = gr.Textbox(label="Org URN (Hidden)", interactive=False, visible=False)
|
133 |
-
status_box
|
|
|
134 |
|
135 |
app.load(fn=get_url_user_token, inputs=None, outputs=[url_user_token_display, org_urn_display], api_name="get_url_params", show_progress=False)
|
136 |
|
137 |
def initial_data_load_sequence(url_token, org_urn_val, current_state):
|
138 |
"""
|
139 |
-
Handles the initial data loading from Bubble.
|
140 |
-
No longer generates dashboard HTML as the Home tab is now static.
|
141 |
"""
|
142 |
status_msg, new_state = load_data_from_bubble(url_token, org_urn_val, current_state)
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
analytics_icons = {'bomb': BOMB_ICON, 'explore': EXPLORE_ICON, 'formula': FORMULA_ICON, 'active': ACTIVE_ICON}
|
146 |
analytics_tab_instance = AnalyticsTab(
|
@@ -281,24 +292,30 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
|
281 |
# Ensure agentic_display_outputs correctly maps to the newly created components
|
282 |
# This list must match the outputs of load_and_display_agentic_results
|
283 |
agentic_display_outputs = [
|
284 |
-
agentic_pipeline_status_md,
|
285 |
-
report_selector_dd,
|
286 |
-
key_results_cbg,
|
287 |
-
okr_detail_display_md,
|
288 |
-
orchestration_raw_results_st,
|
289 |
-
selected_key_result_ids_st,
|
290 |
-
key_results_for_selection_st,
|
291 |
-
report_header_html_display,
|
292 |
-
report_body_markdown_display,
|
293 |
-
reconstruction_cache_st,
|
294 |
-
enhanced_okr_display_html,
|
295 |
-
actionable_okrs_data_st
|
296 |
]
|
297 |
|
|
|
298 |
initial_load_event = org_urn_display.change(
|
|
|
|
|
|
|
|
|
|
|
299 |
fn=initial_data_load_sequence,
|
300 |
inputs=[url_user_token_display, org_urn_display, token_state],
|
301 |
-
outputs=[status_box, token_state],
|
302 |
show_progress="full"
|
303 |
)
|
304 |
|
@@ -332,4 +349,4 @@ if __name__ == "__main__":
|
|
332 |
if not os.environ.get("GEMINI_API_KEY"):
|
333 |
logging.warning("WARNING: 'GEMINI_API_KEY' is not set.")
|
334 |
|
335 |
-
app.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)), debug=True)
|
|
|
76 |
# matching the `outputs` in the .then() call later.
|
77 |
return (
|
78 |
gr.update(value="Modules not loaded."), # agentic_pipeline_status_md (0)
|
79 |
+
gr.update(choices=[], value=None), # report_selector_dd (1)
|
80 |
+
gr.update(choices=[], value=[]), # key_results_cbg (2) - KEPT HIDDEN for compatibility
|
81 |
gr.update(value="Modules not loaded."), # okr_detail_display_md (3) - KEPT HIDDEN for compatibility
|
82 |
+
None, # orchestration_raw_results_st (4)
|
83 |
+
[], # selected_key_result_ids_st (5) - KEPT HIDDEN for compatibility
|
84 |
+
[], # key_results_for_selection_st (6) - KEPT HIDDEN for compatibility
|
85 |
+
gr.update(value=empty_header_html), # report_header_html_display (7)
|
86 |
gr.update(value=empty_body_markdown), # report_body_markdown_display (8)
|
87 |
+
{}, # reconstruction_cache_st (9)
|
88 |
gr.update(value=get_initial_okr_display()), # NEW: enhanced_okr_display_html (10)
|
89 |
gr.update(value={}) # NEW: actionable_okrs_data_st (11)
|
90 |
)
|
|
|
96 |
|
97 |
|
98 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
99 |
+
title="LinkedIn Organization Dashboard") as app:
|
100 |
# --- STATE MANAGEMENT ---
|
101 |
token_state = gr.State(value={
|
102 |
"token": None, "client_id": None, "org_urn": None,
|
|
|
130 |
gr.Markdown("# 🚀 LinkedIn Organization Dashboard")
|
131 |
url_user_token_display = gr.Textbox(label="User Token (Hidden)", interactive=False, visible=False)
|
132 |
org_urn_display = gr.Textbox(label="Org URN (Hidden)", interactive=False, visible=False)
|
133 |
+
# MODIFIED: Initially hide the status_box and make its value empty
|
134 |
+
status_box = gr.Textbox(label="Status", interactive=False, value="", visible=False)
|
135 |
|
136 |
app.load(fn=get_url_user_token, inputs=None, outputs=[url_user_token_display, org_urn_display], api_name="get_url_params", show_progress=False)
|
137 |
|
138 |
def initial_data_load_sequence(url_token, org_urn_val, current_state):
|
139 |
"""
|
140 |
+
Handles the initial data loading from Bubble and controls status_box visibility.
|
|
|
141 |
"""
|
142 |
status_msg, new_state = load_data_from_bubble(url_token, org_urn_val, current_state)
|
143 |
+
|
144 |
+
# Determine if the status box should be visible
|
145 |
+
# It should be visible if the token is not available (None)
|
146 |
+
# OR if the status message indicates an error or warning, even if a token *might* be present.
|
147 |
+
show_status_box = False
|
148 |
+
if new_state.get("token") is None:
|
149 |
+
show_status_box = True
|
150 |
+
elif "Error" in status_msg or "Warning" in status_msg:
|
151 |
+
show_status_box = True
|
152 |
+
|
153 |
+
# Return the gr.update object to control value and visibility
|
154 |
+
return gr.update(value=status_msg, visible=show_status_box), new_state
|
155 |
|
156 |
analytics_icons = {'bomb': BOMB_ICON, 'explore': EXPLORE_ICON, 'formula': FORMULA_ICON, 'active': ACTIVE_ICON}
|
157 |
analytics_tab_instance = AnalyticsTab(
|
|
|
292 |
# Ensure agentic_display_outputs correctly maps to the newly created components
|
293 |
# This list must match the outputs of load_and_display_agentic_results
|
294 |
agentic_display_outputs = [
|
295 |
+
agentic_pipeline_status_md, # 0: Status Markdown (hidden)
|
296 |
+
report_selector_dd, # 1: Dropdown for selecting reports
|
297 |
+
key_results_cbg, # 2: Checkbox group for OKRs (kept hidden)
|
298 |
+
okr_detail_display_md, # 3: Markdown for detailed OKR display (kept hidden)
|
299 |
+
orchestration_raw_results_st, # 4: Raw results state
|
300 |
+
selected_key_result_ids_st, # 5: Selected KR IDs state (kept hidden)
|
301 |
+
key_results_for_selection_st, # 6: All KRs for selection state (kept hidden)
|
302 |
+
report_header_html_display, # 7: New HTML output for header
|
303 |
+
report_body_markdown_display, # 8: New Markdown output for body
|
304 |
+
reconstruction_cache_st, # 9: Reconstruction cache state
|
305 |
+
enhanced_okr_display_html, # 10: NEW: The enhanced HTML display for OKRs
|
306 |
+
actionable_okrs_data_st # 11: NEW: The actionable_okrs dictionary state
|
307 |
]
|
308 |
|
309 |
+
# MODIFIED: Chain the initial_load_event to first show "Loading...", then perform data load.
|
310 |
initial_load_event = org_urn_display.change(
|
311 |
+
fn=lambda: gr.update(value="Loading data...", visible=True), # Show loading message immediately
|
312 |
+
inputs=[],
|
313 |
+
outputs=[status_box],
|
314 |
+
show_progress="full"
|
315 |
+
).then(
|
316 |
fn=initial_data_load_sequence,
|
317 |
inputs=[url_user_token_display, org_urn_display, token_state],
|
318 |
+
outputs=[status_box, token_state], # status_box is updated here with final message/visibility
|
319 |
show_progress="full"
|
320 |
)
|
321 |
|
|
|
349 |
if not os.environ.get("GEMINI_API_KEY"):
|
350 |
logging.warning("WARNING: 'GEMINI_API_KEY' is not set.")
|
351 |
|
352 |
+
app.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)), debug=True)
|