""" Natural — Pick a Food. See How Far It's Come. The thing on your plate and the thing it used to be are barely related. """ import gradio as gr import os import random from huggingface_hub import InferenceClient HF_TOKEN = os.environ.get("HF_TOKEN", "") MODEL = "Qwen/Qwen2.5-7B-Instruct" client = InferenceClient(model=MODEL, token=HF_TOKEN) if HF_TOKEN else None SYSTEM_PROMPT = """Someone names a food. Your job is to show them how far that food has come from its natural, original, wild state. What it used to look like, taste like, and how humans changed it into what they eat today. Not anti-GMO fear. Just the actual journey. Rules: - 5 to 7 sentences. - Show what the original wild version looked like — be specific. Size, color, taste, texture. - Show the key moments of human intervention — selective breeding, hybridization, grafting, industrial processing. Name the era or region when possible. - Include one thing about the modern version that would be unrecognizable to someone who only knew the original. - Don't take a side on whether this is good or bad. Some changes saved millions from starvation. Some changes are just about shelf life. Show both. - The tone is wonder, not warning. Humans have been engineering food for 10,000 years — that's not a scandal, it's a story. - Talk like a friend who just went down a Wikipedia rabbit hole about corn at 2am. - "Natural" is a spectrum, not a binary. Everything on your plate has been touched.""" FOODS = [ "corn", "bananas", "watermelon", "carrots", "chicken", "strawberries", "tomatoes", "almonds", "broccoli", "peaches", "avocados", "wheat", "apples", "beef", "lettuce", "potatoes", "salmon", "soybeans", "grapes", "rice", "milk", "honey", "eggs", "peanuts", "oranges", ] FALLBACKS = [ "**corn**\n\nThe corn on your plate started as teosinte — a grass with tiny cobs the size of your pinky finger, each holding about 10 hard kernels wrapped in a stone-like shell. You couldn't eat it raw. Mesoamerican farmers spent roughly 9,000 years selectively breeding it — picking the biggest ears, replanting those seeds, repeat. The result is so different from the original that scientists argued for decades about whether corn even came from teosinte because they look nothing alike. Modern sweet corn is basically a biological invention. It can't survive in the wild without humans planting it. You're eating something that literally cannot exist without us, and we literally cannot exist without it. That's not a food — that's a relationship.", "**bananas**\n\nWild bananas are small, round, and full of hard black seeds the size of peppercorns. You'd break a tooth before you'd enjoy one. The bananas you eat — Cavendish — are sterile clones. Every single one is genetically identical. They can't reproduce on their own; they're propagated from cuttings. This is why a single fungus (Panama disease TR4) could wipe out the entire global supply — there's no genetic diversity to fight it. We already lost one banana variety this way — the Gros Michel, which is what artificial banana flavor is based on. That's why banana candy doesn't taste like banana. It tastes like a banana that went extinct.", "**watermelon**\n\nA 17th-century painting by Giovanni Stanchi shows what watermelons used to look like — pale, swirly, mostly white rind with small pockets of pink flesh and tons of seeds. They tasted more like cucumber. The red, sweet, water-filled fruit you eat today is the result of centuries of selective breeding in Africa and the Mediterranean. The flesh-to-rind ratio has completely flipped. Wild watermelons were mostly rind with a little fruit. Yours is mostly fruit with a little rind. Someone looked at a hard, bland gourd and said 'I bet I can make this better' and then a hundred generations of farmers actually did.", "**carrots**\n\nCarrots were not originally orange. Wild carrots were thin, white or purple, tough, and bitter — closer to a woody parsnip than anything you'd want to snack on. Orange carrots didn't show up until the 16th-17th century in the Netherlands, probably through selective breeding of yellow and red varieties. The story that they were bred orange to honor William of Orange is likely a myth, but the timing is suspicious. What's real is that the orange version had more beta-carotene, stored better, and tasted sweeter. The baby carrots in your fridge aren't baby anything — they're regular carrots machine-cut into small shapes. The whole 'natural' carrot aisle is an engineering project in disguise.", "**chicken**\n\nThe ancestor of your grocery store chicken is the red junglefowl — a small, lean, semi-wild bird from Southeast Asia that weighs about 2 pounds. A modern broiler chicken weighs 6-8 pounds at just 6 weeks old. That's not an accident. Decades of selective breeding — especially after the 1948 'Chicken of Tomorrow' contest run by the USDA — optimized birds for breast meat, fast growth, and feed efficiency. Modern chickens grow so fast their legs often can't support their body weight. A chicken from the 1950s took 70 days to reach market weight. Today's chicken does it in 42. Same animal. Completely different creature.", "**strawberries**\n\nWild strawberries are tiny — smaller than your fingertip — intensely flavored, and fragile. They grow low to the ground and spoil within hours of picking. The modern strawberry is a hybrid created in France around 1750 by crossing a Chilean variety (big but bland) with a Virginia variety (small but flavorful). That cross gave us size AND flavor, which nature never offered in the same package. But the modern grocery store strawberry has been bred even further — mostly for firmness and shelf life, which is why they can survive a truck ride across the country. The tradeoff is flavor. If you've ever had a farmers market strawberry and wondered why it tastes completely different from a supermarket one, it's because they were bred for different things.", "**almonds**\n\nWild almonds are poisonous. Not slightly bitter, not unpleasant — actually toxic. They contain amygdalin, which your body converts to cyanide when you chew them. A handful of wild almonds could kill a child. Somewhere around 3,000 BCE, humans in the Middle East found individual almond trees with a genetic mutation that disabled the bitterness and the toxin. They planted those trees exclusively. Every almond you've ever eaten descends from mutant trees that ancient farmers chose to keep alive. The almond industry is now a $6 billion operation in California alone, and it takes about a gallon of water to grow a single almond. The sweetest food origin story starts with poison.", "**tomatoes**\n\nWild tomatoes in South America were the size of blueberries — tiny, tart, and barely worth picking. The Aztecs bred them up in size and the Spanish brought them to Europe in the 1500s, where people thought they were poisonous for about 200 years because they're in the nightshade family and they leached lead from pewter plates. The tomato went from decorative plant to kitchen staple only after the poorer population, who ate off wood and clay, proved you could eat them without dying. Today's grocery store tomato has been bred for uniform color, round shape, and the ability to ripen after picking during transport. The gene that makes them uniformly red also suppresses the gene that makes them taste good. Heirloom tomatoes taste better because nobody optimized them for a truck.", "**wheat**\n\nModern wheat barely resembles its ancestor. Wild einkorn wheat had two sets of chromosomes and tiny, hard-to-thresh grains. Over thousands of years, natural hybridization and human selection turned it into emmer (4 chromosome sets), then bread wheat (6 sets). The grain got bigger, the yield got higher, and the plant got shorter. In the 1960s, Norman Borlaug's dwarf wheat varieties launched the Green Revolution — shorter stalks that didn't fall over under the weight of heavy grain heads. It saved an estimated billion people from famine. The wheat in your bread has been engineered by 10,000 years of human hands. It's not the same plant anymore. It's not even close.", ] 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 f"**{thing}**\n\nWhatever you're eating when you eat \"{thing}\" has been touched by human hands for longer than you think. The wild version looked different, tasted different, and probably wouldn't be recognizable on your plate. Somewhere between the original plant or animal and the thing in your grocery store, thousands of years of selective breeding, crossbreeding, and optimization happened. The 'natural' version isn't the one at the farmers market. It's the one nobody alive has ever tasted. Everything on your plate is a collaboration between nature and every generation that decided it could be better." return random.choice(FALLBACKS) def trace(user_input): food = user_input.strip() if user_input and user_input.strip() else "" if client and food: try: response = client.chat_completion( messages=[ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": f"The food: {food}"}, ], max_tokens=500, temperature=0.8, ) result = response.choices[0].message.content if result and result.strip(): return f"**{food}**\n\n{result.strip()}" except Exception: pass return find_fallback(food) def trace_random(): return trace("") 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.6rem; font-weight: 700; background: linear-gradient(135deg, #60a040, #a0c060); -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(96, 160, 64, 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: #60a040 !important; box-shadow: 0 0 20px rgba(96, 160, 64, 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, #60a040, #408030) !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(96, 160, 64, 0.3) !important; } button.primary:hover { box-shadow: 0 4px 30px rgba(96, 160, 64, 0.5) !important; } button.secondary { background: transparent !important; border: 1px solid rgba(96, 160, 64, 0.3) !important; color: #60a040 !important; font-family: 'Space Mono', monospace !important; font-size: 0.8rem !important; border-radius: 20px !important; } button.secondary:hover { background: rgba(96, 160, 64, 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: #a0d060 !important; font-family: 'Space Mono', monospace !important; } .output-box .block { border: none !important; border-style: none !important; overflow: visible !important; box-shadow: none !important; padding: 0 !important; } .output-box .hide-container { border: none !important; border-style: none !important; } .output-box .wrap.hide { display: none !important; } .output-box .label-wrap { display: none !important; } .output-box span.prose, .output-box span.md { border: none !important; padding: 0 !important; display: inline !important; } .output-box .prose:empty, .output-box div.prose:has(span:empty) { border: none !important; padding: 0 !important; min-height: 0 !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: #60a040; text-decoration: none; } """ with gr.Blocks(css=CUSTOM_CSS, title="Natural", theme=gr.themes.Base()) as demo: gr.HTML("""