idia 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- idia-0.3.0/.gitignore +11 -0
- idia-0.3.0/CHANGELOG.md +80 -0
- idia-0.3.0/CONTRIBUTING.md +44 -0
- idia-0.3.0/LICENSE +21 -0
- idia-0.3.0/PKG-INFO +334 -0
- idia-0.3.0/README.md +293 -0
- idia-0.3.0/SECURITY.md +24 -0
- idia-0.3.0/docs/assets/demo/demo.tape +40 -0
- idia-0.3.0/docs/assets/demo/draw.py +319 -0
- idia-0.3.0/docs/assets/demo/triage.py +217 -0
- idia-0.3.0/docs/assets/demo.gif +0 -0
- idia-0.3.0/docs/assets/demo.svg +53 -0
- idia-0.3.0/docs/how-to/README.md +9 -0
- idia-0.3.0/docs/how-to/add-a-provider-to-idia.md +426 -0
- idia-0.3.0/docs/how-to/write-a-leaf.md +1331 -0
- idia-0.3.0/docs/images/idia-1.svg +10 -0
- idia-0.3.0/docs/images/idia-2.svg +10 -0
- idia-0.3.0/docs/spec/README.md +14 -0
- idia-0.3.0/docs/spec/conformance.md +81 -0
- idia-0.3.0/docs/spec/dispatch.md +135 -0
- idia-0.3.0/docs/spec/elicitation.md +58 -0
- idia-0.3.0/docs/spec/fit.md +113 -0
- idia-0.3.0/docs/spec/providers.md +320 -0
- idia-0.3.0/docs/spec/test-doubles.md +109 -0
- idia-0.3.0/docs/spec/vocabulary.md +184 -0
- idia-0.3.0/docs/tutorials/ask-a-provider.md +170 -0
- idia-0.3.0/pyproject.toml +111 -0
- idia-0.3.0/skills/idia/SKILL.md +140 -0
- idia-0.3.0/src/idia/__init__.py +171 -0
- idia-0.3.0/src/idia/_provider.py +281 -0
- idia-0.3.0/src/idia/answers.py +336 -0
- idia-0.3.0/src/idia/cloudflare.py +70 -0
- idia-0.3.0/src/idia/conformance/__init__.py +52 -0
- idia-0.3.0/src/idia/conformance/_base.py +373 -0
- idia-0.3.0/src/idia/conformance/_leaf.py +905 -0
- idia-0.3.0/src/idia/conformance/_provider.py +952 -0
- idia-0.3.0/src/idia/conformance/_review.py +259 -0
- idia-0.3.0/src/idia/conformance/_scripted.py +291 -0
- idia-0.3.0/src/idia/core.py +1626 -0
- idia-0.3.0/src/idia/dispatch.py +815 -0
- idia-0.3.0/src/idia/fit.py +730 -0
- idia-0.3.0/src/idia/limits.py +90 -0
- idia-0.3.0/src/idia/providers/__init__.py +143 -0
- idia-0.3.0/src/idia/providers/_canon.py +419 -0
- idia-0.3.0/src/idia/providers/_gliner.py +507 -0
- idia-0.3.0/src/idia/providers/_openai.py +311 -0
- idia-0.3.0/src/idia/providers/chat/__init__.py +9 -0
- idia-0.3.0/src/idia/providers/chat/openai.py +523 -0
- idia-0.3.0/src/idia/providers/cloudflare.py +1139 -0
- idia-0.3.0/src/idia/providers/gliner.py +26 -0
- idia-0.3.0/src/idia/providers/http.py +475 -0
- idia-0.3.0/src/idia/providers/openai_decisions.py +476 -0
- idia-0.3.0/src/idia/providers/recorded.py +786 -0
- idia-0.3.0/src/idia/providers/scripted.py +263 -0
- idia-0.3.0/src/idia/providers/system_one.py +567 -0
- idia-0.3.0/src/idia/py.typed +0 -0
- idia-0.3.0/src/idia/retry.py +53 -0
- idia-0.3.0/tests/__init__.py +0 -0
- idia-0.3.0/tests/_closable_scripted.py +21 -0
- idia-0.3.0/tests/_cloudflare_cases.py +607 -0
- idia-0.3.0/tests/_cloudflare_harness.py +345 -0
- idia-0.3.0/tests/_complementing_leaf.py +16 -0
- idia-0.3.0/tests/_conformance.py +33 -0
- idia-0.3.0/tests/_dishonest.py +173 -0
- idia-0.3.0/tests/_dishonest_http.py +46 -0
- idia-0.3.0/tests/_dishonest_retry.py +47 -0
- idia-0.3.0/tests/_fake_leaf.py +35 -0
- idia-0.3.0/tests/_fake_leaf_missing_dependency.py +3 -0
- idia-0.3.0/tests/_gliner_cases.py +208 -0
- idia-0.3.0/tests/_gliner_harness.py +139 -0
- idia-0.3.0/tests/_http.py +860 -0
- idia-0.3.0/tests/_openai_cases.py +321 -0
- idia-0.3.0/tests/_openai_harness.py +240 -0
- idia-0.3.0/tests/_stub_http_leaf.py +174 -0
- idia-0.3.0/tests/_support.py +163 -0
- idia-0.3.0/tests/_system_one_cases.py +374 -0
- idia-0.3.0/tests/_system_one_harness.py +160 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/alias.json +171 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/candidate-estimate.json +100 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/emoji.json +126 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/extraction.json +347 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/field-name-probe.json +82 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/order/order-a-1.json +145 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/order/order-a-2.json +145 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/order/order-b.json +145 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/past-context/refused.json +82 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/past-context/truncated.json +117 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/provider.json +171 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/repeats.json +206 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/single-home_team.json +126 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/single-refunds.json +125 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/times.json +148 -0
- idia-0.3.0/tests/cassettes/cloudflare-clairic/clairic/base/unsettled.json +208 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/alias.json +196 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/choice.json +196 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/failure.json +910 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/image.json +174 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/noul.json +119 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/order/order-a-1.json +297 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/order/order-a-2.json +297 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/order/order-b.json +297 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/question-id-probe.json +99 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/recount-one.json +95 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/recount-three.json +143 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/score.json +225 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/single-choice_outcome.json +128 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/single-choice_weather.json +139 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef/base/wording.json +140 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/alias.json +196 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/choice.json +196 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/failure.json +910 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/image.json +174 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/noul.json +119 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/order/order-a-1.json +297 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/order/order-a-2.json +297 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/order/order-b.json +297 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/recount-one.json +95 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/recount-three.json +143 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/score.json +225 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/single-choice_outcome.json +128 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/single-choice_weather.json +139 -0
- idia-0.3.0/tests/cassettes/cloudflare-clef/clef-flash/base/wording.json +140 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/choice.json +347 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/failure.json +90 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/noul.json +314 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/score-absent-level.json +354 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/score.json +361 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/single-choice_outcome.json +339 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/single-choice_weather.json +347 -0
- idia-0.3.0/tests/cassettes/openai-chat/gpt-4.1/base/unauthorized.json +95 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/choice.json +252 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/failure.json +2150 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/noul.json +148 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order/order-a-1.json +252 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order/order-a-2.json +252 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order/order-b.json +252 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-a-1.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-a-2.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-a-3.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-b-1.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-b-2.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-b-3.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-c-1.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-c-2.json +384 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-choice_priority-1.json +181 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-choice_priority-2.json +181 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-choice_reason-1.json +181 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-choice_reason-2.json +181 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-noul_keep-1.json +122 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-noul_keep-2.json +122 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-score_regulars-1.json +188 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-d-score_regulars-2.json +188 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-e-1.json +379 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/order-4/order-e-2.json +379 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/questions-201.json +4672 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/recount-1.json +122 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/recount-3.json +169 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/refusal-probe.json +162 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/score.json +283 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/single-choice_outcome.json +165 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/single-choice_weather.json +183 -0
- idia-0.3.0/tests/cassettes/openai-decisions/gpt-6-luna/base/unknown-model.json +114 -0
- idia-0.3.0/tests/cassettes/stub/stub-1/base/box.json +150 -0
- idia-0.3.0/tests/cassettes/stub/stub-1/base/choice.json +266 -0
- idia-0.3.0/tests/cassettes/stub/stub-1/base/extraction.json +138 -0
- idia-0.3.0/tests/cassettes/stub/stub-1/base/failure.json +102 -0
- idia-0.3.0/tests/cassettes/stub/stub-1/base/noul.json +134 -0
- idia-0.3.0/tests/cassettes/stub/stub-1/base/score.json +266 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/choice.json +191 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/failure.json +170 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/noul.json +114 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/over-limit.json +86 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/score.json +220 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/single-choice_outcome.json +123 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/single-choice_weather.json +134 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/base/wording.json +135 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.13.0/images/probe-noul.json +117 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/base/probe-noul-text.json +114 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/box.json +152 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/choice.json +209 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/failure.json +188 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/noul.json +132 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/probe-image-side/279x279.json +92 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/probe-image-side/279x320.json +92 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/probe-image-side/280x280.json +100 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/probe-image-side/280x320.json +100 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/probe-image-side/320x279.json +92 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/probe-image-side/320x280.json +100 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/provider-box_red.json +118 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/score.json +238 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/single-choice_colour.json +152 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/single-choice_shapes.json +141 -0
- idia-0.3.0/tests/cassettes/system-one/jev-1.14.0/images/wording.json +138 -0
- idia-0.3.0/tests/conftest.py +24 -0
- idia-0.3.0/tests/stored/gliner/fastino/gliner2.5-small-v1/outputs.json +153 -0
- idia-0.3.0/tests/test_answers.py +623 -0
- idia-0.3.0/tests/test_canon.py +389 -0
- idia-0.3.0/tests/test_cloudflare.py +2269 -0
- idia-0.3.0/tests/test_cloudflare_conformance.py +291 -0
- idia-0.3.0/tests/test_cloudflare_live.py +544 -0
- idia-0.3.0/tests/test_composites.py +860 -0
- idia-0.3.0/tests/test_conformance.py +1974 -0
- idia-0.3.0/tests/test_core.py +1303 -0
- idia-0.3.0/tests/test_dispatch.py +828 -0
- idia-0.3.0/tests/test_docs.py +235 -0
- idia-0.3.0/tests/test_fit.py +925 -0
- idia-0.3.0/tests/test_gates.py +64 -0
- idia-0.3.0/tests/test_gliner.py +882 -0
- idia-0.3.0/tests/test_gliner_conformance.py +84 -0
- idia-0.3.0/tests/test_gliner_local_model.py +269 -0
- idia-0.3.0/tests/test_http.py +798 -0
- idia-0.3.0/tests/test_http_harness.py +1447 -0
- idia-0.3.0/tests/test_leaf.py +147 -0
- idia-0.3.0/tests/test_limits.py +252 -0
- idia-0.3.0/tests/test_openai_chat.py +769 -0
- idia-0.3.0/tests/test_openai_conformance.py +80 -0
- idia-0.3.0/tests/test_openai_decisions.py +810 -0
- idia-0.3.0/tests/test_openai_live.py +334 -0
- idia-0.3.0/tests/test_openai_loop.py +287 -0
- idia-0.3.0/tests/test_openai_shared.py +458 -0
- idia-0.3.0/tests/test_package.py +46 -0
- idia-0.3.0/tests/test_provenance.py +1169 -0
- idia-0.3.0/tests/test_provider.py +218 -0
- idia-0.3.0/tests/test_providers.py +135 -0
- idia-0.3.0/tests/test_recorded.py +633 -0
- idia-0.3.0/tests/test_retry.py +74 -0
- idia-0.3.0/tests/test_scripted.py +400 -0
- idia-0.3.0/tests/test_system_one.py +1238 -0
- idia-0.3.0/tests/test_system_one_conformance.py +73 -0
- idia-0.3.0/tests/test_system_one_live.py +225 -0
- idia-0.3.0/tests/test_wording.py +419 -0
idia-0.3.0/.gitignore
ADDED
idia-0.3.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to idia are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0, a minor release may break the API; each break is listed under **Changed** or **Removed**. A new question kind, a new elicitation or a new validation rule is a minor release and is listed here.
|
|
4
|
+
|
|
5
|
+
## [0.3.0] - 2026-11-28
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `Rule.reported_invalid`, a rule a leaf sets itself: the provider reported its own answer invalid or incomplete. Clairic sets it for an answer the wire marks `valid: false` or `complete: false`, observed as the flags sent false joined by commas, with `:` and the wire's `failure_reason` after them when it gives one, the answer as mapped kept in the fault; a candidate shape under such a flag records `candidate_shape` after it. `validate` never sets it and passes such a fault through unchanged.
|
|
10
|
+
- `Gliner(capabilities=...)`, and the same keyword on `idia.provider("gliner")` and `idia.leaf("gliner")`: a changed copy of the declared record replaces it, as for every other leaf.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- The kind of model idia asks, which returns probabilities instead of prose, is called a judgement model in the docs, the skill and the package description, where it was called a decision model. No name in the API changes.
|
|
15
|
+
- `ExtractionAnswer.span` takes `None` among a list's spans: one entry per item, a `Span` or `None` for an item the provider places nowhere, as Clairic gives an item that repeats in the state. A caller reading a list's spans must handle `None`.
|
|
16
|
+
- Clairic faults an answer the wire reports invalid or incomplete under `reported_invalid`, where it read it as an answer; its siblings stand.
|
|
17
|
+
- Clairic no longer raises `provider-truncated`: the wire now refuses a state past its context with 422 and code 3030, nothing truncated, and its `truncated` flag says only that some answer is invalid or incomplete. `WARNING_PROVIDER_TRUNCATED` stays public.
|
|
18
|
+
- Clairic's `max_input_tokens` and `max_question_tokens` are 65,273, where they were 65,536: the wire's limit for one prompt, the state and its fields. The `cloudflare` router's derived token limits are 65,273 over `clef`, the lesser of its members'.
|
|
19
|
+
- Clairic's `extras["passes"]` is kept as the wire reports it, which now counts sequential decoding steps, not passes over the fields.
|
|
20
|
+
- Clairic's estimator models one prompt: 10 tokens; the state's text at a token per ASCII digit and 3 other characters a token; each field by its value type (220 tokens for text, 130 for any other scalar, 1,350 for a list) plus its instruction, counted as text; and each image by its size, a PNG or JPEG under 65,000 pixels scaled up to that area, in 32-pixel patches plus 2, or 4,098 tokens where its size cannot be read. It costed 150 tokens a field and 1,024 an image.
|
|
21
|
+
- The providers spec gives Clairic as served from November 2026: the model reported as `clairic-27b`, the leaf's `model` still `clairic`; `output_tokens` non-zero and kept as reported; a list's `p_null` and a number's span carried; an unsettled text answer with no `guess`.
|
|
22
|
+
|
|
23
|
+
### Removed
|
|
24
|
+
|
|
25
|
+
- The Clairic cassette of a list sent with object items, which the wire no longer refuses.
|
|
26
|
+
|
|
27
|
+
## [0.2.0] - 2026-11-16
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- `extras` on `WireResponse` and `Outcome`, `Mapping[str, JsonValue]`, empty by default: the figures a wire reports beyond the shared vocabulary, under keys each leaf documents in the providers spec. It is no provenance detail and needs no reason. It is held read-only at every depth in the order built, and either constructor refuses a non-mapping with `TypeError`, and a key that is not a string, a value outside the JSON domain or a non-finite float with `ValueError`. Dispatch carries an answered outcome's `extras` from its wire response unchanged; a failed outcome has none. Clairic fills `{"passes": n}` from its usage; every other leaf gives it empty. The scripted leaf's `Reply` takes `extras`, the recorded leaf's log keeps it and leaves it out when empty, and conformance check P8 holds a wrapped leaf's outcome to the leaf's `extras` and a failed outcome to none.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- A `ProviderError`'s message quotes the wire's error whole, where it was cut to 300 characters: the body's `error`, `message` or `detail`, the whole JSON body when it holds none of them (it gave no message before), or the body's text. Cloudflare's leaves quote every `errors[]` entry, in order, joined by `; `, where they quoted the first, and a quota code in any entry makes the error not retryable. Clairic's refusal of a `reference_date` string quotes it whole.
|
|
36
|
+
- The package's classifiers name the operating systems its tests run on, macOS and Linux, in place of `OS Independent`; Windows is not yet tested.
|
|
37
|
+
- The recorded leaf's log is format 4, and a format-3 log is refused until upgraded. `upgrade_log` brings a format-3 log to format 4, moving each logged pass count from the usage to `extras` and dropping `usage.passes` from the reasons and claims, with its keys and everything else unchanged; it still re-keys a format-2 log, now to format 4, and its `requests` default to none. A log that is not JSON is refused as not a recorded leaf's log.
|
|
38
|
+
|
|
39
|
+
### Removed
|
|
40
|
+
|
|
41
|
+
- `Usage.passes`, and `usage.passes` from `DETAILS` and `ProvenanceDetail`: a figure only one provider reports is no longer a typed field of the shared vocabulary. Read Clairic's passes from `outcome.extras["passes"]`. No leaf gives `usage.passes` a reason any longer, and `upgrade_log` no longer gives it `not-exposed`.
|
|
42
|
+
|
|
43
|
+
### Security
|
|
44
|
+
|
|
45
|
+
- Each wire leaf filters the credential it was built with out of every `ProviderError` text it builds from the wire or its client, beside the key shapes Core filters: Cloudflare's API token, System One's API key, and the OpenAI client's `api_key` and `admin_api_key`, read when the error is built. A credential shorter than eight characters is left as it is. `HttpLeaf` takes `credentials`, and `status_error`, `malformed_request` and `client_failed` take the credentials to filter.
|
|
46
|
+
|
|
47
|
+
## [0.1.0] - 2026-10-23
|
|
48
|
+
|
|
49
|
+
The first release.
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- The vocabulary: every shape from `State` to `Response`; the closed kinds (`noul`, `choice`, `score`, `extraction`, `box`) and elicitations (`passthrough`, `logprobs`) with their candidates; the answer union with `Refusal`, `Fault` and `Rule`; `noul_complement`; and the `Leaf`, `Provider` and `TokenEstimator` protocols.
|
|
54
|
+
- A question's wording: its instruction a string or a JSON object or array, and a `noul` optionally carrying `yes` and `no` labels that describe what counts as each. A leaf sends the wording as its wire takes it or refuses it, and never drops it: System One and Clef send both, and the chat leaf writes a noul's descriptions into its prompt.
|
|
55
|
+
- Key order kept: a JSON object's keys are held, sent, recorded and keyed in the order the caller built them, at every depth, in a JSON part, a structured instruction and the options, since key order is part of what a model reads and moves its answers. Each such value is held read-only, objects as read-only mappings and arrays as tuples, so a later change to the caller's object reaches nothing; a shape holding one cannot be pickled or deep-copied; and a value that contains itself or nests too deep is refused with `ValueError` naming the field when it is built. `==` on the shapes compares mappings without regard to order, so two equal shapes may be two different prompts, and `hash()` agrees with it.
|
|
56
|
+
- `Capabilities`, every field stated: the kinds, modalities and limits, `Rounding`, `UNBOUNDED`, the opt-in feature maps, the image fields, and `carries_noul_descriptions` and `carries_structured_instructions`, which say what wording a leaf sends.
|
|
57
|
+
- Answer validation, `validate` and `validate_answers`: fixed rules per kind, with tolerances from the declared rounding, for the sum and for a chosen label, which may lie one rounding step below the highest probability, since a provider may round after it chooses; such a label is kept as given, with a `chosen-below-max` warning (`WARNING_CHOSEN_BELOW_MAX`) naming the question.
|
|
58
|
+
- The errors under `IdiaError`: `DoesNotFit` before any call, `RequestFailed` carrying the response, and `ProviderError`, the one error a leaf raises, its text filtered of key-shaped substrings.
|
|
59
|
+
- Fit: preflight of a request against a provider's capabilities, refusing with `DoesNotFit` before any call a request it cannot split to fit or a wording form the record does not carry, `unchecked-limit` warnings for limits nobody knows, greedy packing of overflowing questions into wire requests that repeat the state, and `OverflowPolicy` with `Fail` as the default.
|
|
60
|
+
- Dispatch: `Dispatcher`, the one loop that runs a fit plan inside the caller's `Deadline`, with `RetryPolicy`, `ConcurrencyLimit` and `RateLimiter`, one `Outcome` per wire request with its attempts and provenance, the re-ask after a fault, and a stop after a credential error; `Dispatcher.plan` for the plan alone; `Router` and `Fallback` with their derived capabilities; `aclose()` and `async with` on every provider.
|
|
61
|
+
- Provenance on every outcome to one profile: each of `DETAILS`, from the model reported to the request id, a value or an `UnreportedReason`, the codes `REASONS` lists, in `unreported` (`not-reported`, `not-pinned`, `not-sent`, `hidden`, `not-applicable`, `not-exposed`), the details a source only `claimed`, the runtime's `versions` and the client libraries' `client_versions`, idia's own among them, and each outcome's `rounding`; the conformance suite holds every leaf to it.
|
|
62
|
+
- `idia.provider(name, ...)` and the registry of leaves, each behind an optional extra whose name the import error gives; `idia.leaf(name, ...)`, which builds the same leaf unwrapped, so a caller can wrap a leaf of its own around it, such as one counting every call; and `idia.provider_names()`, the registered names:
|
|
63
|
+
- `system-one` (extra `system-one`): System One's decision models, `jev-1.14.0` by default, with images and, on the models that take it, `box`; `jev-latest`, a moving alias, is offered without `box`;
|
|
64
|
+
- `openai-decisions` and `openai-chat` (extra `openai`): OpenAI's Decisions API, and a chat model read by the `logprobs` elicitation;
|
|
65
|
+
- `cloudflare-clef` and `cloudflare-clairic` (extra `cloudflare`): Workers AI's Clef for the label kinds and Clairic for extraction, and `cloudflare()` in `idia.cloudflare`, a router over the two sharing one client.
|
|
66
|
+
- `gliner` (extra `gliner`): the GLiNER2 span extractor `fastino/gliner2.5-small-v1`, run in this process, for `extraction` of text from one text part, a value as the top-scoring span with its score as `confidence`, or a list. Its weights are pinned to a revision by default and loaded by an explicit `await leaf.load()`; a model passed in as `runtime` is reported at the `revision` the caller passes, and with none at no snapshot, with the `no-snapshot` warning; its usage counts input tokens with the model's own tokenizer. The leaf, `Gliner`, is in `idia.providers.gliner`, which is not yet part of the public API.
|
|
67
|
+
- `HttpLeaf` in `idia.providers.http`, the base a leaf over a raw HTTP API may inherit: client lifecycle, one POST under the deadline, and the status table.
|
|
68
|
+
- Test doubles: `Scripted`, a leaf answered from a script, and `Recorded`, which records a leaf's calls under the hash of the canonical wire request, key order included, in a format-3 log that keeps each key's request beside its calls, and replays them in modes `none`, `once` and `new`, refusing with `ValueError` a log of another format or one it cannot read and keeping a log's permission bits when it rewrites it; `upgrade_log(log, *, requests, reasons=None)`, which brings a format-2 log, written before this release, to format 3 offline, re-keying only the given requests whose key order cannot have differed, leaving out and counting every other entry, and filling each response's provenance reasons. The scripted leaf's `prompt_sent` is its wire request as compact JSON in the order built.
|
|
69
|
+
- The conformance suite, `idia.conformance`: `leaf_checks` (L1 to L32, L32 holding a leaf to a caller's key order in the body sent and its `prompt_sent`) and `provider_checks` (P1 to P23), run with `run_checks` against a harness built from exchanges, `AnyBody` among them, and an optional `body_sent()` on a leaf harness, so a leaf written outside idia can check itself.
|
|
70
|
+
- The spec in `docs/spec`.
|
|
71
|
+
- The public API: the names in `idia.__all__` and in the `__all__` of `idia.cloudflare`, `idia.conformance`, `idia.providers.http`, `idia.providers.system_one`, `idia.providers.openai_decisions`, `idia.providers.chat`, `idia.providers.cloudflare`, `idia.providers.scripted` and `idia.providers.recorded`; a public name is removed or changed only after a minor release of `DeprecationWarning`.
|
|
72
|
+
|
|
73
|
+
### Notes
|
|
74
|
+
|
|
75
|
+
- The binding to ommat ships with ommat, as `ommat[idia]`; idia has no dependency on ommat.
|
|
76
|
+
|
|
77
|
+
[Unreleased]: https://github.com/CRSiegfried/idia/compare/v0.3.0...HEAD
|
|
78
|
+
[0.3.0]: https://github.com/CRSiegfried/idia/releases/tag/v0.3.0
|
|
79
|
+
[0.2.0]: https://github.com/CRSiegfried/idia/releases/tag/v0.2.0
|
|
80
|
+
[0.1.0]: https://github.com/CRSiegfried/idia/releases/tag/v0.1.0
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in idia. The design and the spec are still young, so contributions start with an issue.
|
|
4
|
+
|
|
5
|
+
## Issues first
|
|
6
|
+
|
|
7
|
+
- **Bugs:** open an issue with a minimal reproduction, the idia and Python versions, the provider, and what you expected.
|
|
8
|
+
- **Changes and features:** open a proposal issue before writing code. Say what problem it solves and which provider it bears on.
|
|
9
|
+
- **Pull requests** are welcome once an issue is agreed. Link it in the PR.
|
|
10
|
+
|
|
11
|
+
## Development
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
uv sync --all-extras
|
|
15
|
+
uv run ruff check
|
|
16
|
+
uv run ruff format --check
|
|
17
|
+
uv run pyright
|
|
18
|
+
uv run python scripts/check_spec.py
|
|
19
|
+
uv run python scripts/check_terms.py
|
|
20
|
+
uv run pytest --cov
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
All six must pass, the coverage floor included: the spec check for the links, headings and index of `docs/spec`, and the terms check that `src/`, `docs/`, `tests/`, `scripts/`, `skills/`, `.github/`, the top-level Markdown and `pyproject.toml` read in plain library terms, its patterns tested against planted terms on every run. The same patterns check that commit subjects describe library changes: `uv run python scripts/check_terms.py --subjects <base>..HEAD` reads a branch's subjects. Plain `uv sync` leaves the extras out, and the provider tests then skip; `--all-extras` installs torch with the `gliner` extra, and `--no-extra gliner` leaves it out. idia has no hosted CI, so the checks run by hand before a change merges, as [the checks for a provider](docs/how-to/add-a-provider-to-idia.md#the-checks) list them: once after `uv sync --all-extras --no-extra gliner` and once with every extra, since the tests that import the `gliner` module, a model run in process on torch, run only with it; then the built wheel installed alone in a fresh venv, where `scripts/check_bare_install.py` checks that idia imports with no extra and that each provider names its extra in the `pip install` hint. idia is pure Python and should work wherever Python 3.11 to 3.14 runs; its checks run on macOS and Linux, and Windows is not yet tested, so a change that bears on a platform is checked on macOS and Linux, and on Windows when one is to hand. Tests never make a live call: a leaf's wire tests replay recorded cassettes, and the core's tests answer from the scripted leaf. A test that must reach a wire API carries the `live` marker, as a module-level `pytestmark` in its own `*_live.py` module, and runs only with `IDIA_LIVE=1`, once per model, recording the cassette it leaves behind with secrets filtered out. Select the live tests with `-m live`, the marker, not `-k live`, which matches names and so picks up other tests too: `IDIA_LIVE=1 uv run pytest -m live -s`. A test that loads a model in this process carries the `local_model` marker instead and runs only with `IDIA_LOCAL_MODEL=1`, which also sets `HF_HUB_OFFLINE=1`, so it reads only cached weights and never downloads: `IDIA_LOCAL_MODEL=1 uv run pytest -m local_model -s`. Such a run compares the stored outputs with the model and writes them back only with `IDIA_RECORD=1` set by hand as well.
|
|
24
|
+
|
|
25
|
+
A script run outside pytest that imports `tests`, such as a one-off live recording, needs the repository root on the path: `PYTHONPATH=. uv run python …`.
|
|
26
|
+
|
|
27
|
+
## Ground rules for changes
|
|
28
|
+
|
|
29
|
+
- **The core has no provider and no engine dependency.** Each leaf with a dependency, a wire SDK or a local runtime such as torch, is an optional extra behind an import guard; the scripted and recorded leaves ship in the core with none. `core.py` imports nothing from `providers/`.
|
|
30
|
+
- **A leaf never retries.** It sends one wire request in one call, sets any SDK's retries to zero, raises `ProviderError` and nothing else, and leaves every retry, wait and attempt count to the core's dispatcher.
|
|
31
|
+
- **Probabilities are what the wire returned.** Nothing renormalizes, rounds or corrects one; a distribution that breaks a rule becomes a typed fault for that question, and its siblings stand.
|
|
32
|
+
- **The spec is normative.** A change that alters behavior the spec describes changes the spec in the same PR, with tests.
|
|
33
|
+
- **`docs/spec` is written one sentence per line**, so a diff shows only the sentences changed.
|
|
34
|
+
- **Every provider passes the conformance suite** before it is used, a leaf half for the leaf and a provider half once wrapped.
|
|
35
|
+
- **The public API is what `idia.__all__` lists, and what the `__all__` of each of these modules lists:** `idia.cloudflare`, `idia.conformance`, `idia.providers.http`, `idia.providers.system_one`, `idia.providers.openai_decisions`, `idia.providers.chat`, `idia.providers.cloudflare`, `idia.providers.scripted` and `idia.providers.recorded`. The leaves live in their own modules rather than in `idia`, since each needs its extra and `import idia` needs none. Every other name is internal: modules and names starting with an underscore, a name a listed module leaves out of its `__all__`, and `idia.providers` itself. Removing or changing a public name needs a deprecation first: one minor release with a `DeprecationWarning`. A new `Capabilities` field is required, so adding one breaks a record written by hand; list each such field under **Changed**.
|
|
36
|
+
- **Record user-visible changes** in [CHANGELOG.md](CHANGELOG.md), under the release being prepared: the top section until it is tagged, then a new `Unreleased` section above it. A new kind, elicitation or validation rule is a minor release.
|
|
37
|
+
|
|
38
|
+
## Releasing
|
|
39
|
+
|
|
40
|
+
A release is cut from `main` once the checks above pass on it:
|
|
41
|
+
|
|
42
|
+
1. Set `version` in `pyproject.toml`, date the top section of [CHANGELOG.md](CHANGELOG.md) and point its link at the new tag, and move the `v<version>` links in the README, the tutorials and [skills/idia/SKILL.md](skills/idia/SKILL.md) to the new tag; `tests/test_docs.py` fails until they match the version.
|
|
43
|
+
2. Tag the commit `v<version>`, annotated, and push `main` and the tag.
|
|
44
|
+
3. Run the `publish` workflow by hand with the tag and `testpypi` for a dry run, then publish a GitHub release for the tag, or run it by hand with `pypi` for a tag made before the workflow: the workflow checks that the tag names the version, builds the sdist and wheel, checks them and installs the wheel alone, then uploads to PyPI by Trusted Publishing once the `pypi` environment approves it.
|
idia-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Christopher Siegfried
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
idia-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: idia
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Ask judgement models many closed questions about one input, packed into calls within each provider's limits, and get their probabilities back, with retries, limits and provenance handled once.
|
|
5
|
+
Project-URL: Homepage, https://github.com/CRSiegfried/idia
|
|
6
|
+
Project-URL: Documentation, https://github.com/CRSiegfried/idia/tree/main/docs/spec
|
|
7
|
+
Project-URL: Repository, https://github.com/CRSiegfried/idia
|
|
8
|
+
Project-URL: Issues, https://github.com/CRSiegfried/idia/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/CRSiegfried/idia/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: Christopher Siegfried <160437306+CRSiegfried@users.noreply.github.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: calibrated probabilities,classification,judgement model,llm,provider
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Framework :: AsyncIO
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Operating System :: MacOS
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.11
|
|
28
|
+
Provides-Extra: cloudflare
|
|
29
|
+
Requires-Dist: httpx2>=2.16; extra == 'cloudflare'
|
|
30
|
+
Provides-Extra: gliner
|
|
31
|
+
Requires-Dist: gliner2[local]>=2.0.0; extra == 'gliner'
|
|
32
|
+
Requires-Dist: protobuf>=4; extra == 'gliner'
|
|
33
|
+
Requires-Dist: sentencepiece>=0.2; extra == 'gliner'
|
|
34
|
+
Requires-Dist: torch>=2.1; extra == 'gliner'
|
|
35
|
+
Provides-Extra: openai
|
|
36
|
+
Requires-Dist: httpx2>=2.16; extra == 'openai'
|
|
37
|
+
Requires-Dist: openai>=3.35.1; extra == 'openai'
|
|
38
|
+
Provides-Extra: system-one
|
|
39
|
+
Requires-Dist: httpx2>=2.16; extra == 'system-one'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# idia
|
|
43
|
+
|
|
44
|
+
idia is a Python library for putting closed questions (yes or no, one label of a set, a level on a scale, a value found in the input) to judgement models, which return probabilities and typed values instead of prose. You write one request: an input and the questions about it. idia checks it against the provider's limits before any call, packs the questions into calls as full as those limits allow, retries inside one deadline, and returns the answers together in one response, each as the provider gave it, with a record of which model took each call.
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
*Eight questions about one support message, each drawn as a small idia, go to a provider that takes three questions per call. idia packs them into three calls that each carry the message, and sends the calls in turn. The second call gets a 429 and is retried. One answer breaks a rule and comes back as a fault, and the other seven stand. Everything returns in one response. The provider is a stand-in with canned answers; the groups, the retry and the fault are drawn from a run of idia by [draw.py](docs/assets/demo/draw.py), and [triage.py](docs/assets/demo/triage.py) prints the same run in a terminal.*
|
|
49
|
+
|
|
50
|
+
## TL;DR
|
|
51
|
+
|
|
52
|
+
- A request is one input and any number of closed questions about it. Each question has a key and one of five kinds: `noul` (yes or no), `choice`, `score`, `extraction` or `box`.
|
|
53
|
+
- Every provider declares its limits in a `Capabilities` record. idia checks the request against it first and raises `DoesNotFit` before any call for a request it can't split to fit. It doesn't truncate.
|
|
54
|
+
- When the questions overflow a limit, idia packs them in order into several calls that each repeat the input, and merges the answers. One deadline covers every call, retry and rate-limit wait of the request.
|
|
55
|
+
- Probabilities come back as the provider returned them. An answer that breaks a rule, such as probabilities that don't sum to 1, becomes a `Fault` for that one question.
|
|
56
|
+
- The response holds one outcome per call: the provider, the model it reported, the attempts, the prompt sent and the usage.
|
|
57
|
+
- The core has no dependencies, and each provider is an optional extra. Python 3.11 to 3.14, MIT.
|
|
58
|
+
|
|
59
|
+
## Install
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
pip install "idia @ git+https://github.com/CRSiegfried/idia@v0.3.0"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
That is the core, which is enough for the example below. idia installs from its git tag until it is on a package index. To call a provider, name its extra, as in `idia[cloudflare]`. The [providers](#providers) table lists them.
|
|
66
|
+
|
|
67
|
+
## Try it without keys
|
|
68
|
+
|
|
69
|
+
This runs as it is, with no API key. A scripted leaf answers in place of a model.
|
|
70
|
+
|
|
71
|
+
Every provider declares what it takes in a `Capabilities` record. A provider that ships with idia brings its own. The scripted leaf has no API behind it, so the example declares one, with a limit of two questions per call:
|
|
72
|
+
|
|
73
|
+
<!-- demo -->
|
|
74
|
+
<details>
|
|
75
|
+
<summary>The stand-in's capabilities record, with every field stated</summary>
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from idia import UNBOUNDED, Capabilities, Rounding
|
|
79
|
+
|
|
80
|
+
RECORD = Capabilities(
|
|
81
|
+
kinds=frozenset({"noul", "choice", "score"}),
|
|
82
|
+
modalities=frozenset({"text"}),
|
|
83
|
+
max_questions=2, # two questions per call
|
|
84
|
+
max_input_tokens=8192,
|
|
85
|
+
max_labels=20,
|
|
86
|
+
max_levels=10,
|
|
87
|
+
calibrated=True,
|
|
88
|
+
rounding=Rounding(probability_decimals=2, score_decimals=None),
|
|
89
|
+
image_carriers=frozenset(),
|
|
90
|
+
max_question_tokens=UNBOUNDED,
|
|
91
|
+
max_body_bytes=UNBOUNDED,
|
|
92
|
+
max_images=0,
|
|
93
|
+
max_images_per_question=0,
|
|
94
|
+
max_image_bytes=UNBOUNDED,
|
|
95
|
+
max_total_image_bytes=UNBOUNDED,
|
|
96
|
+
max_total_options=UNBOUNDED,
|
|
97
|
+
min_levels=None,
|
|
98
|
+
min_image_side=None,
|
|
99
|
+
image_media_types=None,
|
|
100
|
+
key_patterns=(),
|
|
101
|
+
recounts_state_per_question=False,
|
|
102
|
+
returns_refusal=False,
|
|
103
|
+
snapshot_pinnable=True,
|
|
104
|
+
carries_noul_descriptions=True,
|
|
105
|
+
carries_structured_instructions=True,
|
|
106
|
+
truncates_silently=False,
|
|
107
|
+
confidence={},
|
|
108
|
+
opt_in_features=frozenset(),
|
|
109
|
+
enabled_features=frozenset(),
|
|
110
|
+
feature_kinds={},
|
|
111
|
+
feature_modalities={},
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
</details>
|
|
116
|
+
|
|
117
|
+
Three questions about one message go in one request:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import asyncio
|
|
121
|
+
|
|
122
|
+
from idia import Deadline, Dispatcher, Label, LabelAnswer, NoulAnswer, Question, Request
|
|
123
|
+
from idia import State, TextPart
|
|
124
|
+
from idia.providers.scripted import Scripted
|
|
125
|
+
|
|
126
|
+
TOPICS = ("billing", "shipping", "other")
|
|
127
|
+
LEVELS = ("low", "medium", "high")
|
|
128
|
+
|
|
129
|
+
request = Request(
|
|
130
|
+
state=State(parts=(TextPart(text="The invoice is overdue and I want a refund."),)),
|
|
131
|
+
questions=(
|
|
132
|
+
Question(key="complaint", kind="noul", instruction="Is this a complaint?"),
|
|
133
|
+
Question(
|
|
134
|
+
key="topic",
|
|
135
|
+
kind="choice",
|
|
136
|
+
instruction="What is it about?",
|
|
137
|
+
labels=tuple(Label(name=name) for name in TOPICS),
|
|
138
|
+
),
|
|
139
|
+
Question(
|
|
140
|
+
key="urgency",
|
|
141
|
+
kind="score",
|
|
142
|
+
instruction="How urgent is it?",
|
|
143
|
+
labels=tuple(Label(name=name) for name in LEVELS),
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
deadline=Deadline.after(30), # seconds from now, for the whole request
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
# What the stand-in model answers, one item per call.
|
|
150
|
+
leaf = Scripted(
|
|
151
|
+
capabilities=RECORD,
|
|
152
|
+
script=[
|
|
153
|
+
{
|
|
154
|
+
"complaint": NoulAnswer(probability=0.93),
|
|
155
|
+
"topic": LabelAnswer(
|
|
156
|
+
probabilities=(("billing", 0.81), ("shipping", 0.07), ("other", 0.12))
|
|
157
|
+
),
|
|
158
|
+
},
|
|
159
|
+
{"urgency": LabelAnswer(probabilities=(("low", 0.1), ("medium", 0.3), ("high", 0.6)))},
|
|
160
|
+
],
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
async def main() -> None:
|
|
165
|
+
async with Dispatcher(leaf) as provider:
|
|
166
|
+
response = await provider.answer(request)
|
|
167
|
+
print("complaint", response.answers["complaint"].probability)
|
|
168
|
+
print("topic", dict(response.answers["topic"].probabilities))
|
|
169
|
+
print("urgency", dict(response.answers["urgency"].probabilities))
|
|
170
|
+
for outcome in response.outcomes:
|
|
171
|
+
print(outcome.provider, outcome.model_reported, outcome.keys, outcome.attempts)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
asyncio.run(main())
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
It prints:
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
complaint 0.93
|
|
181
|
+
topic {'billing': 0.81, 'shipping': 0.07, 'other': 0.12}
|
|
182
|
+
urgency {'low': 0.1, 'medium': 0.3, 'high': 0.6}
|
|
183
|
+
scripted scripted-1 ('complaint', 'topic') 1
|
|
184
|
+
scripted scripted-1 ('urgency',) 1
|
|
185
|
+
```
|
|
186
|
+
<!-- /demo -->
|
|
187
|
+
|
|
188
|
+
The request held three questions and the record allows two per call, so idia made two calls. Each call carried the message, and the answers came back in one response under the keys the questions had.
|
|
189
|
+
|
|
190
|
+
The last two lines are the outcomes, one per call: the leaf that took it, the model it reported, the questions it held and the attempts it took.
|
|
191
|
+
|
|
192
|
+
To ask a real model, install a provider's extra, export its credentials, and use `idia.provider("cloudflare-clef")` in place of `Dispatcher(leaf)`. The request and the shape of the response stay the same. Clef takes 64 questions per call, so there these three go in one.
|
|
193
|
+
|
|
194
|
+
## Why it exists
|
|
195
|
+
|
|
196
|
+
Judgement models answer a closed question with probabilities, quickly and cheaply enough that my assistant's workflows now ask more than a hundred of them. A workflow asks many of those questions about the same input, and asked one per call, each question sends the whole input again.
|
|
197
|
+
|
|
198
|
+
The providers also differ in their APIs, in their limits on what one call may hold and in their errors. Pydantic AI, the Vercel AI SDK and LiteLLM now reach judgement models too, for the label kinds. As of November 2026, none of them packs questions into calls by the provider's limits, holds every retry and wait to one deadline, keeps the good answers when one comes back broken, or handles extraction beside the label kinds. Hence, idia.
|
|
199
|
+
|
|
200
|
+
It does the checking, packing and retrying in one place and leaves the answers alone. It doesn't renormalize, round or correct a probability, and it says on each outcome whether the provider claims its probabilities are calibrated. It depends on no decision engine. [ommat](https://github.com/CRSiegfried/ommat) is the engine I use it with.
|
|
201
|
+
|
|
202
|
+
## The vocabulary
|
|
203
|
+
|
|
204
|
+
- **State**: the input the questions are about, as text, JSON or image parts.
|
|
205
|
+
- **Question**: a key, a kind and an instruction. A `noul` is yes or no, a `choice` picks one label, a `score` picks a level on an ordered scale, an `extraction` reads a typed value or a list of values out of the input, and a `box` finds a region of an image.
|
|
206
|
+
- **Request**: one state, its questions and a deadline.
|
|
207
|
+
- **Leaf**: the code that sends one call to one provider. It doesn't retry.
|
|
208
|
+
- **Provider**: what you call `answer` on. `idia.provider(name)` builds one, and a `Dispatcher` makes one from any leaf.
|
|
209
|
+
- **Capabilities**: the record of a provider's kinds and limits that every request is checked against.
|
|
210
|
+
- **Outcome**: what happened to one call, including which questions it held, who answered, the attempts and any error.
|
|
211
|
+
|
|
212
|
+
## How a request runs
|
|
213
|
+
|
|
214
|
+
1. You build a `Request` and await `provider.answer(request)`.
|
|
215
|
+
2. idia checks the request against the provider's `Capabilities`. A kind the provider lacks, too many labels on one question or an input too long for one call raises `DoesNotFit`, and no call is made.
|
|
216
|
+
3. A request that fits whole is one call. Otherwise the questions are packed in order into calls as full as the limits allow, and each call repeats the state.
|
|
217
|
+
4. The calls run one after another. A retryable error is retried with backoff, up to three attempts by default, and every wait counts against the request's deadline.
|
|
218
|
+
5. Each answer is checked against the rules for its kind. One that fails is a `Fault` under its key, and the other answers in the call are unaffected.
|
|
219
|
+
6. You get a `Response` with the answers under your keys and one outcome per call. If no call answered, `answer` raises `RequestFailed`, which carries the same response.
|
|
220
|
+
|
|
221
|
+
## Providers
|
|
222
|
+
|
|
223
|
+
`idia.provider(name)` builds a provider by name, and `idia.provider_names()` lists the names.
|
|
224
|
+
|
|
225
|
+
| Name | Extra | Kinds | Claims calibrated |
|
|
226
|
+
|---|---|---|---|
|
|
227
|
+
| `system-one` | `system-one` | `noul`, `choice`, `score`; with `images=True`, `box` too on `jev-1.14.0` and `jev-preview` | yes |
|
|
228
|
+
| `openai-decisions` | `openai` | `noul`, `choice`, `score` | no |
|
|
229
|
+
| `openai-chat` | `openai` | `noul`, `choice`, `score` | no |
|
|
230
|
+
| `cloudflare-clef` | `cloudflare` | `noul`, `choice`, `score` | no |
|
|
231
|
+
| `cloudflare-clairic` | `cloudflare` | `extraction` | no |
|
|
232
|
+
| `gliner` | `gliner` | `extraction` of text | no |
|
|
233
|
+
|
|
234
|
+
Install the extra for the provider you call:
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
pip install "idia[cloudflare] @ git+https://github.com/CRSiegfried/idia@v0.3.0"
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Each provider reads its credentials from the environment unless you pass them. System One, TypeSafe's judgement-model API, reads `TYPESAFE_API_KEY`. OpenAI reads `OPENAI_API_KEY`. Cloudflare reads `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN`. idia reads no `.env` file.
|
|
241
|
+
|
|
242
|
+
`openai-chat` reads label probabilities from a chat model's logprobs. It needs `model=` and takes one question per call, so it gains nothing from packing. `gliner` runs GLiNER2 in your process on torch and must load its weights before its first call. The [providers spec](docs/spec/providers.md) has each provider's options, limits and models.
|
|
243
|
+
|
|
244
|
+
## Is it for you?
|
|
245
|
+
|
|
246
|
+
It fits when:
|
|
247
|
+
|
|
248
|
+
- you ask several closed questions about the same input and want the probabilities, so your code can set its own thresholds;
|
|
249
|
+
- you call more than one judgement-model provider, or expect to change provider, and want to keep one request shape;
|
|
250
|
+
- you need to show afterwards which model answered a question, what was sent and how many attempts it took.
|
|
251
|
+
|
|
252
|
+
It doesn't fit when:
|
|
253
|
+
|
|
254
|
+
- you ask only yes-or-no, choice or score questions of one provider, or you already run Pydantic AI, the Vercel AI SDK or a LiteLLM proxy. Their judgement-model support covers that, with agents, tracing or a gateway that idia lacks;
|
|
255
|
+
- you want generated text, tool calls or an agent loop. idia asks closed questions and does nothing else;
|
|
256
|
+
- later questions depend on earlier answers. idia asks the questions it is given, and an engine such as [ommat](https://github.com/CRSiegfried/ommat) decides which to ask;
|
|
257
|
+
- you need answer caching, evaluation or calibration. idia has none of them, and it passes on a provider's calibration claim without testing it.
|
|
258
|
+
|
|
259
|
+
## Also included
|
|
260
|
+
|
|
261
|
+
### A router and a fallback
|
|
262
|
+
|
|
263
|
+
`Router` sends each question to a provider by its kind, and `Fallback` tries providers in turn when one fails. `idia.cloudflare.cloudflare()` is a router over Clef and Clairic, so one request can hold label questions and extractions. The [dispatch spec](docs/spec/dispatch.md#router-and-fallback) describes both.
|
|
264
|
+
|
|
265
|
+
### Rate and concurrency limits
|
|
266
|
+
|
|
267
|
+
A `Dispatcher` takes a `RateLimiter` and a `ConcurrencyLimit`, and two dispatchers whose providers share a vendor's rate limit can share one `RateLimiter`. Time spent waiting on either counts against the request's deadline. See [the retry policy and the limits](docs/spec/dispatch.md#the-retry-policy-and-the-limits).
|
|
268
|
+
|
|
269
|
+
### Leaves for tests
|
|
270
|
+
|
|
271
|
+
`Scripted` answers from a script, as in the example above. `Recorded` wraps a real leaf, saves its calls to a JSON file and replays them later without calling it. Both ship in the core and are described in the [test-doubles spec](docs/spec/test-doubles.md). A recorded log holds your inputs as written, so store it as carefully as you store them.
|
|
272
|
+
|
|
273
|
+
### A leaf of your own
|
|
274
|
+
|
|
275
|
+
A leaf is a class with four attributes and one `call` method, and it can sit over an HTTP API or a model in your own process. `idia.conformance` is a test suite that holds a leaf to the same rules as the ones idia ships. [Write a leaf](docs/how-to/write-a-leaf.md) builds one from start to finish.
|
|
276
|
+
|
|
277
|
+
### Deciding with ommat
|
|
278
|
+
|
|
279
|
+
[ommat](https://github.com/CRSiegfried/ommat) is a decision engine for workflows that put many small, closed questions to a model. Its `ommat[idia]` extra binds an idia provider as the source of its answers. See ommat's tutorial, [Decide with real models through idia](https://github.com/CRSiegfried/ommat/blob/main/docs/tutorials/decide-with-idia.md).
|
|
280
|
+
|
|
281
|
+
### A skill for coding agents
|
|
282
|
+
|
|
283
|
+
[skills/idia](skills/idia/SKILL.md) tells a coding agent when to use idia, the core pattern and the pitfalls. From a clone at v0.3.0, for Claude Code:
|
|
284
|
+
|
|
285
|
+
```sh
|
|
286
|
+
cp -r skills/idia ~/.claude/skills/
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Docs
|
|
290
|
+
|
|
291
|
+
- [Ask a provider](docs/tutorials/ask-a-provider.md): the tutorial, with live calls to Clef and Clairic.
|
|
292
|
+
- [Write a leaf](docs/how-to/write-a-leaf.md): a provider of your own, tested with the conformance suite.
|
|
293
|
+
- [Add a provider to idia](docs/how-to/add-a-provider-to-idia.md): what a leaf needs to ship in idia itself.
|
|
294
|
+
- [Vocabulary](docs/spec/vocabulary.md): every shape, from `State` to `Response`, and the validation rules.
|
|
295
|
+
- [Providers](docs/spec/providers.md): each provider's request, limits and models.
|
|
296
|
+
- [Fit](docs/spec/fit.md): the checks before a call, packing and state overflow.
|
|
297
|
+
- [Dispatch](docs/spec/dispatch.md): the deadline, retries, limits, outcomes, the router and the fallback.
|
|
298
|
+
- [The spec](docs/spec/README.md): the index of the normative description.
|
|
299
|
+
- [CHANGELOG.md](CHANGELOG.md): each release.
|
|
300
|
+
|
|
301
|
+
## Status
|
|
302
|
+
|
|
303
|
+
idia is pre-release, an alpha at 0.3.0, with one maintainer. Before 1.0 a minor release may break the API, and the changelog lists each break. A public name, one in `idia.__all__` or in the `__all__` of a module [CONTRIBUTING.md](CONTRIBUTING.md#ground-rules-for-changes) lists, is removed or changed only after one minor release in which it raises a `DeprecationWarning`. A new `Capabilities` field is required, so a release that adds one breaks a record written by hand.
|
|
304
|
+
|
|
305
|
+
It is pure Python. Its tests run on macOS and Linux, and Windows is untested. The tests replay recorded exchanges with each provider and make no live call, so a provider that has changed its API since a recording was made can fail in ways the tests don't show.
|
|
306
|
+
|
|
307
|
+
The calls of one request run in sequence. To ask about many inputs at once, await several `answer` calls on one provider, which shares its rate and concurrency limits between them.
|
|
308
|
+
|
|
309
|
+
## Contributing
|
|
310
|
+
|
|
311
|
+
Issues first: see [CONTRIBUTING.md](CONTRIBUTING.md), which also has the development setup and the checks. Report vulnerabilities privately, as [SECURITY.md](SECURITY.md) describes.
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
MIT. See [LICENSE](LICENSE).
|
|
316
|
+
|
|
317
|
+
## The name
|
|
318
|
+
|
|
319
|
+
Idia and Ommat come from *ommatidia*, the thousands of small hexagonal eyes that make up a compound eye and combine into one picture. *Ommat-* is the Greek stem for "eye", *-idia* "little ones". Many small, cheap questions add up to one full picture. Idia puts them to the models; Ommat is the engine that asks them.
|
|
320
|
+
|
|
321
|
+
```text
|
|
322
|
+
______ ______ ______
|
|
323
|
+
/ \ / \ / \
|
|
324
|
+
/ (o) \ / (o) \ / (o) \
|
|
325
|
+
\ / \ / \ /
|
|
326
|
+
\______/ \______/ \______/
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
______ ______
|
|
330
|
+
/ \ / \
|
|
331
|
+
/ (o) \ / (o) \
|
|
332
|
+
\ / \ /
|
|
333
|
+
\______/ \______/
|
|
334
|
+
```
|