Repository navigation
Add lookup_barcode tool - #75
paultristanwagner wants to merge 2 commits into
Conversation
The app's scanner looks foods up with /api/v2/barcode, which returns full food objects. The server matches loosely (leading zeros ignored, and an all-zero code returns foods stored with the placeholder barcode "0"), so the code is validated and only foods that carry it are returned. Claude-Session: https://claude.ai/code/session_01MCJFDo71qoSqTRtcGfkpXJ
|
I'm curious how agents are supposed to use this one - are you taking a picture and the agent is scanning it? Typing the barcode to the agent? |
|
On the question above, from real use: the agent reads the barcode from a photo. I log food from ChatGPT by sending a photo of the package, and the model reads the digits printed under the bars. For regional supermarket own-brand products, |
Why aren't you just using the barcode scanner in the Cronometer for this use-case? I don't understand the need to pass a photo through an LLM. |
|
Fair question. The scanner covers logging one item yourself in the app. My case is logging done in the conversation: I send ChatGPT photos of a meal and its packages in one message, and it estimates portions, splits ingredients, logs them and records its assumptions, without me opening Cronometer. When a barcode is visible in one of those photos, |
Part of #73.
Adds a
lookup_barcodetool: find foods by the barcode on theirpackage, the same lookup the app's scanner does. Barcodes can already be
attached to custom foods (#69); this is the read side.
The scanner calls
POST /api/v2/barcode:{"query": "4006381333931", "auth": {…}, "config": {"call_version": 2}}A known code answers
{"foodId": <first match>, "foods": [<full food objects, as get_food returns them>]}; an unknown one answers{"result": "SUCCESS"}with nofoods. Verified against the live API:049000050103and0049000050103both find foods stored as"49000050103"0000000000000returns 19 unrelatedrestaurant foods whose stored barcode is
"0"Changes:
lookup_barcode(barcode)validates the code withnormalize_barcodes(so a misread digit fails the check digit instead ofmatching nothing), refuses an all-zero code, and returns only the foods
whose
barcodesactually contain it (compared without leading zeros).lookup_barcodetool, returning each food's id, name,source, default measure, measures and barcodes, ready for
add_food_entry.https://claude.ai/code/session_01MCJFDo71qoSqTRtcGfkpXJ