File size: 2,036 Bytes
b7a3a13 37472cf e1ae2f6 1674c86 6bf530c 90d1ce5 1674c86 ba4cf3f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import gradio as gr
dishes = [
{
"dish_id": 1,
"name": "Spaghetti Bolognese",
"description": "Classic Italian pasta with a rich, meaty tomato sauce.",
"price": 12.99
},
{
"dish_id": 2,
"name": "Margherita Pizza",
"description": "Simple and delicious pizza with fresh mozzarella, basil, and tomato sauce.",
"price": 9.99
},
{
"dish_id": 3,
"name": "Caesar Salad",
"description": "Crisp romaine lettuce, parmesan, croutons, and Caesar dressing.",
"price": 8.99
},
{
"dish_id": 4,
"name": "Chicken Alfredo",
"description": "Grilled chicken breast served with creamy Alfredo sauce over fettuccine.",
"price": 14.99
},
{
"dish_id": 5,
"name": "Tiramisu",
"description": "Classic Italian dessert with layers of coffee-soaked ladyfingers and mascarpone cream.",
"price": 5.99
}
]
# Function to generate an invoice based on selected dishes
def generate_invoice(selected_dishes):
total_price = sum(dish["price"] for dish in selected_dishes)
invoice_text = "----- Invoice -----\n"
for dish in selected_dishes:
invoice_text += f"{dish['name']}: ${dish['price']}\n"
invoice_text += f"Total: ${total_price:.2f}\n"
invoice_text += "\nThank you for dining with us! Have a great day!"
return invoice_text
# Sample function to generate invoice
def generate_invoice(dishes):
dishes_list = dishes.split(",")
total = len(dishes_list) * 10 # Assume each dish costs $10
invoice = f"Invoice for dishes: {', '.join(dishes_list)}\nTotal: ${total}"
return invoice
# Create Gradio interface
interface = gr.Interface(
fn=generate_invoice,
inputs=gr.Textbox(label="Enter Dishes (comma-separated)"),
outputs="text",
title="Restaurant Invoice Generator",
description="Enter the names of dishes to generate a themed invoice with a custom message."
)
# Launch the interface
interface.launch()
|