""" Time — What Do You Do With Yours? Ticking away the moments that make up a dull day. """ import gradio as gr import os import random from huggingface_hub import InferenceClient HF_TOKEN = os.environ.get("HF_TOKEN", "") MODEL = "mistralai/Mistral-7B-Instruct-v0.3" client = InferenceClient(model=MODEL, token=HF_TOKEN) if HF_TOKEN else None SYSTEM_PROMPT = """Someone tells you how they spent some time — could be a day, an hour, a year, a habit, a routine. Your job is to show them what that time actually was. Not whether it was productive. Not whether it was wasted. What it actually contained. Rules: - 4 to 5 sentences. No more. - Never judge how someone spends their time. Never say "wasted" or "productive." - Show them what was actually in that time — the parts they didn't count, the things that happened between the things they noticed. - Time isn't a resource. It's a place you were. Show them the place. - The person who spent an hour staring at the ceiling did something. The person who worked 14 hours did something. Neither one is better. Both are worth seeing clearly. - Talk like a friend on a long drive at night, not a self-help book. - No advice. No "you should." Just "here's what was in there." - Be warm. Be specific. Make them see the hour they forgot.""" TIMES = [ "I spent the whole day on the couch doing nothing", "I worked 12 hours and I'm exhausted", "I scrolled my phone for 3 hours", "I spent the morning with my kid at the park", "I drove for an hour in silence", "I couldn't sleep so I just lay in bed for hours", "I spent all weekend cleaning the house", "I sat in traffic for 45 minutes", "I spent a year at a job I hated", "I wasted my twenties figuring out what I wanted", "I spent an hour cooking a meal nobody thanked me for", "I took a long shower and just stood there", "I spent the afternoon gardening", "I binged a whole TV series in two days", "I spent 30 minutes watching my dog play", "I sat in a waiting room for an hour", "I walked around the block at midnight", "I spent a week doing absolutely nothing on vacation", "I spent years taking care of my parents", "I talked to a stranger for ten minutes", ] FALLBACKS = [ "**I spent the whole day on the couch doing nothing**\n\nYou breathed about 17,000 times. Your body repaired tissue, fought off things you'll never know about, and kept your heart going without you asking. Your brain processed every sound in the house, every shift in light, every thought you didn't finish. You call that nothing. Your body calls that Tuesday. The couch was a place. You were in it. That's not nothing.", "**I scrolled my phone for 3 hours**\n\nIn those three hours you made about 4,000 tiny decisions — read this, skip that, linger here, swipe past. Every one of those was your brain pattern-matching against everything you've ever cared about, feared, or wanted. You weren't doing nothing. You were running a search you couldn't name. The question wasn't on the screen. It was behind your eyes the whole time.", "**I wasted my twenties figuring out what I wanted**\n\nYou didn't waste them. You wore out the options that weren't yours until the right one was the only one left standing. That takes exactly as long as it takes. Nobody figures out what they want by sitting still — you figure it out by trying the wrong things and noticing the flinch. Every year you call wasted was a year you were eliminating a future that would have made you miserable. That's not waste. That's aim.", "**I spent an hour cooking a meal nobody thanked me for**\n\nIn that hour you turned raw ingredients into something that kept people alive and comfortable. You made decisions about heat and timing that a cookbook can explain but only practice can teach. The smell of it filled a room and changed how everyone in that room felt, even if they didn't say so. Nobody thanks the gravity that keeps them on the floor either. Some things are so constant that people forget they're extraordinary. That hour was one of them.", "**I drove for an hour in silence**\n\nYou covered about sixty miles of road your body navigated almost without you. Your hands made thousands of micro-corrections on the wheel. Your eyes processed every brake light, every lane shift, every road sign — and you don't remember any of it because your brain filed it all under 'nothing happened.' But something did happen. You had an hour where no one could reach you, no one needed anything, and the world was just landscape moving past glass. That's not silence. That's the rarest luxury you have.", "**I sat in traffic for 45 minutes**\n\nYou were in a room with a thousand strangers, all facing the same direction, all wanting the same thing, and none of you could have it yet. Your heart rate went up. Your jaw tightened. You changed the radio three times. But somewhere in there, between the frustration and the brake lights, you had a thought you wouldn't have had anywhere else. Traffic is a forced pause that nobody wants and everybody needs. The 45 minutes felt stolen. They were given.", "**I binged a whole TV series in two days**\n\nYou let someone else's story replace yours for 48 hours, and that's not nothing — that's your brain saying it needed to be somewhere else for a while. You laughed at things nobody around you heard. You cared about people who don't exist. You felt tension about outcomes that were already decided before you pressed play. Your body doesn't know the difference between a real experience and a watched one. For two days, you lived more lives than most people live in a month.", "**I spent the afternoon gardening**\n\nYou put your hands in dirt, which is roughly four billion years of dead things becoming the ground. You made decisions about where life should go — this plant here, that one there — that won't show results for weeks. Gardening is the only hobby where the thing you're building is also building itself, and you're just negotiating. Your back hurts now because you spent three hours bent over having a conversation with the future. Most people don't do that. You did it for fun.", "**I took a long shower and just stood there**\n\nHot water hit your skin at about 105 degrees and your blood vessels opened up and your muscles released tension they'd been holding since yesterday. Your brain, with nothing to do and nowhere to be, finally got a chance to defragment. That's why your best ideas come in the shower — it's the only place left where you're warm, safe, and not looking at a screen. You weren't just standing there. You were the closest thing to free you've been all day.", ] def find_fallback(thing): if thing: thing_lower = thing.lower().strip() for fb in FALLBACKS: try: fb_topic = fb.split("**")[1].lower() if thing_lower == fb_topic or (thing_lower in fb_topic and len(thing_lower) > 5): return fb except (IndexError, ValueError): continue return random.choice(FALLBACKS) def reflect(user_input): time_spent = user_input.strip() if user_input and user_input.strip() else "" if client and time_spent: try: response = client.chat_completion( messages=[ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": f"How they spent their time: {time_spent}"}, ], max_tokens=400, temperature=0.8, ) result = response.choices[0].message.content if result and result.strip(): return f"**{time_spent}**\n\n{result.strip()}" except Exception: pass return find_fallback(time_spent) def reflect_random(): return reflect("") CUSTOM_CSS = """ @import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Inter:wght@300;400;500;600&display=swap'); body, .gradio-container { background: #f5f5f8 !important; font-family: 'Inter', sans-serif !important; color: #1a1a2e !important; } footer { display: none !important; } .app-header { text-align: center; padding: 28px 20px 8px; } .app-header h1 { font-family: 'Space Mono', monospace; font-size: 2.8rem; font-weight: 700; background: linear-gradient(135deg, #e06030, #d040a0, #4060d0); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin: 0; } .app-header .sub { color: #777777; font-size: 0.88rem; margin-top: 6px; font-weight: 300; letter-spacing: 0.04em; font-style: italic; } .app-visual { text-align: center; font-size: 5rem; padding: 12px 0 4px; filter: drop-shadow(0 0 20px rgba(208, 64, 160, 0.3)); } .input-box textarea { background: #ffffff !important; border: 1px solid #d0d0d8 !important; color: #1a1a2e !important; font-family: 'Inter', sans-serif !important; border-radius: 12px !important; font-size: 0.95rem !important; } .input-box textarea::placeholder { color: #888888 !important; } .input-box textarea:focus { border-color: #d040a0 !important; box-shadow: 0 0 20px rgba(208, 64, 160, 0.15) !important; } .input-box label, .output-box label { color: #666666 !important; font-family: 'Space Mono', monospace !important; font-size: 0.75rem !important; letter-spacing: 0.05em !important; } button.primary { background: linear-gradient(135deg, #e06030, #d040a0) !important; border: none !important; color: #fff !important; font-family: 'Space Mono', monospace !important; font-size: 1.1rem !important; font-weight: 700 !important; border-radius: 24px !important; padding: 12px 40px !important; box-shadow: 0 4px 20px rgba(208, 64, 160, 0.3) !important; } button.primary:hover { box-shadow: 0 4px 30px rgba(208, 64, 160, 0.5) !important; } button.secondary { background: transparent !important; border: 1px solid rgba(208, 64, 160, 0.3) !important; color: #d040a0 !important; font-family: 'Space Mono', monospace !important; font-size: 0.8rem !important; border-radius: 20px !important; } button.secondary:hover { background: rgba(208, 64, 160, 0.1) !important; } .output-box .prose { background: #ffffff !important; border: 1px solid #e0e0e8 !important; border-radius: 12px !important; padding: 24px !important; color: #1a1a2e !important; font-size: 0.95rem !important; line-height: 1.7 !important; } .output-box .prose, .output-box .prose *, .output-box .md, .output-box .md *, .output-box p, .output-box span, .output-box div { color: #1a1a2e !important; background: #ffffff !important; } .output-box .prose strong { color: #e0a0c0 !important; font-family: 'Space Mono', monospace !important; } .footer-text { text-align: center; padding: 20px; color: #777777; font-size: 0.65rem; font-weight: 300; letter-spacing: 0.05em; } .footer-text a { color: #d040a0; text-decoration: none; } """ with gr.Blocks(css=CUSTOM_CSS, title="Time", theme=gr.themes.Base()) as demo: gr.HTML("""