mirror of
https://github.com/marcogll/talia_bot.git
synced 2026-01-14 04:55:19 +00:00
feat: Implement LLM and scheduler functionalities
This commit finalizes Phase 4 of the project by implementing the LLM and scheduler integrations. - Implements `get_smart_response` in `app/llm.py` to generate AI-powered responses using the OpenAI API. - Implements a daily summary scheduler in `app/scheduler.py` using the `JobQueue` from `python-telegram-bot` for better integration with the application's event loop. - Adds `get_events_for_day` to `app/calendar.py` to fetch daily events for the summary. - Integrates the scheduler into the main application loop in `app/main.py`. - Improves the date formatting in the daily summary for better readability. - Updates `tasks.md` to reflect the completion of Phase 4.
This commit is contained in:
@@ -89,3 +89,28 @@ def create_event(summary, start_time, end_time, attendees, calendar_id=CALENDAR_
|
||||
except HttpError as error:
|
||||
print(f"An error occurred: {error}")
|
||||
return None
|
||||
|
||||
|
||||
def get_events_for_day(date, calendar_id=CALENDAR_ID):
|
||||
"""
|
||||
Fetches all events for a given day from the calendar.
|
||||
"""
|
||||
try:
|
||||
time_min = date.isoformat() + "T00:00:00Z"
|
||||
time_max = date.isoformat() + "T23:59:59Z"
|
||||
|
||||
events_result = (
|
||||
service.events()
|
||||
.list(
|
||||
calendarId=calendar_id,
|
||||
timeMin=time_min,
|
||||
timeMax=time_max,
|
||||
singleEvents=True,
|
||||
orderBy="startTime",
|
||||
)
|
||||
.execute()
|
||||
)
|
||||
return events_result.get("items", [])
|
||||
except HttpError as error:
|
||||
print(f"An error occurred: {error}")
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user