File size: 4,671 Bytes
e9739ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

import streamlit as st
from task_operations import TaskManager
from task_visualization import TaskVisualizer
from llm_part import get_task_advice  # Import the LLM advice function
import pandas as pd
from datetime import datetime

def main():
    st.title("Daily Task Tracker")

    task_manager = TaskManager()
    visualizer = TaskVisualizer()

    # Ensure tasks are loaded from the database into session state
    if 'tasks' not in st.session_state:
        st.session_state.tasks = task_manager.load_tasks()

    # Task input fields
    task_name = st.text_input("Task Name")
    task_time = st.time_input("Task Time")
    task_duration_hours = st.number_input("Task Duration (Hours)", min_value=0, step=1, format="%d")
    task_duration_minutes = st.number_input("Task Duration (Minutes)", min_value=0, max_value=59, step=1, format="%d")
    task_category = st.selectbox("Task Category", TaskManager.CATEGORIES)

    # Create a button to add the task
    if st.button("Add Task"):
        # Add the task to the task manager
        task_manager.add_task(task_name, task_time, task_duration_hours, task_duration_minutes, task_category)
        st.success(f"Task '{task_name}' added!")

        # Get advice from both LLMs
        advice_gemini, advice_llama = get_task_advice(task_name, task_category, task_duration_hours, task_duration_minutes)

        # Store the responses in session state
        st.session_state.advice_gemini = advice_gemini
        st.session_state.advice_llama = advice_llama

        # Create tabs for LLM advice display
        tab1, tab2 = st.tabs(["Gemini LLM", "Llama LLM"])

        with tab1:
            st.header("Gemini LLM")
            st.write("**Gemini Advice:**")
            st.write(st.session_state.advice_gemini)

        with tab2:
            st.header("Llama LLM")
            st.write("**Llama Advice:**")
            st.write(st.session_state.advice_llama)

    # Display tasks for today only
    if st.session_state.tasks:
        st.write("Today's Tasks:")

        # Convert session tasks to DataFrame and filter tasks for today
        df = pd.DataFrame(st.session_state.tasks)
        df['Task Time'] = pd.to_datetime(df['Task Time'])
        today_tasks = df[df['Task Time'].dt.date == datetime.today().date()]

        if not today_tasks.empty:
            st.table(today_tasks[['Task ID', 'Task Name', 'Task Time', 'Task Duration (hours)', 
                                  'Task Duration (minutes)', 'Category']])
        else:
            st.write("No tasks for today.")

        # Task deletion option by ID
        task_id_to_delete = st.number_input("Enter Task ID to Delete", min_value=0, step=1)
        if st.button("Delete Task by ID"):
            if task_manager.delete_task_by_id(task_id_to_delete):
                st.success(f"Task with ID '{task_id_to_delete}' deleted!")
            else:
                st.error(f"Task with ID '{task_id_to_delete}' not found.")

    # Report options and other visualizations remain unchanged
    if st.button("Daily Report"):
        report = task_manager.generate_report('daily')
        if not report.empty:
            st.write("Daily Report:")
            st.dataframe(report)
            visualizer.plot_category_performance('daily', task_manager)
        else:
            st.warning("No tasks for today.")

    if st.button("Weekly Report"):
        report = task_manager.generate_report('weekly')
        if not report.empty:
            st.write("Weekly Report:")
            st.dataframe(report)
            visualizer.plot_category_performance('weekly', task_manager)
        else:
            st.warning("No tasks for this week.")

    if st.button("Monthly Report"):
        report = task_manager.generate_report('monthly')
        if not report.empty:
            st.write("Monthly Report:")
            st.dataframe(report)
            visualizer.plot_category_performance('monthly', task_manager)
        else:
            st.warning("No tasks for this month.")

    if st.button("Yearly Report"):
        report = task_manager.generate_report('yearly')
        if not report.empty:
            st.write("Yearly Report:")
            st.dataframe(report)
            visualizer.plot_category_performance('yearly', task_manager)
        else:
            st.warning("No tasks for this year.")

    # Performance visualizations
    visualizer.plot_performance()
    visualizer.plot_overall_category_performance()

    # Option to download the report
    visualizer.download_report()

if __name__ == "__main__":
    main()