import gradio as gr from transformers import pipeline # Light & fast model for CPU Basic pipe = pipeline( "text-generation", model="Qwen/Qwen2.5-1.5B-Instruct", device="cpu", torch_dtype="auto" ) def generate_lunch_plan(preferences, allergies, num_people, days=5): prompt = f"""You are a friendly lunch planner for a Kenyan organization of {num_people} people. Preferences: {preferences or 'Varied Kenyan meals, healthy options'} Allergies/Restrictions: {allergies or 'None'} Create a {days}-day lunch plan. For each day: - Main dish with short description - Side or accompaniment - Main ingredients - Why it fits the group Make it practical, affordable and delicious.""" response = pipe(prompt, max_new_tokens=600, temperature=0.7, do_sample=True)[0]['generated_text'] # Simple cleanup if "You are a friendly" in response: response = response.split("You are a friendly")[-1].strip() return response with gr.Blocks(title="🍲 Team Lunch Planner", theme=gr.themes.Soft()) as demo: gr.Markdown("# 🍲 Team Lunch Planner\nHelping your organization eat better together") with gr.Row(): with gr.Column(): prefs = gr.Textbox( label="Food Preferences", placeholder="Ugali, githeri, pilau, lots of veggies...", value="Kenyan staples, healthy options, quick to prepare" ) allergies = gr.Textbox( label="Allergies / Restrictions", placeholder="No peanuts, no dairy..." ) with gr.Column(): people = gr.Slider(5, 100, value=20, label="Number of people") days = gr.Slider(1, 7, value=5, label="Days to plan") btn = gr.Button("Generate Lunch Plan", variant="primary", size="large") output = gr.Markdown(label="Your Lunch Ideas") btn.click( generate_lunch_plan, inputs=[prefs, allergies, people, days], outputs=output ) # Important for HF Spaces if __name__ == "__main__": demo.launch( server_name="0.0.0.0", server_port=7860, share=False )