Spaces:
Running
Running
Update run_agentic_pipeline.py
Browse files- run_agentic_pipeline.py +44 -10
run_agentic_pipeline.py
CHANGED
@@ -44,7 +44,7 @@ except ImportError as e:
|
|
44 |
def extract_key_results_for_selection(okrs_dict): return [] # Placeholder
|
45 |
def format_single_okr_for_display(okr_data, **kwargs): return "Agentic modules not loaded. OKR display unavailable." # Placeholder
|
46 |
|
47 |
-
from services.report_data_handler import save_report_results, save_actionable_okrs
|
48 |
|
49 |
logger = logging.getLogger(__name__)
|
50 |
|
@@ -165,20 +165,54 @@ async def run_agentic_pipeline_autonomously(current_token_state_val, orchestrati
|
|
165 |
)
|
166 |
return
|
167 |
|
168 |
-
#DA AGGIORNARE CON RIPORTO DEI DATI PRESI DA BUBBLE E FORMATTATI NEL MODO GIUSTO
|
169 |
if not current_token_state_val.get("agentic_pipeline_should_run_now", False):
|
170 |
-
logging.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
yield (
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
|
|
|
|
|
|
176 |
)
|
177 |
return
|
178 |
|
179 |
-
# else:
|
180 |
-
# continue
|
181 |
-
|
182 |
|
183 |
try:
|
184 |
# Parameters for 'Sempre' filter for the agentic pipeline
|
|
|
44 |
def extract_key_results_for_selection(okrs_dict): return [] # Placeholder
|
45 |
def format_single_okr_for_display(okr_data, **kwargs): return "Agentic modules not loaded. OKR display unavailable." # Placeholder
|
46 |
|
47 |
+
from services.report_data_handler import save_report_results, save_actionable_okrs, fetch_and_reconstruct_data_from_bubble
|
48 |
|
49 |
logger = logging.getLogger(__name__)
|
50 |
|
|
|
165 |
)
|
166 |
return
|
167 |
|
|
|
168 |
if not current_token_state_val.get("agentic_pipeline_should_run_now", False):
|
169 |
+
logging.info("Fetching existing data from Bubble as pipeline run is not required.")
|
170 |
+
|
171 |
+
# Call the new function to get reconstructed data
|
172 |
+
retrieved_data = fetch_and_reconstruct_data_from_bubble(org_urn)
|
173 |
+
|
174 |
+
if not retrieved_data:
|
175 |
+
logging.warning(f"No data found in Bubble for org_urn {org_urn}. Informing user.")
|
176 |
+
yield (
|
177 |
+
gr.update(value="Nessun dato di analisi precedente trovato in Bubble."),
|
178 |
+
gr.update(choices=[], value=[], interactive=False),
|
179 |
+
gr.update(value="Eseguire la pipeline per generare un nuovo report."),
|
180 |
+
None, [], [], "Pipeline AI: Dati non disponibili"
|
181 |
+
)
|
182 |
+
return
|
183 |
+
|
184 |
+
# If data is found, format it for the UI
|
185 |
+
report_str = retrieved_data.get('report_str')
|
186 |
+
actionable_okrs = retrieved_data.get('actionable_okrs')
|
187 |
+
|
188 |
+
agentic_report_md_update = gr.update(value=format_report_to_markdown(report_str))
|
189 |
+
|
190 |
+
krs_for_ui_selection_list = extract_key_results_for_selection(actionable_okrs)
|
191 |
+
kr_choices_for_cbg = [(kr['kr_description'], kr['unique_kr_id']) for kr in krs_for_ui_selection_list]
|
192 |
+
key_results_cbg_update = gr.update(choices=kr_choices_for_cbg, value=[], interactive=True)
|
193 |
+
|
194 |
+
all_okrs_md_parts = []
|
195 |
+
if actionable_okrs and isinstance(actionable_okrs.get("okrs"), list):
|
196 |
+
for okr_idx, okr_item in enumerate(actionable_okrs["okrs"]):
|
197 |
+
all_okrs_md_parts.append(format_single_okr_for_display(okr_item, accepted_kr_indices=None, okr_main_index=okr_idx))
|
198 |
+
|
199 |
+
if not all_okrs_md_parts:
|
200 |
+
okr_detail_display_md_update = gr.update(value="Nessun OKR trovato per il report più recente.")
|
201 |
+
else:
|
202 |
+
okr_detail_display_md_update = gr.update(value="\n\n---\n\n".join(all_okrs_md_parts))
|
203 |
+
|
204 |
+
# Yield the updates for the Gradio interface
|
205 |
yield (
|
206 |
+
agentic_report_md_update,
|
207 |
+
key_results_cbg_update,
|
208 |
+
okr_detail_display_md_update,
|
209 |
+
retrieved_data, # Store full retrieved data in state
|
210 |
+
[], # Reset selected KRs state
|
211 |
+
krs_for_ui_selection_list, # Update state with list of KR dicts
|
212 |
+
"Pipeline AI: Dati caricati da Bubble"
|
213 |
)
|
214 |
return
|
215 |
|
|
|
|
|
|
|
216 |
|
217 |
try:
|
218 |
# Parameters for 'Sempre' filter for the agentic pipeline
|