import logging from typing import Dict, Any from schemas import AgentState logger = logging.getLogger(__name__) def timeline_node(state: AgentState) -> Dict[str, Any]: """ Węzeł generujący harmonogram (timeline_events) dla naborów w których firma może wziąć udział. """ grants = state.eligible_grants if not grants: return {"current_agent": "supervisor"} # Posortuj po skorygowanym relevance_score, weź max 3 by nie zaśmiecać widoku top_grants = sorted( grants, key=lambda x: x.relevance_score if x.relevance_score else 0.0, reverse=True, )[:3] events = [] # Tworzymy symulowany kalendarz na podstawie zebranych dotacji for idx, grant in enumerate(top_grants): # Wydarzenie startowe: rozpoczęcie prac nad wnioskiem events.append( { "id": f"start_prep_{grant.id}", "title": f"Rozpoczęcie przygotowań do: {grant.title}", "description": "Zebranie dokumentacji technicznej i finansowej", "date": "Dzisiaj", "status": "upcoming", } ) # Ostateczny termin deadline_str = grant.deadline if grant.deadline else "Brak podanej daty" events.append( { "id": f"deadline_{grant.id}", "title": f"Wysłanie wniosku: {grant.title}", "description": f"Instytucja przyjmująca: {grant.institution}. Budżet: ok. {grant.max_amount} PLN", "date": deadline_str, "status": "pending", } ) # Przewidywana ocena wniosku (zakładamy 90 dni) events.append( { "id": f"evaluation_{grant.id}", "title": f"Spodziewane ogłoszenie wyników: {grant.title}", "description": "Zakończenie oceny eksperckiej wniosku przez instytucję", "date": "+90 dni od wpłynięcia", "status": "future", } ) logger.info( f"Timeline node wygenerował {len(events)} wydarzeń na osi czasu dla top {len(top_grants)} dotacji." ) return {"timeline_events": events, "current_agent": "supervisor"}