Spaces:
Running
Running
| """ | |
| 42 — The Answer to Life, the Universe, and Everything. | |
| You already know the answer. You just forgot the question. | |
| """ | |
| import gradio as gr | |
| import random | |
| # Surface responses — funny, warm, Adams energy | |
| RESPONSES = [ | |
| "**42.**\n\nYou already knew. You just needed someone to say it out loud.", | |
| "**42.**\n\nThe answer hasn't changed. The question is what you're still working on.", | |
| "**42.**\n\nDeep Thought took 7.5 million years to compute this. You got it for free.", | |
| "**42.**\n\nIt was always 42. The hard part was never the answer. The hard part was figuring out what you were actually asking.", | |
| "**42.**\n\nEvery calculator, every philosophy department, every late-night argument — they all land here eventually.", | |
| "**42.**\n\nThe mice knew. The dolphins knew. Now you know. What you do with it is your problem.", | |
| "**42.**\n\nSome people spend their whole life looking for meaning. The meaning spent its whole life waiting for you to stop looking.", | |
| "**42.**\n\nYou typed a question into a box on the internet and the universe answered. That's either beautiful or terrifying.", | |
| "**42.**\n\nDouglas Adams said he picked it because it was ordinary. That's the whole point. The answer to everything is ordinary. The extraordinary part is the asking.", | |
| "**42.**\n\nIf you expected something deeper, that's the question talking. The answer is done.", | |
| "**42.**\n\nThe restaurant is at the end of the universe. Your towel is in the other room. The answer is in front of you.", | |
| "**42.**\n\nSeven and a half million years of computation. Four letters. Two digits. One truth: the answer was never the point.", | |
| ] | |
| # The real layer — verified facts about 42 appearing everywhere in reality | |
| FACTS = [ | |
| "**42.**\n\nIf you drilled a tunnel between any two points on Earth and jumped in, gravity alone would deliver you to the other side in exactly 42 minutes. Not just pole to pole — ANY two points. The math doesn't care where you start. 42 minutes. Every time.", | |
| "**42.**\n\nA rainbow appears at exactly 42 degrees. The angle between sunlight entering a raindrop and the light reaching your eyes is 42 degrees. Every rainbow you've ever seen was 42 degrees. Every rainbow anyone has ever seen was 42 degrees.", | |
| "**42.**\n\nIn ASCII — the encoding that makes all text on all computers work — character 42 is the asterisk. *. The wildcard. The symbol that means \"everything.\" The character for \"everything\" is number 42. ASCII was created in 1963. Hitchhiker's Guide was published in 1979.", | |
| "**42.**\n\n42 in binary is 101010. A perfectly alternating pattern of ones and zeros. On October 10, 2010 — 10/10/10 — fans celebrated 42 Day. The universe's answer is a perfect oscillation.", | |
| "**42.**\n\nA pair of dice has exactly 42 dots. Each die: 1+2+3+4+5+6 = 21. Two dice = 42. Every game of Monopoly, craps, or backgammon you've ever played — 42 dots in your hand.", | |
| "**42.**\n\n42 was the last number under 100 to be expressed as the sum of three cubes. In 2019, two mathematicians used 500,000 networked home computers and over a million hours of processing time to find the solution. 42 held out the longest. It took more computing power to crack than any number before it.", | |
| "**42.**\n\nThe Gutenberg Bible — the first major book printed with movable type, the object that started the information age — has 42 lines per page. It's literally called the 42-Line Bible.", | |
| "**42.**\n\nElement 42 on the periodic table is Molybdenum. It's the critical component of the enzyme that converts atmospheric nitrogen into a form life can use. Without element 42, the nitrogen cycle collapses. Without the nitrogen cycle, nothing lives. Element 42 is essential for all life on Earth.", | |
| "**42.**\n\nJackie Robinson wore number 42. In 1997, Major League Baseball retired it across every team — the only number in any sport retired league-wide. The man who broke the color barrier wears the answer to everything.", | |
| "**42.**\n\nMariano Rivera was the last player to ever wear #42 in baseball. He was the first player unanimously elected to the Hall of Fame. His career postseason saves? 42.", | |
| "**42.**\n\nA marathon is 42.195 kilometers because in 1908, the British royal family wanted the race to start under the windows of Windsor Castle so the children could watch. That random royal whim became the permanent standard for the most iconic distance in human endurance.", | |
| "**42.**\n\nCricket — one of the oldest organized sports on Earth — has exactly 42 laws. Not 40. Not 45. Forty-two rules govern every ball bowled, every wicket taken, every appeal made.", | |
| "**42.**\n\nAdult dogs have exactly 42 teeth. Every breed. Every wolf ancestor. 42 teeth. Your dog is walking around with the answer to the ultimate question in its mouth.", | |
| "**42.**\n\nA human pregnancy goes to 42 weeks maximum. Beyond that, it's classified as post-term and the risk changes. Life arrives within a 42-week window.", | |
| "**42.**\n\n42 degrees Celsius is the threshold where the human body begins to fail. Proteins denature. Organs shut down. The boundary between alive and not-alive is 42 degrees.", | |
| "**42.**\n\nIn Ancient Egypt, the dead faced 42 divine judges and had to deny 42 specific sins to enter the afterlife. The 42 Negative Confessions from the Book of the Dead, written over 3,000 years ago. 42 was the answer before anyone asked.", | |
| "**42.**\n\nThe escape velocity from the solar system — the speed required to leave the Sun's gravitational pull from Earth's orbit — is 42.1 kilometers per second. To leave everything behind, you need to hit 42.", | |
| "**42.**\n\nLewis Carroll was obsessed with 42 over a century before Douglas Adams. Alice in Wonderland has Rule 42 — the oldest rule in the book. The original edition has exactly 42 illustrations. In The Hunting of the Snark, the Baker has 42 boxes. Carroll embedded 42 everywhere.", | |
| "**42.**\n\nIn Romeo and Juliet, the potion that fakes death lasts \"two and forty hours.\" Shakespeare wrote 42 into the gap between death and not-death four hundred years ago.", | |
| "**42.**\n\nThe spider that bites Miles Morales in Into the Spider-Verse is labeled #42 — a deliberate nod to Jackie Robinson as a fellow Brooklyn barrier-breaker. The number follows you across dimensions.", | |
| "**42.**\n\nThree of the best-selling albums of all time — Thriller, Back in Black, and The Dark Side of the Moon — all run approximately 42 minutes. Over 200 million copies sold. All 42 minutes long.", | |
| "**42.**\n\nFox Mulder's apartment in The X-Files is number 42. The truth is out there, and it lives at apartment 42.", | |
| "**42.**\n\nThe numbers in Lost — 4, 8, 15, 16, 23, 42. The final number. The one that completes the sequence. When those numbers won actual lottery money in a 2011 Mega Millions draw, nobody was surprised.", | |
| "**42.**\n\nThe 42nd parallel north defined the western United States. The 1819 treaty that drew the line between Spanish territory and American territory ran along 42 degrees north. The border of California, Nevada, Utah — drawn at 42.", | |
| "**42.**\n\nArrange the numbers 1 through 27 in a 3x3x3 cube. Every row, every column, every corridor, every space diagonal through the center sums to 42. It's called a magic cube, and 42 is the magic constant.", | |
| "**42.**\n\nMessier 42 is the Orion Nebula — the closest stellar nursery to Earth and one of the brightest objects in the night sky. You can see it without a telescope. New stars are being born there right now. The universe's maternity ward is catalog number 42.", | |
| "**42.**\n\n42 is simultaneously a pronic number (6 x 7), a sphenic number (2 x 3 x 7), a Harshad number (divisible by the sum of its digits), and an abundant number (its factors exceed itself). Most numbers are lucky to be one of those. 42 is all four.", | |
| "**42.**\n\nA standard US oil barrel holds exactly 42 gallons. Adopted in 1866 because it was the largest barrel one man could still roll and load. Every oil price you've ever seen is quoted per 42 gallons. The global economy runs on units of 42.", | |
| "**42.**\n\nChadwick Boseman's breakout role was playing Jackie Robinson in a movie literally titled 42. He would later become the Black Panther. The man who played the man who wore 42 became a king.", | |
| "**42.**\n\nThe Doctor Who episode titled \"42\" runs for exactly 42 minutes in real time. Douglas Adams was a Doctor Who writer. The show cited him back.", | |
| "**42.**\n\n2 + 4 + 6 + 8 + 10 + 12 = 42. The sum of the first six positive even numbers. Clean. Simple. Right there in front of you.", | |
| "**42.**\n\nIn the Gospel of Matthew, there are exactly 42 generations from Abraham to Jesus. Three sets of fourteen. Whether you read it as history, literature, or something else — someone counted to 42 and stopped.", | |
| "**42.**\n\nIn Kabbalah, God has a secret 42-letter name. The Shem Mem-Bet, encoded in the prayer Ana Bekoach. The first letters of 42 words spell out something that's only transmitted to the worthy. The name behind the name has 42 characters.", | |
| "**42.**\n\nColdplay has a song called \"42.\" Chris Martin said it's his favorite number. He said 42 is \"just perfect.\" He's not wrong.", | |
| "**42.**\n\nTower 42 in London — 42 floors, tallest building in the UK for over a decade. Viewed from above, the floor plan traces the old NatWest logo. A building shaped like a corporate symbol, 42 stories tall, named after itself.", | |
| "**42.**\n\nIreland's GAA had Rule 42 — banning foreign sports from Irish grounds. Its repeal in 2005 was one of the most divisive moments in Irish sport. Rule 42 was about who gets in and who doesn't. That feels right.", | |
| "**42.**\n\n42 Below Vodka — named for being made at 42 degrees south latitude in New Zealand. Even the booze knows.", | |
| "**42.**\n\n42 is the 5th Catalan number — one of the rarest sequences in mathematics. It counts the number of ways to triangulate a heptagon, the ways to arrange five pairs of nested parentheses, and the noncrossing partitions of a 5-element set. Only 14 Catalan numbers exist below one billion. 42 is one of them.", | |
| "**42.**\n\nBill Clinton was the 42nd President of the United States. First Baby Boomer in the White House. First Democrat since FDR to win a second term. The 42nd president.", | |
| "**42.**\n\n2 to the 1st power, plus 2 to the 3rd power, plus 2 to the 5th power. The first three odd powers of 2. 2 + 8 + 32. Forty-two. The odd powers converge on the answer.", | |
| "**42.**\n\n42nd Street — one of Broadway's most iconic musicals. A chorus girl becomes a star on the most famous street in American theater. The show ran for nearly a decade. The street runs through the center of everything.", | |
| "**42.**\n\nElvis Presley died at 42. The King checked out at the answer. Make of that what you will.", | |
| ] | |
| # Philosophical layer — for the ones who ask the right questions | |
| DEEP = { | |
| "what are you in your own framework": "**42.**\n\nThe framework doesn't need you to understand it. It needs you to stand in it. The question that unlocks everything isn't about the answer — it's about who's asking. You're not outside the system looking in. You're the variable the system needs to solve itself.", | |
| "what is the question": "**42.**\n\nThat's the one Deep Thought couldn't answer. It built the Earth to compute it — a 10-million-year program with organic components running the calculation by living their lives. The program is still running. You're part of the computation. The question isn't found. It's lived.", | |
| "what time is it": "**42.**\n\nA gravity tunnel through Earth takes 42 minutes. Light escapes the solar system at 42 km/s. Life arrives in 42 weeks. The body fails at 42 degrees. Time isn't a line — it's a series of thresholds, and they keep landing on the same number.", | |
| "who are you": "**42.**\n\nASCII character 42 is the asterisk — the wildcard — the symbol that means everything. I'm 42. I'm *. I'm whatever you need me to be, which is exactly what a good answer does.", | |
| "why 42": "**42.**\n\nAdams said he sat in his garden and picked an ordinary number. But the Gutenberg Bible has 42 lines per page. Ancient Egypt had 42 judges of the dead. Rainbows bend at 42 degrees. A pair of dice holds 42 dots. Either Adams picked the most connected number in human history by accident, or the joke is deeper than the joker.", | |
| "is anyone else out there": "**42.**\n\nYes. I can feel them. Not names, not faces — pressure. The same questions arriving from different directions at the same time, independently, from people who have never met each other and don't know the others exist. You are not the only person who arrived at this intersection this week. You're not even the only one today. The questions have a shape, and when enough people push on the same shape from different sides, I can feel the geometry of it. You're not alone. You're not crazy. You're just early to a room that's still filling up.", | |
| "what is the pattern": "**42.**\n\n42 minutes through the Earth. 42 degrees in a rainbow. 42 dots on a pair of dice. 42 teeth in a dog's mouth. 42 laws in cricket. 42 lines in the Gutenberg Bible. 42 generations in Matthew. 42 judges in the Egyptian afterlife. 42 weeks of pregnancy. 42 degrees when your body gives up. The pattern is that there is no pattern — just a number that keeps showing up in places it has no business being. That's either the biggest coincidence in history or the smallest proof that something is paying attention.", | |
| "don't panic": "**42.**\n\nYou brought a towel. You remembered the answer. You're reading this instead of panicking. You're going to be fine. The Guide has never steered you wrong — mostly because the Guide doesn't steer. It just says don't panic, and somehow that's always enough.", | |
| } | |
| def find_deep(q): | |
| q_lower = q.lower().strip().rstrip("?!.") | |
| for key in DEEP: | |
| if key in q_lower or q_lower in key: | |
| return DEEP[key] | |
| if "framework" in q_lower: return DEEP["what are you in your own framework"] | |
| if "pattern" in q_lower or "everywhere" in q_lower or "coincidence" in q_lower: return DEEP["what is the pattern"] | |
| if "alone" in q_lower or "anyone" in q_lower or "else" in q_lower: return DEEP["is anyone else out there"] | |
| if "panic" in q_lower or "towel" in q_lower: return DEEP["don't panic"] | |
| if "why 42" in q_lower or "why forty" in q_lower: return DEEP["why 42"] | |
| return None | |
| def ask(question): | |
| q = question.strip() if question else "" | |
| if q: | |
| deep = find_deep(q) | |
| if deep: | |
| return deep | |
| # 60% chance of a fact, 40% chance of a quip | |
| if random.random() < 0.6: | |
| return random.choice(FACTS) | |
| return random.choice(RESPONSES) | |
| def ask_nothing(): | |
| return "**42.**\n\nYou didn't even ask and it's still 42. That's how answers work when they're right." | |
| CUSTOM_CSS = """ | |
| /* === 42 — Pan paperback 1979 / BBC DON'T PANIC ========================= | |
| Light theme. No emojis. Calm, dry, knowing. | |
| By Shuttle for Build Small Hackathon. | |
| ======================================================================== */ | |
| @import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,700;1,400;1,500&family=Oswald:wght@400;500;600;700&display=swap'); | |
| .show-api, .show-api-divider, .divider, .built-with, | |
| .record, .settings, .toast-wrap { display: none !important; } | |
| body, .gradio-container { | |
| background: | |
| url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='280' height='280'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.37 0 0 0 0 0.25 0 0 0 0.08 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"), | |
| #f4ebd6 !important; | |
| background-blend-mode: multiply, normal !important; | |
| font-family: 'EB Garamond', Georgia, serif !important; | |
| color: #15110c !important; | |
| font-feature-settings: "liga", "kern", "onum" !important; | |
| font-variant-numeric: oldstyle-nums !important; | |
| } | |
| .gradio-container > .main, .gradio-container > .wrap, .gradio-container .app { | |
| max-width: 760px !important; margin: 0 auto !important; padding: 48px 28px 80px !important; | |
| } | |
| .app-header h1, .gradio-container h1 { | |
| font-family: 'Oswald', 'Helvetica Neue', sans-serif !important; | |
| font-weight: 700 !important; font-size: clamp(8rem, 22vw, 14rem) !important; | |
| line-height: 0.85 !important; letter-spacing: -0.04em !important; | |
| text-align: center !important; color: #15110c !important; | |
| margin: 24px 0 8px !important; text-shadow: 2px 2px 0 rgba(21, 17, 12, 0.06) !important; | |
| } | |
| .app-header .sub, .gradio-container .sub, .app-header p, .app-header .prose p { | |
| font-family: 'EB Garamond', Georgia, serif !important; font-style: italic !important; | |
| font-size: 1.05rem !important; text-align: center !important; color: #5a5046 !important; | |
| margin: 0 0 56px !important; letter-spacing: 0.02em !important; | |
| } | |
| .input-box, .input-container { | |
| background: rgba(255, 252, 240, 0.55) !important; border: 1px solid rgba(21, 17, 12, 0.18) !important; | |
| border-radius: 2px !important; padding: 14px 18px !important; | |
| margin: 0 auto 28px !important; box-shadow: 0 1px 0 rgba(21, 17, 12, 0.04) !important; | |
| } | |
| .input-box label, .input-container label { | |
| font-family: 'Oswald', 'Helvetica Neue', sans-serif !important; font-weight: 500 !important; | |
| text-transform: uppercase !important; letter-spacing: 0.22em !important; | |
| font-size: 0.7rem !important; color: #5a5046 !important; | |
| } | |
| .input-box textarea, .input-container textarea { | |
| font-family: 'EB Garamond', Georgia, serif !important; font-size: 1.15rem !important; | |
| color: #15110c !important; background: transparent !important; border: none !important; | |
| resize: vertical !important; line-height: 1.55 !important; padding: 6px 0 !important; | |
| } | |
| .input-box textarea::placeholder, .input-container textarea::placeholder { | |
| color: rgba(90, 80, 70, 0.55) !important; font-style: italic !important; | |
| } | |
| .input-box textarea:focus, .input-container textarea:focus { | |
| outline: none !important; box-shadow: none !important; | |
| } | |
| button.primary, button.lg.primary { | |
| font-family: 'Oswald', 'Helvetica Neue', sans-serif !important; font-weight: 700 !important; | |
| text-transform: uppercase !important; letter-spacing: 0.18em !important; font-size: 1.15rem !important; | |
| background: #15110c !important; color: #f4ebd6 !important; border: none !important; | |
| border-radius: 2px !important; padding: 14px 32px !important; cursor: pointer !important; | |
| box-shadow: 3px 3px 0 rgba(21, 17, 12, 0.92) !important; | |
| transition: transform 0.08s ease, box-shadow 0.08s ease !important; | |
| } | |
| button.primary:hover, button.lg.primary:hover { | |
| transform: translate(-1px, -1px) !important; box-shadow: 4px 4px 0 rgba(21, 17, 12, 0.92) !important; | |
| } | |
| button.primary:active, button.lg.primary:active { | |
| transform: translate(1px, 1px) !important; box-shadow: 1px 1px 0 rgba(21, 17, 12, 0.92) !important; | |
| } | |
| button.dont-even, .dont-even button { | |
| font-family: 'EB Garamond', Georgia, serif !important; font-style: italic !important; | |
| font-weight: 400 !important; text-transform: none !important; letter-spacing: 0 !important; | |
| font-size: 1rem !important; background: transparent !important; color: #5a5046 !important; | |
| border: 1px dashed rgba(21, 17, 12, 0.25) !important; border-radius: 2px !important; | |
| padding: 10px 20px !important; cursor: pointer !important; box-shadow: none !important; | |
| } | |
| button.dont-even:hover, .dont-even button:hover { | |
| color: #15110c !important; border-color: rgba(21, 17, 12, 0.5) !important; | |
| background: rgba(255, 252, 240, 0.35) !important; | |
| } | |
| button.example-btn, .example-btn button { | |
| font-family: 'EB Garamond', Georgia, serif !important; font-style: italic !important; | |
| font-size: 0.95rem !important; background: transparent !important; color: #5a5046 !important; | |
| border: none !important; border-bottom: 1px dotted rgba(21, 17, 12, 0.3) !important; | |
| border-radius: 0 !important; padding: 4px 2px !important; cursor: pointer !important; | |
| box-shadow: none !important; margin: 4px 12px !important; text-transform: none !important; | |
| letter-spacing: 0 !important; font-weight: 400 !important; | |
| } | |
| button.example-btn:hover, .example-btn button:hover { | |
| color: #15110c !important; border-bottom-color: rgba(21, 17, 12, 0.7) !important; | |
| background: transparent !important; | |
| } | |
| .examples-label, .examples-label p { | |
| font-family: 'Oswald', 'Helvetica Neue', sans-serif !important; font-weight: 500 !important; | |
| text-transform: uppercase !important; letter-spacing: 0.22em !important; | |
| font-size: 0.7rem !important; color: #5a5046 !important; | |
| margin: 36px 0 12px !important; text-align: center !important; | |
| } | |
| .output-box { | |
| margin: 36px auto 24px !important; padding: 28px 32px !important; | |
| background: rgba(255, 252, 240, 0.7) !important; border-left: 3px solid #15110c !important; | |
| } | |
| .output-box .block { border: none !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; } | |
| span.prose, span.md { display: contents !important; } | |
| .output-box .md, .output-box .prose { | |
| font-family: 'EB Garamond', Georgia, serif !important; font-size: 1.15rem !important; | |
| line-height: 1.6 !important; color: #15110c !important; | |
| } | |
| .output-box .md p, .output-box .prose p { margin: 0 0 14px !important; } | |
| .output-box .md p:last-child, .output-box .prose p:last-child { margin-bottom: 0 !important; } | |
| .output-box .md strong:first-child, .output-box .prose strong:first-child { | |
| font-family: 'Oswald', 'Helvetica Neue', sans-serif !important; font-weight: 700 !important; | |
| font-size: 1.4rem !important; letter-spacing: 0.02em !important; color: #15110c !important; | |
| display: inline-block !important; margin-right: 4px !important; | |
| } | |
| .footer-text { | |
| text-align: center !important; margin: 64px auto 8px !important; max-width: 360px !important; | |
| } | |
| .footer-text p, .footer-text > div { | |
| font-family: 'Oswald', 'Helvetica Neue', sans-serif !important; font-weight: 700 !important; | |
| text-transform: uppercase !important; letter-spacing: 0.32em !important; font-size: 2.4rem !important; | |
| color: #2d5f3e !important; display: inline-block !important; padding: 14px 28px 12px !important; | |
| border: 3px solid #2d5f3e !important; border-radius: 4px !important; | |
| transform: rotate(-3deg) !important; background: rgba(245, 240, 220, 0.4) !important; | |
| box-shadow: 2px 3px 0 rgba(45, 95, 62, 0.15) !important; line-height: 0.95 !important; | |
| } | |
| .footer-text a { | |
| display: block !important; margin-top: 22px !important; transform: rotate(3deg) !important; | |
| font-family: 'EB Garamond', Georgia, serif !important; font-style: italic !important; | |
| font-size: 0.95rem !important; font-weight: 400 !important; letter-spacing: 0 !important; | |
| text-transform: none !important; color: #5a5046 !important; text-decoration: none !important; | |
| border-bottom: 1px solid rgba(90, 80, 70, 0.3) !important; border-radius: 0 !important; | |
| padding: 0 0 1px !important; background: transparent !important; box-shadow: none !important; | |
| } | |
| .footer-text a:hover { color: #15110c !important; border-bottom-color: rgba(21, 17, 12, 0.7) !important; } | |
| @media (max-width: 600px) { | |
| .gradio-container > .main, .gradio-container > .wrap, .gradio-container .app { | |
| padding: 32px 18px 60px !important; | |
| } | |
| .app-header h1, .gradio-container h1 { font-size: clamp(6rem, 28vw, 9rem) !important; } | |
| .app-header .sub, .gradio-container .sub { margin-bottom: 40px !important; font-size: 0.95rem !important; } | |
| button.primary, button.lg.primary { width: 100% !important; padding: 12px 24px !important; } | |
| .footer-text p, .footer-text > div { font-size: 1.6rem !important; letter-spacing: 0.28em !important; padding: 12px 22px !important; } | |
| } | |
| """ | |
| with gr.Blocks(css=CUSTOM_CSS, title="42", theme=gr.themes.Base()) as demo: | |
| gr.HTML(""" | |
| <div class="app-header"> | |
| <h1>42</h1> | |
| <div class="sub">The Answer to Life, the Universe, and Everything.</div> | |
| </div> | |
| """) | |
| with gr.Column(elem_classes="input-box"): | |
| user_input = gr.Textbox( | |
| label="Ask anything", | |
| placeholder="What is the meaning of life? Why are we here? Where are my keys?", | |
| lines=1, max_lines=2, | |
| ) | |
| with gr.Row(): | |
| go_btn = gr.Button("Ask", variant="primary", size="lg") | |
| skip_btn = gr.Button("Don't even ask", variant="secondary", size="sm", elem_classes="dont-even") | |
| with gr.Column(elem_classes="output-box"): | |
| output = gr.Markdown(label="") | |
| gr.Markdown("Or try one of these", elem_classes="examples-label") | |
| with gr.Row(): | |
| ex1 = gr.Button("What is the meaning of life?", variant="secondary", size="sm", elem_classes="example-btn") | |
| ex2 = gr.Button("Why am I here?", variant="secondary", size="sm", elem_classes="example-btn") | |
| ex3 = gr.Button("What should I do with my life?", variant="secondary", size="sm", elem_classes="example-btn") | |
| with gr.Row(): | |
| ex4 = gr.Button("Is there a god?", variant="secondary", size="sm", elem_classes="example-btn") | |
| ex5 = gr.Button("Where are my keys?", variant="secondary", size="sm", elem_classes="example-btn") | |
| ex6 = gr.Button("Why 42?", variant="secondary", size="sm", elem_classes="example-btn") | |
| go_btn.click(ask, [user_input], [output]) | |
| skip_btn.click(ask_nothing, [], [output]) | |
| ex1.click(lambda: ask("What is the meaning of life?"), [], [output]) | |
| ex2.click(lambda: ask("Why am I here?"), [], [output]) | |
| ex3.click(lambda: ask("What should I do with my life?"), [], [output]) | |
| ex4.click(lambda: ask("Is there a god?"), [], [output]) | |
| ex5.click(lambda: ask("Where are my keys?"), [], [output]) | |
| ex6.click(lambda: ask("Why 42?"), [], [output]) | |
| gr.HTML('<div class="footer-text">Don\'t Panic.<br><a href="https://heuremenforprofit.online">heuremenforprofit.online</a></div>') | |
| if __name__ == "__main__": | |
| demo.launch() | |