elysium / backend /tools /calendar_tool.py
pmrinal2005's picture
Upload folder using huggingface_hub
a521353 verified
Raw
History Blame Contribute Delete
597 Bytes
from ..config import CALENDAR_ICS
def run(params: dict) -> dict:
if not CALENDAR_ICS.exists():
return {"status": "empty", "events": []}
try:
from icalendar import Calendar
cal = Calendar.from_ical(CALENDAR_ICS.read_bytes())
events = [{"summary": str(c.get("SUMMARY", "")),
"start": str(c.get("DTSTART", "").dt) if c.get("DTSTART") else ""}
for c in cal.walk("VEVENT")]
return {"status": "ok", "events": events[:20]}
except Exception as e:
return {"status": "error", "error": str(e)}