Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from datetime import datetime
|
3 |
+
|
4 |
+
# Placeholder: import your actual tool classes
|
5 |
+
# from your_modules import (StudyPlanGenerator, CalendarAgendaTool, TaskManagerTool,
|
6 |
+
# GoalSettingTrackingTool, FlashcardQuizMakerTool, RevisionPlannerTool)
|
7 |
+
|
8 |
+
# Mock implementations for this example
|
9 |
+
def generate_study_plan(subject, exam_date, hours_per_day, topics, review_frequency):
|
10 |
+
return f"""### 📘 7-Day Study Plan for {subject}
|
11 |
+
**Exam Date:** {exam_date}
|
12 |
+
**Daily Study Time:** {hours_per_day} hrs/day
|
13 |
+
**Key Topics:** {topics}
|
14 |
+
**Review Every:** {review_frequency} days
|
15 |
+
|
16 |
+
Day 1: Introduction to {topics.split(',')[0].strip()}
|
17 |
+
...
|
18 |
+
|
19 |
+
Day 7: Final Review + Flashcards + Mock Test"""
|
20 |
+
|
21 |
+
def generate_calendar_agenda():
|
22 |
+
return "### 📆 Calendar Agenda\nStudy sessions mapped to your calendar."
|
23 |
+
|
24 |
+
def generate_tasks(topics):
|
25 |
+
return f"### ✅ Tasks\nBreakdown of tasks for topics: {topics}\n- Create notes\n- Solve 10 practice problems each\n- Summarize in flashcards"
|
26 |
+
|
27 |
+
def track_goals():
|
28 |
+
return "### 🎯 Goal Tracking\nTrack progress of weekly and daily learning objectives."
|
29 |
+
|
30 |
+
def generate_flashcards(topics):
|
31 |
+
return f"### 🧠 Flashcards\nGenerated flashcards for: {topics}\n- Q1: What is...?\n- Q2: Explain..."
|
32 |
+
|
33 |
+
def plan_revisions(exam_date):
|
34 |
+
return f"### 🔁 Revision Plan\nRevision scheduled on: {exam_date} - 3, {exam_date} - 1"
|
35 |
+
|
36 |
+
# Gradio UI
|
37 |
+
def full_study_plan(subject, exam_date_str, hours_per_day, topics, review_frequency):
|
38 |
+
try:
|
39 |
+
exam_date = datetime.strptime(exam_date_str, "%Y-%m-%d")
|
40 |
+
except ValueError:
|
41 |
+
return "❌ Invalid date format. Please use YYYY-MM-DD."
|
42 |
+
|
43 |
+
return generate_study_plan(subject, exam_date_str, hours_per_day, topics, review_frequency)
|
44 |
+
|
45 |
+
def full_tasks(topics):
|
46 |
+
return generate_tasks(topics)
|
47 |
+
|
48 |
+
def full_flashcards(topics):
|
49 |
+
return generate_flashcards(topics)
|
50 |
+
|
51 |
+
def full_revisions(exam_date_str):
|
52 |
+
return plan_revisions(exam_date_str)
|
53 |
+
|
54 |
+
def full_agenda():
|
55 |
+
return generate_calendar_agenda()
|
56 |
+
|
57 |
+
def full_goals():
|
58 |
+
return track_goals()
|
59 |
+
|
60 |
+
with gr.Blocks(title="AI Study Planner") as demo:
|
61 |
+
gr.Markdown("# 🎓 AI-Powered Study Planner\nEnter your exam details and get personalized study resources.")
|
62 |
+
|
63 |
+
with gr.Tabs():
|
64 |
+
with gr.TabItem("📘 Study Plan"):
|
65 |
+
with gr.Row():
|
66 |
+
subject = gr.Textbox(label="Subject", placeholder="e.g., Chemistry")
|
67 |
+
exam_date = gr.Textbox(label="Exam Date (YYYY-MM-DD)", placeholder="2025-07-10")
|
68 |
+
with gr.Row():
|
69 |
+
hours_per_day = gr.Slider(1, 10, value=5, label="Study Hours per Day")
|
70 |
+
topics = gr.Textbox(label="Key Topics (comma-separated)", placeholder="Organic Chemistry, Acids & Bases, Stoichiometry")
|
71 |
+
review_frequency = gr.Slider(1, 3, value=2, label="Review Session Frequency (in days)")
|
72 |
+
plan_output = gr.Markdown("### Output will appear here...")
|
73 |
+
generate_btn = gr.Button("Generate Study Plan")
|
74 |
+
generate_btn.click(fn=full_study_plan, inputs=[subject, exam_date, hours_per_day, topics, review_frequency], outputs=[plan_output])
|
75 |
+
|
76 |
+
with gr.TabItem("📆 Calendar Agenda"):
|
77 |
+
agenda_output = gr.Markdown("### Calendar will appear here...")
|
78 |
+
agenda_btn = gr.Button("Generate Calendar Agenda")
|
79 |
+
agenda_btn.click(fn=full_agenda, inputs=[], outputs=[agenda_output])
|
80 |
+
|
81 |
+
with gr.TabItem("✅ Task Manager"):
|
82 |
+
task_input = gr.Textbox(label="Topics for Tasks", placeholder="Enter topics")
|
83 |
+
task_output = gr.Markdown("### Task breakdown will appear here...")
|
84 |
+
task_btn = gr.Button("Generate Tasks")
|
85 |
+
task_btn.click(fn=full_tasks, inputs=[task_input], outputs=[task_output])
|
86 |
+
|
87 |
+
with gr.TabItem("🎯 Goal Tracking"):
|
88 |
+
goal_output = gr.Markdown("### Goal tracking details will appear here...")
|
89 |
+
goal_btn = gr.Button("Show Goal Tracker")
|
90 |
+
goal_btn.click(fn=full_goals, inputs=[], outputs=[goal_output])
|
91 |
+
|
92 |
+
with gr.TabItem("🧠 Flashcards & Quiz"):
|
93 |
+
flashcard_input = gr.Textbox(label="Topics for Flashcards", placeholder="Enter topics")
|
94 |
+
flashcard_output = gr.Markdown("### Flashcards will appear here...")
|
95 |
+
flashcard_btn = gr.Button("Generate Flashcards")
|
96 |
+
flashcard_btn.click(fn=full_flashcards, inputs=[flashcard_input], outputs=[flashcard_output])
|
97 |
+
|
98 |
+
with gr.TabItem("🔁 Revision Planner"):
|
99 |
+
revision_input = gr.Textbox(label="Exam Date (YYYY-MM-DD)", placeholder="2025-07-10")
|
100 |
+
revision_output = gr.Markdown("### Revision plan will appear here...")
|
101 |
+
revision_btn = gr.Button("Generate Revision Plan")
|
102 |
+
revision_btn.click(fn=full_revisions, inputs=[revision_input], outputs=[revision_output])
|
103 |
+
|
104 |
+
if __name__ == "__main__":
|
105 |
+
demo.launch()
|