Repository navigation
feat: add Clairic extraction beside keyed decisions - #32
Conversation
|
Triage: Pass No changes needed from you. A maintainer will review this pull request. |
TheGreatAxios
left a comment
There was a problem hiding this comment.
Review · Request changes
Adds Clairic extraction beside the keyed decisions API. The decisions generic bound does not change keyed runtime behavior.
Findings
-
src/extraction.ts:166—textAnsweronly readsstart/endoroffsets.start/offsets.end. A documented text answer{ type: "text", value: "INV-2291", span: [8, 16], confidence: 1 }comes back as{ value: "INV-2291" }with no offsets, including when wrapped in the Workers AI{ result }envelope.src/extraction.test.tslocks the invented shape, so it cannot catch this. A temporary test failed on that sample. -
src/extraction.ts:217—estimateAnswerlooks for a nestedinterval. The documented estimate is{ type: "estimate", value: 30, median: 30, p10: 21, p90: 38 }withp10/p90as siblings. The same probe gotmedian: 30andinterval: undefined, so the 80% interval is dropped. -
src/extraction.ts:197—list("number")is accepted (text | number | date), butAnswerOftypes the value asstring[] | nulland the parser keeps onlytypeof item === "string".{ type: "list", value: [250, 80] }becomes[]. -
src/extraction.ts:155— a text answer whosevalueis not a string,{ type: "text", value: 1080 }, is mapped to{ value: null }andanswersOfstill returns success. That is indistinguishable from a real null. The response is also cast withas ExtractionAnswersinstead of being checked.
decisions.ts only tightens the input generic. tsc --noEmit on choice, noul, score, and box narrowing exited 0. Omitted kinds (time, datetime, duration, forecast), images, reference_date, integer, and scale were treated as an intentional subset.
Commit 3ceb3b8 is Merge the keyed-decisions polish into the extraction branch. That subject has a trailing period and no type. A conventional subject under 72 characters would be easier for triage to accept.
Review · Follow-upCommit Text
|
|
Superseded by the 0.4.0 release, which is merged: #34 |
Summary
@corbits/system-one/extractionwithextract()and field helperstext,date,number,list, andestimate.extractcalls Cloudflare Workers AI Clairic. It does not call the Jev endpoint. Missing credentials and bad responses are a fallback, not a throw.numberfield is a type error in a decision, and achoiceis a type error in an extraction. The root package does not re-export the extraction helpers.Verification
bun run checkexited 0 (45 tests).6cef41afound no defects.tsc --noEmitconfirms the@ts-expect-errorlines are real.Stacked on #31.
Fixes CL-11531