Docs
OfficialJev Cookbooks
Cookbook: Pre-Parsed Value Extraction
Regex finds candidate emails, phone numbers, and amounts; Jev picks the requested span so code copies a verbatim value that cannot be invented, with no free-text extraction required.
- Format
- Docs
- Reading time
- 2 min
- Published by
- TypeSafe AI
- Last verified
- Sep 2026
Works forJev for Extraction
Used inJev for Software & DevTools
Highlights
- Jev only chooses among regex-found spans, so the returned value is copied verbatim and cannot be invented.
- A receipt email was picked at 0.98, a cell number normalized to +14155550177, and an invoice total read as $1,315.50.
- Amounts parse to Decimal in code, while a $50.00 courtesy credit was flagged at P(credit) 0.99.
- find() over-finds and dedupes while pick() offers the spans as options plus a none hatch.
Quickstart
python
EMAIL_RE = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
candidates = find(EMAIL_RE, EMAIL_DOC) # regex over-finds, deduped, document order
answer = ts.system_one(
state=EMAIL_DOC,
questions={"pick": Choice(
instructions="Which email address does the sender want their receipt sent to?",
criteria={c: None for c in candidates} | {NONE: "None of these is the requested value."},
)},
model=TYPESAFE_MODEL,
).answers["pick"]
receipt = answer.choice.lower() # verbatim copy of one regex match, or "none"Watch out
Choice caps at 255 options, and candidates without a regex, such as names, must come from a roster, NER, or an LLM.
Questions about this entry
Short answers drawn from the linked project or page.
Because Jev only chooses among regex-found spans and code copies the selected one verbatim. The receipt email was picked at 0.98; amounts parse to Decimal in code, and a courtesy credit was flagged at P(credit) 0.99.
It must come from somewhere else: a roster, NER, or an LLM. The caveat also notes Choice caps at 255 options, and find() over-finds then dedupes while pick() offers the spans plus a none hatch.
In code, with three regexes: one for email addresses, one for phone numbers and one for currency-prefixed money. find() is recall-tuned, so it over-finds, dedupes on a seen set and returns the spans in document order. The model only ever sees that list as options.
A choice and a confidence. The options are the candidate spans themselves plus a none hatch reading as none of these being the requested value, so the returned choice is a verbatim copy of one of the matches or that hatch. The model chooses; code owns the string.
classify is a Choice over a fixed label set, used here for currency and country. is_true is a Noul asking P(yes), used here to test whether an amount is a credit. Every one of these calls is cached to json_cache.json, so a re-render makes no API calls.
Four addresses appear in the headers, including a billing alias, a personal address on Reply-To and a sender address, and the body asks for the receipt to go to the personal address instead of the billing alias. Which address wins is decided by reading the body, not the headers, so two questions are asked: which gets the receipt, and which one sent the message.
It happens in code rather than in the model. The receipt email is copied verbatim and lower-cased, a cell number is normalized to a canonical form such as +14155550177, and an invoice total is read as $1,315.50 with amounts parsed to Decimal.
Reactions & coverage
Posts, threads, and videos about this entry from around the web.
X: A 26-sheet plan set in 2.9 seconds
X: Which exam questions come back
X: 900 images in 40 seconds
From the Jev guides
Original write-ups on what this entry is for.
From the Jev AI model community
Posts from builders shipping with Jev right now.