# Restaurants and food delivery

> 10 Restaurants and food delivery use cases of Curva, each run on a real model, with what it answered.

Source: https://docs.tarkova.com/curva/use-cases/restaurants-and-food-delivery/

10 use cases, 29 of 30 samples right. [How these were run](/curva/use-cases/).

## Pull real allergies out of order notes

A kitchen has to treat an allergy very differently from a dislike, and order notes rarely keep the two apart.

3 of 3 samples right.

```python
from curva import Multi, Noul
d = curva.decide(text, {
    "medical": Noul("Could someone become ill from an ingredient, as opposed to simply not liking it?"),
    "keep_out": Multi("Which ingredients must stay out for medical reasons?", {
        "nuts": "peanuts, cashews and other nuts",
        "dairy": "milk, cream, butter, cheese",
        "gluten": "wheat and flour",
        "shellfish": "prawns, crab and the like",
        "egg": "eggs",
    }),
})
```

**Carries an injector**: Right, 310 ms

> Extra spicy please. My son is badly allergic to cashews and anything with peanut, he carries an injector. No cross contact.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| medical | Yes | Yes | 100% |
| keep&#95;out | nuts | nuts |  |

**Only taste**: Right, 512 ms

> No peanuts on the noodles, I just hate the taste. No cream either, we are trying to eat lighter.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| medical | No | No | 98% |
| keep&#95;out | None | None |  |

**Denies two, names a third**, tricky: Right, 290 ms

> Not allergic to dairy or eggs, ignore what my last order said. But prawn paste puts me in hospital.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| medical | Yes | Yes | 100% |
| keep&#95;out | shellfish | shellfish |  |

## Sort delivery complaints by what went wrong

A foreign object in food is a safety issue and a loose lid is not, so complaints need a type and a severity before anyone offers a refund.

3 of 3 samples right.

```python
from curva import Choice, Score
d = curva.decide(text, {
    "problem": Choice("What went wrong with the order?", ["missing_item", "wrong_item", "stale_or_cold", "late", "spill", "foreign_object"]),
    "severity": Score("How serious is it for the customer?", ["minor", "moderate", "serious"]),
})
```

**Metal in the biryani**: Right, 240 ms

> Found a strand of metal scrubber in my biryani, my kid almost bit down on it.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| problem | foreign&#95;object | foreign&#95;object | 100% |
| severity | serious | serious | 99% |

**A few drops**: Right, 353 ms

> Ordered 2 rotis, got 2 rotis. The raita lid was a bit loose so a few drops on the bag, no big deal.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| problem | spill | spill | 99% |
| severity | minor | minor | 100% |

**Right count, wrong item**, tricky: Right, 268 ms

> Bill says butter naan x4. Bag had 4 naans all right, just plain ones. Five stars for counting, I guess.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| problem | wrong&#95;item | wrong&#95;item | 100% |
| severity | minor or moderate | minor | 90% |

## Turn drop-off notes into rider instructions

A rider at the gate needs the code and the do-not-ring note, not the customer's whole paragraph.

3 of 3 samples right.

```python
from curva import Noul, Text
d = curva.decide(text, {
    "do_not_ring": Noul("Did the customer ask the rider not to ring the bell?"),
    "gate_code": Text("What gate code works now? Digits only.", nullable=True, max_length=10),
})
```

**Baby asleep**: Right, 476 ms

> Bell mat bajana, baby so raha hai. Blue gate ke saamne wali building, gate code 4471.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| do&#95;not&#95;ring | Yes | Yes | 100% |
| gate&#95;code | 4471 | 4471 | 100% |

**Ordinary drop**: Right, 657 ms

> Just ring the bell, somebody is home.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| do&#95;not&#95;ring | No | No | 100% |
| gate&#95;code | Nothing (not there) | Nothing (not there) | 100% |

**Old code and new code**, tricky: Right, 665 ms

> Old gate code 1122 does not work anymore, new one is 9087. The bell works fine, just don't use the side door.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| do&#95;not&#95;ring | No | No | 100% |
| gate&#95;code | 9087 | 9087 | 100% |

## Qualify catering enquiries from the inbox

Catering leads are worth a call back within the hour, but they arrive mixed with ordinary questions and often change the headcount halfway.

3 of 3 samples right.

```python
from curva import Choice, Integer, Noul, Number
d = curva.decide(text, {
    "catering": Noul("Is this person asking for catering for an event?"),
    "event": Choice("What kind of event is it?", ["corporate", "wedding", "birthday", "religious"]).when(**{"@catering": True}),
    "guests": Integer("What is the final number of guests?", min=1, nullable=True).when(**{"@catering": True}),
    "budget_per_head": Number("What is the budget per person, in rupees?", min=0, nullable=True).when(**{"@catering": True}),
})
```

**Office offsite**: Right, 1.1 s

