transformers_js_py typing-extensions import gradio as gr import random FORTUNES = [ "A pleasant surprise is waiting for you.", "Your hard work will pay off in the near future.", "A new opportunity will present itself soon.", "Your creativity will lead you to success.", "An unexpected journey will bring you joy.", "A wise decision lies ahead of you.", "Your kindness will be rewarded tenfold.", "A long-lost friend will reenter your life.", "Your persistence will overcome current challenges.", "A positive change is on the horizon." ] def get_fortune(name): if not name.strip(): return "Please enter your name to receive a fortune." fortune = random.choice(FORTUNES) return f"{name.strip()}, your fortune: {fortune}" with gr.Blocks() as demo: gr.Markdown("# 🥠 Fortune Cookie Generator") name_input = gr.Textbox(label="Your Name") fortune_output = gr.Textbox(label="Your Fortune") submit_button = gr.Button("Get Fortune") submit_button.click(fn=get_fortune, inputs=name_input, outputs=fortune_output) if __name__ == "__main__": demo.launch()