Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
161ee6b to
c05af7a
Compare
Clairic now returns a null span for a list item that occurs more than once in the input, since it cannot tell which occurrence it read. 0.1's TextListAnswer required a Span for every item, so any text list with a repeated name failed with "answers that do not fit". TextListAnswer.spans becomes list[Span | None]. The new list_repeated_items recording (Alice and Bob repeated, Carol once) drives an answer test, a client test and the typing check; a live test covers the same case against the API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clairic now rejects unknown options per field type with HTTP 422, and the November schema narrowed several of them: - unit no longer applies to text (err_text_unit), - null_threshold applies to compute, date, time, datetime and duration only, so text and number reject it (err_text_null_threshold), - decimals applies to number items only, so text and date lists reject it (err_text_list_decimals). Text loses unit and null_threshold and keeps no option; the class stays so declarations that attach Text() keep compiling. Number loses null_threshold. The compiler refuses List(decimals=...) on text and date lists before any request. ACCEPTED_KEYS now follows the published input schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clairic's truncated flag changed meaning: it now reports that a generated answer or list is invalid or incomplete, and the input is never truncated (#15). ClairicTruncationWarning described the old meaning, so 0.2 renames it without an alias. The warning names the fields whose raw answer has valid: false or complete: false ("Clairic returned 2 invalid answers: budget, due"), and falls back to "Clairic reported truncated: true" when none is marked. The warning tests replay truncated_invalid_answers, the first recorded truncated: true response: two source-only fields read "1,200 EUR" and "Friday", which Clairic could not normalize. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docstrings and README still described the launch API: fields packed into parallel 8,192-token passes, output_tokens always 0, a best-candidate guess on every single value, and spans locating that guess. Now: - Usage: passes are sequential decode steps, input_tokens counts every prompt token including retries, output_tokens counts the tokens generated for text, number and list answers. - Text and number answers are generated: guess stays None, confidence is the probability of the returned value, and a span is None when the value repeats or is not printed in the input. - The size limit is 65,273 tokens per prompt (input plus fields). - The README cost section quotes the December 2026 figures (1,823 input tokens over 9 decode steps for the invoice example), and the example no longer prints a guess. The usage test now reads a current recording instead of asserting the launch-era pass arithmetic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
httpx has had no stable release since 0.28.1 (December 2024); httpx2 (pydantic/httpx2) is its maintained successor with the same API under a new import name, and python_jev already uses it (#17). - The clients, tests and drift script import httpx2. The public `timeout` and `http_client` parameters now take httpx2 types. - httpx2 requires Python 3.11, so requires-python, the classifiers, ruff, pyright and the CI matrix move to 3.11-3.14. Self and assert_type come from typing, and the typing-extensions dependency goes. - A lowest-dependencies CI job, as in python_jev, runs the suite on 3.11 with the lowest allowed versions of the direct dependencies. Closes #17. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
There was a problem hiding this comment.
Dropping support for 3.10
There was a problem hiding this comment.
Yes, deliberately. It comes with the httpx2 switch (S5, #17): httpx2 declares requires-python >=3.11 (2.18.0 on PyPI), so it can't be installed on 3.10. Python 3.10 also reached end of life in October 2026, and python-jev already targets 3.11–3.14.
Keeping 3.10 would mean staying on httpx 0.28.1, which has had no stable release since December 2024, or supporting both clients side by side. Neither seemed worth it before the 1.0 API freeze.
The PR description lists this under breaking changes, and the 0.2.0 release notes will say it too. CI now runs 3.11–3.14, plus a job on 3.11 with the lowest allowed dependency versions.
🤖 Claude Code
| print(f"Invoice number: {number.value} (confidence {number.confidence:.4f})") | ||
| print(f"Due date: {data.due_date.value}") | ||
| print(f"Total: {data.total.value} USD") | ||
| print(f"PO number: {po.value} (p_null {po.p_null:.4f}, best guess {po.guess!r})") |
There was a problem hiding this comment.
Since Cloudflare's November update, Clairic no longer returns a guess for text (or number) answers. They are now generated answers: Clairic writes the value, or null, and checks it, so there's no separate best candidate.
guess is only returned for typed answers (date, time, datetime, duration, compute). The new output schema says so: "guess: Typed answers only". The re-recorded invoice response confirms it: po_number comes back with value: null and no guess key.
In 0.2, TextAnswer.guess stays for compatibility but is always None. With the line kept, the example printed best guess None, which is misleading. 0.3 (#24) removes the attribute from text and number answers altogether.
🤖 Claude Code
| print(f"PO number: {po.value} (p_null {po.p_null:.4f})") | ||
| print(f"Days to pay: {estimate.value} (80% interval {estimate.p10} to {estimate.p90})") | ||
| print(f"Input tokens: {result.usage.input_tokens} over {result.usage.passes} passes") | ||
| print(f"Input tokens: {result.usage.input_tokens} over {result.usage.passes} decode steps") |
There was a problem hiding this comment.
Yes, that's how the new output schema defines it: usage.passes, "Sequential decode steps."
At launch, passes counted the parallel 8,192-token passes fields were split into. Now Clairic decodes its generated answers step by step, and passes counts those steps. The invoice example takes 9 for 6 fields.
The SDK keeps the API's field name, usage.passes, and only the wording around it changes. Cloudflare's model page still describes passes the old way, so the schema is the only source for the new meaning.
If you prefer, the example could print {passes} passes (decode steps) to keep the API's word visible.
🤖 Claude Code
| Text, number and list answers are generated: Clairic writes the value, then checks it against the | ||
| field's options, so they carry no `guess`. Date, time, datetime and duration answers are scored | ||
| and keep a `guess`. Estimates and forecasts carry a distribution. Typed output constrains the | ||
| shape of an answer, not its correctness: use `confidence`, `p_null` and the percentile range to | ||
| decide which answers to act on and which to review. | ||
|
|
||
| Source: https://developers.cloudflare.com/workers-ai/concepts/extraction-models/ |
There was a problem hiding this comment.
Thanks! 0.3 (#24) builds the class hierarchy on exactly this split. TypedAnswer (date, time, datetime, duration, compute: guess) and GeneratedAnswer (text, number, boolean, enum, object, lists, source-only: valid, complete, raw, failure_reason) become base classes, so the distinction this docstring describes is visible in the types.
🤖 Claude Code
| The extracted text, or `None` when the input does not contain it. | ||
| guess: str | None | ||
| The best candidate text, reported even when `value` is `None`. | ||
| Always `None`: Clairic no longer returns a best candidate for text answers. |
There was a problem hiding this comment.
Let's add a line to say that this use to be valid with the initial Clairic API release but changed with Cloudflare updates
There was a problem hiding this comment.
Agreed. Proposed wording for the guess attribute:
Always
None: Clairic returned the best candidate text here, even whenvaluewasNone, until Cloudflare's November 2026 update; it no longer returns one for text answers.
The same note fits NumberAnswer.guess, and the span line, which used to locate the guess. I'll apply it to all three once you give the go-ahead.
In 0.3 (#24) the attribute is gone, so there the history moves to the README's "Upgrading from 0.2" section.
🤖 Claude Code
| "value": null, | ||
| "valid": false, |
There was a problem hiding this comment.
Why the answer isn't found / isn't valid here ?
clairic 0.2.0: works with the November 2026 Clairic API
Between Nov 16 and Nov 23, Cloudflare changed Clairic's schemas without notice (found by the drift check, #20). 0.1.0 still passed its live tests but failed on common inputs. This PR updates the vendored schemas and makes everything 0.1 lets you declare work again. The new field types and answer metadata come in 0.3.
Commits
TextListAnswer.spansislist[Span | None].Textlosesunitandnull_threshold, andNumberlosesnull_threshold(each now a 422).List(decimals=…)is refused on text and date lists before any request is sent.ClairicInvalidAnswerWarning.truncated: truenow means some generated answers are invalid (Find what triggers truncated: true #15). The warning names them.guesson text and number answers, and the 65,273-token limit.Breaking changes
ClairicTruncationWarningis renamedClairicInvalidAnswerWarning.Text(unit=…),Text(null_threshold=…)andNumber(null_threshold=…)are removed (Clairic rejects them).List(decimals=…)on text or date lists raisesModelDefinitionError.TextListAnswer.spansitems can beNone.timeoutandhttp_clienttake httpx2 types. Python 3.10 is no longer supported.Testing
list_repeated_items,truncated_invalid_answers, anderr_text_*errors.pytest -m livepasses, including a new repeated-item test.examples/invoice.pyruns live.scripts/check_schema_drift.pyexits 0 against Cloudflare's current schemas.🤖 Generated with Claude Code