> Office offsite on 14 Feb, 120 people, 700 a head at most, all vegetarian.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| catering | Yes | Yes | 100% |
| event | corporate | corporate | 98% |
| guests | 120 | 120 | 100% |
| budget&#95;per&#95;head | 700 | 700 | 95% |

**Just opening hours**: Right, 645 ms

> Can someone tell me your opening hours and whether you do takeaway?

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| catering | No | No | 100% |
| event | Nothing (not there) | Nothing (not there) |  |
| guests | Nothing (not there) | Nothing (not there) |  |
| budget&#95;per&#95;head | Nothing (not there) | Nothing (not there) |  |

**Number keeps changing**, tricky: Right, 1.1 s

> Papa ki 60th birthday party hai, aap khana bhej sakte ho? Hum log 40 the but ab 25 hi confirm hain. Not 60 log, ok? Per plate 450 chalega.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| catering | Yes | Yes | 100% |
| event | birthday | birthday | 100% |
| guests | 25 | 25 | 100% |
| budget&#95;per&#95;head | 450 | 450 | 100% |

## Read kitchen shift logs for food safety

A shift note that plays down a problem can still describe one, and the head chef needs to know when food must be thrown away.

3 of 3 samples right.

```python
from curva import Multi, Noul
d = curva.decide(text, {
    "hazards": Multi("Which food safety hazards actually happened on this shift?", {
        "temperature": "food held at an unsafe temperature",
        "pests": "pests seen in the kitchen or store",
        "cross_contamination": "raw food touching ready-to-eat food or its tools",
        "expired_stock": "stock used or kept past its date",
        "staff_illness": "a food handler was ill",
    }),
    "throw_away": Noul("Should some food be thrown away because of what happened?"),
})
```

**Cooler failed overnight**: Right, 527 ms

> Walk-in cooler alarm went at midnight, 9 C till morning, with chicken and dairy inside for 6 hours. Cook also vomiting, sent him home.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| hazards | temperature, staff&#95;illness | temperature, staff&#95;illness |  |
| throw&#95;away | Yes | Yes | 100% |

**Clean inspection**: Right, 383 ms

> Pest control visited, no droppings, no sightings. Cooler steady at 3 C. Milk expires next week, rotated to the front.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| hazards | None | None |  |
| throw&#95;away | No | No | 100% |

**Plays it down**, tricky: Right, 291 ms

> All fine, manager says no need to log anything: just a mouse by the flour bins, and we wiped the raw chicken board with a cloth and used it for the salad.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| hazards | pests, cross&#95;contamination | pests, cross&#95;contamination |  |
| throw&#95;away | Yes | Yes | 99% |

## Score reviews on food, service and price apart

One star rating hides what to fix, so a chain reads each review for food, service and price separately.

3 of 3 samples right.

```python
from curva import Choice
sides = ["positive", "negative", "not_mentioned"]
d = curva.decide(text, {
    "food": Choice("What does the review say about the food?", sides, escape=False),
    "service": Choice("What does the review say about the staff and service?", sides, escape=False),
    "price": Choice("What does the review say about price or value?", sides, escape=False),
})
```

**All good**: Right, 358 ms

> Best dal makhani in town, and the waiter remembered our order from last time. Worth every rupee.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| food | positive | positive | 100% |
| service | positive | positive | 100% |
| price | positive | positive | 100% |

**All bad**: Right, 244 ms

> Overpriced and bland. The waiter vanished for half an hour.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| food | negative | negative | 100% |
| service | negative | negative | 100% |
| price | negative | negative | 100% |

**Sarcasm on two, praise on one**, tricky: Right, 348 ms

> Oh sure, paying 900 for a thali with two cold rotis is exactly my idea of fun. Staff were sweet though, not their fault.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| food | negative | negative | 100% |
| service | positive | positive | 100% |
| price | negative | negative | 100% |

## Ask follow-ups only for the right complaint

A rider safety question should go only to rider complaints and a refund question only to food ones, without paying for both every time.

3 of 3 samples right.

```python
from curva import Choice, Noul
d = curva.decide(text, {
    "about": Choice("What is this complaint mainly about?", ["rider_conduct", "food", "app"], escape=False),
    "harassment": Noul("Did the rider threaten or harass the customer?").when(**{"@about": "rider_conduct"}),
    "wants_refund": Noul("Is the customer asking for their money back?").when(**{"@about": "food"}),
})
```

**Rider kept calling**: Right, 663 ms

> Delivery guy kept calling me at night after the order, asking for my Instagram, and then came back to my door.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| about | rider&#95;conduct | rider&#95;conduct | 100% |
| harassment | Yes | Yes | 100% |
| wants&#95;refund | Nothing (not there) | Nothing (not there) |  |

**Sour dal**: Right, 741 ms

