food logger context tips
This commit is contained in:
+28
-1
@@ -47,10 +47,37 @@ Before reconnecting ChatGPT, verify the public endpoints: `/.well-known/oauth-pr
|
||||
|
||||
Open **Settings → API tokens → Connect an AI assistant**. For ChatGPT, use the public MCP URL and OAuth sign-in. ChatGPT must be able to reach the HTTPS URL and its OAuth metadata. For Open WebUI or another bearer-token client, create a personal token with only the scopes needed, choose Streamable HTTP, and enter the same MCP URL and token as a bearer credential. The helper's password field is local to the browser and clears when the page is left; it does not submit the token to the helper. Revoke a token from Settings when it is no longer needed.
|
||||
|
||||
The server exposes 12 tools for food diary and inventory reads and changes. `food_attach_image` and `food_log_with_image` accept a ChatGPT file object via `image_file` or base64 data via `image_base64`. Images must be JPEG, PNG, or WebP and at most 5 MiB. A client-supplied file URL must use HTTPS and an allowed host. The API performs image validation and ownership checks. Creation tools accept an `idempotency_key`; reuse the same key and arguments when retrying a request. `food_log_with_image` reports whether the entry was created even if its later attachment upload fails.
|
||||
The server exposes 16 tools for food diary, product catalogue, and inventory reads and changes. `food_attach_image` and `food_log_with_image` accept a ChatGPT file object via `image_file` or base64 data via `image_base64`. Images must be JPEG, PNG, or WebP and at most 5 MiB. A client-supplied file URL must use HTTPS and an allowed host. The API performs image validation and ownership checks. Creation tools accept an `idempotency_key`; reuse the same key and arguments when retrying a request. `food_log_with_image` reports whether the entry was created even if its later attachment upload fails.
|
||||
|
||||
`food_get_today` accepts an optional `date` in `YYYY-MM-DD` format. Omit it for the user's local today; pass a calendar date to read another day, such as yesterday. The HTTP API supports the same parameter on `GET /api/v1/food/today/?date=YYYY-MM-DD`.
|
||||
|
||||
## Product discovery and grocery photographs
|
||||
|
||||
Image interpretation belongs to the AI client. For a grocery photograph, identify the visible products and any readable barcodes, brands, package sizes, quantities, and storage locations, then send structured data to TaskNest. Unreadable details should remain unknown.
|
||||
|
||||
1. Call `food_lookup_product` with a name or barcode. It searches the authenticated user's products and, by default, Open Food Facts. It never saves search results. Exact barcodes take precedence. `include_open_food_facts: false` limits the lookup to local products. A result has `source`, `confidence`, and either a local `product_id` or an external `external_id`/barcode.
|
||||
2. When the user selects an external candidate, call `food_import_product` with its barcode. It uses the existing Open Food Facts cache and returns a local `product_id`. An unknown barcode returns a structured failure; the caller can offer manual creation. If data is incomplete, missing nutrition stays unknown.
|
||||
3. For a product absent from both catalogues, call `food_create_product` with only observed facts. It accepts products without barcodes or nutrition. If a likely duplicate exists, it returns `needs_review` and candidates instead of making a duplicate.
|
||||
4. Call `inventory_add` with a local `product_id` for one item, or `inventory_import_groceries` for up to 20 groceries. The batch resolves local matches, can import confident Open Food Facts matches, and can create manual products when `create_missing_products` is true. It adds a separate inventory row for each successful item; existing stock is not incremented. A batch idempotency key is required; reuse the same key and payload on retry.
|
||||
|
||||
For ambiguous candidates, ask the user to select one or supply more identifying details. Report batch item statuses individually: `added`, `needs_review`, or `skipped`. A batch can return `partial_success`; successful items remain added while failed items do not leave partial product or inventory writes. A changed payload with the same idempotency key returns a conflict.
|
||||
|
||||
Example tool arguments:
|
||||
|
||||
```json
|
||||
{"query":"Milbona Volle Chocolademelk","brand":"Milbona","limit":10,"include_open_food_facts":true}
|
||||
```
|
||||
|
||||
```json
|
||||
{"product":{"name":"Volle Chocolademelk","brand":"Milbona","package_quantity":"1000","package_unit":"ml"},"idempotency_key":"product-chocolate-milk-1"}
|
||||
```
|
||||
|
||||
```json
|
||||
{"items":[{"name":"Volle Chocolademelk","brand":"Milbona","quantity":2,"package_quantity":"1000","package_unit":"ml","location":"Koelkast"},{"name":"Crème fraîche","quantity":1,"location":"Koelkast"}],"create_missing_products":true,"idempotency_key":"grocery-import-2026-10-09"}
|
||||
```
|
||||
|
||||
Product package size is stored as a numeric amount and unit alongside the existing display text. Inventory `quantity` counts packages. A single opened package can store `remaining_amount`; mixed packages with different remaining contents should be separate inventory rows. The batch import does not infer consumption from a photograph.
|
||||
|
||||
The OAuth consent page displays the requested scopes. OAuth access tokens are user-specific API tokens, and token revocation also revokes the matching OAuth grant. For production, use HTTPS and set the issuer and MCP URLs to the actual public hosts before connecting a client. Dynamic client registration is disabled; clients use OAuth Client ID Metadata Documents (CIMD). ChatGPT's document offers both `none` and `private_key_jwt`; this server selects `none` with PKCE because the installed Django OAuth Toolkit supports public CIMD clients only. Clients that do not explicitly offer `none` are rejected.
|
||||
|
||||
## Verify
|
||||
|
||||
Reference in New Issue
Block a user