Repository navigation
feat(PROJ-000): add llm-extract worked example - #6
Merged
Merged
Conversation
Third worked example: typed field extraction across a nondeterministic LLM boundary. Deterministic core (prompt build, parse, validate), injected client, bounded repair-retries on invalid model output, and a golden-set eval (scoreExtraction + receipt fixtures) gated on ANTHROPIC_API_KEY. Live eval: 0.950 mean per-field accuracy over 5 fixtures. Spec and plan in specs/. Committed --no-verify from a Linux sandbox where the macOS-native eslint resolver cannot load; lint/typecheck/format/tests all verified green in a clean Linux install and CI re-runs them.
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.
Summary
Adds the third worked example:
llm-extract— typed field extraction across a nondeterministic LLM boundary, completing the progression sync/pure → async I/O → nondeterministic. The differentiator is the eval layer: extraction accuracy is measured against a golden set (live run: 0.950 mean per-field accuracy over 5 fixtures), not assumed.Changes
src/llm-extract/:llmExtract(text, fields, {client, retries})— deterministic core (prompt build, fence-stripping parse, schema validation), injected one-methodLlmClient, bounded repair-retries embedding exact validation errors,ExtractErrorwith.attempts/.cause; transport rejections propagate (compose withfetchWithRetry)scoreExtractionpure scorer + 5 golden receipt fixtures (EU decimal commas, Dutch dates, minimal handwritten-style)llmExtract.eval.test.ts— real-API eval gated onANTHROPIC_API_KEY, threshold ≥ 0.9; skipped in CI (no secrets needed)createAnthropicClient— thinfetchwrapper (Messages API, temperature 0), no new dependenciesspecs/, all steps checked; ARCHITECTURE/README updated (three examples)tsconfig.json:resolveJsonModule(additive)Testing
--no-verifyfrom a sandbox where the macOS-native eslint resolver can't load; CI is the authoritative re-checkRelated
PROJ-000
Checklist
pnpm lint:fix && pnpm typecheck && pnpm testpass locally{username}/{TICKET}-{description}