Spaces:
Build error
Build error
| #planner.py | |
| from tools.calendar_reader import get_todays_events | |
| import json | |
| import datetime | |
| from smolagents import tool | |
| def generate_daily_plan() -> str: | |
| """ | |
| Generate a daily plan based on class schedule and today's calendar events. | |
| Returns a formatted plan string. | |
| """ | |
| # 1. Ders programını oku | |
| with open("data/class_schedule.json", "r", encoding="utf-8") as f: | |
| class_schedule = json.load(f) | |
| # 2. Bugünün haftalık ders gününü bul | |
| weekday = datetime.datetime.now().strftime("%A").lower() | |
| today_classes = class_schedule.get(weekday, []) | |
| # 3. Takvimden etkinlikleri al | |
| calendar_events = get_todays_events() | |
| # 4. Birleştirip planı oluştur | |
| plan_lines = ["📚 Ders Programı:"] | |
| if today_classes: | |
| for cls in today_classes: | |
| plan_lines.append(f"- {cls}") | |
| else: | |
| plan_lines.append("Bugün ders yok.") | |
| plan_lines.append("\n🗓️ Takvim Etkinlikleri:") | |
| if calendar_events: | |
| for event in calendar_events: | |
| plan_lines.append(f"- {event}") | |
| else: | |
| plan_lines.append("Bugün etkinlik yok.") | |
| return "\n".join(plan_lines) | |