File size: 1,872 Bytes
5f5ffcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import gradio as gr
from src.schedule_ai import SimpleScheduler
import traceback

def create_schedule(duration, goals, available_hours, considerations):
    """Create a schedule based on user input"""
    try:
        # Validate inputs
        if not duration or not goals or not considerations:
            return "Error: Please fill in all fields"
        
        # Create scheduler instance
        scheduler = SimpleScheduler()
        
        # Generate schedule
        schedule = scheduler.generate_schedule(
            duration=duration,
            goals=goals,
            available_hours=float(available_hours),
            considerations=considerations
        )
        
        return schedule
    except Exception as e:
        # Print full error traceback for debugging
        print(traceback.format_exc())
        return f"Error: {str(e)}"

# Create interface
iface = gr.Interface(
    fn=create_schedule,
    inputs=[
        gr.Textbox(
            label="Duration",
            placeholder="e.g., 1 week, 1 month, 1 year",
            info="Format: number + week/month/year"
        ),
        gr.Textbox(
            label="Goals",
            placeholder="Describe your goals",
            lines=3
        ),
        gr.Slider(
            label="Available Hours per Day",
            minimum=1,
            maximum=12,
            value=8,
            step=0.5
        ),
        gr.Textbox(
            label="Special Considerations",
            placeholder="e.g., meetings, breaks, preferences",
            lines=2
        )
    ],
    outputs=gr.Textbox(
        label="Your Schedule", 
        lines=30
    ),
    title="πŸ“… Task Planner",
    description="Generate a personalized schedule based on your goals"
)

if __name__ == "__main__":
    iface.launch(show_error=True)