Spaces:
Running
Running
Update services/agentic_handlers.py
Browse files- services/agentic_handlers.py +11 -20
services/agentic_handlers.py
CHANGED
@@ -49,9 +49,8 @@ class AgenticHandlers:
|
|
49 |
|
50 |
# Initial "waiting" status updates
|
51 |
initial_report_status = "Pipeline AI: In attesa dei dati necessari..."
|
52 |
-
# initial_okr_choices = [] # No longer used directly for okrs_cbg_update if it's Markdown
|
53 |
initial_okr_value_for_markdown = "" # Assuming this component is Markdown, value should be string
|
54 |
-
initial_okr_interactive = False
|
55 |
initial_okr_details = "Pipeline AI: In attesa dei dati necessari..."
|
56 |
initial_orchestration_results = self.orchestration_raw_results_st.value # Preserve if re-running
|
57 |
initial_selected_krs = self.selected_key_result_ids_st.value
|
@@ -61,9 +60,9 @@ class AgenticHandlers:
|
|
61 |
report_status_md_update = gr.update(value=initial_report_status) if self.report_components.get("agentic_pipeline_status_md") else gr.update()
|
62 |
report_display_md_update = gr.update() # No change to report display yet
|
63 |
|
64 |
-
# If key_results_cbg is the Markdown component causing the error, its update should not have '
|
65 |
# Its value should be a string.
|
66 |
-
okrs_cbg_update = gr.update(value=initial_okr_value_for_markdown
|
67 |
okrs_detail_md_update = gr.update(value=initial_okr_details) if self.okrs_components.get("okr_detail_display_md") else gr.update()
|
68 |
|
69 |
if not current_token_state_val or not current_token_state_val.get("token"):
|
@@ -86,7 +85,7 @@ class AgenticHandlers:
|
|
86 |
if self.okrs_components.get("okr_detail_display_md"): # Also update OKR detail placeholder
|
87 |
okrs_detail_md_update = gr.update(value="Dettagli OKR (Sempre) in corso di generazione...")
|
88 |
|
89 |
-
# okrs_cbg_update remains as initially defined (waiting state, no choices)
|
90 |
yield (
|
91 |
report_status_md_update, report_display_md_update, okrs_cbg_update, okrs_detail_md_update,
|
92 |
initial_orchestration_results, initial_selected_krs, initial_krs_for_selection
|
@@ -101,9 +100,9 @@ class AgenticHandlers:
|
|
101 |
report_display_md_update = gr.update(value=error_status) # Update report display too
|
102 |
|
103 |
# If key_results_cbg is Markdown, update its value to reflect the error.
|
104 |
-
# No choices argument here.
|
105 |
if self.okrs_components.get("key_results_cbg"):
|
106 |
-
okrs_cbg_update = gr.update(value=error_status
|
107 |
|
108 |
if self.okrs_components.get("okr_detail_display_md"):
|
109 |
okrs_detail_md_update = gr.update(value=error_status) # Update OKR detail too
|
@@ -146,19 +145,11 @@ class AgenticHandlers:
|
|
146 |
krs_for_ui_selection_list = extract_key_results_for_selection(actionable_okrs)
|
147 |
krs_for_selection_update_val = krs_for_ui_selection_list # Store for CBG change handler
|
148 |
|
149 |
-
# kr_choices_for_cbg = [(kr['kr_description'], kr['unique_kr_id']) for kr in krs_for_ui_selection_list] # Original
|
150 |
-
# If key_results_cbg is Markdown, we don't set choices.
|
151 |
-
# We might set its value to a string representation of these KRs, or leave it to be handled by selection logic.
|
152 |
-
# For now, setting value to a generic message or empty if it's Markdown.
|
153 |
-
# If it were a CBG, value=[] would be appropriate for selection reset.
|
154 |
-
# For Markdown, value should be a string.
|
155 |
if self.okrs_components.get("key_results_cbg"):
|
156 |
-
# If this component is Markdown, it cannot take choices.
|
157 |
-
# Its value should be a string.
|
158 |
-
|
159 |
-
okrs_cbg_update = gr.update(value="Key Results available for selection (display as Markdown)", interactive=True)
|
160 |
# Example string value if it's Markdown.
|
161 |
-
# Or simply value=""
|
162 |
|
163 |
# Display all OKRs initially (before any KR selection)
|
164 |
all_okrs_md_parts = []
|
@@ -181,7 +172,7 @@ class AgenticHandlers:
|
|
181 |
|
182 |
# If key_results_cbg is Markdown
|
183 |
if self.okrs_components.get("key_results_cbg"):
|
184 |
-
okrs_cbg_update = gr.update(value="Nessun Key Result (Markdown display)"
|
185 |
|
186 |
if self.okrs_components.get("okr_detail_display_md"):
|
187 |
okrs_detail_md_update = gr.update(value="Nessun OKR generato o errore nella pipeline AI (Sempre).")
|
@@ -204,7 +195,7 @@ class AgenticHandlers:
|
|
204 |
|
205 |
# If key_results_cbg is Markdown
|
206 |
if self.okrs_components.get("key_results_cbg"):
|
207 |
-
okrs_cbg_update = gr.update(value=f"Errore Key Results (Markdown): {str(e)}"
|
208 |
|
209 |
if self.okrs_components.get("okr_detail_display_md"):
|
210 |
okrs_detail_md_update = gr.update(value=f"Errore generazione OKR AI (Sempre): {str(e)}")
|
|
|
49 |
|
50 |
# Initial "waiting" status updates
|
51 |
initial_report_status = "Pipeline AI: In attesa dei dati necessari..."
|
|
|
52 |
initial_okr_value_for_markdown = "" # Assuming this component is Markdown, value should be string
|
53 |
+
# initial_okr_interactive = False # Markdown does not take 'interactive' in gr.update
|
54 |
initial_okr_details = "Pipeline AI: In attesa dei dati necessari..."
|
55 |
initial_orchestration_results = self.orchestration_raw_results_st.value # Preserve if re-running
|
56 |
initial_selected_krs = self.selected_key_result_ids_st.value
|
|
|
60 |
report_status_md_update = gr.update(value=initial_report_status) if self.report_components.get("agentic_pipeline_status_md") else gr.update()
|
61 |
report_display_md_update = gr.update() # No change to report display yet
|
62 |
|
63 |
+
# If key_results_cbg is the Markdown component causing the error, its update should not have 'interactive'.
|
64 |
# Its value should be a string.
|
65 |
+
okrs_cbg_update = gr.update(value=initial_okr_value_for_markdown) if self.okrs_components.get("key_results_cbg") else gr.update()
|
66 |
okrs_detail_md_update = gr.update(value=initial_okr_details) if self.okrs_components.get("okr_detail_display_md") else gr.update()
|
67 |
|
68 |
if not current_token_state_val or not current_token_state_val.get("token"):
|
|
|
85 |
if self.okrs_components.get("okr_detail_display_md"): # Also update OKR detail placeholder
|
86 |
okrs_detail_md_update = gr.update(value="Dettagli OKR (Sempre) in corso di generazione...")
|
87 |
|
88 |
+
# okrs_cbg_update remains as initially defined (waiting state, no choices/interactive)
|
89 |
yield (
|
90 |
report_status_md_update, report_display_md_update, okrs_cbg_update, okrs_detail_md_update,
|
91 |
initial_orchestration_results, initial_selected_krs, initial_krs_for_selection
|
|
|
100 |
report_display_md_update = gr.update(value=error_status) # Update report display too
|
101 |
|
102 |
# If key_results_cbg is Markdown, update its value to reflect the error.
|
103 |
+
# No choices or interactive argument here.
|
104 |
if self.okrs_components.get("key_results_cbg"):
|
105 |
+
okrs_cbg_update = gr.update(value=error_status) # Value is string
|
106 |
|
107 |
if self.okrs_components.get("okr_detail_display_md"):
|
108 |
okrs_detail_md_update = gr.update(value=error_status) # Update OKR detail too
|
|
|
145 |
krs_for_ui_selection_list = extract_key_results_for_selection(actionable_okrs)
|
146 |
krs_for_selection_update_val = krs_for_ui_selection_list # Store for CBG change handler
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
if self.okrs_components.get("key_results_cbg"):
|
149 |
+
# If this component is Markdown, it cannot take choices or interactive.
|
150 |
+
# Its value should be a string.
|
151 |
+
okrs_cbg_update = gr.update(value="Key Results available for selection (display as Markdown)")
|
|
|
152 |
# Example string value if it's Markdown.
|
|
|
153 |
|
154 |
# Display all OKRs initially (before any KR selection)
|
155 |
all_okrs_md_parts = []
|
|
|
172 |
|
173 |
# If key_results_cbg is Markdown
|
174 |
if self.okrs_components.get("key_results_cbg"):
|
175 |
+
okrs_cbg_update = gr.update(value="Nessun Key Result (Markdown display)") # String value
|
176 |
|
177 |
if self.okrs_components.get("okr_detail_display_md"):
|
178 |
okrs_detail_md_update = gr.update(value="Nessun OKR generato o errore nella pipeline AI (Sempre).")
|
|
|
195 |
|
196 |
# If key_results_cbg is Markdown
|
197 |
if self.okrs_components.get("key_results_cbg"):
|
198 |
+
okrs_cbg_update = gr.update(value=f"Errore Key Results (Markdown): {str(e)}") # String value
|
199 |
|
200 |
if self.okrs_components.get("okr_detail_display_md"):
|
201 |
okrs_detail_md_update = gr.update(value=f"Errore generazione OKR AI (Sempre): {str(e)}")
|