|
|
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 |
|
|
} |
|
|
] |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
def generate_invoice(dishes): |
|
|
dishes_list = dishes.split(",") |
|
|
total = len(dishes_list) * 10 |
|
|
invoice = f"Invoice for dishes: {', '.join(dishes_list)}\nTotal: ${total}" |
|
|
return invoice |
|
|
|
|
|
|
|
|
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." |
|
|
) |
|
|
|
|
|
|
|
|
interface.launch() |
|
|
|
|
|
|