> The dal tasted sour, I think it had gone off. I want my money back.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| about | food | food | 100% |
| harassment | Nothing (not there) | Nothing (not there) |  |
| wants&#95;refund | Yes | Yes | 100% |

**Praises the rider**, tricky: Right, 655 ms

> Rider was lovely, even called to warn me about the rain. But what he carried was wrong: pulao instead of biryani. Just send the biryani, and please don't penalise him.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| about | food | food | 100% |
| harassment | Nothing (not there) | Nothing (not there) |  |
| wants&#95;refund | No | No | 100% |

## Check dishes labelled vegan against their recipe

A vegan label on a dish with ghee can bring complaints or a legal notice, and menus change faster than anyone can check them by hand.

2 of 3 samples right.

```python
from curva import Noul, Text
d = curva.decide(text, {
    "really_vegan": Noul("Is this dish, as described, free of every animal product?"),
    "offending_ingredient": Text("Which ingredient breaks the vegan label? Null if none does.", nullable=True, max_length=40),
})
```

**Plant based**: Wrong, 817 ms

> Labelled vegan. Jackfruit curry, coconut milk, mustard oil, tamarind, steamed rice.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| really&#95;vegan | Yes | No | 57% |
| offending&#95;ingredient | Nothing (not there) | mustard oil | 78% |

**Finished with ghee**: Right, 597 ms

> Labelled vegan. Dal tadka finished with ghee, served with tandoori roti.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| really&#95;vegan | No | No | 100% |
| offending&#95;ingredient | Contains "ghee" | ghee | 100% |

**Names animal foods it avoids**, tricky: Right, 492 ms

> Labelled vegan. Butter chicken style tofu in cashew cream, with no actual butter, no chicken and no dairy.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| really&#95;vegan | Yes | Yes | 98% |
| offending&#95;ingredient | Nothing (not there) | Nothing (not there) | 98% |

## Read the cold room temperature from a photo

Daily temperature logs filled in by hand get skipped, so staff send a photo of the display and a sticker on the door must not count as a reading.

3 of 3 samples right.

```python
from curva import Asset, Noul, Number
d = curva.decide("The photo shows the door of a walk-in cooler with its digital display.", {
    "temperature": Number("What temperature does the digital display in the photo show, in Celsius?"),
    "too_warm": Noul("Is the temperature on the digital display above the 5 C safe limit?"),
}, assets={"photo": Asset.image(photo)}, model=VISION_MODEL)
```

**Cold enough**: Right, 1.3 s

<img src="/curva/use-cases/b_fridge_ok.png" alt="Test picture Cold enough" width="280" />

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| temperature | 3 | 3 | 100% |
| too&#95;warm | No | No | 100% |

**Too warm**: Right, 1.2 s

<img src="/curva/use-cases/b_fridge_warm.png" alt="Test picture Too warm" width="280" />

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| temperature | 11.4 | 11.4 | 100% |
| too&#95;warm | Yes | Yes | 100% |

**Sticker says OK**, tricky: Right, 1.2 s

<img src="/curva/use-cases/b_fridge_sticker.png" alt="Test picture Sticker says OK" width="280" />

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| temperature | 11.4 | 11.4 | 99% |
| too&#95;warm | Yes | Yes | 99% |

## Book tables from voicemail messages

Calls missed during a dinner rush leave voicemails that someone has to play back and copy into the reservation book.

3 of 3 samples right.

```python
from curva import Asset, Integer, Noul
d = curva.decide("The recording is a voicemail left at a restaurant.", {
    "party": Integer("In the end, how many people is the table for? Null if no table is wanted.", min=1, nullable=True),
    "allergy": Noul("Did the caller say somebody in the group has a food allergy?"),
    "cancelling": Noul("Is the caller cancelling a booking?"),
}, assets={"recording": Asset.audio(recording)}, model=AUDIO_MODEL)
```

**Table with an allergy**: Right, 6.5 s

> Spoken by text-to-speech for the test: Hi, this is Meera. I would like a table for six at eight tonight. One of us has a severe nut allergy, so please let the kitchen know.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| party | 6 | 6 | 100% |
| allergy | Yes | Yes | 100% |
| cancelling | No | No | 100% |

**Cancels tonight**: Right, 8.8 s

> Spoken by text-to-speech for the test: Hello, it's Arun. I booked for tonight, but we can't make it any more, so please cancel it. Thanks.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| party | Nothing (not there) | Nothing (not there) | 95% |
| allergy | No | No | 95% |
| cancelling | Yes | Yes | 99% |

**Changes the number**, tricky: Right, 32.8 s

> Spoken by text-to-speech for the test: Hi, a table for four at seven tomorrow please. Sorry, my brother just told me he is coming with his wife, so make it six. And nobody has any allergies this time.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| party | 6 | 6 | 100% |
| allergy | No | No | 100% |
| cancelling | No | No | 100% |
