Repository navigation
Add lookup_barcode tool - #75
Open
paultristanwagner wants to merge 2 commits into
Open
paultristanwagner wants to merge 2 commits into
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
9 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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