> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://support.haddock.app/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# AI dish generation

The AI dish generation tool reads your menus, recipe sheets, or POS exports and turns them into dishes and preparations inside haddock. It extracts the dish name, type, price, ingredients, quantities and units, and where possible matches each ingredient to a product already in your account.

This article explains what the feature does, how it works under the hood, and how to use it.

## What it does

From a single upload, the tool produces draft dishes that include:

- **Dish name, kind** (dish, preparation, modifier, or combo), **section/tag**, and **selling price** when present in the source.
- **Ingredient list** with name, quantity, unit (g, kg, ml, l, units), and a suggested product match against your existing catalogue.
- **Yield information** (total mass and portion count) for recipes.
- **Sub-preparations**, ordered so that any preparation referenced by another is created first.
- **Combo slots** for bundled dishes with option choices.
- **Allergens**, inherited from the matched products.
- **A generated dish image**, produced in the background.
- **A confidence score** (high, medium, low) and a predicted commit action (create new vs. update existing) for every draft.

## Supported inputs

| Type | Formats | Use case |
|------|---------|----------|
| Images | PNG, JPEG, WebP | Photos of a printed menu or recipe sheet |
| Documents | PDF, DOCX | Digital menus, recipe books, supplier sheets |
| Spreadsheets | XLSX | Recipe matrices and cost sheets |

**Limits**

- Maximum file size: 25 MB per file.
- Maximum aggregate size: 100 MB per import job.
- Maximum files per job: 10.
- Languages: multilingual. Menus in Spanish, English, French and others are extracted natively.
- Processing time: small menus (up to ~25 dishes) are usually ready in 2–4 minutes. Larger files take roughly 1 minute per 10 dishes — around 100 dishes takes about 10–15 minutes, and several hundred dishes can approach an hour. Jobs run asynchronously, so you can leave the page and come back later. For very large spreadsheets, splitting them into smaller batches makes reviewing the results easier.

## How it works

1. **Upload.** Files are uploaded as a single multipart request and validated against the format and size limits above.
2. **Extraction.** Each file is processed in parallel (up to three at a time) by Google Gemini. Images and PDFs go through a vision pipeline; spreadsheets are parsed sheet by sheet; Word documents are read as text. The model returns a structured JSON draft for every dish it finds.
3. **Ingredient matching.** For each extracted ingredient, the system runs a fuzzy match against the products already in your account and against the global catalogue. Matches above a similarity threshold are linked automatically; weaker matches are surfaced as suggestions for you to confirm.
4. **Image generation.** A food photo is generated per dish in a background task and attached to the draft when ready.
5. **Review.** All drafts are presented in a review screen. You can edit any field, change matches, remove drafts, or accept them as-is.
6. **Commit.** When you confirm, each draft is committed using upsert logic (see below).

## How saving works (upsert)

Dishes are never overwritten in place. For every draft, haddock looks for an existing dish with the same name (case-insensitive, trimmed) and decides whether to create or update.

- If no dish with that name exists, a new dish is **created** with the extracted ingredients and metadata.
- If a dish with that name already exists, the existing dish is **updated** with the new information.

The update path is purely **additive** on ingredients:

- New ingredients detected by the AI are **added** to the existing dish.
- If an existing ingredient is detected again with a different **quantity** or **unit**, both fields are **updated** in place.
- If an ingredient that was already in the dish is **not** included in the new extraction, it is **kept**. Re-importing never deletes ingredients.

This behaviour protects manual edits, custom ingredients, and quantities your team has set up. Any ingredient you want removed must be deleted explicitly from the dish.

## Step by step

1. Open the **Dishes** or **Preparations** section. From the empty state, the list toolbar, or the activation checklist, click **Import with AI**. If a previous import is still in progress, the button resumes that job.
2. On the generator screen, **drop your files** into the upload zone, or use **Browse** or **Take Photo** to add them. You can mix images, PDFs and spreadsheets in the same job.
3. Confirm the upload. The job starts and shows progress per file. You can navigate away; the URL contains a `jobId` you can return to.
4. When extraction finishes, the **review screen** lists every draft dish with its ingredients, suggested matches, confidence score, and predicted action (create or update).
5. Edit any field that needs adjusting: dish name, type, price, ingredient quantity or unit, matched product, allergens.
6. Click **Commit** to save the selected drafts into your account. Created dishes appear in the list; updated dishes show the merged ingredient set.

## Partial results and errors

- If extraction produces partial output (for example, three of five dishes were recognised), the recognised drafts are shown together with a warning banner listing what was skipped and why.
- If a file is unreadable or its output is malformed, the file is skipped and reported in the warnings.
- If the job fails entirely, you can re-run the import; previously committed drafts are not affected.

## Best practices

- Upload **clear, high-resolution** images. Photos taken straight on, with the full menu visible and good lighting, produce the best extraction.
- Split very large menus into batches of up to ten files to stay within job limits.
- Review the **confidence score** before committing. Low-confidence drafts are worth a second look.
- For dishes you have already built manually, expect the importer to **update** them rather than recreate them. Verify the merged ingredients after the first run.

---