|
My Project
|
Functions | |
| AlertsAgentState | get_new_events (AlertsAgentState state) |
| AlertsAgentState | get_interests (AlertsAgentState state) |
| AlertsAgentState | filter_relivent_events (AlertsAgentState state) |
| AlertsAgentOutput | insert_relevant_events (AlertsAgentState state) |
Variables | |
| ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) | |
| PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
Copyright 2026 Luca Silver Nodes that execute the alerts agent workflow for filtering and inserting relevant events for the current student user. Functions: - `get_new_events`: Queries the database for upcoming events added since the student's last event check. - `get_interests`: Retrieves the student's interests from the database for personalized event filtering. - `filter_relivent_events`: Filters upcoming events based on student interests and sets urgency levels. - `insert_relevant_events`: Inserts the filtered relevant events into the database with their urgency levels.
| AlertsAgentState filter_relivent_events | ( | AlertsAgentState | state | ) |
Uses LLM to filter events relevant to the student's interests and assess urgency.
Leverages an LLM model to intelligently match upcoming events against
the student's interests. For each matching event, assigns an urgency level based on the
time/effort required and time remaining until the event.
Args:
state (AlertsAgentState): The current state containing:
- 'upcoming_events': List of event dictionaries with ID, Name, Description, and Dates
- 'student_interests': List of interest strings
Returns:
AlertsAgentState: Dictionary with 'relevant_events' key containing a list of event
dictionaries marked as relevant. Each dict includes:
- 'ID': Event identifier
- 'Urgency': Urgency level (int from 1 to 5, with 5 being most urgent)
Raises:
ValueError: If LLM response cannot be parsed into RelevantEventsSchema.
Note:
- Returns empty list if no relevant events found or if LLM response is None
- Uses system prompt to guide LLM decision-making
- Response is parsed via structured output into RelevantEventsSchema
| AlertsAgentState get_interests | ( | AlertsAgentState | state | ) |
Retrieves the student's interests from the database and updates agent state.
Queries the database to fetch all interests associated with a specific student,
enabling the agent to personalize event filtering based on what the student cares about.
Args:
state (AlertsAgentState): The current state of the alerts agent containing the student_id.
Expected to have the key 'student_id' with an integer student ID.
Returns:
AlertsAgentState: Dictionary with 'student_interests' key containing a list of interest
strings (e.g., ['sports', 'music', 'technology']). Empty list if no interests found.
Raises:
sqlite3.DatabaseError: If there's an issue connecting to or querying the database.
| AlertsAgentState get_new_events | ( | AlertsAgentState | state | ) |
Retrieves new events from the database since the last check and updates agent state.
This function queries the database for events that were added since the student's last
event check, filtering for events that are upcoming (future dates or today with future times).
It also updates the LastEventCheck timestamp in the database to the current time.
Args:
state (AlertsAgentState): The current state of the alerts agent containing the student_id.
Expected to have the key 'student_id' with an integer student ID.
Returns:
AlertsAgentState: Updated state dictionary with 'upcoming_events' key containing a list
of event dictionaries. Each event dict has:
- 'ID': Event identifier
- 'Name': Event name
- 'Description': Event description
- 'Dates': List of date dictionaries with Date, StartTime, EndTime, Location, TimeAdded
Raises:
sqlite3.DatabaseError: If there's an issue connecting to or querying the database.
Side Effects:
- Updates the 'LastEventCheck' timestamp for the student in the database.
| AlertsAgentOutput insert_relevant_events | ( | AlertsAgentState | state | ) |
Persists relevant events to the database and returns the formatted output.
Inserts all events identified as relevant (from the filtering step) into the
RelevantEvents table in the database, associating them with the student and
their assigned urgency levels.
Args:
state (AlertsAgentState): The current state containing:
- 'student_id': Integer ID of the student
- 'relevant_events': List of event dicts with 'ID' and 'Urgency' keys
Returns:
AlertsAgentOutput: Dictionary with 'relevant_events' key containing the list of
events that were inserted into the database.
Raises:
sqlite3.DatabaseError: If database insertion fails.
Side Effects:
- Inserts rows into the RelevantEvents table in the database
- Commits transaction to persist changes
| lg_agent.utilities.alert_nodes.PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) |
| lg_agent.utilities.alert_nodes.ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) |