mimir-decisions 1.0.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.
Files changed (77) hide show
  1. mimir_decisions-1.0.0/LICENSE +202 -0
  2. mimir_decisions-1.0.0/PKG-INFO +357 -0
  3. mimir_decisions-1.0.0/README.md +281 -0
  4. mimir_decisions-1.0.0/pyproject.toml +409 -0
  5. mimir_decisions-1.0.0/pyproject.toml.orig +305 -0
  6. mimir_decisions-1.0.0/src/mimir/__init__.py +92 -0
  7. mimir_decisions-1.0.0/src/mimir/cli/__init__.py +1 -0
  8. mimir_decisions-1.0.0/src/mimir/cli/app.py +717 -0
  9. mimir_decisions-1.0.0/src/mimir/cli/toolfile.py +80 -0
  10. mimir_decisions-1.0.0/src/mimir/client/__init__.py +1 -0
  11. mimir_decisions-1.0.0/src/mimir/client/http.py +267 -0
  12. mimir_decisions-1.0.0/src/mimir/compat/__init__.py +1 -0
  13. mimir_decisions-1.0.0/src/mimir/compat/laya/__init__.py +1 -0
  14. mimir_decisions-1.0.0/src/mimir/compat/laya/v1.py +169 -0
  15. mimir_decisions-1.0.0/src/mimir/compat/systemone/__init__.py +1 -0
  16. mimir_decisions-1.0.0/src/mimir/compat/systemone/v1.py +218 -0
  17. mimir_decisions-1.0.0/src/mimir/core/__init__.py +1 -0
  18. mimir_decisions-1.0.0/src/mimir/core/checks.py +122 -0
  19. mimir_decisions-1.0.0/src/mimir/core/context.py +260 -0
  20. mimir_decisions-1.0.0/src/mimir/core/decider.py +402 -0
  21. mimir_decisions-1.0.0/src/mimir/core/decisions.py +316 -0
  22. mimir_decisions-1.0.0/src/mimir/core/errors.py +111 -0
  23. mimir_decisions-1.0.0/src/mimir/core/intervals.py +21 -0
  24. mimir_decisions-1.0.0/src/mimir/core/labels.py +124 -0
  25. mimir_decisions-1.0.0/src/mimir/core/results.py +186 -0
  26. mimir_decisions-1.0.0/src/mimir/core/schema.py +51 -0
  27. mimir_decisions-1.0.0/src/mimir/core/tools.py +135 -0
  28. mimir_decisions-1.0.0/src/mimir/core/values.py +95 -0
  29. mimir_decisions-1.0.0/src/mimir/core/wire.py +100 -0
  30. mimir_decisions-1.0.0/src/mimir/evaluation/__init__.py +1 -0
  31. mimir_decisions-1.0.0/src/mimir/evaluation/bench.py +81 -0
  32. mimir_decisions-1.0.0/src/mimir/extras.py +34 -0
  33. mimir_decisions-1.0.0/src/mimir/integrations/__init__.py +5 -0
  34. mimir_decisions-1.0.0/src/mimir/integrations/agent_framework.py +55 -0
  35. mimir_decisions-1.0.0/src/mimir/integrations/crewai.py +64 -0
  36. mimir_decisions-1.0.0/src/mimir/integrations/google_adk.py +77 -0
  37. mimir_decisions-1.0.0/src/mimir/integrations/langchain.py +121 -0
  38. mimir_decisions-1.0.0/src/mimir/integrations/llamaindex.py +60 -0
  39. mimir_decisions-1.0.0/src/mimir/integrations/openai_agents.py +69 -0
  40. mimir_decisions-1.0.0/src/mimir/integrations/pydantic_ai.py +64 -0
  41. mimir_decisions-1.0.0/src/mimir/integrations/smolagents.py +48 -0
  42. mimir_decisions-1.0.0/src/mimir/mcp/__init__.py +1 -0
  43. mimir_decisions-1.0.0/src/mimir/mcp/server.py +207 -0
  44. mimir_decisions-1.0.0/src/mimir/mcp/transport.py +20 -0
  45. mimir_decisions-1.0.0/src/mimir/policy/__init__.py +4 -0
  46. mimir_decisions-1.0.0/src/mimir/policy/assessment.py +82 -0
  47. mimir_decisions-1.0.0/src/mimir/policy/binding.py +79 -0
  48. mimir_decisions-1.0.0/src/mimir/policy/certification.py +105 -0
  49. mimir_decisions-1.0.0/src/mimir/policy/conformal.py +65 -0
  50. mimir_decisions-1.0.0/src/mimir/policy/distributions.py +126 -0
  51. mimir_decisions-1.0.0/src/mimir/policy/document.py +232 -0
  52. mimir_decisions-1.0.0/src/mimir/policy/gate.py +32 -0
  53. mimir_decisions-1.0.0/src/mimir/py.typed +0 -0
  54. mimir_decisions-1.0.0/src/mimir/runtime/__init__.py +1 -0
  55. mimir_decisions-1.0.0/src/mimir/runtime/answer.py +237 -0
  56. mimir_decisions-1.0.0/src/mimir/runtime/artifact.py +232 -0
  57. mimir_decisions-1.0.0/src/mimir/runtime/batching.py +41 -0
  58. mimir_decisions-1.0.0/src/mimir/runtime/calibrate.py +158 -0
  59. mimir_decisions-1.0.0/src/mimir/runtime/chunking.py +163 -0
  60. mimir_decisions-1.0.0/src/mimir/runtime/engine.py +341 -0
  61. mimir_decisions-1.0.0/src/mimir/runtime/equivalence.py +141 -0
  62. mimir_decisions-1.0.0/src/mimir/runtime/graph.py +115 -0
  63. mimir_decisions-1.0.0/src/mimir/runtime/hardware.py +59 -0
  64. mimir_decisions-1.0.0/src/mimir/runtime/layout.py +315 -0
  65. mimir_decisions-1.0.0/src/mimir/runtime/readout.py +70 -0
  66. mimir_decisions-1.0.0/src/mimir/runtime/release.py +95 -0
  67. mimir_decisions-1.0.0/src/mimir/runtime/rendering.py +163 -0
  68. mimir_decisions-1.0.0/src/mimir/runtime/session.py +132 -0
  69. mimir_decisions-1.0.0/src/mimir/runtime/signature.py +46 -0
  70. mimir_decisions-1.0.0/src/mimir/server/__init__.py +1 -0
  71. mimir_decisions-1.0.0/src/mimir/server/app.py +205 -0
  72. mimir_decisions-1.0.0/src/mimir/server/auth.py +84 -0
  73. mimir_decisions-1.0.0/src/mimir/server/batcher.py +145 -0
  74. mimir_decisions-1.0.0/src/mimir/server/errors.py +90 -0
  75. mimir_decisions-1.0.0/src/mimir/server/limits.py +72 -0
  76. mimir_decisions-1.0.0/src/mimir/server/metrics.py +91 -0
  77. mimir_decisions-1.0.0/src/mimir/server/model.py +170 -0
