import gradio as gr
import random
subjects = ['You', 'Your family', 'Your friends', 'A stranger', 'An opportunity']
verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
def generate_fortune(name):
fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
if name:
return f"{name}, {fortune.lower()}"
return fortune
def fortune_cookie(name):
return generate_fortune(name)
iface = gr.Interface(
fn=fortune_cookie,
inputs=gr.Textbox(label="Enter your name (optional)"),
outputs=gr.Textbox(label="Your Fortune"),
title="Fortune Cookie Generator",
description="Get your personalized fortune!",
)
iface.launch()