From c05af7a655e31b89b717079ec257e1a4f78a2943 Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Tue, 24 Nov 2026 22:57:09 +0100 Subject: [PATCH 1/9] Update the vendored Clairic schemas (2026-11-24) Co-Authored-By: Claude Opus 5.5 --- tests/fixtures/schemas/schema-input.json | 180 ++++++++++++++++++++-- tests/fixtures/schemas/schema-output.json | 117 +++++++++++++- 2 files changed, 278 insertions(+), 19 deletions(-) diff --git a/tests/fixtures/schemas/schema-input.json b/tests/fixtures/schemas/schema-input.json index c7136cc..8c355b7 100644 --- a/tests/fixtures/schemas/schema-input.json +++ b/tests/fixtures/schemas/schema-input.json @@ -1,14 +1,60 @@ { "properties": { + "documents": { + "description": "Optional embedded PDFs (4 MiB each). Rendered pages plus images must total at most 4. Encrypted PDFs are rejected.", + "items": { + "anyOf": [ + { + "pattern": "^[Dd][Aa][Tt][Aa]:[Aa][Pp][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]/[Pp][Dd][Ff];[Bb][Aa][Ss][Ee]64,", + "title": "Data URL", + "type": "string" + }, + { + "properties": { + "base64": { + "type": "string" + }, + "content_type": { + "enum": [ + "application/pdf" + ], + "type": "string" + } + }, + "required": [ + "content_type", + "base64" + ], + "title": "Base64 PDF", + "type": "object" + } + ] + }, + "maxItems": 4, + "type": "array" + }, "fields": { "additionalProperties": { "properties": { "decimals": { - "description": "Numbers, durations and number lists only.", + "description": "number, compute, duration and number lists only. Values are rounded half-up.", "maximum": 6, "minimum": 0, "type": "integer" }, + "enum": { + "description": "Allowed values. Required for enum fields; optional for text, number and list fields.", + "minItems": 1, + "type": "array" + }, + "exclusiveMaximum": { + "description": "number only.", + "type": "number" + }, + "exclusiveMinimum": { + "description": "number only.", + "type": "number" + }, "horizon": { "description": "Forecast only: number of steps.", "maximum": 64, @@ -20,7 +66,7 @@ "type": "string" }, "integer": { - "description": "Numbers and durations only.", + "description": "number, compute, duration and number lists only.", "type": "boolean" }, "interval": { @@ -38,45 +84,139 @@ "type": "string" }, "items": { - "description": "Required for list fields.", - "enum": [ - "text", - "number", - "date" + "anyOf": [ + { + "enum": [ + "text", + "number", + "date" + ], + "type": "string" + }, + { + "properties": { + "properties": { + "minProperties": 1, + "type": "object" + }, + "type": { + "enum": [ + "object" + ], + "type": "string" + } + }, + "required": [ + "type", + "properties" + ], + "title": "Object item", + "type": "object" + } ], - "type": "string" + "description": "Required for list fields: \"text\", \"number\", \"date\", or an object item spec." + }, + "knowledge": { + "default": false, + "description": "text, number, and text/number lists only. Allows answers from prior knowledge that do not appear in the input. Not combinable with source_only.", + "type": "boolean" }, "max": { "description": "Required for estimate/forecast: a number, or an ISO date for date estimates." }, + "maxLength": { + "description": "text only.", + "minimum": 0, + "type": "integer" + }, + "max_items": { + "description": "List only. Maximum number of items to return.", + "minimum": 0, + "type": "integer" + }, + "maximum": { + "description": "number only.", + "type": "number" + }, "min": { "description": "Required for estimate/forecast: a number, or an ISO date for date estimates." }, + "minLength": { + "description": "text only.", + "minimum": 0, + "type": "integer" + }, + "minimum": { + "description": "number only.", + "type": "number" + }, "null_threshold": { - "description": "Probability of null above which the value is null (default 0.5).", + "description": "compute, date, time, datetime and duration only. Probability of null above which the value is null (default 0.5).", "exclusiveMinimum": 0, "maximum": 1, "type": "number" }, + "nullable": { + "default": true, + "description": "When false, text, number, boolean, enum and object answers cannot be null. compute requires true.", + "type": "boolean" + }, + "pattern": { + "description": "text only. Regular expression the answer must match.", + "type": "string" + }, + "properties": { + "additionalProperties": { + "properties": { + "type": { + "enum": [ + "text", + "number", + "boolean", + "enum" + ], + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "description": "Required for object fields and object list items. Map of property name to a spec whose type is text, number, boolean or enum.", + "minProperties": 1, + "propertyNames": { + "pattern": "^[A-Za-z_][A-Za-z0-9_.\\-]{0,63}$" + }, + "type": "object" + }, "scale": { - "default": "linear", "enum": [ "linear", "log" ], "type": "string" }, + "source_only": { + "description": "number, date, time, datetime, and number/date lists only. The answer must be printed in the input and is normalized from the printed text. Not combinable with null_threshold or knowledge.", + "type": "boolean" + }, "step": { "description": "Estimate grid: a positive number (days for date estimates), or \"month\" / \"year\"." }, "type": { + "description": "compute: a number derived from the input. boolean, enum, object: generated answers constrained to that shape.", "enum": [ "text", "number", + "compute", "date", "time", "datetime", "duration", + "boolean", + "enum", + "object", "list", "estimate", "forecast" @@ -84,7 +224,7 @@ "type": "string" }, "unit": { - "description": "Unit label. For durations, one of seconds, minutes, hours, days, weeks, months, years (default seconds).", + "description": "number, compute, duration, list, estimate, forecast. For durations, one of seconds, minutes, hours, days, weeks, months, years (default seconds).", "type": "string" } }, @@ -93,7 +233,7 @@ ], "type": "object" }, - "description": "Required. Map of field name to a typed field spec. At least one field; no upper limit. Fields that do not fit next to the state in one 8,192-token pass are split across parallel passes.", + "description": "Required. Map of field name to a typed field spec. At least one field; no upper limit. Each prompt (state plus fields) must fit in 65,273 input tokens; input is never truncated and oversized requests are rejected. Unknown keys for a field's type are rejected.", "minProperties": 1, "propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_.\\-]{0,63}$" @@ -101,7 +241,7 @@ "type": "object" }, "images": { - "description": "Optional embedded PNG, JPEG or WebP images placed before the state (max 4; 4 MiB each, 8 MiB total decoded; request body max 16 MiB). Remote URLs are not accepted.", + "description": "Optional embedded PNG, JPEG or WebP images placed before the state (max 4; 4 MiB each, 8 MiB total decoded across images and documents; request body max 16 MiB). Remote URLs are not accepted.", "items": { "anyOf": [ { @@ -116,6 +256,16 @@ }, "content_type": { "type": "string" + }, + "rotation": { + "description": "Clockwise rotation to apply. Orientation is detected automatically when omitted.", + "enum": [ + 0, + 90, + 180, + 270 + ], + "type": "integer" } }, "required": [ @@ -132,7 +282,7 @@ }, "model": { "default": "clairic", - "description": "Required. The model selector: \"clairic\".", + "description": "Required. The model selector: \"clairic\"", "pattern": "^(clairic|@cf/cloudflare/clairic)$", "type": "string" }, @@ -157,7 +307,7 @@ }, "state": { "default": "", - "description": "The text to read and predict from. Must be non-empty unless images are sent. Text answers are spans of this string.", + "description": "The text to read and predict from. Must be non-empty unless images or documents are sent. Text answers are spans of this string.", "type": "string" } }, diff --git a/tests/fixtures/schemas/schema-output.json b/tests/fixtures/schemas/schema-output.json index c675a9f..874b38c 100644 --- a/tests/fixtures/schemas/schema-output.json +++ b/tests/fixtures/schemas/schema-output.json @@ -3,13 +3,52 @@ "properties": { "answers": { "additionalProperties": { + "additionalProperties": true, "properties": { + "complete": { + "description": "Generated answers: whether generation terminated normally.", + "type": "boolean" + }, "confidence": { + "description": "Generated answers: probability of the returned value (including a null value); 0 when invalid. Typed answers: probability of guess.", + "type": "number" + }, + "confidence_method": { + "type": "string" + }, + "confidences": { + "description": "Lists: confidence per item.", + "items": { + "type": "number" + }, + "type": "array" + }, + "decoder": { + "description": "Generated answers: decoder that produced the value, e.g. parallel-ar-json-scalar-v1 or native_source_scalar_v1.", + "type": "string" + }, + "failure_reason": { + "description": "Why an answer is invalid, e.g. not_in_source.", + "type": "string" + }, + "grounding_method": { + "type": "string" + }, + "guess": { + "description": "Typed answers only: the best non-null candidate, returned even when value is null." + }, + "log_probability": { + "description": "Generated answers: log probability of the generated sequence. Present only when valid.", "type": "number" }, - "guess": {}, "mean": {}, "median": {}, + "normalization_method": { + "type": "string" + }, + "null_recovered": { + "type": "boolean" + }, "p10": {}, "p90": {}, "p_above": { @@ -21,21 +60,74 @@ "p_null": { "type": "number" }, + "p_null_method": { + "type": "string" + }, + "p_nulls": { + "description": "Lists: null probability per item.", + "items": { + "type": "number" + }, + "type": "array" + }, + "printed_value": { + "description": "source_only fields: the text as printed in the input.", + "type": [ + "string", + "null" + ] + }, + "property_spans": { + "description": "Object lists read from tables: per row, a map of property name to span or null.", + "items": { + "type": "object" + }, + "type": "array" + }, "quantiles": { "type": "array" }, + "raw": { + "description": "Generated answers: the raw generated JSON.", + "type": "string" + }, + "retry_input_tokens": { + "description": "Input tokens spent on retries for this field.", + "type": "integer" + }, + "source": { + "enum": [ + "input", + "image", + "readout" + ], + "type": "string" + }, "span": { + "description": "[start, end] character offsets into state, or null when the value has no unique match in the input.", "items": { "type": "integer" }, - "type": "array" + "maxItems": 2, + "minItems": 2, + "type": [ + "array", + "null" + ] + }, + "span_method": { + "type": "string" }, "spans": { + "description": "Lists: one span or null per item.", "items": { "items": { "type": "integer" }, - "type": "array" + "type": [ + "array", + "null" + ] }, "type": "array" }, @@ -43,9 +135,21 @@ "description": "Forecast only: one estimate per step.", "type": "array" }, + "tokens": { + "description": "Generated answers: completion tokens, including retries.", + "type": "integer" + }, "type": { "type": "string" }, + "unit": { + "description": "Duration only.", + "type": "string" + }, + "valid": { + "description": "Generated answers: whether the output satisfied the field's schema. value is null when false.", + "type": "boolean" + }, "value": {} }, "required": [ @@ -54,16 +158,18 @@ ], "type": "object" }, - "description": "One answer per field, keyed by field name. value is null when the input does not determine it.", + "description": "One answer per field, keyed by field name. value is null when the input does not determine it. Generated answers (text, number, boolean, enum, object, source_only fields, lists) carry valid/complete/decoder metadata; typed answers (date, time, datetime, duration, compute) carry guess instead.", "type": "object" }, "model": { + "description": "Always \"clairic-27b\", whichever selector was sent.", "type": "string" }, "state_text": { "type": "string" }, "truncated": { + "description": "True when any generated answer or list is invalid or incomplete. Input is never truncated.", "type": "boolean" }, "usage": { @@ -72,12 +178,15 @@ "type": "integer" }, "input_tokens": { + "description": "All prompt tokens, including retries.", "type": "integer" }, "output_tokens": { + "description": "All generated tokens.", "type": "integer" }, "passes": { + "description": "Sequential decode steps.", "type": "integer" }, "schema_tokens": { From f91815e2b4fb1e1f60b268989c095795a9227a80 Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 09:59:00 +0100 Subject: [PATCH 2/9] S1 Accept null spans in text lists 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 --- README.md | 2 +- src/clairic/answers.py | 9 +- .../responses/list_repeated_items.json | 115 ++++++++++++++++++ tests/live/test_live.py | 14 +++ tests/test_answers.py | 27 +++- tests/test_client.py | 13 ++ tests/typing/answer_types.py | 2 +- 7 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 tests/fixtures/responses/list_repeated_items.json diff --git a/README.md b/README.md index 0db038b..553c763 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ Every answer holds a `value` and the metadata Clairic attaches to it, all typed | Answers | Attributes | |---|---| | Single values (`text`, `number`, `date`, `time`, `datetime`, `duration`) | `value`, `guess`, `confidence`, `p_null` | -| Text | `span`, end-exclusive offsets into the input (`text[span.start:span.end]`). Text lists carry `spans` | +| Text | `span`, end-exclusive offsets into the input (`text[span.start:span.end]`). Text lists carry `spans`. A span is `None` when the value occurs more than once in the input | | Number and date lists | `confidences`, one per item | | Estimates | `value` (the mean rounded to the `step` grid), `mean`, `median`, `p10`, `p90`. With number bounds, `p_below` and `p_above` hold the probability mass below `min` and above `max` | | Forecasts | Per-step lists `value`, `median`, `p10`, `p90`, and `steps` with the full estimate of each step | diff --git a/src/clairic/answers.py b/src/clairic/answers.py index a38d231..398de47 100644 --- a/src/clairic/answers.py +++ b/src/clairic/answers.py @@ -200,22 +200,23 @@ class DurationAnswer(_SingleValueAnswer, Generic[N]): class TextListAnswer(Answer): - """Answer to a `list` field of text items: every matching span of the input, in order. + """Answer to a `list` field of text items, in input order. An empty list means nothing in the input matches. Attributes: value: list[str] The extracted texts, in input order. - spans: list[Span] - Location of each item of `value` in the input. + spans: list[Span | None] + Location of each item of `value` in the input. An item's span is `None` when the item + occurs more than once in the input, since Clairic cannot tell which occurrence it read. confidence: float Confidence in the list as a whole. """ type: Literal["list"] = "list" value: list[str] - spans: list[Span] + spans: list[Span | None] confidence: float diff --git a/tests/fixtures/responses/list_repeated_items.json b/tests/fixtures/responses/list_repeated_items.json new file mode 100644 index 0000000..cf24150 --- /dev/null +++ b/tests/fixtures/responses/list_repeated_items.json @@ -0,0 +1,115 @@ +{ + "status": 200, + "headers": { + "Content-Type": "application/json", + "cf-ai-req-id": "c7cd5af2-14a3-4039-a6dc-a588c8ee1a28", + "CF-RAY": "a651d8b10e5ac120-CDG" + }, + "request": { + "model": "clairic", + "state": "Meeting notes, 2 Dec 2026. Attendees: Alice, Bob and Alice's manager Carol. Alice will send the report by Friday. Budget: 1,200 EUR, approved by Bob.", + "fields": { + "attendees": { + "type": "list", + "items": "text", + "instructions": "Everyone who attended" + }, + "approver": { + "type": "text", + "instructions": "Who approved the budget" + }, + "manager": { + "type": "text", + "instructions": "Alice's manager" + } + } + }, + "response": { + "result": { + "model": "clairic-27b", + "answers": { + "attendees": { + "type": "list", + "value": [ + "Alice", + "Bob", + "Carol" + ], + "confidences": [ + 0.9996561897842547, + 0.999271781044341, + 0.8153325513547447 + ], + "confidence": 0.813980705425012, + "valid": true, + "complete": true, + "p_null": 6.411889755098527e-08, + "p_null_method": "first_item_null_probability", + "p_nulls": [ + 6.411889755098527e-08, + 7.888557432185847e-06, + 0.0005801353902841099 + ], + "log_probability": -0.20581861666960322, + "confidence_method": "ar_sequence_probability", + "spans": [ + null, + null, + [ + 69, + 74 + ] + ] + }, + "approver": { + "type": "text", + "value": "Bob", + "valid": true, + "complete": true, + "decoder": "parallel-ar-json-scalar-v1", + "tokens": 4, + "raw": "\"Bob\"", + "span": null, + "grounding_method": "literal_source", + "p_null": 2.9022733552684914e-06, + "p_null_method": "ar_first_token_null_probability", + "confidence": 0.9995446554987416, + "log_probability": -0.0004554482020466821, + "confidence_method": "ar_sequence_probability" + }, + "manager": { + "type": "text", + "value": "Carol", + "valid": true, + "complete": true, + "decoder": "parallel-ar-json-scalar-v1", + "tokens": 4, + "raw": "\"Carol\"", + "span": [ + 69, + 74 + ], + "grounding_method": "literal_source", + "span_method": "unique_literal_match", + "p_null": 0.00015841508899074532, + "p_null_method": "ar_first_token_null_probability", + "confidence": 0.9980970042843706, + "log_probability": -0.0019048087124247104, + "confidence_method": "ar_sequence_probability" + } + }, + "truncated": false, + "usage": { + "state_tokens": 46, + "image_tokens": 0, + "schema_tokens": 646, + "input_tokens": 1106, + "output_tokens": 30, + "passes": 4 + } + }, + "success": true, + "errors": [], + "messages": [] + } +} diff --git a/tests/live/test_live.py b/tests/live/test_live.py index e1b8b2c..fafb4f1 100644 --- a/tests/live/test_live.py +++ b/tests/live/test_live.py @@ -120,6 +120,20 @@ def test_forecast(clairic: Clairic) -> None: assert len(forecast.value) == len(forecast.steps) == 3 +class Meeting(BaseModel): + attendees: TextListAnswer = Field(description="Everyone who attended") + + +def test_text_list_with_repeated_items(clairic: Clairic) -> None: + """Should extract a text list whose items occur more than once in the input.""" + notes = "Attendees: Alice, Bob and Alice's manager Carol. Alice sends the report, Bob approves." + + result = clairic.extract(notes, Meeting) + + assert set(result.data.attendees.value) >= {"Alice", "Bob"} + assert len(result.data.attendees.spans) == len(result.data.attendees.value) + + def test_invalid_token_raises_authentication_error() -> None: """Should raise AuthenticationError for a token Cloudflare rejects.""" client = Clairic(account_id="0123456789abcdef0123456789abcdef", api_token="invalid") diff --git a/tests/test_answers.py b/tests/test_answers.py index 325431b..0cca474 100644 --- a/tests/test_answers.py +++ b/tests/test_answers.py @@ -88,7 +88,32 @@ def test_spans_slice_the_input_to_the_extracted_text() -> None: assert span is not None assert span == Span(118, 126) assert text[span.start : span.end] == parsed.order_id.value - assert [text[s.start : s.end] for s in parsed.damage.spans] == parsed.damage.value + spans = [s for s in parsed.damage.spans if s is not None] + assert [text[s.start : s.end] for s in spans] == parsed.damage.value + + +class Notes(BaseModel): + attendees: TextListAnswer + approver: TextAnswer + manager: TextAnswer + + +def test_values_repeated_in_the_input_have_no_span() -> None: + """Should accept a None span for items and values that occur more than once in the input. + + Recorded in list_repeated_items: Alice and Bob each appear more than once, Carol once. + """ + text = state("list_repeated_items") + parsed = Notes.model_validate(answers("list_repeated_items")) + + assert parsed.attendees.value == ["Alice", "Bob", "Carol"] + assert parsed.attendees.spans[:2] == [None, None] + carol = parsed.attendees.spans[2] + assert carol is not None + assert text[carol.start : carol.end] == "Carol" + assert parsed.approver.value == "Bob" + assert parsed.approver.span is None + assert parsed.manager.span is not None def test_absent_values_are_none_with_a_guess() -> None: diff --git a/tests/test_client.py b/tests/test_client.py index 7aa2086..46ca7d1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -123,6 +123,19 @@ class Total(BaseModel): assert result.request_id == "21d0233d-a285-4f04-969e-1f63c84d097d" +def test_extract_accepts_list_items_without_a_span() -> None: + """Should return a text list whose repeated items have no span instead of failing.""" + recorder = Recorder("list_repeated_items") + + class Attendees(BaseModel): + attendees: TextListAnswer = Field(description="Everyone who attended") + + result = _client(recorder).extract("Meeting notes.", Attendees) + + assert result.data.attendees.value == ["Alice", "Bob", "Carol"] + assert result.data.attendees.spans[0] is None + + def test_datetime_reference_date_is_sent_as_a_date() -> None: """Should send only the date part of a datetime reference date.""" recorder = Recorder("invoice") diff --git a/tests/typing/answer_types.py b/tests/typing/answer_types.py index 9626b00..6c8997a 100644 --- a/tests/typing/answer_types.py +++ b/tests/typing/answer_types.py @@ -45,7 +45,7 @@ def check(data: Extraction) -> None: assert_type(data.total.value, float | None) assert_type(data.items.guess, int | None) assert_type(data.wait.value, int | None) - assert_type(data.contacts.spans, list[Span]) + assert_type(data.contacts.spans, list[Span | None]) assert_type(data.dates.value, list[dt.date]) assert_type(data.dates.confidences, list[float]) assert_type(data.days_to_pay.p90, int) From 8560238e67d960c2f14a034f2a7f6a3b17440f65 Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 10:16:41 +0100 Subject: [PATCH 3/9] S2 Drop the options Clairic now rejects 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 --- README.md | 8 ++--- src/clairic/_compile.py | 10 +++++++ src/clairic/specs.py | 19 ++---------- .../responses/err_text_list_decimals.json | 30 +++++++++++++++++++ .../responses/err_text_null_threshold.json | 29 ++++++++++++++++++ tests/fixtures/responses/err_text_unit.json | 29 ++++++++++++++++++ tests/test_compile.py | 12 +++++++- tests/test_specs.py | 26 ++++++++-------- 8 files changed, 130 insertions(+), 33 deletions(-) create mode 100644 tests/fixtures/responses/err_text_list_decimals.json create mode 100644 tests/fixtures/responses/err_text_null_threshold.json create mode 100644 tests/fixtures/responses/err_text_unit.json diff --git a/README.md b/README.md index 553c763..c584094 100644 --- a/README.md +++ b/README.md @@ -135,12 +135,12 @@ Each field of the extraction model has an answer type, which sets the Clairic fi | Answer type | Clairic type | Spec (options) | |---|---|---| -| `TextAnswer` | `text`: a span of the input | `Text(unit, null_threshold)` | -| `NumberAnswer[float]`, `NumberAnswer[int]` | `number` (`int` requests whole numbers) | `Number(unit, null_threshold, decimals)` | +| `TextAnswer` | `text` | `Text()`, no options | +| `NumberAnswer[float]`, `NumberAnswer[int]` | `number` (`int` requests whole numbers) | `Number(unit, decimals)` | | `DateAnswer`, `TimeAnswer`, `DatetimeAnswer` | `date`, `time`, `datetime` | `Date(null_threshold)`, `Time(...)`, `Datetime(...)` | | `DurationAnswer[float]`, `DurationAnswer[int]` | `duration` | `Duration(unit, null_threshold, decimals)`, unit defaults to seconds | -| `TextListAnswer` | `list` of text spans | `List(unit, decimals)` | -| `ListAnswer[int]`, `ListAnswer[float]`, `ListAnswer[date]` | `list` of numbers or dates | `List(unit, decimals)` | +| `TextListAnswer` | `list` of texts | `List(unit)` | +| `ListAnswer[int]`, `ListAnswer[float]`, `ListAnswer[date]` | `list` of numbers or dates | `List(unit, decimals)`, decimals for numbers only | | `EstimateAnswer[int]`, `EstimateAnswer[float]` | `estimate` with number bounds | `Estimate(min, max, step, scale, unit)`, required | | `DateEstimateAnswer` | `estimate` with date bounds | `Estimate(min=date, max=date, step="month")`, required | | `ForecastAnswer` | `forecast` of a series | `Forecast(min, max, horizon, interval, step, scale, unit)`, required | diff --git a/src/clairic/_compile.py b/src/clairic/_compile.py index 86a77b2..84d36ca 100644 --- a/src/clairic/_compile.py +++ b/src/clairic/_compile.py @@ -170,9 +170,11 @@ def _type_options(where: str, origin: type[BaseModel], argument: Any, spec: Spec if origin in (NumberAnswer, DurationAnswer): return {"integer": True} if argument is int else {} if origin is TextListAnswer: + _check_number_list_options(where, spec, "text") return {"items": "text"} if origin is ListAnswer: if argument is dt.date: + _check_number_list_options(where, spec, "date") return {"items": "date"} return {"items": "number", "integer": True} if argument is int else {"items": "number"} if isinstance(spec, Estimate): @@ -180,6 +182,14 @@ def _type_options(where: str, origin: type[BaseModel], argument: Any, spec: Spec return {} +def _check_number_list_options(where: str, spec: Spec, items: str) -> None: + """Reject list options Clairic applies to number items only (err_text_list_decimals).""" + if isinstance(spec, List) and spec.decimals is not None: + raise ModelDefinitionError( + f"{where}: decimals applies to number lists only, not {items} lists" + ) + + def _check_estimate_bounds( where: str, origin: type[BaseModel], argument: Any, spec: Estimate ) -> None: diff --git a/src/clairic/specs.py b/src/clairic/specs.py index feb8d06..feae62e 100644 --- a/src/clairic/specs.py +++ b/src/clairic/specs.py @@ -124,22 +124,13 @@ def _check_bounds( class Text(Spec): """Options of a `text` field, answered by `TextAnswer`. - Attributes: - unit: str | None - Unit label shown to the model. - null_threshold: float | None - Probability of absence above which the value is `None`, in (0, 1]. Defaults to 0.5. - Raise it to keep low-certainty values, lower it to drop them. + Clairic accepts no option on text fields besides the instructions, which come from + `Field(description=...)`; it rejects `unit` and `null_threshold`. `Text()` stays valid so + declarations that attach it keep working. """ field_type: ClassVar[str] = "text" - unit: str | None = None - null_threshold: float | None = None - - def __post_init__(self) -> None: - _check_null_threshold(self.null_threshold) - @dataclasses.dataclass(frozen=True, kw_only=True) class Number(Spec): @@ -150,8 +141,6 @@ class Number(Spec): Attributes: unit: str | None Unit label, such as `"USD"`. - null_threshold: float | None - Probability of absence above which the value is `None`, in (0, 1]. Defaults to 0.5. decimals: int | None Number of decimals to round to, between 0 and 6. """ @@ -159,11 +148,9 @@ class Number(Spec): field_type: ClassVar[str] = "number" unit: str | None = None - null_threshold: float | None = None decimals: int | None = None def __post_init__(self) -> None: - _check_null_threshold(self.null_threshold) _check_decimals(self.decimals) diff --git a/tests/fixtures/responses/err_text_list_decimals.json b/tests/fixtures/responses/err_text_list_decimals.json new file mode 100644 index 0000000..6953a0c --- /dev/null +++ b/tests/fixtures/responses/err_text_list_decimals.json @@ -0,0 +1,30 @@ +{ + "status": 422, + "headers": { + "Content-Type": "application/json", + "cf-ai-req-id": "a59d91fb-1ba0-4eb6-bbc9-afb61417b4e1", + "CF-RAY": "a651d8b4cdbac2cf-CDG" + }, + "request": { + "model": "clairic", + "state": "Colors: red, blue.", + "fields": { + "f": { + "type": "list", + "items": "text", + "decimals": 2 + } + } + }, + "response": { + "errors": [ + { + "message": "AiError: AiError: field f: integer and decimals apply to numbers and durations only (a59d91fb-1ba0-4eb6-bbc9-afb61417b4e1)", + "code": 3030 + } + ], + "success": false, + "result": {}, + "messages": [] + } +} diff --git a/tests/fixtures/responses/err_text_null_threshold.json b/tests/fixtures/responses/err_text_null_threshold.json new file mode 100644 index 0000000..6c4365b --- /dev/null +++ b/tests/fixtures/responses/err_text_null_threshold.json @@ -0,0 +1,29 @@ +{ + "status": 422, + "headers": { + "Content-Type": "application/json", + "cf-ai-req-id": "bf8b4a64-f00b-49c7-ba09-fd69f4f96f4d", + "CF-RAY": "a651d8b3e93345f1-CDG" + }, + "request": { + "model": "clairic", + "state": "Order A-1 shipped.", + "fields": { + "f": { + "type": "text", + "null_threshold": 0.3 + } + } + }, + "response": { + "errors": [ + { + "message": "AiError: AiError: field f: unknown options ['null_threshold'] (bf8b4a64-f00b-49c7-ba09-fd69f4f96f4d)", + "code": 3030 + } + ], + "success": false, + "result": {}, + "messages": [] + } +} diff --git a/tests/fixtures/responses/err_text_unit.json b/tests/fixtures/responses/err_text_unit.json new file mode 100644 index 0000000..a618198 --- /dev/null +++ b/tests/fixtures/responses/err_text_unit.json @@ -0,0 +1,29 @@ +{ + "status": 422, + "headers": { + "Content-Type": "application/json", + "cf-ai-req-id": "6e0c8b70-4d6d-439d-a1b6-70e7a686941e", + "CF-RAY": "a651d8b32d8c04a6-CDG" + }, + "request": { + "model": "clairic", + "state": "Paid 12 EUR.", + "fields": { + "f": { + "type": "text", + "unit": "EUR" + } + } + }, + "response": { + "errors": [ + { + "message": "AiError: AiError: field f: unknown options ['unit'] (6e0c8b70-4d6d-439d-a1b6-70e7a686941e)", + "code": 3030 + } + ], + "success": false, + "result": {}, + "messages": [] + } +} diff --git a/tests/test_compile.py b/tests/test_compile.py index 8de4441..f083e5d 100644 --- a/tests/test_compile.py +++ b/tests/test_compile.py @@ -20,7 +20,7 @@ TimeAnswer, ) from clairic.errors import ModelDefinitionError -from clairic.specs import Duration, Estimate, Forecast, Number, Text +from clairic.specs import Duration, Estimate, Forecast, List, Number, Text class Invoice(BaseModel): @@ -164,6 +164,14 @@ class _Empty(BaseModel): pass +class _TextListDecimals(BaseModel): + tags: Annotated[TextListAnswer, List(decimals=2)] + + +class _DateListDecimals(BaseModel): + dates: Annotated[ListAnswer[dt.date], List(decimals=2)] + + @pytest.mark.parametrize( ("model", "message"), [ @@ -180,6 +188,8 @@ class _Empty(BaseModel): (_InvalidName, "field names must match"), (_ValidationAlias, "validation_alias"), (_Empty, "no fields"), + (_TextListDecimals, "decimals applies to number lists only"), + (_DateListDecimals, "decimals applies to number lists only"), ], ) def test_invalid_models_are_rejected_with_the_field_name( diff --git a/tests/test_specs.py b/tests/test_specs.py index 56153d4..fb7fd72 100644 --- a/tests/test_specs.py +++ b/tests/test_specs.py @@ -1,7 +1,7 @@ """Spec payloads and constructor rules. -Every rejected value below was rejected by the live API on 2026-10-25; the recorded response is -named in each test (tests/fixtures/responses/err_*.json). +Every rejected value below was rejected by the live API; the recorded response is named in each +test (tests/fixtures/responses/err_*.json). """ import datetime as dt @@ -22,14 +22,16 @@ Time, ) -# Keys the live API accepts per field type, besides `type` and `instructions`, as listed in its -# error messages (err_unknown_field_key and the keys_* probes). +# Keys the live API accepts per field type, besides `type` and `instructions`, limited to the +# options the specs can send. Source: the field option descriptions of the published input schema +# (tests/fixtures/schemas/schema-input.json, 2026-11-24). Text rejects unit (err_text_unit) and +# null_threshold (err_text_null_threshold). ACCEPTED_KEYS = { - "text": {"unit", "null_threshold"}, - "number": {"unit", "null_threshold", "integer", "decimals"}, - "date": {"unit", "null_threshold"}, - "time": {"unit", "null_threshold"}, - "datetime": {"unit", "null_threshold"}, + "text": set[str](), + "number": {"unit", "integer", "decimals"}, + "date": {"null_threshold"}, + "time": {"null_threshold"}, + "datetime": {"null_threshold"}, "duration": {"unit", "null_threshold", "integer", "decimals"}, "list": {"unit", "items", "integer", "decimals"}, "estimate": {"unit", "min", "max", "scale", "step"}, @@ -37,8 +39,8 @@ } FULLY_SET: list[Spec] = [ - Text(unit="ref", null_threshold=0.9), - Number(unit="USD", null_threshold=0.9, decimals=2), + Text(), + Number(unit="USD", decimals=2), Date(null_threshold=0.9), Time(null_threshold=0.9), Datetime(null_threshold=0.9), @@ -77,7 +79,7 @@ def test_date_bounds_are_sent_as_iso_dates() -> None: def test_null_threshold_outside_zero_one_is_rejected(null_threshold: float) -> None: """Should reject a null_threshold outside (0, 1] (err_null_threshold_zero).""" with pytest.raises(ValueError, match="null_threshold"): - Text(null_threshold=null_threshold) + Date(null_threshold=null_threshold) @pytest.mark.parametrize("decimals", [-1, 7]) From 6e873662f92b3e32ac8a0fbd3176c4645a90722c Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 10:32:50 +0100 Subject: [PATCH 4/9] S3 Rename the truncation warning to ClairicInvalidAnswerWarning 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 --- README.md | 14 ++- src/clairic/__init__.py | 4 +- src/clairic/_client.py | 24 +++- src/clairic/errors.py | 13 ++- src/clairic/result.py | 4 +- .../responses/truncated_invalid_answers.json | 104 ++++++++++++++++++ tests/test_client.py | 46 +++++--- 7 files changed, 176 insertions(+), 33 deletions(-) create mode 100644 tests/fixtures/responses/truncated_invalid_answers.json diff --git a/README.md b/README.md index c584094..ba98acb 100644 --- a/README.md +++ b/README.md @@ -205,9 +205,12 @@ async with AsyncClairic() as clairic: | `APIError` | Any other error response, or answers outside the model's shape. Base class of the API errors. | | `APIConnectionError`, `APITimeoutError` | Cloudflare was unreachable, or the timeout expired (30 seconds by default). | -API errors carry `status_code`, the Cloudflare error `code`, `message` and `request_id`. When -Clairic reports a truncated input, the client emits `ClairicTruncationWarning` and sets -`result.truncated`. +API errors carry `status_code`, the Cloudflare error `code`, `message` and `request_id`. + +When a generated answer comes back invalid, for example a value Clairic could not normalize, its +`value` is `None` and Clairic reports `truncated: true`. The client then sets `result.truncated` and +emits `ClairicInvalidAnswerWarning` naming the fields. Turn it into an error with +`warnings.simplefilter("error", ClairicInvalidAnswerWarning)`. ## Cost @@ -219,9 +222,8 @@ extraction above took 655 input tokens over 3 passes. ## Preview status Clairic is a preview model. Cloudflare provides it as is and may withdraw it at any time. Field -options can change too, and a weekly CI job compares Cloudflare's published schemas with the ones -vendored here. The cause of `truncated: true` is under investigation in -[#15](https://github.com/VianneyMI/clairic/issues/15). +options and answers can change too, as they did in November 2026, and a weekly CI job compares +Cloudflare's published schemas with the ones vendored here. ## Going further diff --git a/src/clairic/__init__.py b/src/clairic/__init__.py index 34a9cd3..b68a53d 100644 --- a/src/clairic/__init__.py +++ b/src/clairic/__init__.py @@ -33,7 +33,7 @@ AuthenticationError, ClairicConfigurationError, ClairicError, - ClairicTruncationWarning, + ClairicInvalidAnswerWarning, ContextWindowExceededError, InvalidRequestError, ModelDefinitionError, @@ -64,7 +64,7 @@ "Clairic", "ClairicConfigurationError", "ClairicError", - "ClairicTruncationWarning", + "ClairicInvalidAnswerWarning", "ContextWindowExceededError", "Date", "DateAnswer", diff --git a/src/clairic/_client.py b/src/clairic/_client.py index 73bcd27..e498a69 100644 --- a/src/clairic/_client.py +++ b/src/clairic/_client.py @@ -6,7 +6,7 @@ import os import warnings from types import TracebackType -from typing import Any, TypeVar +from typing import Any, TypeVar, cast import httpx from pydantic import BaseModel, ValidationError @@ -20,7 +20,7 @@ APITimeoutError, AuthenticationError, ClairicConfigurationError, - ClairicTruncationWarning, + ClairicInvalidAnswerWarning, ContextWindowExceededError, InvalidRequestError, ) @@ -99,9 +99,7 @@ def _parse(response: httpx.Response, model: type[M]) -> Result[M]: ) from error if result.truncated: warnings.warn( - "Clairic truncated the input: the answers were computed on part of it", - ClairicTruncationWarning, - stacklevel=3, + _invalid_answers_message(result.answers), ClairicInvalidAnswerWarning, stacklevel=3 ) return Result[model]( data=data, @@ -134,6 +132,22 @@ class _ResultBody(BaseModel): model: str +def _invalid_answers_message(answers: dict[str, Any]) -> str: + """Name the fields whose raw answer Clairic marks invalid or incomplete.""" + invalid = [name for name, answer in answers.items() if _is_invalid(answer)] + if not invalid: + return "Clairic reported truncated: true" + noun = "answer" if len(invalid) == 1 else "answers" + return f"Clairic returned {len(invalid)} invalid {noun}: {', '.join(invalid)}" + + +def _is_invalid(answer: Any) -> bool: + if not isinstance(answer, dict): + return False + fields = cast("dict[str, Any]", answer) + return fields.get("valid") is False or fields.get("complete") is False + + def _api_error(status_code: int, envelope: _Envelope, request_id: str | None) -> APIError: first = envelope.errors[0] if envelope.errors else _ErrorItem() message = first.message or f"HTTP {status_code}" diff --git a/src/clairic/errors.py b/src/clairic/errors.py index ed37385..85eb157 100644 --- a/src/clairic/errors.py +++ b/src/clairic/errors.py @@ -9,7 +9,7 @@ "AuthenticationError", "ClairicConfigurationError", "ClairicError", - "ClairicTruncationWarning", + "ClairicInvalidAnswerWarning", "ContextWindowExceededError", "InvalidRequestError", "ModelDefinitionError", @@ -92,8 +92,13 @@ class APITimeoutError(APIConnectionError): """Raised when the Cloudflare API does not answer within the client timeout.""" -class ClairicTruncationWarning(UserWarning): - """Emitted when Clairic reports `truncated: true`: answers were computed on part of the input. +class ClairicInvalidAnswerWarning(UserWarning): + """Emitted when Clairic reports `truncated: true`: some generated answers are invalid. - Turn it into an error with `warnings.simplefilter("error", ClairicTruncationWarning)`. + Clairic sets the flag when a generated answer or list is invalid or incomplete, for example a + `source_only` value it could not normalize; the input itself is never truncated. The message + names the fields whose raw answer reports `valid: false` or `complete: false`. Their `value` + is `None`. + + Turn it into an error with `warnings.simplefilter("error", ClairicInvalidAnswerWarning)`. """ diff --git a/src/clairic/result.py b/src/clairic/result.py index 5aca540..27f52cd 100644 --- a/src/clairic/result.py +++ b/src/clairic/result.py @@ -69,7 +69,9 @@ class Result(BaseModel, Generic[M]): usage: Usage Token counts of the request. truncated: bool - True when Clairic computed the answers on part of the input only. + True when some generated answers are invalid or incomplete; their `value` is `None`. + Clairic never truncates the input. The client also emits + `ClairicInvalidAnswerWarning` naming those fields. model: str Clairic model that answered. request_id: str | None diff --git a/tests/fixtures/responses/truncated_invalid_answers.json b/tests/fixtures/responses/truncated_invalid_answers.json new file mode 100644 index 0000000..0e8d443 --- /dev/null +++ b/tests/fixtures/responses/truncated_invalid_answers.json @@ -0,0 +1,104 @@ +{ + "status": 200, + "headers": { + "Content-Type": "application/json", + "cf-ai-req-id": "04331745-1e4c-430f-9498-50611a1fa1db", + "CF-RAY": "a651d8b56a2fb940-CDG" + }, + "request": { + "model": "clairic", + "state": "Meeting notes, 2 Dec 2026. Attendees: Alice, Bob and Alice's manager Carol. Alice will send the report by Friday. Budget: 1,200 EUR, approved by Bob.", + "fields": { + "budget": { + "type": "number", + "source_only": true, + "instructions": "The budget" + }, + "due": { + "type": "date", + "source_only": true, + "instructions": "When the report is due" + }, + "owner": { + "type": "text", + "instructions": "Who will send the report" + } + }, + "reference_date": "2026-12-02" + }, + "response": { + "result": { + "model": "clairic-27b", + "answers": { + "budget": { + "type": "number", + "value": null, + "valid": false, + "complete": true, + "decoder": "parallel-ar-json-scalar-v1", + "tokens": 9, + "raw": "\"1,200 EUR\"", + "span": null, + "grounding_method": "literal_source", + "span_method": "unique_literal_match", + "p_null": 0.0004877388130624359, + "p_null_method": "ar_first_token_null_probability", + "confidence": 0, + "log_probability": -0.005651223055558319, + "confidence_method": "ar_sequence_probability", + "failure_reason": "invalid_printed_number" + }, + "due": { + "type": "date", + "value": null, + "valid": false, + "complete": true, + "decoder": "parallel-ar-json-scalar-v1", + "tokens": 4, + "raw": "\"Friday\"", + "span": [ + 106, + 112 + ], + "grounding_method": "literal_source", + "span_method": "unique_literal_match", + "p_null": 0.01798513070825972, + "p_null_method": "ar_first_token_null_probability", + "confidence": 0, + "log_probability": -0.10608010785654187, + "confidence_method": "ar_sequence_probability", + "printed_value": "Friday", + "failure_reason": "invalid_printed_temporal" + }, + "owner": { + "type": "text", + "value": "Alice", + "valid": true, + "complete": true, + "decoder": "parallel-ar-json-scalar-v1", + "tokens": 4, + "raw": "\"Alice\"", + "span": null, + "grounding_method": "literal_source", + "p_null": 8.315025502651219e-07, + "p_null_method": "ar_first_token_null_probability", + "confidence": 0.9996078222201802, + "log_probability": -0.0003922547016372846, + "confidence_method": "ar_sequence_probability" + } + }, + "truncated": true, + "usage": { + "state_tokens": 46, + "image_tokens": 0, + "schema_tokens": 300, + "input_tokens": 438, + "output_tokens": 17, + "passes": 9 + } + }, + "success": true, + "errors": [], + "messages": [] + } +} diff --git a/tests/test_client.py b/tests/test_client.py index 46ca7d1..35ae133 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -17,7 +17,7 @@ AuthenticationError, Clairic, ClairicConfigurationError, - ClairicTruncationWarning, + ClairicInvalidAnswerWarning, ContextWindowExceededError, DateAnswer, Estimate, @@ -214,19 +214,39 @@ class WholeTotal(BaseModel): _client(Recorder("types_present")).extract("Total $140.39", WholeTotal) -def test_truncated_result_emits_a_warning() -> None: - """Should warn, pointing at the caller, when Clairic reports a truncated input.""" +class Report(BaseModel): + budget: NumberAnswer[float] = Field(description="The budget") + due: DateAnswer = Field(description="When the report is due") + owner: TextAnswer = Field(description="Who will send the report") - def truncate(body: dict[str, Any]) -> None: - body["result"]["truncated"] = True - with pytest.warns(ClairicTruncationWarning) as caught: - result = _client(Recorder("invoice", truncate)).extract(INVOICE_STATE, InvoiceExtraction) +def test_invalid_answers_emit_a_warning_naming_them() -> None: + """Should warn, pointing at the caller, naming the answers Clairic marks invalid. + + Recorded in truncated_invalid_answers: two source-only fields read "1,200 EUR" and "Friday", + which Clairic could not normalize, so it reported truncated: true. + """ + with pytest.warns( + ClairicInvalidAnswerWarning, match="2 invalid answers: budget, due" + ) as caught: + result = _client(Recorder("truncated_invalid_answers")).extract("Meeting notes.", Report) assert result.truncated is True + assert result.data.budget.value is None + assert result.data.owner.value == "Alice" assert caught[0].filename == __file__ +def test_truncated_result_without_invalid_answers_still_warns() -> None: + """Should warn with a generic message when no answer is marked invalid.""" + + def truncate(body: dict[str, Any]) -> None: + body["result"]["truncated"] = True + + with pytest.warns(ClairicInvalidAnswerWarning, match="reported truncated: true"): + _client(Recorder("invoice", truncate)).extract(INVOICE_STATE, InvoiceExtraction) + + def test_untruncated_result_emits_no_warning() -> None: """Should not warn on a complete result.""" with warnings.catch_warnings(): @@ -361,14 +381,10 @@ def handler(request: httpx.Request) -> httpx.Response: @pytest.mark.anyio -async def test_async_truncated_result_emits_a_warning() -> None: +async def test_async_invalid_answers_emit_a_warning() -> None: """Should warn, pointing at the caller, with the async client.""" - - def truncate(body: dict[str, Any]) -> None: - body["result"]["truncated"] = True - - async with _async_client(Recorder("invoice", truncate)) as client: - with pytest.warns(ClairicTruncationWarning) as caught: - await client.extract(INVOICE_STATE, InvoiceExtraction) + async with _async_client(Recorder("truncated_invalid_answers")) as client: + with pytest.warns(ClairicInvalidAnswerWarning, match="budget, due") as caught: + await client.extract("Meeting notes.", Report) assert caught[0].filename == __file__ From 6c00ec0173ef9dae77c551f89bdf81b84ac6f3b2 Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 11:07:19 +0100 Subject: [PATCH 5/9] S4 Describe the current Clairic API in docstrings and README 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 --- README.md | 23 +++++++++++------------ examples/invoice.py | 4 ++-- src/clairic/_client.py | 6 +++--- src/clairic/answers.py | 29 ++++++++++++++++------------- src/clairic/errors.py | 4 +++- src/clairic/result.py | 13 ++++++------- tests/test_result.py | 11 ++++++----- 7 files changed, 47 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index ba98acb..bd49c70 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,7 @@ invoice.total.confidence # 0.99995 invoice.contacts.value # ['Dana Ruiz', 'Priya Shah'] invoice.po_number.value # None -invoice.po_number.p_null # 0.9999994, the probability that the PO number is absent -invoice.po_number.guess # 'INV-2291', the best candidate +invoice.po_number.p_null # 0.9996, the probability that the PO number is absent ``` ### Estimates @@ -161,16 +160,16 @@ Every answer holds a `value` and the metadata Clairic attaches to it, all typed | Answers | Attributes | |---|---| -| Single values (`text`, `number`, `date`, `time`, `datetime`, `duration`) | `value`, `guess`, `confidence`, `p_null` | +| Single values (`text`, `number`, `date`, `time`, `datetime`, `duration`) | `value`, `confidence`, `p_null`. Dates, times, datetimes and durations also carry `guess` | | Text | `span`, end-exclusive offsets into the input (`text[span.start:span.end]`). Text lists carry `spans`. A span is `None` when the value occurs more than once in the input | | Number and date lists | `confidences`, one per item | | Estimates | `value` (the mean rounded to the `step` grid), `mean`, `median`, `p10`, `p90`. With number bounds, `p_below` and `p_above` hold the probability mass below `min` and above `max` | | Forecasts | Per-step lists `value`, `median`, `p10`, `p90`, and `steps` with the full estimate of each step | -`value` turns to `None` when `p_null` exceeds the field's `null_threshold`, 0.5 by default, and -`guess` keeps the best candidate. On "can be reached at +33 6 12 34 56 78 or at -firstname.name@gmail.com", Clairic returned the phone number with a confidence of 1.0, and for the -email a `p_null` of 0.66 with the address in `guess`. +Text and number answers are generated: Clairic writes the value, or null when the input does not +determine it, and `confidence` is the probability of what it wrote. Date, time, datetime and +duration answers are scored: `value` turns to `None` when `p_null` exceeds the field's +`null_threshold`, 0.5 by default, and `guess` keeps the best candidate. The p10 to p90 range is an 80% interval. Cloudflare publishes calibration measurements, and intervals can come out too narrow on new kinds of data. @@ -201,7 +200,7 @@ async with AsyncClairic() as clairic: | `ClairicConfigurationError` | The account id or token is missing. | | `AuthenticationError` | HTTP 401: invalid token or unknown account. | | `InvalidRequestError` | HTTP 400 or 422: Cloudflare rejected the request content. | -| `ContextWindowExceededError` | HTTP 413: the input exceeds the 65,536-token context window. | +| `ContextWindowExceededError` | HTTP 413: the input and field definitions exceed Clairic's 65,273-token limit. | | `APIError` | Any other error response, or answers outside the model's shape. Base class of the API errors. | | `APIConnectionError`, `APITimeoutError` | Cloudflare was unreachable, or the timeout expired (30 seconds by default). | @@ -214,10 +213,10 @@ emits `ClairicInvalidAnswerWarning` naming the fields. Turn it into an error wit ## Cost -Clairic bills input tokens, at $0.10 per million at the time of writing. It packs fields next to -the input in 8,192-token passes and runs extra passes in parallel when they overflow. Each pass -reads the whole input, and `result.usage.input_tokens` counts it once per pass. The full invoice -extraction above took 655 input tokens over 3 passes. +Cloudflare prices Clairic per input token, at $0.10 per million at the time of writing. +`result.usage.input_tokens` counts every prompt token, retries included, and `output_tokens` the +tokens Clairic generates for text, number and list answers. In December 2026 the full invoice +extraction above took 1,823 input tokens over 9 decode steps (`usage.passes`). ## Preview status diff --git a/examples/invoice.py b/examples/invoice.py index 1ea1db4..4be0f23 100644 --- a/examples/invoice.py +++ b/examples/invoice.py @@ -63,9 +63,9 @@ def main() -> None: 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})") + 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") print() print(result.values_as(Invoice)) diff --git a/src/clairic/_client.py b/src/clairic/_client.py index e498a69..da79229 100644 --- a/src/clairic/_client.py +++ b/src/clairic/_client.py @@ -209,14 +209,14 @@ def extract( ) -> Result[M]: """Extract the fields of `model` from `state`. - Clairic answers every field in a single pass without generating text, usually in under - a second. Each field of `model` declares its Clairic type through its answer type, its + Each field of `model` declares its Clairic type through its answer type, its options through an `Annotated` spec, and its instructions through `Field(description=...)`. Args: state: str - Text to read, up to Clairic's 65,536-token context window. + Text to read. With the field definitions, each prompt must fit in 65,273 + tokens. model: type[M] Extraction model whose fields are answer types. reference_date: date | None diff --git a/src/clairic/answers.py b/src/clairic/answers.py index 398de47..7521d01 100644 --- a/src/clairic/answers.py +++ b/src/clairic/answers.py @@ -6,9 +6,11 @@ Clairic answers a field with `value = None` when the input does not determine it. Single-value answers carry a confidence score and the probability that the value is absent (`p_null`). -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. +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/ """ @@ -79,10 +81,13 @@ class _SingleValueAnswer(Answer): Attributes: p_null: float - Probability that the input does not contain or determine the value. `value` is - `None` when it exceeds the field's `null_threshold` (default 0.5). + Probability that the input does not contain or determine the value. For dates, + times, datetimes and durations, `value` is `None` when it exceeds the field's + `null_threshold` (default 0.5). confidence: float - Probability that `guess` is the correct value, given that a value exists. + For text and number answers, the probability of the returned value, null included, + and 0 when Clairic marks the answer invalid. For dates, times, datetimes and + durations, the probability that `guess` is the correct value. """ p_null: float @@ -90,18 +95,16 @@ class _SingleValueAnswer(Answer): class TextAnswer(_SingleValueAnswer): - """Answer to a `text` field: an exact span of the input. - - `guess` and `span` describe the best candidate even when `value` is `None`, which lets you - show a reviewer what Clairic considered before deciding the value was absent. + """Answer to a `text` field. Attributes: value: str | None 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. span: Span | None - Location of `guess` in the input. + Location of `value` in the input, or `None` when the value occurs more than once in + the input or is not printed in it. """ type: Literal["text"] = "text" @@ -122,7 +125,7 @@ class NumberAnswer(_SingleValueAnswer, Generic[N]): value: N | None The number, or `None` when the input does not determine it. guess: N | None - The best candidate number, reported even when `value` is `None`. + Always `None`: Clairic no longer returns a best candidate for number answers. """ type: Literal["number"] = "number" diff --git a/src/clairic/errors.py b/src/clairic/errors.py index 85eb157..a44b0b1 100644 --- a/src/clairic/errors.py +++ b/src/clairic/errors.py @@ -78,7 +78,9 @@ class InvalidRequestError(APIError): class ContextWindowExceededError(APIError): - """Raised on HTTP 413: the input is estimated to exceed Clairic's 65,536-token context window. + """Raised on HTTP 413: the input is estimated to exceed Clairic's context window. + + Each prompt, the input plus the field definitions, must fit in 65,273 tokens. Cloudflare estimates the input size from its length in characters before tokenizing it. """ diff --git a/src/clairic/result.py b/src/clairic/result.py index 27f52cd..1e01183 100644 --- a/src/clairic/result.py +++ b/src/clairic/result.py @@ -21,11 +21,10 @@ class Usage(BaseModel): - """Token counts of an extraction. Clairic bills input tokens only. + """Token counts of an extraction. - Fields that do not fit next to the input in one 8,192-token pass are split across parallel - passes, and every pass reads the whole input: `input_tokens` counts the state once per pass. - Fewer fields, or a shorter input, lower the number of passes. + Cloudflare prices Clairic per input token. Each prompt holds the input and field definitions + and must fit in 65,273 tokens; larger requests are rejected, never truncated. Attributes: state_tokens: int @@ -35,11 +34,11 @@ class Usage(BaseModel): schema_tokens: int Tokens of the field definitions. input_tokens: int - Billed input tokens, across all passes. + All prompt tokens, including those spent on retries. output_tokens: int - Generated tokens, always 0: Clairic answers without generating text. + Tokens Clairic generated for text, number and list answers. passes: int - Number of parallel passes the fields were split into. + Sequential decode steps Clairic ran to answer the fields. """ model_config = ConfigDict(frozen=True, extra="allow") diff --git a/tests/test_result.py b/tests/test_result.py index 27ad8a4..e3f7c09 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -122,12 +122,13 @@ class Aliased(BaseModel): assert restored == result -def test_usage_counts_the_state_once_per_pass() -> None: - """Should report billed input tokens covering every pass (recorded 9k-token state).""" - response = load("trunc_10k")["response"] +def test_usage_reports_decode_steps_and_generated_tokens() -> None: + """Should read the usage of a current response, where generated answers produce tokens.""" + response = load("list_repeated_items")["response"] assert isinstance(response, dict) usage = Usage.model_validate(response["result"]["usage"]) - assert usage.passes == 2 - assert usage.input_tokens == 2 * usage.state_tokens + usage.schema_tokens + assert usage.passes >= 1 + assert usage.output_tokens > 0 + assert usage.input_tokens >= usage.state_tokens + usage.schema_tokens From d3f72fa9ca905c431f015a3b75c5c7d537d15105 Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 11:24:08 +0100 Subject: [PATCH 6/9] S5 Switch the HTTP client to httpx2 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 --- .github/workflows/ci.yml | 12 ++- README.md | 2 +- pyproject.toml | 10 +-- scripts/check_schema_drift.py | 6 +- src/clairic/_client.py | 35 ++++---- tests/test_client.py | 38 ++++---- tests/typing/answer_types.py | 3 +- uv.lock | 158 ++++++++-------------------------- 8 files changed, 92 insertions(+), 172 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2066df8..5d35e28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] + python-version: ["3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v6 @@ -22,3 +22,13 @@ jobs: - run: uv run ruff check - run: uv run pyright - run: uv run pytest + + lowest-dependencies: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v6 + with: + python-version: "3.11" + - run: uv sync --resolution lowest-direct + - run: uv run pytest diff --git a/README.md b/README.md index bd49c70..aca58a9 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ that model. pip install clairic ``` -Python 3.10 or later. The client reads `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN`, or takes +Python 3.11 or later. The client reads `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN`, or takes them as arguments with `Clairic(account_id="...", api_token="...")`. Create the token in the Cloudflare dashboard with access to Workers AI. diff --git a/pyproject.toml b/pyproject.toml index 5dca35a..ac2dfe7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,14 +9,13 @@ description = "Unofficial typed Python SDK for Cloudflare's Clairic extraction m readme = "README.md" authors = [{ name = "Vianney Mixtur", email = "vianney@consio.ai" }] license = { file = "LICENSE" } -requires-python = ">=3.10" +requires-python = ">=3.11" classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", @@ -24,9 +23,8 @@ classifiers = [ "Typing :: Typed", ] dependencies = [ - "httpx>=0.27", + "httpx2>=2.16", "pydantic>=2.7", - "typing-extensions>=4.12", ] [project.urls] @@ -55,7 +53,7 @@ include = ["/src", "/LICENSE", "/NOTICE", "/README.md", "/pyproject.toml"] [tool.ruff] line-length = 100 -target-version = "py310" +target-version = "py311" [tool.ruff.lint] select = ["E", "F", "W", "I", "B", "UP", "SIM", "RUF", "D"] @@ -74,7 +72,7 @@ convention = "google" [tool.pyright] include = ["src", "tests", "scripts", "examples"] -pythonVersion = "3.10" +pythonVersion = "3.11" typeCheckingMode = "strict" extraPaths = ["scripts"] diff --git a/scripts/check_schema_drift.py b/scripts/check_schema_drift.py index b5b6f4b..c2e2f1d 100644 --- a/scripts/check_schema_drift.py +++ b/scripts/check_schema_drift.py @@ -22,7 +22,7 @@ from pathlib import Path from typing import Any, Literal, cast -import httpx +import httpx2 SCHEMAS = Path(__file__).resolve().parent.parent / "tests" / "fixtures" / "schemas" BASE_URL = "https://developers.cloudflare.com/workers-ai/models/clairic" @@ -233,7 +233,9 @@ def main(argv: list[str]) -> int: sections: list[str] = [] line_diffs: list[str] = [] for name in NAMES: - published = _normalized(httpx.get(f"{BASE_URL}/{name}", timeout=30).raise_for_status().text) + published = _normalized( + httpx2.get(f"{BASE_URL}/{name}", timeout=30).raise_for_status().text + ) vendored_path = SCHEMAS / name vendored = _normalized(vendored_path.read_text()) if published == vendored: diff --git a/src/clairic/_client.py b/src/clairic/_client.py index da79229..8f721ff 100644 --- a/src/clairic/_client.py +++ b/src/clairic/_client.py @@ -6,11 +6,10 @@ import os import warnings from types import TracebackType -from typing import Any, TypeVar, cast +from typing import Any, Self, TypeVar, cast -import httpx +import httpx2 from pydantic import BaseModel, ValidationError -from typing_extensions import Self from clairic._compile import build_data, fields_payload from clairic._version import __version__ @@ -74,7 +73,7 @@ def _body(state: str, model: type[BaseModel], reference_date: dt.date | None) -> return body @staticmethod - def _parse(response: httpx.Response, model: type[M]) -> Result[M]: + def _parse(response: httpx2.Response, model: type[M]) -> Result[M]: status_code = response.status_code request_id = response.headers.get("cf-ai-req-id") try: @@ -180,9 +179,9 @@ class Clairic(_ClientBase): Cloudflare API token. base_url: str Cloudflare API root, to route requests through a proxy. - timeout: float | httpx.Timeout + timeout: float | httpx2.Timeout Seconds to wait for a response. Ignored when `http_client` is given. - http_client: httpx.Client | None + http_client: httpx2.Client | None HTTP client to send requests with, for custom transports or proxies. The caller closes it. @@ -197,12 +196,12 @@ def __init__( account_id: str | None = None, api_token: str | None = None, base_url: str = DEFAULT_BASE_URL, - timeout: float | httpx.Timeout = DEFAULT_TIMEOUT, - http_client: httpx.Client | None = None, + timeout: float | httpx2.Timeout = DEFAULT_TIMEOUT, + http_client: httpx2.Client | None = None, ) -> None: super().__init__(account_id=account_id, api_token=api_token, base_url=base_url) self._owns_http_client = http_client is None - self._http_client = http_client or httpx.Client(timeout=timeout) + self._http_client = http_client or httpx2.Client(timeout=timeout) def extract( self, state: str, model: type[M], *, reference_date: dt.date | None = None @@ -243,9 +242,9 @@ def extract( body = self._body(state, model, reference_date) try: response = self._http_client.post(self._url, json=body, headers=self._headers()) - except httpx.TimeoutException as error: + except httpx2.TimeoutException as error: raise APITimeoutError(f"Clairic did not answer in time: {error}") from error - except httpx.TransportError as error: + except httpx2.TransportError as error: raise APIConnectionError(f"Could not reach Cloudflare: {error}") from error return self._parse(response, model) @@ -283,9 +282,9 @@ class AsyncClairic(_ClientBase): Cloudflare API token. base_url: str Cloudflare API root, to route requests through a proxy. - timeout: float | httpx.Timeout + timeout: float | httpx2.Timeout Seconds to wait for a response. Ignored when `http_client` is given. - http_client: httpx.AsyncClient | None + http_client: httpx2.AsyncClient | None HTTP client to send requests with. The caller closes it. Raises: @@ -299,12 +298,12 @@ def __init__( account_id: str | None = None, api_token: str | None = None, base_url: str = DEFAULT_BASE_URL, - timeout: float | httpx.Timeout = DEFAULT_TIMEOUT, - http_client: httpx.AsyncClient | None = None, + timeout: float | httpx2.Timeout = DEFAULT_TIMEOUT, + http_client: httpx2.AsyncClient | None = None, ) -> None: super().__init__(account_id=account_id, api_token=api_token, base_url=base_url) self._owns_http_client = http_client is None - self._http_client = http_client or httpx.AsyncClient(timeout=timeout) + self._http_client = http_client or httpx2.AsyncClient(timeout=timeout) async def extract( self, state: str, model: type[M], *, reference_date: dt.date | None = None @@ -313,9 +312,9 @@ async def extract( body = self._body(state, model, reference_date) try: response = await self._http_client.post(self._url, json=body, headers=self._headers()) - except httpx.TimeoutException as error: + except httpx2.TimeoutException as error: raise APITimeoutError(f"Clairic did not answer in time: {error}") from error - except httpx.TransportError as error: + except httpx2.TransportError as error: raise APIConnectionError(f"Could not reach Cloudflare: {error}") from error return self._parse(response, model) diff --git a/tests/test_client.py b/tests/test_client.py index 35ae133..e30a4ef 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -4,7 +4,7 @@ from collections.abc import Callable from typing import Annotated, Any -import httpx +import httpx2 import pytest from pydantic import BaseModel, Field from recorded import load @@ -48,7 +48,7 @@ class InvoiceExtraction(BaseModel): ) -Handler = Callable[[httpx.Request], httpx.Response] +Handler = Callable[[httpx2.Request], httpx2.Response] class Recorder: @@ -62,19 +62,19 @@ def __init__(self, fixture: str, edit: Callable[[dict[str, Any]], None] | None = if edit is not None: assert isinstance(self.body, dict) edit(self.body) - self.requests: list[httpx.Request] = [] + self.requests: list[httpx2.Request] = [] - def __call__(self, request: httpx.Request) -> httpx.Response: + def __call__(self, request: httpx2.Request) -> httpx2.Response: self.requests.append(request) content = self.body if isinstance(self.body, str) else json.dumps(self.body) - return httpx.Response(self.status, headers=self.headers, content=content) + return httpx2.Response(self.status, headers=self.headers, content=content) def _client(handler: Handler) -> Clairic: return Clairic( account_id=ACCOUNT_ID, api_token=TOKEN, - http_client=httpx.Client(transport=httpx.MockTransport(handler)), + http_client=httpx2.Client(transport=httpx2.MockTransport(handler)), ) @@ -82,7 +82,7 @@ def _async_client(handler: Handler) -> AsyncClairic: return AsyncClairic( account_id=ACCOUNT_ID, api_token=TOKEN, - http_client=httpx.AsyncClient(transport=httpx.MockTransport(handler)), + http_client=httpx2.AsyncClient(transport=httpx2.MockTransport(handler)), ) @@ -182,8 +182,8 @@ def test_error_responses_raise_typed_errors( def test_unknown_error_status_raises_api_error() -> None: """Should raise the base APIError for statuses without a dedicated exception.""" - def handler(request: httpx.Request) -> httpx.Response: - return httpx.Response( + def handler(request: httpx2.Request) -> httpx2.Response: + return httpx2.Response( 503, json={"success": False, "errors": [{"code": 7000, "message": "Unavailable"}]} ) @@ -197,8 +197,8 @@ def handler(request: httpx.Request) -> httpx.Response: def test_non_json_response_raises_api_error() -> None: """Should raise APIError carrying the body when the response is not JSON.""" - def handler(request: httpx.Request) -> httpx.Response: - return httpx.Response(502, text="Bad gateway") + def handler(request: httpx2.Request) -> httpx2.Response: + return httpx2.Response(502, text="Bad gateway") with pytest.raises(APIError, match="Bad gateway"): _client(handler).extract(INVOICE_STATE, InvoiceExtraction) @@ -257,8 +257,8 @@ def test_untruncated_result_emits_no_warning() -> None: def test_timeout_raises_api_timeout_error() -> None: """Should raise APITimeoutError when Cloudflare does not answer in time.""" - def handler(request: httpx.Request) -> httpx.Response: - raise httpx.ReadTimeout("timed out", request=request) + def handler(request: httpx2.Request) -> httpx2.Response: + raise httpx2.ReadTimeout("timed out", request=request) with pytest.raises(APITimeoutError): _client(handler).extract(INVOICE_STATE, InvoiceExtraction) @@ -267,8 +267,8 @@ def handler(request: httpx.Request) -> httpx.Response: def test_connection_failure_raises_api_connection_error() -> None: """Should raise APIConnectionError when Cloudflare cannot be reached.""" - def handler(request: httpx.Request) -> httpx.Response: - raise httpx.ConnectError("refused", request=request) + def handler(request: httpx2.Request) -> httpx2.Response: + raise httpx2.ConnectError("refused", request=request) with pytest.raises(APIConnectionError): _client(handler).extract(INVOICE_STATE, InvoiceExtraction) @@ -303,7 +303,7 @@ def test_credentials_fall_back_to_the_environment(monkeypatch: pytest.MonkeyPatc monkeypatch.setenv("CLOUDFLARE_API_TOKEN", TOKEN) recorder = Recorder("invoice") - Clairic(http_client=httpx.Client(transport=httpx.MockTransport(recorder))).extract( + Clairic(http_client=httpx2.Client(transport=httpx2.MockTransport(recorder))).extract( INVOICE_STATE, InvoiceExtraction ) @@ -336,7 +336,7 @@ def test_context_manager_closes_an_owned_http_client() -> None: """Should close the HTTP client it created, and leave a passed-in one open.""" with Clairic(account_id=ACCOUNT_ID, api_token=TOKEN) as owned: pass - passed_in = httpx.Client() + passed_in = httpx2.Client() with Clairic(account_id=ACCOUNT_ID, api_token=TOKEN, http_client=passed_in): pass @@ -372,8 +372,8 @@ async def test_async_error_responses_raise_typed_errors() -> None: async def test_async_timeout_raises_api_timeout_error() -> None: """Should raise APITimeoutError with the async client.""" - def handler(request: httpx.Request) -> httpx.Response: - raise httpx.ReadTimeout("timed out", request=request) + def handler(request: httpx2.Request) -> httpx2.Response: + raise httpx2.ReadTimeout("timed out", request=request) async with _async_client(handler) as client: with pytest.raises(APITimeoutError): diff --git a/tests/typing/answer_types.py b/tests/typing/answer_types.py index 6c8997a..fb03b3e 100644 --- a/tests/typing/answer_types.py +++ b/tests/typing/answer_types.py @@ -6,10 +6,9 @@ # pyright: reportUnnecessaryTypeIgnoreComment=true import datetime as dt -from typing import Annotated +from typing import Annotated, assert_type from pydantic import BaseModel -from typing_extensions import assert_type from clairic import AsyncClairic, Clairic from clairic.answers import ( diff --git a/uv.lock b/uv.lock index e418ecc..9110c64 100644 --- a/uv.lock +++ b/uv.lock @@ -1,6 +1,10 @@ version = 1 revision = 3 -requires-python = ">=3.10" +requires-python = ">=3.11" +resolution-markers = [ + "python_full_version >= '3.12' and sys_platform == 'emscripten'", + "python_full_version < '3.12' or sys_platform != 'emscripten'", +] [[package]] name = "annotated-types" @@ -16,7 +20,6 @@ name = "anyio" version = "4.15.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, { name = "idna" }, { name = "typing-extensions", marker = "python_full_version < '3.15'" }, ] @@ -25,22 +28,12 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/12/b8/4bd346e22b28902df4d651910f5242c28d84e4a5c2435ca5c3f797ed7e2e/anyio-4.15.1-py3-none-any.whl", hash = "sha256:6152fdbbf9a77fdec97731721bebf7c4c44f7c29b424b0065826173efc7ed101", size = 132079, upload-time = "2026-09-05T10:42:37.923Z" }, ] -[[package]] -name = "certifi" -version = "2026.10.23" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/fd/11/b524cbd9bbdaca58608e4cf4053fd463417549e1959fa8d3aa18319f9555/certifi-2026.10.23.tar.gz", hash = "sha256:a9895e6e2758b371e0545e321a3a8fd1fcfd9829ada8824a936dfb16aaaf36cd", size = 136225, upload-time = "2026-10-23T11:36:16.478Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/32/d1/a3652fe2c19134d0d15922177821d863cbd7e842d53a21bbe7e8e3a1b5ac/certifi-2026.10.23-py3-none-any.whl", hash = "sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1", size = 135082, upload-time = "2026-10-23T11:36:14.763Z" }, -] - [[package]] name = "clairic" source = { editable = "." } dependencies = [ - { name = "httpx" }, + { name = "httpx2" }, { name = "pydantic" }, - { name = "typing-extensions" }, ] [package.dev-dependencies] @@ -54,9 +47,8 @@ dev = [ [package.metadata] requires-dist = [ - { name = "httpx", specifier = ">=0.27" }, + { name = "httpx2", specifier = ">=2.16" }, { name = "pydantic", specifier = ">=2.7" }, - { name = "typing-extensions", specifier = ">=4.12" }, ] [package.metadata.requires-dev] @@ -77,18 +69,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, ] -[[package]] -name = "exceptiongroup" -version = "1.3.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "typing-extensions", marker = "python_full_version < '3.13'" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" }, -] - [[package]] name = "h11" version = "0.16.0" @@ -99,31 +79,42 @@ wheels = [ ] [[package]] -name = "httpcore" -version = "1.0.9" +name = "httpcore2" +version = "2.18.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "certifi" }, - { name = "h11" }, + { name = "h11", marker = "python_full_version < '3.12' or sys_platform != 'emscripten'" }, + { name = "truststore", marker = "python_full_version < '3.12' or sys_platform != 'emscripten'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } +sdist = { url = "https://files.pythonhosted.org/packages/05/38/48d4836fd8711f0ab56f33a4018dcd1a3bea4ba783780c8750f4c2ecbd62/httpcore2-2.18.0.tar.gz", hash = "sha256:b1214ec379c7f96d8c7c587fb4d7fe13489c399899705c2f2d99a1a1051d3e18", size = 72522, upload-time = "2026-12-04T11:08:49.627Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, + { url = "https://files.pythonhosted.org/packages/66/7c/20362d5cb203f5be2b182128967b5fb77dbeb159a5bcda4402468c9b24b0/httpcore2-2.18.0-py3-none-any.whl", hash = "sha256:6e41b9eb2ab5ec4a295cdb5aafe829bc927870fea18c08b68a59e38401727486", size = 87148, upload-time = "2026-12-04T11:08:46.93Z" }, ] [[package]] -name = "httpx" -version = "0.28.1" +name = "httpx2" +version = "2.18.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "anyio" }, - { name = "certifi" }, - { name = "httpcore" }, + { name = "anyio", marker = "sys_platform != 'emscripten'" }, + { name = "httpcore2", marker = "sys_platform != 'emscripten'" }, + { name = "httpx2-jsfetch", marker = "python_full_version >= '3.12' and sys_platform == 'emscripten'" }, { name = "idna" }, + { name = "truststore", marker = "sys_platform != 'emscripten'" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } +sdist = { url = "https://files.pythonhosted.org/packages/4b/4d/9ed9d75337432185bb42e00b615ad6054db6a9e09157533cce0cc71ce824/httpx2-2.18.0.tar.gz", hash = "sha256:a979cb9e0b67d5de238b5abb039f5342c2501fd2d09772843947ebe7bc699601", size = 106421, upload-time = "2026-12-04T11:08:50.931Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a8/a5/fe74fb4529649e553510ab82feb8108e2994935b52ff7e6afe7188d895ed/httpx2-2.18.0-py3-none-any.whl", hash = "sha256:38208e71fc37da11d103abdcfa47811d3c18eb0f4d1bcab87c7734fc8857e9bf", size = 99738, upload-time = "2026-12-04T11:08:48.333Z" }, +] + +[[package]] +name = "httpx2-jsfetch" +version = "1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cd/c4/0e5636363151a2a1795e0a77617168b9ca438e1748ec05fc9b5687f93d64/httpx2_jsfetch-1.0.tar.gz", hash = "sha256:70a0e3eabfef7cce5ad9c629f7d01ca05e418f586646f4ddf14782e4c1454c60", size = 6872, upload-time = "2026-08-07T00:13:07.492Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, + { url = "https://files.pythonhosted.org/packages/9b/43/832f631d32e4f1211caa2ba368317739fe71f0b8530e4c9d15dc454bac2a/httpx2_jsfetch-1.0-py3-none-any.whl", hash = "sha256:cb916b707601e69a07721aabc8f3f6659be3a6893bc1ff5c6f9e02241df2da32", size = 6382, upload-time = "2026-08-07T00:13:06.567Z" }, ] [[package]] @@ -195,20 +186,6 @@ dependencies = [ ] sdist = { url = "https://files.pythonhosted.org/packages/a6/24/af4ec4be49fbc810f35b0bdcacc3d433b56bbfa469fd3bfd4ae116cd9bf1/pydantic_core-2.50.1.tar.gz", hash = "sha256:e50d7b94baac6c7d09927fa5ca5800a0c7ee5015c7fcff65beb3a1931b5a6e09", size = 513515, upload-time = "2026-10-11T18:35:44.82Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/09/db/c9cc34707ba2c23ce90d54e8a4ee9307583ad054b9df2ce570ba550cb576/pydantic_core-2.50.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:b281a3b0f0822618fe5e3e0d8a2048b6356b14388505dc9374ccffeb69989713", size = 2154222, upload-time = "2026-10-11T18:31:38.345Z" }, - { url = "https://files.pythonhosted.org/packages/c1/17/6963f4ee55b7df7658f5c036c0f90baf8cd3d413f5d8b551f227e8467afc/pydantic_core-2.50.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1fa4c8bc12c1354c5550c0c35c1852c8c1901e89e06561724e03f8d0342e1f87", size = 2048126, upload-time = "2026-10-11T18:31:41.061Z" }, - { url = "https://files.pythonhosted.org/packages/bf/be/f75637e222085d29a3076edbc5cfd0dd9b77d145e310ff7dc1150f07558a/pydantic_core-2.50.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3aa9de446b793de2beb6fa2d9d0961803126c4e2a99c2f25ab59b9fd6ea125c0", size = 2052460, upload-time = "2026-10-11T18:31:42.321Z" }, - { url = "https://files.pythonhosted.org/packages/7a/1e/3d192ffa39ce3bd0e98e988fb5c055cfbf4af6e6e155a4ca5baa86d1f2cc/pydantic_core-2.50.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:de531ce1e2a3364e8767878b58f4ff728a434b4fde089781fe30b1e08e2396e0", size = 2190750, upload-time = "2026-10-11T18:31:43.572Z" }, - { url = "https://files.pythonhosted.org/packages/b2/7e/12ea94df5220ab316ee5bb498ebcf710cff2db352653039fb6033f6997d1/pydantic_core-2.50.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a7c58106de36ac6a56314182958de20db8d3a29dfd5db527192cc754e4f8e7fb", size = 2390043, upload-time = "2026-10-11T18:31:44.745Z" }, - { url = "https://files.pythonhosted.org/packages/f6/bc/4fbb6dc90af038628ec824434a9841be9d46854f9267bb658f09e315024d/pydantic_core-2.50.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8b4c3df25bd323bf1d36a648d563cf1fc69d717451569927151bdad7cad07a77", size = 2432397, upload-time = "2026-10-11T18:31:46.186Z" }, - { url = "https://files.pythonhosted.org/packages/1b/1a/21a58791021397d9ca35295e3f4291c16e319155c5904334b89eb07e97e1/pydantic_core-2.50.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f77ac30b19221cd9bd3fcfa3d4614eff93140d0572ab730cded17b64adca05f3", size = 2160719, upload-time = "2026-10-11T18:31:47.557Z" }, - { url = "https://files.pythonhosted.org/packages/73/6a/d5b2c5876162fd2c444eaed0064b5d9d9d0ef0d31530fc6a7997e8685ad8/pydantic_core-2.50.1-cp310-cp310-manylinux_2_31_riscv64.whl", hash = "sha256:d939de9c82e2126f7f48a7e658f8a85ed46d57662d53f44c49b8895fe94a3eb7", size = 2256164, upload-time = "2026-10-11T18:31:48.797Z" }, - { url = "https://files.pythonhosted.org/packages/af/e8/1a6625d6e99250388dd0ae817c5d75839cd6103e7b790f59e0ffff74955d/pydantic_core-2.50.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:30ddf019d082c117b5d309e5b86710c2a78909907ec1a9381feec3eec02eca0b", size = 2271176, upload-time = "2026-10-11T18:31:49.987Z" }, - { url = "https://files.pythonhosted.org/packages/19/9f/bbdd137d7ec41284701dab4d1489ea597d401dff2f5f3e6b41ea872e0b12/pydantic_core-2.50.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:2ab756b72bd5054e4c7ef3ded331b35786cbd3cf931531a508f79a9537517064", size = 2304637, upload-time = "2026-10-11T18:31:51.251Z" }, - { url = "https://files.pythonhosted.org/packages/49/5d/7bd322e649b41b45130bc00bfa34dc57498c853aa8e6fc9604e33bc7087c/pydantic_core-2.50.1-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:b087b1c5be7ac687cf22eabfe4b6b608d40df23610651e93611e1f49118baf84", size = 2467374, upload-time = "2026-10-11T18:31:52.587Z" }, - { url = "https://files.pythonhosted.org/packages/53/48/41a91111590eb7ba68a7c64c03139235a4b8349930abcb87931aa80da796/pydantic_core-2.50.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a44101320cfe99432db74237545a63057dc7a88dfe792cbcad0647f2af56cb81", size = 2480832, upload-time = "2026-10-11T18:31:54.06Z" }, - { url = "https://files.pythonhosted.org/packages/2a/02/4ac93a3d3f0ff412df1a36a9619743336fe6eec68c0df8a914163a3d22b4/pydantic_core-2.50.1-cp310-cp310-win32.whl", hash = "sha256:a4aaaa791bdae1c972a7e81765f4f3571c926b8e0b9b6e47346499fb80079665", size = 2123154, upload-time = "2026-10-11T18:31:55.396Z" }, - { url = "https://files.pythonhosted.org/packages/6d/ba/3a7af3dcd480c4739aa82cd9fedee79a5531a7c553346abcf095bd05f0de/pydantic_core-2.50.1-cp310-cp310-win_amd64.whl", hash = "sha256:2eedf82ee4753cdab8e50044c6bd569577eebc3859b11fecf4eb9223761ff966", size = 2179366, upload-time = "2026-10-11T18:31:56.697Z" }, { url = "https://files.pythonhosted.org/packages/45/1b/ca81811da3d2aea724fb3c4ba6b83f50ab8f210576306ccd601973142d35/pydantic_core-2.50.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:c531166c42ea7bdfecc8c50049581f05dd1993b09cc7c52bb36a14e96deaec7d", size = 2152145, upload-time = "2026-10-11T18:31:58.046Z" }, { url = "https://files.pythonhosted.org/packages/59/20/938ef7e0541af0a314e2f9d63848dbd1656ba2ebfe5ca0469f7ebee00d5e/pydantic_core-2.50.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b6d0c2183008c188e19f4906d426b293bdc4f67ab17df8e180fe16cda208fa71", size = 2045761, upload-time = "2026-10-11T18:31:59.35Z" }, { url = "https://files.pythonhosted.org/packages/2f/4b/456497fe2affa18f49b226e89bde31e8a204751ee343dd9beaac5438123e/pydantic_core-2.50.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94be440c03fede26969a5ce75468e0e6a9927a1b46d9b679ee8adc1b057b0350", size = 2049557, upload-time = "2026-10-11T18:32:01.121Z" }, @@ -361,12 +338,10 @@ version = "9.1.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, - { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, { name = "iniconfig" }, { name = "packaging" }, { name = "pluggy" }, { name = "pygments" }, - { name = "tomli", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/e4/47/b9efed96c114afcfa3c9d3fe98a76a1d14c74a9e266d397cf6eb64be5e01/pytest-9.1.1.tar.gz", hash = "sha256:1088fbde8f2b49d95a549a195707afa7a76a3ce9bcadc26b6d71f0ffda5fe313", size = 1636369, upload-time = "2026-06-19T10:58:32.857Z" } wheels = [ @@ -408,75 +383,12 @@ wheels = [ ] [[package]] -name = "tomli" -version = "2.5.0" +name = "truststore" +version = "0.10.5" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/b0/78/9ad63712633ed3ab5cc1a648d863d7e7da371e9425e209555a0fe711b695/tomli-2.5.0.tar.gz", hash = "sha256:264507556cd8b8c8e7c6ee037cdf443a463f03f4c958e57195e3d369711b8ff6", size = 17662, upload-time = "2026-10-07T12:23:37.892Z" } +sdist = { url = "https://files.pythonhosted.org/packages/ee/9f/c5201d42a484c061e528825fc8e2d565f5abd50a4ced6fb7d29c4ec99b2b/truststore-0.10.5.tar.gz", hash = "sha256:30d36967ccaded5cbb38d602c433f53600036c79d502f4533a49b60a03bbefcd", size = 28091, upload-time = "2026-10-12T22:27:31.808Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/22/a6/ab99b60ee52acd949684febabc3005d0045d0f66bebd9cdebd67372d26dd/tomli-2.5.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c4dc1c1781f2f716de763d1e9a7b34c6a894e167e291c7c5d16c72f7a9538545", size = 163901, upload-time = "2026-10-07T12:22:15.601Z" }, - { url = "https://files.pythonhosted.org/packages/bc/00/ee01b7ed4579180fff07142d290257f25ba786f23f3ec6005f620933c2f5/tomli-2.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:eff8babca5a7999bc137acbc7482a8b7e17ffca5075ab41f5d770ab408c7bfef", size = 163756, upload-time = "2026-10-07T12:22:16.957Z" }, - { url = "https://files.pythonhosted.org/packages/72/c2/4efebf65372f6583185f79799312109dddb61102d47e5c33dcfd1a297aca/tomli-2.5.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:86665cee9c4835b7a7f1e8ec2c719b5258d4dc782887aded5a8ae7352a96843b", size = 268038, upload-time = "2026-10-07T12:22:18.135Z" }, - { url = "https://files.pythonhosted.org/packages/53/07/5850468e925d898abb36038666f9c333a94d2a223e802a8ba5b6d319d23f/tomli-2.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d7e369fd63331746182360977b1892bfc215476a30d61612d732425311639f56", size = 276422, upload-time = "2026-10-07T12:22:19.567Z" }, - { url = "https://files.pythonhosted.org/packages/b4/87/f293984cdcf83c054196d4fd3dad44fc68ae55b4b8c44bc76cef360c3150/tomli-2.5.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7ad1ea345759240d6463efa0ed1c704402752e49aa21476620738d74d72d8aa1", size = 272616, upload-time = "2026-10-07T12:22:20.794Z" }, - { url = "https://files.pythonhosted.org/packages/ce/ce/db582886b3c1219d3fec93ebd669332482e5aee7a91e0f7838d84f2d1759/tomli-2.5.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:96243987194634bd411066ce40c952e108f86af04db533ecd8ac3ff2a85b1885", size = 276593, upload-time = "2026-10-07T12:22:22.12Z" }, - { url = "https://files.pythonhosted.org/packages/bf/72/7619b87dea4261fc27dd7b54c4461c129c1f7d9bb7ba3aec89c797a431b8/tomli-2.5.0-cp311-cp311-win32.whl", hash = "sha256:610b27d99f28ec5f191c7064a48f3ddb179a1fe6ca73d571483ae859f57b605e", size = 101830, upload-time = "2026-10-07T12:22:23.651Z" }, - { url = "https://files.pythonhosted.org/packages/1e/74/220106da34502304b6751a2a9b8a9fbca6c3fd47e737a2e2e3da7c61c9db/tomli-2.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:c804ae44fe7b4bab5da295e4f980a1ff04670bca9d23fe0a4e887e08ebd741a8", size = 112742, upload-time = "2026-10-07T12:22:24.972Z" }, - { url = "https://files.pythonhosted.org/packages/27/99/7d9c8b41837a7773613e169504147375c157a290167aa59ad74a085f521f/tomli-2.5.0-cp311-cp311-win_arm64.whl", hash = "sha256:cfac177ebd6236003846ea339981f71457cb6eb748f23381eb257e45092e3980", size = 109332, upload-time = "2026-10-07T12:22:26.117Z" }, - { url = "https://files.pythonhosted.org/packages/52/ed/7baa86f87493646a594de388c7c1c40a39dd0461f7e9c0359cbeefc91fe8/tomli-2.5.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1f4a40d03fb9f63424f0979855bdeaf44dd7696b8d59501822c10ed30ba532df", size = 164854, upload-time = "2026-10-07T12:22:27.444Z" }, - { url = "https://files.pythonhosted.org/packages/a5/b1/44c0341f2224397855723c7a8a39f718ea6fcbcc3dacc66e5aeca0f334e3/tomli-2.5.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9ebf8d19b17bd0daeb7b7dec81a946a439b753942fd0210d6e96c532249eea6b", size = 164074, upload-time = "2026-10-07T12:22:28.679Z" }, - { url = "https://files.pythonhosted.org/packages/23/04/e2d5b7d3fba47adedb23de616c16d428ea076c79a3d8e1d95d649ffe197e/tomli-2.5.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bf0b5e8e0f68ebb494356e577c06c139161efd8d3b9050f93b39b7c26cc54ff0", size = 274274, upload-time = "2026-10-07T12:22:29.804Z" }, - { url = "https://files.pythonhosted.org/packages/43/90/6090e706ff27a6f89f4a40578e3324b95c3cd8c4150868aabf33a8f414c3/tomli-2.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6cf74416bdc94ae458b14e37286c1073081850ac8459a00d0c5efef5d44294c6", size = 286435, upload-time = "2026-10-07T12:22:31.297Z" }, - { url = "https://files.pythonhosted.org/packages/0a/9e/a2c40768df16c408f22430afb0a73e9d7e5f79c950884954649d1146b74d/tomli-2.5.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:61ea1ebe1e55a34ea8199cc8dbff398d35027b82271c8ac4802fd3a1fd5b1bcc", size = 278119, upload-time = "2026-10-07T12:22:32.601Z" }, - { url = "https://files.pythonhosted.org/packages/12/25/3c0cb485b98e9cfac495629b1c93c87ccf0b72fbe9d2689fd8fe62c6d5a3/tomli-2.5.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ed53f7e89bb04f6d9e8e7799112360b0c4d5cbff067de0814c98c37c39b920f7", size = 286177, upload-time = "2026-10-07T12:22:33.745Z" }, - { url = "https://files.pythonhosted.org/packages/77/8b/0144c65f0e37e51c18d04ae15c21b19431c165002d0131fe9aa8b0b8b1e8/tomli-2.5.0-cp312-cp312-win32.whl", hash = "sha256:e7ad033e27a516a233bea839cdb77b80146facb3b4f40bf02cd0cac165cdd5c2", size = 102760, upload-time = "2026-10-07T12:22:34.887Z" }, - { url = "https://files.pythonhosted.org/packages/de/32/5d6d8f42fc9a05fce69354e00ff256484192f5f2fc9a2165718fa0de61ec/tomli-2.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:bd05de8c1698f8413dd7d869492693a0bf2211543b787ac78cd5e7536af1a6d7", size = 112722, upload-time = "2026-10-07T12:22:36.162Z" }, - { url = "https://files.pythonhosted.org/packages/30/65/df18032218db0fb9b769fb23c8039a051f15c811993995ea04c350273a32/tomli-2.5.0-cp312-cp312-win_arm64.whl", hash = "sha256:069435bd5480429b98c5e5afb02ab21c219b6f0064680671c6dc0d46817346ea", size = 109534, upload-time = "2026-10-07T12:22:37.296Z" }, - { url = "https://files.pythonhosted.org/packages/42/e5/51736d70da209350969e15aca5c5ab6e2ce1ea87a0a892a6c13aec172a86/tomli-2.5.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:943276cf269e0071948d9ff697159c1735e623c1151d88abb09b74659ef0cbea", size = 163328, upload-time = "2026-10-07T12:22:38.373Z" }, - { url = "https://files.pythonhosted.org/packages/ec/55/086f80dab4ab497602644274e6dea7ec5dd0b4e262e443a8ad3bb7edee2d/tomli-2.5.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:463b16086865b97facd8d0b3fb4cb7c544e3f58d2a69dc3113d6db9653fdb043", size = 162246, upload-time = "2026-10-07T12:22:39.673Z" }, - { url = "https://files.pythonhosted.org/packages/aa/eb/3ecc94459f3635c92321f4e7bde571323fdb2267c50e19e3188a281eae3b/tomli-2.5.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1245a6638fc4bb0a60af38a7d45413db34a13842027c77597c712c998c62fdf0", size = 272655, upload-time = "2026-10-07T12:22:41.08Z" }, - { url = "https://files.pythonhosted.org/packages/c0/d7/494fd1f0c37a621f1ad9975c2efadb523e8101f144ed6edb2e7fe64738f2/tomli-2.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5d8bac3d603c97e6854424e5b2b5b741bdbde387e09f162fb0446812b4a8362b", size = 283595, upload-time = "2026-10-07T12:22:42.222Z" }, - { url = "https://files.pythonhosted.org/packages/70/51/bb8d62b1317e6640866f6949b2d5855e5300f2c99d46de1cd245570bba65/tomli-2.5.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:21e4cae4114aba25aa0d4f85cdf486d290fb35c0954d7bba536248da64d43066", size = 276253, upload-time = "2026-10-07T12:22:43.625Z" }, - { url = "https://files.pythonhosted.org/packages/66/f4/f46bd7f0763cd47de2db697dca9257c6a4adfd1a93b018cc75c8190ed5a8/tomli-2.5.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:bbaefc84548d754be821bba7c4141c4787dda182f9e77f2f87b71213529efa7b", size = 283582, upload-time = "2026-10-07T12:22:44.983Z" }, - { url = "https://files.pythonhosted.org/packages/ac/03/70f2bcb2923a6db37818d917e124270a7f4cfd38ea576f5aa753a91c0ef5/tomli-2.5.0-cp313-cp313-win32.whl", hash = "sha256:abdbf6313b8d9efe157edeb7ab6eae4de064b1300ad31abf73755154b30abe68", size = 102628, upload-time = "2026-10-07T12:22:46.508Z" }, - { url = "https://files.pythonhosted.org/packages/dc/98/d52024bb5b0ff68b4f0d276d867f634c84a67319a7e9f6b7708a37742333/tomli-2.5.0-cp313-cp313-win_amd64.whl", hash = "sha256:fd4dc129784e0c5335bd4e61dfcc4487499a013419e655cf2da1d091b7e0efdc", size = 113301, upload-time = "2026-10-07T12:22:47.647Z" }, - { url = "https://files.pythonhosted.org/packages/6f/f2/540db3a70572a8c23a28aba3e9c358ce0ffffbafc990905c1343aa265b31/tomli-2.5.0-cp313-cp313-win_arm64.whl", hash = "sha256:69491c143d2fe063046e0301e62a810bed338fa4d1ce0fd870c27dc1e09b0d84", size = 109744, upload-time = "2026-10-07T12:22:48.925Z" }, - { url = "https://files.pythonhosted.org/packages/e4/49/caf6b307766eb9567664a8707e9d6be5fcc0e8903f18781c6677a60d80c7/tomli-2.5.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d3182ee2d887e507bd67319a0a61105d1dd33facc111329559a233b772c1a105", size = 162899, upload-time = "2026-10-07T12:22:50.088Z" }, - { url = "https://files.pythonhosted.org/packages/d3/c8/68cfce773a2733a49c74f99d627fb461bd990756860099eac25617889585/tomli-2.5.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:521345fd1f19d45b8df87657aaa38b6f2ca3800059fadf428e7ebf479a383646", size = 162080, upload-time = "2026-10-07T12:22:51.558Z" }, - { url = "https://files.pythonhosted.org/packages/7e/b2/e5bb8651fdad593f670501a7d718b1a7f73f064d44dea15e04c04dfef45d/tomli-2.5.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e95c7614e705bfe2b04b27aa124adec59752d15813df37e2156747cab3a006b", size = 273380, upload-time = "2026-10-07T12:22:52.918Z" }, - { url = "https://files.pythonhosted.org/packages/8d/d2/9e2d7f8b1dfe0e2b34c245986ebd55c4c553ea4ce6c47c443b332673253f/tomli-2.5.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7ac2027d37c3afbdf4bdd377f2676f6f1d2122a5be1f1137b49dced590b37e75", size = 283228, upload-time = "2026-10-07T12:22:54.173Z" }, - { url = "https://files.pythonhosted.org/packages/ba/df/ec7b876b7b1a2718bd74a3743c076fff565b04029ba33e8f61fac262739f/tomli-2.5.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c414be4ed9d3cac80c42e348fa5a956117d1a48227f48026e31f59cb4a7671eb", size = 277189, upload-time = "2026-10-07T12:22:55.342Z" }, - { url = "https://files.pythonhosted.org/packages/7d/7b/e192d9eed0b9cb80da799f4d77052297fb9a2c3cc9b19f571f56ea88add6/tomli-2.5.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:9b03d7dc168353b4132965bde20feceabaa470e570c6f59660dfae59b1f9eeb3", size = 283632, upload-time = "2026-10-07T12:22:56.735Z" }, - { url = "https://files.pythonhosted.org/packages/84/50/ff94454e75461d75623e47401ed323d65c10aab8fe9033242c20cd2fdf32/tomli-2.5.0-cp314-cp314-win32.whl", hash = "sha256:6f041843c4d3a37245c0c056fd955b186bf8b1fb85690cbe40b81230891dc34b", size = 103535, upload-time = "2026-10-07T12:22:58.084Z" }, - { url = "https://files.pythonhosted.org/packages/54/0b/bdacf05f963bd6026ebf6eeb0beda847d1d60e03e440725c64a4e08a0afd/tomli-2.5.0-cp314-cp314-win_amd64.whl", hash = "sha256:f4b653094e18f9031102d3a1da5c729c8f222d85225b18037dac621695e46e1a", size = 114621, upload-time = "2026-10-07T12:22:59.2Z" }, - { url = "https://files.pythonhosted.org/packages/61/99/53f438fa6ae4f9d4ed0ddde3e7242b3bdc34b48c8f9948b72b9e9b127676/tomli-2.5.0-cp314-cp314-win_arm64.whl", hash = "sha256:3f89d10c1ff6a38d992c27fc8a4816af71a909e08a40ec66934240b1e74347c3", size = 111572, upload-time = "2026-10-07T12:23:00.479Z" }, - { url = "https://files.pythonhosted.org/packages/b9/20/1f88f19427d380a40e90a770e087489eaafe4aeee070ae88ed2bbec00acd/tomli-2.5.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:e9e15b4a6c7dd6b85b5fbab29488a73f1f70de516942308daa266bf0e0aeb0d4", size = 171814, upload-time = "2026-10-07T12:23:01.914Z" }, - { url = "https://files.pythonhosted.org/packages/d0/56/cbe5079c9f9a54b9b3e27fc82f08f3cb36edee75561679f53d2380c801d6/tomli-2.5.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:e12bbcd32897272fb05929110362ae9ff4c1b9bb26bd9e971e71dcd3275b4c3d", size = 171324, upload-time = "2026-10-07T12:23:03.18Z" }, - { url = "https://files.pythonhosted.org/packages/2b/30/1d53fd3b0f1cb3ba542e345ec32c26aefdddc4e829e4f3429af8a4f27782/tomli-2.5.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:20aa36de8f2cf87237143bc1fa1aae8d6612c09118f4da21c6a684db5dd1f6f9", size = 297441, upload-time = "2026-10-07T12:23:04.345Z" }, - { url = "https://files.pythonhosted.org/packages/66/d9/0800acb6a111686f764c1b91ef15cc42a20a66a46013bb42220f1d2c61c1/tomli-2.5.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:22185fad8a1e622f064e78008018a0dd3323550dcb479cb7a1d296888d74024f", size = 307476, upload-time = "2026-10-07T12:23:05.671Z" }, - { url = "https://files.pythonhosted.org/packages/e8/63/30a8f3cd51b5bec37f04744bad0b0dc6160df84aad4f27b0e9283d66f221/tomli-2.5.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:984012f71908165449a951de2050d52f276bfe3aa5d5f570f63ddad814370374", size = 296113, upload-time = "2026-10-07T12:23:07.202Z" }, - { url = "https://files.pythonhosted.org/packages/ab/18/0b9ffc597e69c5a1e20a7823cb60d54b39a9f54e91edcb8574f022186758/tomli-2.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f79203b3965b4000e91808aaa7c040206093f2b8bf86f455982f2274c9ccf442", size = 307725, upload-time = "2026-10-07T12:23:08.508Z" }, - { url = "https://files.pythonhosted.org/packages/ab/c7/18f8baae0b5607a60e8e19b4a7fedee43a8ff6458e3896dcbbadeeac9c22/tomli-2.5.0-cp314-cp314t-win32.whl", hash = "sha256:91294a9fb94a75542f6e46e4a2ae709bd8d9b51134098cae5cf3bea5478b6d03", size = 108546, upload-time = "2026-10-07T12:23:09.956Z" }, - { url = "https://files.pythonhosted.org/packages/72/34/4cca9739254130627bde87500b3f2b512154fe2f278efa7e2a5e10ad4bcb/tomli-2.5.0-cp314-cp314t-win_amd64.whl", hash = "sha256:f15e3e0b835a6d68b10c86bf80a3149780498d6911c93c3ffd1861d19f9200f1", size = 117814, upload-time = "2026-10-07T12:23:11.486Z" }, - { url = "https://files.pythonhosted.org/packages/7d/fb/afa530d47dd80a78fce43beac6bc6e00f84558eafcffbc6f37b21e80d056/tomli-2.5.0-cp314-cp314t-win_arm64.whl", hash = "sha256:6664b7ae7af7294256c53960a6103077f4914cec8ff98479c352f622c6f6b2f0", size = 115188, upload-time = "2026-10-07T12:23:12.728Z" }, - { url = "https://files.pythonhosted.org/packages/66/98/316fdc00f8c0939e6fe50461dd343c162d3ad51d1286eb25b7db54361d50/tomli-2.5.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:a525685c2f97da40762b8695eb7aa0af4c8344ca1905c73e4e29cb04d34607dc", size = 162775, upload-time = "2026-10-07T12:23:13.941Z" }, - { url = "https://files.pythonhosted.org/packages/c5/22/7b10fa5bb01c9539f53f69b619361b19350acc73657772ea7ac70ba309a8/tomli-2.5.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:9dbb18c1cfb2f6517942fc9314437f66aa06d94436ffb1f06102ef3572f35276", size = 161406, upload-time = "2026-10-07T12:23:15.215Z" }, - { url = "https://files.pythonhosted.org/packages/9c/e7/1a069d86dfd20f1f84f71c63faed9f83c1d890bc06c27d82dc7d888fb573/tomli-2.5.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:752e8b1aa6a4367ef8bf6a1a1e005540f7ed055ba36d7193796812ca5404eb52", size = 273855, upload-time = "2026-10-07T12:23:16.471Z" }, - { url = "https://files.pythonhosted.org/packages/ae/83/d1ef43d1687d092ab9c235455c76e6e709483b346b056f086095c7c263a5/tomli-2.5.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c47300f9bf791808f77d82747691c4bb09cb14bdf3060cca99b42cdc4361d5a7", size = 284910, upload-time = "2026-10-07T12:23:18.166Z" }, - { url = "https://files.pythonhosted.org/packages/cc/05/f4d9cf7de61822ece0c3873f30d291e324911c71a378b8bfe5ced13fd9f5/tomli-2.5.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:19b0dd8749f4ea2f112c5fcfb3c5248390c899d7e2e173f1d91abee1fa0ff391", size = 277723, upload-time = "2026-10-07T12:23:19.355Z" }, - { url = "https://files.pythonhosted.org/packages/42/28/78262493141fa543151cf005760c3cb01d09fc28a11f993c05109902cb8c/tomli-2.5.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:57b1c3b01fab802e2899bc3d168dca320e14165e2fd9fd584760fb4ca5826859", size = 285115, upload-time = "2026-10-07T12:23:20.698Z" }, - { url = "https://files.pythonhosted.org/packages/1a/b9/e1dab9a30bcb677b5cc5cee810609cfd64f24306a3055767dd3fda00b1e0/tomli-2.5.0-cp315-cp315-win32.whl", hash = "sha256:667e521b37a6c5ccaa044202c235b530f90177ffe2cd4a64ecc213c7dd535feb", size = 103475, upload-time = "2026-10-07T12:23:21.941Z" }, - { url = "https://files.pythonhosted.org/packages/4c/bd/31a3790c11d6ea95fcf5e6022ac0f8d0543c9b61120b730fc481bd43d3b4/tomli-2.5.0-cp315-cp315-win_amd64.whl", hash = "sha256:d747252933c8a65ef6bd8da0fbb7ce28a90eb6119d8cd00772cd528aa07b68d5", size = 114589, upload-time = "2026-10-07T12:23:23.098Z" }, - { url = "https://files.pythonhosted.org/packages/47/a2/4f6310fa699364f0e3af7ee3af88dddd9af066d33e716a0265bbe2b3ea84/tomli-2.5.0-cp315-cp315-win_arm64.whl", hash = "sha256:75dbcde8751b0a960aa3de173aa5e894d590755c6d7758b7e774c06f1dc3cbdd", size = 111493, upload-time = "2026-10-07T12:23:24.233Z" }, - { url = "https://files.pythonhosted.org/packages/68/14/00853f0b396d8971107ae1921bb5b322fdee1650d2f16bf06c20adb532e5/tomli-2.5.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:2419c2a189551987b59d80e63ec355671283336f41c6b9b89462df679c7d0c57", size = 171380, upload-time = "2026-10-07T12:23:25.512Z" }, - { url = "https://files.pythonhosted.org/packages/89/ad/fa6949321dadee46b27363974fb197b94c911c3b0f7a5fd26d7dc18fc2a0/tomli-2.5.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:0dc598040da8d42cf20f0be588ed7004f46db12a0ac6c32e03a59dccedaaadcd", size = 170553, upload-time = "2026-10-07T12:23:26.855Z" }, - { url = "https://files.pythonhosted.org/packages/53/aa/3056c919eb3e084df3752b2cf5f865dcc04af0b27dba2f66d7b28af4633a/tomli-2.5.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:49096930c8d886c9bbdab62d2d0d17ce823ddeea522309a190b36245d5b49e01", size = 294428, upload-time = "2026-10-07T12:23:28.132Z" }, - { url = "https://files.pythonhosted.org/packages/96/b2/faeeb5d8769ea3832021d73e892c8391eae7b4b4f8b55a789127bd8b18a9/tomli-2.5.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8ade5023067f99fe72b88accd30d0ea05a158e9e32a11f124e731ea9695313f", size = 304909, upload-time = "2026-10-07T12:23:29.381Z" }, - { url = "https://files.pythonhosted.org/packages/f6/52/f094c09e73fb654b621716d019acb5d29bdfd1be01df80c281d552bda48d/tomli-2.5.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:b69564772b5c8f22ea5f498dff08cfa825045b4d4c4400529000bdf818aa3b2a", size = 293220, upload-time = "2026-10-07T12:23:30.608Z" }, - { url = "https://files.pythonhosted.org/packages/86/f5/0c30541078ca4b505ce3bd76ed931facbfec524dd018535d691d1af0a6d2/tomli-2.5.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:8ff3a2ca028c7eee0c777f9a092038d0a594a9fa04e215f929a22c329e2cb142", size = 305705, upload-time = "2026-10-07T12:23:32.181Z" }, - { url = "https://files.pythonhosted.org/packages/05/74/590e7d19d6a118fc5cc5704ff358e21d95b8573f6b9443b1519f29ca8825/tomli-2.5.0-cp315-cp315t-win32.whl", hash = "sha256:62fc1bc8eb03e3a9cadfca713d65614ed8e09d974a283295ffe3a831976b4dc5", size = 108432, upload-time = "2026-10-07T12:23:33.496Z" }, - { url = "https://files.pythonhosted.org/packages/1c/b8/63a75cfb27a17c38550e44025d3a6e7be64516fd8608a3b75703bf37d81b/tomli-2.5.0-cp315-cp315t-win_amd64.whl", hash = "sha256:f3fcbc57b1791fa6cbe5d8434179d51de12be1a4811469529f47f6e7487a2571", size = 117281, upload-time = "2026-10-07T12:23:34.648Z" }, - { url = "https://files.pythonhosted.org/packages/72/01/e8c1debb2173973372934c68fc8e46170ab60ef23ed4592dff4dec6e8993/tomli-2.5.0-cp315-cp315t-win_arm64.whl", hash = "sha256:d2ba24db8a9376921b5e87b4762b9adb0f3f1deaea68f2b8b0bb2c11efb9c3e7", size = 115069, upload-time = "2026-10-07T12:23:35.77Z" }, - { url = "https://files.pythonhosted.org/packages/60/3f/3e3f8fd0919249b0200c80fbc4f9a1e70be19f9883da71dfb7f8b9ab8aca/tomli-2.5.0-py3-none-any.whl", hash = "sha256:32a7b79ac57a2e83670ce329ccf675798bc5a2094783a63676866b70503f2e2b", size = 14765, upload-time = "2026-10-07T12:23:36.875Z" }, + { url = "https://files.pythonhosted.org/packages/51/e9/3a7820be2bb0fe53b6bc9c3be26d3d1158004e4c3ab953aa6840b955b1e9/truststore-0.10.5-py3-none-any.whl", hash = "sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c", size = 19017, upload-time = "2026-10-12T22:27:30.377Z" }, ] [[package]] From 00e0bf1817ea4e10fc13de7533511b814228982d Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 11:24:15 +0100 Subject: [PATCH 7/9] Prepare the 0.2.0 release Co-Authored-By: Claude Opus 5.5 --- src/clairic/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clairic/_version.py b/src/clairic/_version.py index 3dc1f76..d3ec452 100644 --- a/src/clairic/_version.py +++ b/src/clairic/_version.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "0.2.0" From 34c38bae4cca1f934b03654225e2d9fe9fb452a0 Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 16:14:04 +0100 Subject: [PATCH 8/9] Address review comments on #21 - TextAnswer.guess, NumberAnswer.guess and TextAnswer.span now say how they behaved before Cloudflare's November 2026 update. - The example prints "passes (decode steps)", keeping the API's word. - A blank line separates the docstring of the repeated-item live test from its code. Co-Authored-By: Claude Opus 5.5 --- examples/invoice.py | 3 ++- src/clairic/answers.py | 11 ++++++++--- tests/live/test_live.py | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/invoice.py b/examples/invoice.py index 4be0f23..3fc956d 100644 --- a/examples/invoice.py +++ b/examples/invoice.py @@ -65,7 +65,8 @@ def main() -> None: print(f"Total: {data.total.value} USD") 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} decode steps") + usage = result.usage + print(f"Input tokens: {usage.input_tokens} over {usage.passes} passes (decode steps)") print() print(result.values_as(Invoice)) diff --git a/src/clairic/answers.py b/src/clairic/answers.py index 7521d01..c50b109 100644 --- a/src/clairic/answers.py +++ b/src/clairic/answers.py @@ -101,10 +101,13 @@ class TextAnswer(_SingleValueAnswer): value: str | None The extracted text, or `None` when the input does not contain it. guess: str | None - Always `None`: Clairic no longer returns a best candidate for text answers. + Always `None`. Until Cloudflare's November 2026 update, Clairic returned the best + candidate text here, even when `value` was `None`; it no longer returns one for text + answers. span: Span | None Location of `value` in the input, or `None` when the value occurs more than once in - the input or is not printed in it. + the input or is not printed in it. Before the November 2026 update, it located + `guess`. """ type: Literal["text"] = "text" @@ -125,7 +128,9 @@ class NumberAnswer(_SingleValueAnswer, Generic[N]): value: N | None The number, or `None` when the input does not determine it. guess: N | None - Always `None`: Clairic no longer returns a best candidate for number answers. + Always `None`. Until Cloudflare's November 2026 update, Clairic returned the best + candidate number here, even when `value` was `None`; it no longer returns one for + number answers. """ type: Literal["number"] = "number" diff --git a/tests/live/test_live.py b/tests/live/test_live.py index fafb4f1..267c072 100644 --- a/tests/live/test_live.py +++ b/tests/live/test_live.py @@ -126,6 +126,7 @@ class Meeting(BaseModel): def test_text_list_with_repeated_items(clairic: Clairic) -> None: """Should extract a text list whose items occur more than once in the input.""" + notes = "Attendees: Alice, Bob and Alice's manager Carol. Alice sends the report, Bob approves." result = clairic.extract(notes, Meeting) From 97b09f1480eae7482fbb6052160b1b4877f8e834 Mon Sep 17 00:00:00 2001 From: Vianney Mixtur Date: Sat, 5 Dec 2026 16:15:19 +0100 Subject: [PATCH 9/9] Separate test docstrings from code across the PR Review comment on #21: a blank line between a test's docstring and its code, for every test this pull request adds or changes. Co-Authored-By: Claude Opus 5.5 --- tests/test_answers.py | 2 ++ tests/test_client.py | 5 +++++ tests/test_result.py | 1 + tests/test_specs.py | 1 + 4 files changed, 9 insertions(+) diff --git a/tests/test_answers.py b/tests/test_answers.py index 0cca474..0599929 100644 --- a/tests/test_answers.py +++ b/tests/test_answers.py @@ -81,6 +81,7 @@ def test_single_value_answers_parse_the_recorded_values() -> None: def test_spans_slice_the_input_to_the_extracted_text() -> None: """Should locate text answers and text list items in the input with end-exclusive spans.""" + text = state("types_present") parsed = TypesPresent.model_validate(answers("types_present")) @@ -103,6 +104,7 @@ def test_values_repeated_in_the_input_have_no_span() -> None: Recorded in list_repeated_items: Alice and Bob each appear more than once, Carol once. """ + text = state("list_repeated_items") parsed = Notes.model_validate(answers("list_repeated_items")) diff --git a/tests/test_client.py b/tests/test_client.py index e30a4ef..46cb8e7 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -125,6 +125,7 @@ class Total(BaseModel): def test_extract_accepts_list_items_without_a_span() -> None: """Should return a text list whose repeated items have no span instead of failing.""" + recorder = Recorder("list_repeated_items") class Attendees(BaseModel): @@ -226,6 +227,7 @@ def test_invalid_answers_emit_a_warning_naming_them() -> None: Recorded in truncated_invalid_answers: two source-only fields read "1,200 EUR" and "Friday", which Clairic could not normalize, so it reported truncated: true. """ + with pytest.warns( ClairicInvalidAnswerWarning, match="2 invalid answers: budget, due" ) as caught: @@ -299,6 +301,7 @@ def test_empty_state_fails_before_any_request() -> None: def test_credentials_fall_back_to_the_environment(monkeypatch: pytest.MonkeyPatch) -> None: """Should read the account id and token from the Cloudflare environment variables.""" + monkeypatch.setenv("CLOUDFLARE_ACCOUNT_ID", ACCOUNT_ID) monkeypatch.setenv("CLOUDFLARE_API_TOKEN", TOKEN) recorder = Recorder("invoice") @@ -334,6 +337,7 @@ def test_repr_does_not_reveal_the_token() -> None: def test_context_manager_closes_an_owned_http_client() -> None: """Should close the HTTP client it created, and leave a passed-in one open.""" + with Clairic(account_id=ACCOUNT_ID, api_token=TOKEN) as owned: pass passed_in = httpx2.Client() @@ -383,6 +387,7 @@ def handler(request: httpx2.Request) -> httpx2.Response: @pytest.mark.anyio async def test_async_invalid_answers_emit_a_warning() -> None: """Should warn, pointing at the caller, with the async client.""" + async with _async_client(Recorder("truncated_invalid_answers")) as client: with pytest.warns(ClairicInvalidAnswerWarning, match="budget, due") as caught: await client.extract("Meeting notes.", Report) diff --git a/tests/test_result.py b/tests/test_result.py index e3f7c09..ddfcddf 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -124,6 +124,7 @@ class Aliased(BaseModel): def test_usage_reports_decode_steps_and_generated_tokens() -> None: """Should read the usage of a current response, where generated answers produce tokens.""" + response = load("list_repeated_items")["response"] assert isinstance(response, dict) diff --git a/tests/test_specs.py b/tests/test_specs.py index fb7fd72..ddd74cb 100644 --- a/tests/test_specs.py +++ b/tests/test_specs.py @@ -78,6 +78,7 @@ def test_date_bounds_are_sent_as_iso_dates() -> None: @pytest.mark.parametrize("null_threshold", [0, -0.1, 1.5]) def test_null_threshold_outside_zero_one_is_rejected(null_threshold: float) -> None: """Should reject a null_threshold outside (0, 1] (err_null_threshold_zero).""" + with pytest.raises(ValueError, match="null_threshold"): Date(null_threshold=null_threshold)