@@ -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.
@@ -0,0 +1,357 @@
1
+ Metadata-Version: 2.4
2
+ Name: mimir-decisions
3
+ Version: 1.0.0
4
+ Summary: Typed, calibrated and certified decisions from MIMIR, a non-generative decision model
5
+ Keywords: decision-model,classification,abstention,calibration,onnx,agents
6
+ Author: Mythologic
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Dist: httpx>=0.28.1,<1
23
+ Requires-Dist: packaging>=24
24
+ Requires-Dist: pydantic>=2.11,<3
25
+ Requires-Dist: rich>=13.9,<16
26
+ Requires-Dist: typer>=0.16,<1
27
+ Requires-Dist: google-adk>=2.10,<3 ; extra == 'adk'
28
+ Requires-Dist: agent-framework-core>=1.19,<2 ; extra == 'agent-framework'
29
+ Requires-Dist: mimir-decisions[local,server,mcp] ; extra == 'all'
30
+ Requires-Dist: crewai>=1.15,<2 ; python_full_version < '3.14' and extra == 'crewai'
31
+ Requires-Dist: langchain>=1.3,<2 ; extra == 'langchain'
32
+ Requires-Dist: llama-index-core>=0.14.25,<0.15 ; extra == 'llamaindex'
33
+ Requires-Dist: huggingface-hub>=1.0,<2 ; extra == 'local'
34
+ Requires-Dist: numpy>=2.3,<3 ; extra == 'local'
35
+ Requires-Dist: onnx>=1.23,<2 ; extra == 'local'
36
+ Requires-Dist: onnxruntime==1.30.0 ; extra == 'local'
37
+ Requires-Dist: sigstore>=4.5,<5 ; extra == 'local'
38
+ Requires-Dist: tokenizers>=0.23.2,<0.24 ; extra == 'local'
39
+ Requires-Dist: huggingface-hub>=1.0,<2 ; extra == 'local-gpu'
40
+ Requires-Dist: numpy>=2.3,<3 ; extra == 'local-gpu'
41
+ Requires-Dist: onnx>=1.23,<2 ; extra == 'local-gpu'
42
+ Requires-Dist: onnxruntime-gpu==1.30.0 ; extra == 'local-gpu'
43
+ Requires-Dist: sigstore>=4.5,<5 ; extra == 'local-gpu'
44
+ Requires-Dist: tokenizers>=0.23.2,<0.24 ; extra == 'local-gpu'
45
+ Requires-Dist: mcp>=2.2,<3 ; extra == 'mcp'
46
+ Requires-Dist: pyyaml>=6.0.3,<7 ; extra == 'mcp'
47
+ Requires-Dist: uvicorn>=0.54,<1 ; extra == 'mcp'
48
+ Requires-Dist: openai-agents>=0.21,<1 ; extra == 'openai-agents'
49
+ Requires-Dist: pydantic-ai-slim>=2.16,<3 ; extra == 'pydantic-ai'
50
+ Requires-Dist: fastapi>=0.141.1,<1 ; extra == 'server'
51
+ Requires-Dist: prometheus-client>=0.26,<1 ; extra == 'server'
52
+ Requires-Dist: pyyaml>=6.0.3,<7 ; extra == 'server'
53
+ Requires-Dist: uvicorn>=0.54,<1 ; extra == 'server'
54
+ Requires-Dist: smolagents>=1.26,<2 ; extra == 'smolagents'
55
+ Requires-Python: >=3.11
56
+ Project-URL: Homepage, https://github.com/abderahmane-ai/mimir
57
+ Project-URL: Documentation, https://abderahmane-ai.github.io/mimir/
58
+ Project-URL: Changelog, https://github.com/abderahmane-ai/mimir/blob/main/CHANGELOG.md
59
+ Project-URL: Source, https://github.com/abderahmane-ai/mimir
60
+ Project-URL: Tracker, https://github.com/abderahmane-ai/mimir/issues
61
+ Project-URL: Model, https://huggingface.co/Mythologic/MIMIR-1
62
+ Provides-Extra: adk
63
+ Provides-Extra: agent-framework
64
+ Provides-Extra: all
65
+ Provides-Extra: crewai
66
+ Provides-Extra: langchain
67
+ Provides-Extra: llamaindex
68
+ Provides-Extra: local
69
+ Provides-Extra: local-gpu
70
+ Provides-Extra: mcp
71
+ Provides-Extra: openai-agents
72
+ Provides-Extra: pydantic-ai
73
+ Provides-Extra: server
74
+ Provides-Extra: smolagents
75
+ Description-Content-Type: text/markdown
76
+
77
+ # mimir-decisions
78
+
79
+ **Decisions your agents can act on.** MIMIR is a non-generative decision model: give it
80
+ a context, a question and the options, and get back a typed answer with calibrated
81
+ probabilities, the evidence behind it, and a certified verdict on whether to act or
82
+ escalate. No text generated. Nothing to parse. Nothing to hallucinate.
83
+
84
+ It beats Laya and GLiNER2.5-Decide head-to-head on six of ten tasks — by 54.7 points on
85
+ Banking77, 42.3 on MASSIVE, 36.3 on typed decisions — and where it cannot back an
86
+ answer, it abstains instead of guessing.
87
+
88
+ ```bash
89
+ pip install "mimir-decisions[local]" # CPU engine
90
+ pip install "mimir-decisions[local-gpu]" # CUDA engine
91
+ pip install mimir-decisions # data models and HTTP client only
92
+ ```
93
+
94
+ Python 3.11+. Documentation: <https://abderahmane-ai.github.io/mimir/>
95
+
96
+ ---
97
+
98
+ ## Why MIMIR
99
+
100
+ Most agents route, classify, and verify using a general-purpose language model: slow, expensive, and impossible to audit. MIMIR is built for structured decisions. It runs on ONNX Runtime in milliseconds, returns calibrated probabilities with every answer, and issues a mathematical certificate — a formal guarantee that its realised error rate stays at or below the risk level you ask for, measured on held-out data.
101
+
102
+ - **No generation.** Answers are drawn from the options you supply, not synthesised. The model cannot hallucinate an answer that wasn't on the list.
103
+ - **Calibrated confidence.** Probabilities are not softmax scores; they are calibrated to match realised accuracy on held-out data.
104
+ - **Certified deferral.** When confidence falls short of the certified threshold, the decision defers rather than guessing. The coverage and the error rate of taken decisions are proven.
105
+ - **One typed contract.** Seven decision types — choice, multi-choice, yes/no, verify, rank, rate, estimate — all returning the same result shape, over any context.
106
+ - **Portable.** The same Python interface works locally on CPU or GPU, over HTTP, and over MCP. Framework adapters exist for eight agent SDKs.
107
+
108
+ ---
109
+
110
+ ## Quickstart
111
+
112
+ ```python
113
+ from mimir import Mimir
114
+
115
+ model = Mimir.from_pretrained("Mythologic/MIMIR-1")
116
+ result = model.choose(
117
+ "My card was charged twice for the same order.",
118
+ "Which team should handle this ticket?",
119
+ options={"billing": "Billing: payments, refunds", "security": "Security: account access"},
120
+ )
121
+
122
+ result.status # Status.DECIDED, Status.ABSTAINED or Status.DEFERRED
123
+ result.answer # an option id, or None when no option applies
124
+ result.probabilities # calibrated probability of each option id
125
+ result.certificate # the certified threshold the decision was checked against
126
+ ```
127
+
128
+ `answer` is the model's prediction. `status` is the policy's verdict:
129
+
130
+ - `DECIDED` — the answer is an option and is certified at the requested risk level.
131
+ - `ABSTAINED` — no listed option applies, and that is certified.
132
+ - `DEFERRED` — not certified; `result.deferral.reason` is `below_threshold`, `out_of_distribution`, or `no_certified_threshold`.
133
+
134
+ The first call downloads the model from the Hugging Face Hub at the revision this package version pins, verifies its Sigstore signature, checks every file against the manifest's SHA-256, and loads it.
135
+
136
+ ---
137
+
138
+ ## Decision types
139
+
140
+ | Spec | Answer |
141
+ |---|---|
142
+ | `Choice(question, options)` | an option id, or `None` |
143
+ | `MultiChoice(question, options)` | the option ids that apply |
144
+ | `YesNo(question)` | `True` or `False` |
145
+ | `Verify(claim)` | `supported`, `contradicted`, or `not_enough_information` |
146
+ | `Rank(question, candidates)` | candidate ids, best first |
147
+ | `Rate(question, levels)` | a level id; levels given lowest first |
148
+ | `Estimate(question, low, high, unit)` | a number in `[low, high]`, with a confidence interval |
149
+
150
+ ```python
151
+ from mimir import Context, Field, Passage, Rate, Table
152
+
153
+ context = Context(
154
+ passages=[Passage(title="Ticket #4412", text="The export has failed every night this week.")],
155
+ tables=[Table.from_rows([["2026-03-02", "failed"]], header=["date", "status"])],
156
+ fields=Field.from_json({"customer": {"plan": "enterprise", "seats": 240}}),
157
+ )
158
+ result = model.decide(context, Rate("How urgent is this?", ["low", "medium", "high"]), risk=0.01)
159
+ ```
160
+
161
+ A context can be a string, a list of strings, a dict read as a JSON state, or a `Context` of typed passages, tables, and fields. `Table.from_dataframe(frame)` reads a pandas or polars DataFrame. `decide_many` batches multiple decisions, and every method has an async counterpart (`adecide`, `adecide_many`, …).
162
+
163
+ ---
164
+
165
+ ## Certification
166
+
167
+ `decide` takes a risk level certified by the loaded policy (`model.info().risk_levels`). A decision is taken only when its calibrated confidence clears a threshold certified on held-out data to keep the realised error rate at or below that risk with 95% confidence, and when the context passes the out-of-distribution gate. `decide_uncertified` returns the raw model answer with no policy applied.
168
+
169
+ A certificate covers one exact configuration: model files, variant, ONNX Runtime version, execution provider, and options. On hardware not listed in the certificate, the first load runs the release's equivalence set and requires every decision to match. To certify thresholds on your own labelled data:
170
+
171
+ ```bash
172
+ mimir calibrate labelled.jsonl --risk 0.01 --confidence 0.95 --out policy.json
173
+ ```
174
+
175
+ ```python
176
+ model = Mimir.from_pretrained("Mythologic/MIMIR-1", policy="policy.json")
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Remote use
182
+
183
+ ```python
184
+ from mimir import MimirClient
185
+
186
+ remote = MimirClient("https://mimir.internal", api_key="...")
187
+ remote.choose("...", "Which team?", options=["billing", "security"])
188
+ ```
189
+
190
+ `MimirClient` has the same interface as `Mimir`, so all code, decision tools, and framework adapters accept either. It requires only the base install. Connection errors, timeouts, and 429/502/503/504/529 responses are retried with exponential backoff that honours `Retry-After`.
191
+
192
+ ---
193
+
194
+ ## Decision tools
195
+
196
+ ```python
197
+ from mimir import Choice
198
+
199
+ route_ticket = model.tool(
200
+ "route_ticket",
201
+ Choice("Which team should handle this ticket?", options=["billing", "security"]),
202
+ description="Route a support ticket to the team that owns it.",
203
+ )
204
+ route_ticket("My card was charged twice")
205
+ route_ticket.input_schema, route_ticket.output_schema
206
+ ```
207
+
208
+ Tools can also be declared in a YAML file, which the HTTP and MCP servers load:
209
+
210
+ ```yaml
211
+ tools:
212
+ - name: route_ticket
213
+ description: Route a support ticket to the team that owns it.
214
+ decision:
215
+ type: choice
216
+ question: Which team should handle this ticket?
217
+ options: [billing, security]
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Tool-call checks
223
+
224
+ A tool-call check decides, against rules you write, whether an agent's pending tool call may run. A certified yes allows it, a certified no denies it, and anything else escalates to a person.
225
+
226
+ ```python
227
+ check = model.tool_call_check(
228
+ ["Refunds above 500 dollars need a manager's approval."], tools=["issue_refund"]
229
+ )
230
+ outcome = check("issue_refund", {"order": "4412", "amount": 900})
231
+ outcome.permission # Permission.ALLOW, Permission.DENY or Permission.ESCALATE
232
+ outcome.reason # one sentence for the agent or the approver
233
+ ```
234
+
235
+ ---
236
+
237
+ ## Agent frameworks
238
+
239
+ Each adapter turns decision tools into the framework's native tool type and wires a tool-call check into that framework's own approval hook.
240
+
241
+ | Framework | Install | Tools | Tool-call check |
242
+ |---|---|---|---|
243
+ | OpenAI Agents SDK | `mimir-decisions[openai-agents]` | `as_function_tool` | `guard`: escalations pause the run for approval |
244
+ | LangChain / LangGraph | `mimir-decisions[langchain]` | `as_structured_tool` | `ToolCallCheckMiddleware`: escalations interrupt with the human-in-the-loop request |
245
+ | PydanticAI | `mimir-decisions[pydantic-ai]` | `as_toolset` | `guard`: escalations end the run with `DeferredToolRequests` |
246
+ | CrewAI | `mimir-decisions[crewai]` | `as_crewai_tool` | `tool_call_hook`: escalations go to your approver |
247
+ | Google ADK | `mimir-decisions[adk]` | `as_adk_tool` | `tool_call_callback`: escalations ask for ADK confirmation |
248
+ | Microsoft Agent Framework | `mimir-decisions[agent-framework]` | `as_function_tool` | `ToolCallCheckMiddleware`: only certified calls run |
249
+ | LlamaIndex | `mimir-decisions[llamaindex]` | `as_llamaindex_tool` | none |
250
+ | smolagents | `mimir-decisions[smolagents]` | `as_smolagents_tool` | none |
251
+
252
+ ```python
253
+ from agents import Agent
254
+ from mimir.integrations.openai_agents import as_function_tool
255
+
256
+ agent = Agent(name="support", tools=[as_function_tool(route_ticket)])
257
+ ```
258
+
259
+ Every framework also reaches MIMIR through its own MCP client. [`examples/`](examples) has a native, an MCP, and a checked agent for each framework, plus a Vercel AI SDK agent in TypeScript.
260
+
261
+ ---
262
+
263
+ ## HTTP server
264
+
265
+ ```bash
266
+ pip install "mimir-decisions[local,server]"
267
+ MIMIR_API_KEYS=key-one,key-two mimir serve --host 0.0.0.0 --tools tools.yaml
268
+ ```
269
+
270
+ | Route | Does |
271
+ |---|---|
272
+ | `POST /v1/decide` | one certified decision: `{context, decision, risk, alpha}` |
273
+ | `POST /v1/decide/uncertified` | the model's raw answer: `{context, decision}` |
274
+ | `POST /v1/decide/batch` | up to 64 decisions in one call |
275
+ | `POST /v1/tools/{name}` | a tool from `--tools`, given only `{context}` |
276
+ | `POST /v1/systemone` | Jev's request and response format |
277
+ | `GET /v1/models` | model, revision, runtime and certified risk levels |
278
+ | `GET /healthz`, `GET /readyz` | liveness, and readiness once the model is loaded |
279
+ | `GET /metrics` | Prometheus metrics |
280
+
281
+ Concurrent requests are batched. With keys in `MIMIR_API_KEYS`, every route except the probes requires `Authorization: Bearer <key>`. A server with no keys listens only on loopback unless started with `--allow-no-auth`. The OpenAPI 3.1 document is [`openapi.json`](openapi.json).
282
+
283
+ ---
284
+
285
+ ## MCP server
286
+
287
+ Each configured tool becomes an MCP tool that takes only a context; `--generic-tools` adds `mimir_choose`, `mimir_verify`, `mimir_rank`, and `mimir_rate`. A deferred decision is a normal result telling the agent to escalate.
288
+
289
+ ```bash
290
+ uvx --from "mimir-decisions[local,mcp]" mimir-decisions mcp --tools tools.yaml # stdio
291
+ MIMIR_API_KEYS=... mimir mcp --http --host 0.0.0.0 --tools tools.yaml # Streamable HTTP at /mcp
292
+ mimir mcp --tools tools.yaml --remote https://mimir.internal # forward to a server
293
+ mimir serve --mcp --tools tools.yaml # HTTP API and /mcp together
294
+ ```
295
+
296
+ In Claude Code:
297
+
298
+ ```bash
299
+ claude mcp add mimir -- uvx --from "mimir-decisions[local,mcp]" mimir-decisions mcp --tools /path/to/tools.yaml
300
+ claude mcp add --transport http mimir https://mimir.internal/mcp --header "Authorization: Bearer ..."
301
+ ```
302
+
303
+ Claude Desktop, Cursor, and VS Code take the same command or the same URL and header in their MCP configuration. The server is registered in the MCP Registry as `io.github.abderahmane-ai/mimir`.
304
+
305
+ <!-- mcp-name: io.github.abderahmane-ai/mimir -->
306
+
307
+ ---
308
+
309
+ ## Containers
310
+
311
+ ```bash
312
+ docker run -p 8000:8000 -e MIMIR_API_KEYS=... -v mimir-models:/models ghcr.io/abderahmane-ai/mimir:1.0.0-cpu
313
+ docker run --gpus all -p 8000:8000 -e MIMIR_API_KEYS=... -v mimir-models:/models ghcr.io/abderahmane-ai/mimir:1.0.0-cuda
314
+ ```
315
+
316
+ Images carry the runtime, never the model weights. On first start, the model is downloaded at the revision the package version pins, verified, and cached in `/models`. To run from that cache with no network access, append `serve --host 0.0.0.0 --model-cache /models --offline`.
317
+
318
+ Images are signed with Sigstore by the release workflow:
319
+
320
+ ```bash
321
+ cosign verify ghcr.io/abderahmane-ai/mimir:1.0.0-cpu \
322
+ --certificate-identity https://github.com/abderahmane-ai/mimir/.github/workflows/release.yml@refs/heads/main \
323
+ --certificate-oidc-issuer https://token.actions.githubusercontent.com
324
+ ```
325
+
326
+ ---
327
+
328
+ ## Command line
329
+
330
+ | Command | Description |
331
+ |---|---|
332
+ | `mimir serve` | the HTTP server; `--mcp` also serves MCP at `/mcp` |
333
+ | `mimir mcp` | the MCP server, over stdio or `--http` |
334
+ | `mimir decide` | one decision from flags, or a JSON request on stdin |
335
+ | `mimir bench FILE` | accuracy, coverage and realised risk on labelled decisions |
336
+ | `mimir calibrate FILE` | certify thresholds on labelled decisions |
337
+ | `mimir schema` | JSON Schemas of every spec, result and request |
338
+ | `mimir download` | download and verify a release for offline use |
339
+ | `mimir doctor` | report the environment; `--verify` loads the model and runs the equivalence check |
340
+
341
+ ---
342
+
343
+ ## Integrity
344
+
345
+ Releases are loaded from a pinned Hugging Face revision. Before any model file is read, the manifest's Sigstore signature is verified against the `abderahmane-ai/mimir` release workflow, every file is checked against the manifest's SHA-256, and the ONNX graph is checked against its operator allowlist and signature. No pickle is used anywhere.
346
+
347
+ ---
348
+
349
+ ## Migrating
350
+
351
+ `mimir.compat.systemone.v1` converts Jev `/v1/systemone` requests and responses, and `mimir.compat.laya.v1` exposes `load(...).predict(state, questions)` in Laya 0.3.20's shape. See the [migration guides](https://abderahmane-ai.github.io/mimir/migrating/jev/) for step-by-step instructions.
352
+
353
+ ---
354
+
355
+ ## License
356
+
357
+ The `mimir-decisions` package is licensed under [Apache 2.0](LICENSE). The MIMIR model weights are distributed under their own license on the [Hugging Face Hub](https://huggingface.co/Mythologic/MIMIR-1).