Download app.py from ngocng19/mindset: direct link, hf CLI and curl.
- Browser
- Download file 3.41 kB
-
https://huggingface.co/spaces/ngocng19/mindset/resolve/main/app.py
- Command line
-
hf download hf://spaces/ngocng19/mindset/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ngocng19/mindset/resolve/main/app.py
3.41 kB
| import datetime | |
| import time | |
| import gradio as gr | |
| # Data structures | |
| subtask_map = { | |
| "Investment": ["control and compliance", "Industry/peers research", "Stock information", "Manage and circulate news to existing customers", "Selling"], | |
| "Leasing": ["Investment efficiency", "Credit-Nhóm nợ vay", "Debt collect and check-up for business feasibility"], | |
| "Admin-Payment/Payroll": ["Chamber's social and communication", "Inquiries/Billings/Invoices", "Payment/Banking", "Accounting Schedules", "managed Stakeholders"], | |
| "Psychology": ["Psychology", "Reflection-Journal", "Deep thinking"], | |
| "ADHD": ["Focus Strategies", "Workflow", "Organization", "Deep-thinking/Cognitive", "Stressed/Burnout"], | |
| "Soft skill": ["Networking-Linkedin"], | |
| "Technology": ["Excel Automation", "Data cleaning and manipulation", "AI skills"], | |
| } | |
| # Function to update subtasks based on selected category | |
| def update_subtasks(cat): | |
| choices = subtask_map.get(cat, []) | |
| return choices, choices[0] if choices else None | |
| # Pomodoro Timer Function | |
| def handle_timer(duration, current_task): | |
| if not current_task: | |
| return "00:00", "⚠️ Please select a task!" | |
| secs = duration * 60 | |
| while secs >= 0: | |
| mins, s = divmod(secs, 60) | |
| time_str = f"{mins:02d}:{s:02d}" | |
| time.sleep(1) # Simulate the timer | |
| secs -= 1 | |
| yield time_str, f"🔥 Focusing on: {current_task}" | |
| yield "00:00", "✅ Session Complete! Take a break." | |
| # Function to track the task records | |
| def track_task(cat, task, bg, curr, target, root, confirm, follow): | |
| new_row = { | |
| "Date": datetime.date.today().strftime("%d/%m"), | |
| "Category": cat, | |
| "Task": task, | |
| "Background": bg, | |
| "Current condition": curr, | |
| "Goal/Target condition": target, | |
| "Root Cause Analysis": root, | |
| "Confirmation": confirm, | |
| "Follow-up": follow | |
| } | |
| print(new_row) # Example: Replace with saving logic | |
| # Build Gradio UI | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| category = gr.Dropdown(choices=list(subtask_map.keys()), label="Select Category", value=list(subtask_map.keys())[0]) | |
| subtask = gr.Dropdown(label="Select Subtask", value="") | |
| category.change(fn=update_subtasks, inputs=category, outputs=subtask) | |
| task = gr.Textbox(label="Current Task") | |
| # Timer Section | |
| duration = gr.Slider(minimum=1, maximum=60, label="Duration (minutes)", value=25) # Default to 25 minutes | |
| timer_output = gr.Textbox(label="Timer") | |
| status_output = gr.Textbox(label="Status Message") | |
| start_button = gr.Button("Start Pomodoro") | |
| # Functionality to start the timer | |
| start_button.click(fn=handle_timer, | |
| inputs=[duration, task], | |
| outputs=[timer_output, status_output]) | |
| # Tracking Section | |
| bg = gr.Textbox(label="Background") | |
| curr = gr.Textbox(label="Current Condition") | |
| target = gr.Textbox(label="Goal/Target Condition") | |
| root = gr.Textbox(label="Root Cause Analysis") | |
| confirm = gr.Checkbox(label="Confirmation") | |
| follow = gr.Textbox(label="Follow-up Actions") | |
| submit_btn = gr.Button("Record Task") | |
| submit_btn.click(fn=track_task, | |
| inputs=[category, subtask, bg, curr, target, root, confirm, follow], | |
| outputs=None) # No output for this one | |
| demo.launch(share="True") |