cci-sdk 0.1.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.
- cci_sdk-0.1.0/LICENSE +202 -0
- cci_sdk-0.1.0/PKG-INFO +430 -0
- cci_sdk-0.1.0/README.md +381 -0
- cci_sdk-0.1.0/examples/README.md +143 -0
- cci_sdk-0.1.0/examples/_mock.py +723 -0
- cci_sdk-0.1.0/examples/agents/.env.example +38 -0
- cci_sdk-0.1.0/examples/agents/README.md +369 -0
- cci_sdk-0.1.0/examples/agents/_shared/__init__.py +4 -0
- cci_sdk-0.1.0/examples/agents/_shared/adk_models.py +241 -0
- cci_sdk-0.1.0/examples/agents/_shared/calibration.py +81 -0
- cci_sdk-0.1.0/examples/agents/_shared/display.py +63 -0
- cci_sdk-0.1.0/examples/agents/_shared/langchain_models.py +52 -0
- cci_sdk-0.1.0/examples/agents/_shared/maf_models.py +196 -0
- cci_sdk-0.1.0/examples/agents/_shared/providers.py +170 -0
- cci_sdk-0.1.0/examples/agents/_shared/review.py +49 -0
- cci_sdk-0.1.0/examples/agents/agent_framework/credit_underwriting_agent.py +425 -0
- cci_sdk-0.1.0/examples/agents/agent_framework/pharmacovigilance_agent.py +396 -0
- cci_sdk-0.1.0/examples/agents/data/README.md +245 -0
- cci_sdk-0.1.0/examples/agents/data/adverse_events.jsonl +300 -0
- cci_sdk-0.1.0/examples/agents/data/aml_alerts.jsonl +360 -0
- cci_sdk-0.1.0/examples/agents/data/credit_applications.jsonl +320 -0
- cci_sdk-0.1.0/examples/agents/data/discharge_claims.jsonl +240 -0
- cci_sdk-0.1.0/examples/agents/data/generate_adverse_events.py +239 -0
- cci_sdk-0.1.0/examples/agents/data/generate_aml_alerts.py +367 -0
- cci_sdk-0.1.0/examples/agents/data/generate_credit_applications.py +212 -0
- cci_sdk-0.1.0/examples/agents/data/generate_discharge_claims.py +335 -0
- cci_sdk-0.1.0/examples/agents/data/generate_insurance_claims.py +317 -0
- cci_sdk-0.1.0/examples/agents/data/generate_refund_requests.py +377 -0
- cci_sdk-0.1.0/examples/agents/data/generate_triage_messages.py +295 -0
- cci_sdk-0.1.0/examples/agents/data/generate_trial_screening.py +293 -0
- cci_sdk-0.1.0/examples/agents/data/insurance_claims.jsonl +320 -0
- cci_sdk-0.1.0/examples/agents/data/refund_requests.jsonl +320 -0
- cci_sdk-0.1.0/examples/agents/data/triage_messages.jsonl +320 -0
- cci_sdk-0.1.0/examples/agents/data/trial_screening.jsonl +320 -0
- cci_sdk-0.1.0/examples/agents/google_adk/aml_account_hold_agent.py +448 -0
- cci_sdk-0.1.0/examples/agents/google_adk/clinical_trial_screening_agent.py +426 -0
- cci_sdk-0.1.0/examples/agents/langchain/finance_refund_agent.py +600 -0
- cci_sdk-0.1.0/examples/agents/langchain/healthcare_patient_triage.py +625 -0
- cci_sdk-0.1.0/examples/agents/langgraph/clinical_summary_graph.py +480 -0
- cci_sdk-0.1.0/examples/agents/langgraph/insurance_claims_graph.py +559 -0
- cci_sdk-0.1.0/examples/custom_backend_evidence.py +139 -0
- cci_sdk-0.1.0/examples/llm_judge_cascade.py +143 -0
- cci_sdk-0.1.0/examples/model_cascade_routing.py +97 -0
- cci_sdk-0.1.0/examples/offline_calibration_no_network.py +317 -0
- cci_sdk-0.1.0/examples/rag_claim_filtering.py +125 -0
- cci_sdk-0.1.0/examples/support_routing_gate.py +260 -0
- cci_sdk-0.1.0/pyproject.toml +68 -0
- cci_sdk-0.1.0/src/cli_sdk/__init__.py +127 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/__init__.py +29 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/base.py +28 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/belief_answer.py +45 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/claim_answer.py +53 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/gate_answer.py +33 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/guarantee.py +163 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/interval_answer.py +34 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/judge_answer.py +30 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/response.py +130 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/route_answer.py +29 -0
- cci_sdk-0.1.0/src/cli_sdk/answers/set_answer.py +45 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/__init__.py +37 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/anthropic.py +22 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/azure_openai.py +22 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/base.py +192 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/bedrock.py +20 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/custom.py +5 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/gemini.py +18 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/openai.py +22 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/openrouter.py +23 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/sglang.py +29 -0
- cci_sdk-0.1.0/src/cli_sdk/backends/vllm.py +31 -0
- cci_sdk-0.1.0/src/cli_sdk/calibration/__init__.py +28 -0
- cci_sdk-0.1.0/src/cli_sdk/calibration/audit.py +94 -0
- cci_sdk-0.1.0/src/cli_sdk/calibration/examples.py +55 -0
- cci_sdk-0.1.0/src/cli_sdk/calibration/label_efficient.py +78 -0
- cci_sdk-0.1.0/src/cli_sdk/calibration/profile.py +236 -0
- cci_sdk-0.1.0/src/cli_sdk/cli_tool.py +151 -0
- cci_sdk-0.1.0/src/cli_sdk/client/__init__.py +7 -0
- cci_sdk-0.1.0/src/cli_sdk/client/async_client.py +113 -0
- cci_sdk-0.1.0/src/cli_sdk/client/base.py +207 -0
- cci_sdk-0.1.0/src/cli_sdk/client/retries.py +72 -0
- cci_sdk-0.1.0/src/cli_sdk/client/sync_client.py +140 -0
- cci_sdk-0.1.0/src/cli_sdk/constants.py +31 -0
- cci_sdk-0.1.0/src/cli_sdk/evidence/__init__.py +45 -0
- cci_sdk-0.1.0/src/cli_sdk/evidence/_prompts.py +165 -0
- cci_sdk-0.1.0/src/cli_sdk/evidence/anthropic.py +140 -0
- cci_sdk-0.1.0/src/cli_sdk/evidence/base.py +121 -0
- cci_sdk-0.1.0/src/cli_sdk/evidence/langchain.py +114 -0
- cci_sdk-0.1.0/src/cli_sdk/evidence/mock.py +133 -0
- cci_sdk-0.1.0/src/cli_sdk/evidence/openai_compatible.py +278 -0
- cci_sdk-0.1.0/src/cli_sdk/exceptions.py +60 -0
- cci_sdk-0.1.0/src/cli_sdk/integrations/__init__.py +33 -0
- cci_sdk-0.1.0/src/cli_sdk/integrations/_guard.py +356 -0
- cci_sdk-0.1.0/src/cli_sdk/integrations/agent_framework.py +140 -0
- cci_sdk-0.1.0/src/cli_sdk/integrations/google_adk.py +148 -0
- cci_sdk-0.1.0/src/cli_sdk/integrations/langchain.py +251 -0
- cci_sdk-0.1.0/src/cli_sdk/integrations/langgraph.py +216 -0
- cci_sdk-0.1.0/src/cli_sdk/local/__init__.py +14 -0
- cci_sdk-0.1.0/src/cli_sdk/local/client.py +532 -0
- cci_sdk-0.1.0/src/cli_sdk/local/engine.py +645 -0
- cci_sdk-0.1.0/src/cli_sdk/local/scoring.py +170 -0
- cci_sdk-0.1.0/src/cli_sdk/local/store.py +151 -0
- cci_sdk-0.1.0/src/cli_sdk/monitoring/__init__.py +6 -0
- cci_sdk-0.1.0/src/cli_sdk/monitoring/alerts.py +47 -0
- cci_sdk-0.1.0/src/cli_sdk/monitoring/monitor.py +180 -0
- cci_sdk-0.1.0/src/cli_sdk/py.typed +0 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/__init__.py +15 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/base.py +59 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/belief.py +25 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/claim.py +27 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/gate.py +38 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/interval.py +33 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/judge.py +27 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/route.py +35 -0
- cci_sdk-0.1.0/src/cli_sdk/queries/set.py +35 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/__init__.py +25 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/__init__.py +28 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/_quantile.py +144 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/aps.py +98 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/cqr.py +42 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/crc.py +71 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/lac.py +37 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/ltt.py +77 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/mondrian.py +72 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/raps.py +85 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/conformal/rcps.py +103 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/evalues/__init__.py +20 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/evalues/anytime.py +124 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/evalues/ebh.py +53 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/evalues/eprocess.py +55 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/evalues/ppi.py +91 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/venn_abers/__init__.py +11 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/venn_abers/_isotonic.py +39 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/venn_abers/cvap.py +62 -0
- cci_sdk-0.1.0/src/cli_sdk/stats/venn_abers/ivap.py +104 -0
- cci_sdk-0.1.0/tests/conftest.py +80 -0
- cci_sdk-0.1.0/tests/support.py +121 -0
- cci_sdk-0.1.0/tests/test_agents_agent_framework.py +292 -0
- cci_sdk-0.1.0/tests/test_agents_google_adk.py +294 -0
- cci_sdk-0.1.0/tests/test_agents_langchain.py +348 -0
- cci_sdk-0.1.0/tests/test_agents_langchain_resume.py +121 -0
- cci_sdk-0.1.0/tests/test_agents_langgraph.py +354 -0
- cci_sdk-0.1.0/tests/test_answers.py +485 -0
- cci_sdk-0.1.0/tests/test_calibration_monitoring.py +764 -0
- cci_sdk-0.1.0/tests/test_cli_tool.py +201 -0
- cci_sdk-0.1.0/tests/test_client.py +1108 -0
- cci_sdk-0.1.0/tests/test_conformal.py +155 -0
- cci_sdk-0.1.0/tests/test_evalues.py +116 -0
- cci_sdk-0.1.0/tests/test_evidence.py +251 -0
- cci_sdk-0.1.0/tests/test_guard.py +158 -0
- cci_sdk-0.1.0/tests/test_guard_mondrian_group.py +54 -0
- cci_sdk-0.1.0/tests/test_local_mode.py +443 -0
- cci_sdk-0.1.0/tests/test_local_mode_regressions.py +158 -0
- cci_sdk-0.1.0/tests/test_local_profile_method.py +69 -0
- cci_sdk-0.1.0/tests/test_queries.py +491 -0
- cci_sdk-0.1.0/tests/test_stats_regressions.py +117 -0
- cci_sdk-0.1.0/tests/test_venn_abers.py +67 -0
cci_sdk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
cci_sdk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cci-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK and standalone statistics engine for Conformal Logit Inference (CLI) — conformal prediction, Venn-Abers calibration, and e-values for LLM decisions.
|
|
5
|
+
Project-URL: Homepage, https://cci.gitdate.ink
|
|
6
|
+
Project-URL: Documentation, https://cci-docs.gitdate.ink
|
|
7
|
+
Project-URL: Repository, https://github.com/rahvis/cci-sdk
|
|
8
|
+
Author-email: CCI <rahul.vishwakarma@workonward.org>
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: calibration,conformal-prediction,e-values,llm,uncertainty-quantification,venn-abers
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Requires-Dist: httpx>=0.27
|
|
19
|
+
Requires-Dist: numpy>=1.24
|
|
20
|
+
Provides-Extra: agent-framework
|
|
21
|
+
Requires-Dist: agent-framework-core>=1.19; extra == 'agent-framework'
|
|
22
|
+
Provides-Extra: all
|
|
23
|
+
Requires-Dist: agent-framework-core>=1.19; extra == 'all'
|
|
24
|
+
Requires-Dist: anthropic>=1.0; extra == 'all'
|
|
25
|
+
Requires-Dist: google-adk>=2.0; extra == 'all'
|
|
26
|
+
Requires-Dist: langchain-core>=1.0; extra == 'all'
|
|
27
|
+
Requires-Dist: langchain>=1.0; extra == 'all'
|
|
28
|
+
Requires-Dist: langgraph>=1.0; extra == 'all'
|
|
29
|
+
Requires-Dist: openai>=1.40; extra == 'all'
|
|
30
|
+
Provides-Extra: anthropic
|
|
31
|
+
Requires-Dist: anthropic>=1.0; extra == 'anthropic'
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
37
|
+
Provides-Extra: google-adk
|
|
38
|
+
Requires-Dist: google-adk>=2.0; extra == 'google-adk'
|
|
39
|
+
Provides-Extra: langchain
|
|
40
|
+
Requires-Dist: langchain-core>=1.0; extra == 'langchain'
|
|
41
|
+
Requires-Dist: langchain>=1.0; extra == 'langchain'
|
|
42
|
+
Requires-Dist: langgraph>=1.0; extra == 'langchain'
|
|
43
|
+
Provides-Extra: langgraph
|
|
44
|
+
Requires-Dist: langchain-core>=1.0; extra == 'langgraph'
|
|
45
|
+
Requires-Dist: langgraph>=1.0; extra == 'langgraph'
|
|
46
|
+
Provides-Extra: openai
|
|
47
|
+
Requires-Dist: openai>=1.40; extra == 'openai'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# cci-sdk — Python SDK for Conformal Logit Inference
|
|
51
|
+
|
|
52
|
+
Conformal Logit Inference (CLI) turns the raw output of any LLM into
|
|
53
|
+
finite-sample statistical guarantees. This package contains:
|
|
54
|
+
|
|
55
|
+
- **`cli_sdk`** — sync and async clients for the hosted API, the seven
|
|
56
|
+
guarantee-bearing query primitives, typed answers, calibration profiles,
|
|
57
|
+
and drift monitors.
|
|
58
|
+
- **`cli_sdk.stats`** — the standalone statistics engine (conformal
|
|
59
|
+
prediction, Venn-Abers calibration, e-values). It needs only NumPy and
|
|
60
|
+
makes no network calls, so it runs inside air-gapped environments on
|
|
61
|
+
precomputed score arrays.
|
|
62
|
+
|
|
63
|
+
- **`cli_sdk.local`** and **`cli_sdk.evidence`** — local mode: calibrate and
|
|
64
|
+
evaluate the same queries in-process on your own model (OpenAI, Azure
|
|
65
|
+
OpenAI, Anthropic, Gemini, or open weights such as Gemma on vLLM or
|
|
66
|
+
SGLang), with calibration profiles stored as reviewable JSON files.
|
|
67
|
+
- **`cli_sdk.integrations`** — calibrated guardrails for agent tool calls in
|
|
68
|
+
LangChain, LangGraph, Google ADK and Microsoft Agent Framework: allow,
|
|
69
|
+
escalate to a human, or block, each with a stated guarantee.
|
|
70
|
+
|
|
71
|
+
Every guarantee is marginal or group-conditional over data exchangeable with
|
|
72
|
+
a stated calibration set. None is a promise about one decision in isolation.
|
|
73
|
+
|
|
74
|
+
## Install
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install cci-sdk # or: uv add cli-sdk
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Optional extras for model providers and agent frameworks (Python 3.10+ for
|
|
81
|
+
the frameworks):
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install "cci-sdk[openai]" # OpenAI, Azure OpenAI, vLLM, SGLang evidence backends
|
|
85
|
+
pip install "cci-sdk[anthropic]" # Claude evidence backend
|
|
86
|
+
pip install "cci-sdk[langchain,openai]" # or [langgraph], [google-adk], [agent-framework], [all]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For development in this repository:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cd sdk/python
|
|
93
|
+
pip install -e ".[dev]"
|
|
94
|
+
pytest
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Authenticate
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
export CLI_API_KEY=sk_live_...
|
|
101
|
+
# optional, for a self-hosted deployment:
|
|
102
|
+
export CLI_BASE_URL=https://cli.internal.example.com/v1
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
A key is not required when `CLI_BASE_URL` points at `localhost`.
|
|
106
|
+
|
|
107
|
+
## Accessing the API
|
|
108
|
+
|
|
109
|
+
### Over HTTP
|
|
110
|
+
|
|
111
|
+
Every call is `POST https://cci.gitdate.ink/api/v1/evaluate` with a bearer token:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
curl https://cci.gitdate.ink/api/v1/evaluate \
|
|
115
|
+
-H "Authorization: Bearer $CLI_API_KEY" \
|
|
116
|
+
-H "Content-Type: application/json" \
|
|
117
|
+
-d '{
|
|
118
|
+
"context": {"ticket": "My payouts have been failing for 3 days."},
|
|
119
|
+
"backend": {"provider": "openai", "model": "gpt-4.1-2025-04-14"},
|
|
120
|
+
"queries": {
|
|
121
|
+
"department": {
|
|
122
|
+
"type": "set",
|
|
123
|
+
"instructions": "Which team should handle this ticket?",
|
|
124
|
+
"options": {"billing": null, "technical": null, "sales": null},
|
|
125
|
+
"calibration_profile": "support-routing-v3",
|
|
126
|
+
"alpha": 0.10
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
| Endpoint | Purpose |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `POST /v1/evaluate` | Evaluate a context against one or more queries |
|
|
135
|
+
| `POST /v1/calibration-profiles` | Create a calibration profile |
|
|
136
|
+
| `GET /v1/calibration-profiles/{name}` | Size, coverage interval, audit history |
|
|
137
|
+
| `POST /v1/calibration-profiles/{name}/examples` | Add labelled examples |
|
|
138
|
+
| `POST /v1/calibration-profiles/{name}/label-with-judge` | Judge-labelled pool plus a human sample, combined validly |
|
|
139
|
+
| `POST /v1/calibration-profiles/{name}/audit` | Audit against fresh labelled examples |
|
|
140
|
+
| `POST /v1/calibration-profiles/{name}/monitors` | Create an anytime-valid drift monitor |
|
|
141
|
+
| `GET /v1/calibration-profiles/{name}/monitors/{id}/alerts` | Poll monitor alerts |
|
|
142
|
+
| `GET /v1/backends` | Configured backends and their detected access level |
|
|
143
|
+
|
|
144
|
+
### With the SDK
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from cli_sdk import CLIClient, Set, Gate
|
|
148
|
+
|
|
149
|
+
with CLIClient() as client:
|
|
150
|
+
result = client.evaluate(
|
|
151
|
+
context={"ticket": "My payouts have been failing for 3 days."},
|
|
152
|
+
backend={"provider": "openai", "model": "gpt-4.1-2025-04-14"},
|
|
153
|
+
queries={
|
|
154
|
+
"department": Set(
|
|
155
|
+
instructions="Which team should handle this ticket?",
|
|
156
|
+
options={"billing": None, "technical": None, "sales": None},
|
|
157
|
+
calibration_profile="support-routing-v3",
|
|
158
|
+
alpha=0.10,
|
|
159
|
+
),
|
|
160
|
+
"route": Gate(
|
|
161
|
+
instructions="Auto-route this ticket without human review?",
|
|
162
|
+
calibration_profile="support-routing-v3",
|
|
163
|
+
guarantee="fdr",
|
|
164
|
+
target=0.05,
|
|
165
|
+
),
|
|
166
|
+
},
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
department = result.answers["department"]
|
|
170
|
+
print(department.set, department.guarantee.describe())
|
|
171
|
+
|
|
172
|
+
if result.answers["route"].approved:
|
|
173
|
+
assign_queue(department.top)
|
|
174
|
+
else:
|
|
175
|
+
send_to_human_triage(department.set)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The async client has the same interface, with `await` on each call (`monitors.poll` returns a list rather than a generator):
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from cli_sdk import AsyncCLIClient
|
|
182
|
+
|
|
183
|
+
async with AsyncCLIClient() as client:
|
|
184
|
+
result = await client.evaluate(context=..., backend=..., queries=...)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## The seven primitives
|
|
188
|
+
|
|
189
|
+
| Primitive | Returns | Guarantee |
|
|
190
|
+
|---|---|---|
|
|
191
|
+
| `Belief` | Venn-Abers interval `[p0, p1]` for one statement | calibrated probability bracket |
|
|
192
|
+
| `Set` | a set of options | coverage >= 1 - alpha |
|
|
193
|
+
| `Interval` | a conformalized ordinal/continuous interval | coverage >= 1 - alpha |
|
|
194
|
+
| `Gate` | `auto_approve` / `escalate` / `abstain` | risk <= alpha, risk with probability 1 - delta, or batch FDR <= q |
|
|
195
|
+
| `Claim` | long-form output filtered to supported claims | P(all retained claims true) >= 1 - alpha |
|
|
196
|
+
| `Judge` | a verdict with an escalation cascade | human agreement >= 1 - alpha on accepted verdicts |
|
|
197
|
+
| `Route` | which backend in a cascade served the request | cost or accuracy bound |
|
|
198
|
+
|
|
199
|
+
Every answer carries `answer.guarantee`, a `Guarantee` with `type`,
|
|
200
|
+
`method`, `alpha`/`delta`/`target`, `calibration_profile`, `calibration_n`,
|
|
201
|
+
`coverage_ci`, and `last_audited`. `guarantee.is_heuristic` is `True` when an
|
|
202
|
+
answer carries no formal guarantee, for example because its profile is still
|
|
203
|
+
below the minimum size. Pass `strict_guarantees=True` to the client to raise
|
|
204
|
+
`InsufficientCalibrationError` instead of receiving heuristic answers.
|
|
205
|
+
|
|
206
|
+
## Typed responses
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from cli_sdk import EvaluateResponse, SetAnswer
|
|
210
|
+
|
|
211
|
+
class RoutingResponse(EvaluateResponse):
|
|
212
|
+
department: SetAnswer
|
|
213
|
+
|
|
214
|
+
result = client.evaluate(..., response_model=RoutingResponse)
|
|
215
|
+
result.department # a SetAnswer; a missing or mistyped answer raises at parse time
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Calibration profiles
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
client.calibration_profiles.create(
|
|
222
|
+
name="support-routing-v3",
|
|
223
|
+
backend={"provider": "openai", "model": "gpt-4.1-2025-04-14"},
|
|
224
|
+
method="APS",
|
|
225
|
+
alpha=0.10,
|
|
226
|
+
group_by="account_tier", # optional Mondrian (per-group) calibration
|
|
227
|
+
)
|
|
228
|
+
client.calibration_profiles.add_examples(
|
|
229
|
+
"support-routing-v3",
|
|
230
|
+
examples=[{"context": {"ticket": "I was charged twice."}, "label": "billing"}],
|
|
231
|
+
)
|
|
232
|
+
profile = client.calibration_profiles.get("support-routing-v3")
|
|
233
|
+
profile.n, profile.minimum_n, profile.recommended_n, profile.realized_coverage_ci
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
| alpha | hard minimum n | recommended n |
|
|
237
|
+
|---|---|---|
|
|
238
|
+
| 0.20 | 4 | ~300 |
|
|
239
|
+
| 0.10 | 9 | ~1,000 |
|
|
240
|
+
| 0.05 | 19 | ~1,500 |
|
|
241
|
+
| 0.01 | 99 | ~2,500 |
|
|
242
|
+
|
|
243
|
+
Label-efficient calibration labels a pool with a judge and a random human
|
|
244
|
+
subset, combined so the result is valid regardless of judge quality:
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
client.calibration_profiles.label_with_judge(
|
|
248
|
+
"support-routing-v3",
|
|
249
|
+
judge={"provider": "openai", "model": "gpt-4.1-2025-04-14"},
|
|
250
|
+
unlabelled_examples=pool,
|
|
251
|
+
human_labelled_sample_size=300,
|
|
252
|
+
)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Drift monitoring
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
client.calibration_profiles.monitors.create(
|
|
259
|
+
"support-routing-v3", type="coverage", target=0.90,
|
|
260
|
+
false_alarm_rate=0.05, labelled_sample_rate=0.02,
|
|
261
|
+
)
|
|
262
|
+
for alert in client.calibration_profiles.monitors.poll("support-routing-v3"):
|
|
263
|
+
pause_auto_actioning()
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Monitors are e-processes: the false-alarm rate holds no matter how often or
|
|
267
|
+
for how long you check them. `LocalMonitor` runs the same test in-process:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
from cli_sdk import LocalMonitor
|
|
271
|
+
|
|
272
|
+
monitor = LocalMonitor(type="coverage", target=0.90, false_alarm_rate=0.05)
|
|
273
|
+
for label, prediction_set in stream:
|
|
274
|
+
if alert := monitor.update(label in prediction_set):
|
|
275
|
+
page_oncall(alert)
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Backends
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
from cli_sdk import OpenAIBackend, AnthropicBackend, VLLMBackend
|
|
282
|
+
|
|
283
|
+
OpenAIBackend(model="gpt-4.1-2025-04-14") # L1 on non-reasoning configs
|
|
284
|
+
AnthropicBackend(model="claude-sonnet-5", sample_count=20) # L0: sampling only
|
|
285
|
+
VLLMBackend(model="Qwen/Qwen3-8B", base_url="http://vllm:8000") # up to L4
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Plain dicts (`{"provider": "openai", "model": ...}`) work anywhere a backend
|
|
289
|
+
is accepted.
|
|
290
|
+
|
|
291
|
+
### Bring your own model
|
|
292
|
+
|
|
293
|
+
A `CustomBackend` runs your model locally and sends only the evidence
|
|
294
|
+
(probabilities, samples, scores) to CLI. Implement the methods your access
|
|
295
|
+
level supports:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
from cli_sdk import CLIClient, CustomBackend
|
|
299
|
+
|
|
300
|
+
class MyEngine(CustomBackend):
|
|
301
|
+
access_level = "L1"
|
|
302
|
+
|
|
303
|
+
def score_options(self, context, instructions, options):
|
|
304
|
+
return my_model.option_probabilities(context, instructions, list(options))
|
|
305
|
+
|
|
306
|
+
def sample(self, context, instructions, n):
|
|
307
|
+
return [my_model.generate(context, instructions) for _ in range(n)]
|
|
308
|
+
|
|
309
|
+
client = CLIClient(backend=MyEngine())
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Local mode
|
|
313
|
+
|
|
314
|
+
`LocalCLIClient` runs the same queries fully in-process: it scores labelled
|
|
315
|
+
examples with a model you bring, stores the calibration profile as a JSON
|
|
316
|
+
file, and answers with the same typed answers and guarantee cards as the
|
|
317
|
+
hosted client. Nothing leaves your process except calls to your own model
|
|
318
|
+
provider.
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
from cli_sdk import Gate, LocalCLIClient
|
|
322
|
+
from cli_sdk.evidence import OpenAIEvidenceBackend, vllm_backend
|
|
323
|
+
|
|
324
|
+
evidence = OpenAIEvidenceBackend("gpt-4.1-mini", api_key="YOUR_OPENAI_API_KEY")
|
|
325
|
+
# or open weights: evidence = vllm_backend("google/gemma-4-12B-it", base_url="http://localhost:8000/v1")
|
|
326
|
+
|
|
327
|
+
client = LocalCLIClient(evidence, store=".cli_profiles")
|
|
328
|
+
refund = Gate(instructions="Is issuing this refund correct under the policy?",
|
|
329
|
+
calibration_profile="refund-approvals-v1", guarantee="risk", target=0.05)
|
|
330
|
+
client.calibrate(refund, labelled_examples) # [{"context": {...}, "label": True}, ...]
|
|
331
|
+
answer = client.evaluate(context=case, queries={"refund": refund}).answers["refund"]
|
|
332
|
+
print(answer.decision, answer.guarantee.describe())
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Profiles are fingerprinted with the backend configuration and the query's
|
|
336
|
+
prompt: change either and answers fall back to their safe heuristic form
|
|
337
|
+
(escalate, every option, `[0, 1]`) until you recalibrate. See the
|
|
338
|
+
[local mode guide](https://cci-docs.gitdate.ink/agents/local-mode).
|
|
339
|
+
|
|
340
|
+
## Agent frameworks
|
|
341
|
+
|
|
342
|
+
`ToolGuard` decides each proposed tool call from a calibrated answer and
|
|
343
|
+
maps it onto the framework's native human-in-the-loop mechanism:
|
|
344
|
+
|
|
345
|
+
```python
|
|
346
|
+
from cli_sdk.integrations import GuardRule, ToolGuard
|
|
347
|
+
from cli_sdk.integrations.langchain import cli_middleware
|
|
348
|
+
|
|
349
|
+
guard = ToolGuard(client, [GuardRule(tool="issue_refund", query=refund, context=refund_context)])
|
|
350
|
+
agent = create_agent(model, tools=[lookup_order, issue_refund],
|
|
351
|
+
middleware=cli_middleware(guard), checkpointer=InMemorySaver())
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
| Framework | Module | Hook | Human review |
|
|
355
|
+
|---|---|---|---|
|
|
356
|
+
| LangChain 1.x | `cli_sdk.integrations.langchain` | `wrap_tool_call` middleware | `HumanInTheLoopMiddleware` |
|
|
357
|
+
| LangGraph | `cli_sdk.integrations.langgraph` | guard node before `ToolNode` | `interrupt()` / `Command(resume=...)` |
|
|
358
|
+
| Google ADK 2.x | `cli_sdk.integrations.google_adk` | `before_tool_callback` or plugin | tool confirmation |
|
|
359
|
+
| Microsoft Agent Framework | `cli_sdk.integrations.agent_framework` | `FunctionMiddleware` | function approval requests |
|
|
360
|
+
|
|
361
|
+
Eight runnable examples in risk-sensitive domains (refunds, patient triage,
|
|
362
|
+
insurance claims, discharge summaries, AML holds, trial screening, credit
|
|
363
|
+
tiers, drug safety) are in `examples/agents/`. Each runs offline with
|
|
364
|
+
`--provider mock` and with your own keys for OpenAI, Azure, Anthropic,
|
|
365
|
+
Gemini, or Gemma on vLLM or SGLang. See the
|
|
366
|
+
[agent frameworks guide](https://cci-docs.gitdate.ink/agents).
|
|
367
|
+
|
|
368
|
+
## Offline statistics engine
|
|
369
|
+
|
|
370
|
+
```python
|
|
371
|
+
from cli_sdk.stats.conformal import aps, crc
|
|
372
|
+
from cli_sdk.stats.venn_abers import ivap
|
|
373
|
+
from cli_sdk.stats.evalues import ebh, ppi, CoverageMonitor
|
|
374
|
+
|
|
375
|
+
q_hat = aps.calibrate(cal_probs, cal_labels, alpha=0.10)
|
|
376
|
+
sets = aps.predict(test_probs, q_hat)
|
|
377
|
+
|
|
378
|
+
p0, p1 = ivap.calibrate_and_predict(cal_scores, cal_labels, test_scores)
|
|
379
|
+
|
|
380
|
+
selected = ebh.select(e_values, q=0.10)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
| Module | Methods |
|
|
384
|
+
|---|---|
|
|
385
|
+
| `stats.conformal` | LAC, APS, RAPS, CQR, CRC, RCPS, Learn-then-Test, Mondrian |
|
|
386
|
+
| `stats.venn_abers` | IVAP, CVAP, interval merging and width |
|
|
387
|
+
| `stats.evalues` | anytime-valid risk and coverage monitors, e-BH, prediction-powered inference |
|
|
388
|
+
|
|
389
|
+
## Command-line tool
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
cli calibration show support-routing-v3
|
|
393
|
+
cli calibration audit support-routing-v3 --examples fresh.jsonl --fail-below 0.88
|
|
394
|
+
cli calibration audit-local --covered outcomes.txt --target 0.90
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
`audit` exits with status 1 on failure, so it can block a deploy in CI.
|
|
398
|
+
|
|
399
|
+
## Errors
|
|
400
|
+
|
|
401
|
+
| Exception | When |
|
|
402
|
+
|---|---|
|
|
403
|
+
| `AuthenticationError` | 401: missing or invalid API key |
|
|
404
|
+
| `ValidationError` | 422: the request failed validation |
|
|
405
|
+
| `InsufficientCalibrationError` | a profile is too small for the guarantee (raised only with `strict_guarantees=True`) |
|
|
406
|
+
| `RateLimitError` | 429 after retries are exhausted |
|
|
407
|
+
| `BackendError` | 502 / 529: the model backend errored or reported a lower access level than required |
|
|
408
|
+
| `ConfigurationError` | client-side misconfiguration, raised before any request |
|
|
409
|
+
|
|
410
|
+
`429`, `502` and `529` are retried with full-jitter exponential backoff,
|
|
411
|
+
honoring `retry-after`. Configure with `CLIClient(retry=RetryConfig(max_attempts=5, base_delay=0.5))`.
|
|
412
|
+
|
|
413
|
+
## Package layout
|
|
414
|
+
|
|
415
|
+
```
|
|
416
|
+
src/cli_sdk/
|
|
417
|
+
client/ sync + async clients, retry policy
|
|
418
|
+
queries/ Belief, Set, Interval, Gate, Claim, Judge, Route
|
|
419
|
+
answers/ typed answers, the Guarantee card, EvaluateResponse
|
|
420
|
+
calibration/ profiles, examples, audits, label-efficient calibration
|
|
421
|
+
monitoring/ hosted monitors, alerts, LocalMonitor
|
|
422
|
+
backends/ one adapter per provider, plus CustomBackend
|
|
423
|
+
stats/ offline engine: conformal/, venn_abers/, evalues/
|
|
424
|
+
local/ LocalCLIClient: in-process calibration and evaluation
|
|
425
|
+
evidence/ evidence backends: OpenAI, Azure, Anthropic, Gemini, vLLM, SGLang, mock
|
|
426
|
+
integrations/ ToolGuard and adapters for LangChain, LangGraph, ADK, Agent Framework
|
|
427
|
+
cli_tool.py the `cli` command
|
|
428
|
+
examples/ runnable end-to-end examples (agents/: agent-framework examples)
|
|
429
|
+
tests/ engine and client tests
|
|
430
|
+
```
|