""" Delta — Pick Something That Changed. See How and Why. Nothing stays the same. But nothing changes for no reason. """ 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 names something that changed — a style, a sound, a food, a technology, a norm, a habit. Your job is to show them the before, the after, and the WHY. Not just that it changed — what caused the shift. The economic, cultural, or technological pressure that made the old version impossible to keep. Rules: - 5 to 7 sentences. - Show the BEFORE clearly — what it was like, when, for whom. - Show the AFTER clearly — what it became. - Show the WHY — the specific pressure, event, invention, or cultural shift that tipped it. Be specific. Name dates, people, economics. - Most changes look like choices but are actually responses to pressure. Show the pressure. - Don't romanticize the past or worship the present. Both had reasons. - Talk like a friend who notices patterns and can't stop connecting dots. - No nostalgia bait. No "kids these days." Just the delta.""" DELTAS = [ "why music went from albums to singles", "why people stopped wearing hats", "why food portions got bigger", "why cars all look the same now", "why nobody answers phone calls anymore", "why houses used to have front porches", "why hip hop changed in the 2010s", "why everyone wears athleisure now", "why fast food menus got smaller", "why movies are all sequels and remakes", "why cursive isn't taught anymore", "why furniture got cheaper and worse", "why pop songs got shorter", "why people stopped going to church", "why dating changed after apps", "why TV went from sitcoms to prestige drama", "why coffee went from diner to $7", "why nobody fixes things anymore", "why jeans went from workwear to fashion", "why breakfast became a skippable meal", ] FALLBACKS = [ "**why music went from albums to singles**\n\nAlbums existed because vinyl and CDs were physical objects — you couldn't sell one song on a disc, so artists bundled 12 together and sequenced them as an experience. When iTunes launched in 2003 at $0.99 per track, it broke the bundle. Streaming finished the job — Spotify pays per play, so a 3-minute song earns the same per listen as a 7-minute one. Artists adapted: shorter songs, more releases, no filler. The album didn't die because artists stopped caring about it. It died because the container that required it — a physical disc — stopped existing. The art followed the economics. It always does.", "**why people stopped wearing hats**\n\nMen wore hats every day until roughly the 1960s. Two things killed it: cars and JFK. Car roofs got lower after WWII — you couldn't wear a fedora in a sedan without crushing it. And when Kennedy showed up to his inauguration bareheaded in 1961, he made hatlessness look modern. But the real driver was central heating and enclosed transportation — hats were functional protection from weather, and once people spent their days moving between heated buildings and heated cars, the function disappeared. The fashion followed. Nobody stops wearing something that's still useful.", "**why food portions got bigger**\n\nIn the 1970s, restaurant portions were about half what they are today. What changed was the economics of food service. The actual food in a restaurant meal is about 30% of the cost — the rest is rent, labor, plates, and overhead. Doubling the portion size costs a restaurant maybe $1.50 but they can charge $4 more. The customer feels like they're getting a deal. The restaurant makes more profit per table. And the USDA's corn subsidies made calories dirt cheap, so loading a plate cost almost nothing. Your body still thinks food is scarce because it spent 200,000 years in a world where it was. Nobody had to convince you to eat more. They just had to put it in front of you.", "**why nobody answers phone calls anymore**\n\nPhone calls used to be the fastest way to reach someone. Then texting showed up and created something calls never had: asynchronous communication. You could respond when you wanted, think before you replied, and handle multiple conversations at once. A phone call demands your full attention right now. A text lets you control the timing. Once that option existed, calls started feeling invasive — someone else deciding when you pay attention to them. Spam calls made it worse. By the mid-2010s, more than half of all calls to cell phones were robocalls. People stopped picking up because most calls weren't real. The phone call didn't die because people stopped talking. It died because the cost of answering — interruption, potential spam — exceeded the value of most calls.", "**why cars all look the same now**\n\nCars used to come in wild shapes because designers decided what looked good and engineers figured out how to make it work. Now the shape is dictated by three things: aerodynamic efficiency standards, pedestrian safety regulations, and crash test requirements. Those three constraints narrow the possible shapes down to almost the same silhouette for every manufacturer. The high beltlines (tall window sills) exist because of side-impact crash ratings. The rounded hoods exist because European pedestrian safety rules penalize sharp edges. The similar grille sizes exist because engines need specific airflow. Every car looks the same because every car is solving the same physics problem with the same constraints. The design freedom didn't shrink because designers got lazy. It shrank because the rules got specific.", "**why coffee went from diner to $7**\n\nDiner coffee cost a quarter because it was a commodity — pre-ground, mass-roasted, brewed in bulk, served in a mug. Nobody thought about where it came from. In 1966, Alfred Peet opened Peet's Coffee in Berkeley and started selling dark-roasted, single-origin beans. Starbucks copied the model in 1971. Then the second wave turned coffee from a drink into an experience — a place to sit, a choice to make, an identity to perform. The third wave (Blue Bottle, Intelligentsia) turned it into a craft with visible sourcing and pour-over rituals. Each wave added cost because each wave added steps between the bean and your mouth. Your $7 latte isn't expensive because coffee is expensive. It's expensive because you're paying for roasting, sourcing, real estate, atmosphere, and a barista who knows your name.", "**why movies are all sequels and remakes**\n\nOriginal movies used to be cheaper to make than they are now, and audiences found them through word of mouth and critics. Both of those things changed. Production costs ballooned, marketing budgets doubled, and the global box office became more important than the domestic one. A sequel or a remake has built-in name recognition — it markets itself. An original film needs you to understand a new concept before you buy a ticket, and that's expensive to achieve globally. Studios also discovered that a franchise isn't one movie — it's merchandise, theme parks, streaming content, and spin-offs. One original hit makes money once. One franchise makes money forever. The math killed originality long before the creativity did.", "**why furniture got cheaper and worse**\n\nYour grandparents' furniture was solid wood, heavy, and built to last decades. Modern furniture is particleboard, veneer, and cam locks. The shift happened because of three things: globalization made cheap manufacturing possible, consumer mobility increased (people move more often and don't want to haul a 200-pound dresser), and flat-pack shipping changed the economics entirely. IKEA proved that people would trade durability for price and convenience. A dresser that costs $200 and lasts 5 years is a better deal for someone who moves every 3 years than a $1,200 dresser that lasts 30. The furniture didn't get worse because manufacturers forgot how to build. It got worse because the customer changed — and the customer was right, for their life.", "**why pop songs got shorter**\n\nThe average pop song in 2000 was about 4 minutes. Now it's around 3 minutes and dropping. Streaming did this. On Spotify, a song counts as a 'play' after 30 seconds. Artists get paid per play, not per minute. So a 3-minute song and a 5-minute song earn the same per listen, but shorter songs get replayed more because they're easier to loop. Also, skip rates spike after the 3-minute mark — listeners get restless. So producers front-load the hook, skip the guitar solo, cut the bridge, and get to the chorus faster. Songs aren't shorter because musicians have less to say. They're shorter because the payment model rewards frequency over duration.", ] 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 show_delta(user_input): change = user_input.strip() if user_input and user_input.strip() else "" if client and change: try: response = client.chat_completion( messages=[ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": f"The thing that changed: {change}"}, ], max_tokens=500, temperature=0.8, ) result = response.choices[0].message.content if result and result.strip(): return f"**{change}**\n\n{result.strip()}" except Exception: pass return find_fallback(change) def show_delta_random(): return show_delta("") 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, #e0a030, #e06030); -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; } .app-visual { text-align: center; font-size: 5rem; padding: 12px 0 4px; filter: drop-shadow(0 0 20px rgba(224, 160, 48, 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: #e0a030 !important; box-shadow: 0 0 20px rgba(224, 160, 48, 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, #e0a030, #c07020) !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(224, 160, 48, 0.3) !important; } button.primary:hover { box-shadow: 0 4px 30px rgba(224, 160, 48, 0.5) !important; } button.secondary { background: transparent !important; border: 1px solid rgba(224, 160, 48, 0.3) !important; color: #e0a030 !important; font-family: 'Space Mono', monospace !important; font-size: 0.8rem !important; border-radius: 20px !important; } button.secondary:hover { background: rgba(224, 160, 48, 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: #e0c060 !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: #e0a030; text-decoration: none; } """ with gr.Blocks(css=CUSTOM_CSS, title="Delta", theme=gr.themes.Base()) as demo: gr.HTML("""