ebaml 0.3.1__tar.gz → 0.3.3__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 (171) hide show
  1. {ebaml-0.3.1 → ebaml-0.3.3}/PKG-INFO +30 -19
  2. {ebaml-0.3.1 → ebaml-0.3.3}/README.md +26 -18
  3. {ebaml-0.3.1 → ebaml-0.3.3}/pyproject.toml +11 -4
  4. {ebaml-0.3.1 → ebaml-0.3.3}/pyproject.toml.orig +10 -5
  5. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/.baml-generator-output.json +5 -5
  6. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/__init__.py +67 -17
  7. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/__init__.pyi +55 -14
  8. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/_baml_sources.py +2 -2
  9. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/_inlinedbaml.py +1 -1
  10. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/_typemap.py +3 -1
  11. ebaml-0.3.3/src/ebaml/__init__.py +176 -0
  12. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/core/exceptions.py +4 -0
  13. ebaml-0.3.3/src/ebaml/graphs/request_text.py +76 -0
  14. ebaml-0.3.3/src/ebaml/graphs/token_budget.py +345 -0
  15. ebaml-0.3.3/src/ebaml/graphs/token_weights.py +466 -0
  16. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/llm/descriptors.py +89 -8
  17. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/llm/options.py +6 -1
  18. ebaml-0.3.3/src/ebaml/llm/token_learning.py +322 -0
  19. ebaml-0.3.3/src/ebaml/llm/token_weights.json +30 -0
  20. ebaml-0.3.1/src/ebaml/__init__.py +0 -73
  21. ebaml-0.3.1/src/ebaml/graphs/token_budget.py +0 -84
  22. {ebaml-0.3.1 → ebaml-0.3.3}/LICENSE +0 -0
  23. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/.baml-generator-output-root +0 -0
  24. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/.gitignore +0 -0
  25. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/_function_registry.py +0 -0
  26. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/_invocation_types.py +0 -0
  27. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/_invocation_types.pyi +0 -0
  28. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/__init__.py +0 -0
  29. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/__init__.pyi +0 -0
  30. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/clients/__init__.py +0 -0
  31. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/clients/__init__.pyi +0 -0
  32. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/content/__init__.py +0 -0
  33. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/content/__init__.pyi +0 -0
  34. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/errors/__init__.py +0 -0
  35. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/errors/__init__.pyi +0 -0
  36. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/events/__init__.py +0 -0
  37. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/events/__init__.pyi +0 -0
  38. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/internal/__init__.py +0 -0
  39. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/internal/__init__.pyi +0 -0
  40. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/mcp/__init__.py +0 -0
  41. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/mcp/__init__.pyi +0 -0
  42. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/stream/__init__.py +0 -0
  43. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/stream/__init__.pyi +0 -0
  44. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/tools/__init__.py +0 -0
  45. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/tools/__init__.pyi +0 -0
  46. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/wire/__init__.py +0 -0
  47. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/ai/wire/__init__.pyi +0 -0
  48. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/__init__.py +0 -0
  49. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/__init__.pyi +0 -0
  50. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/crypto/__init__.py +0 -0
  51. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/crypto/__init__.pyi +0 -0
  52. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/csv/__init__.py +0 -0
  53. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/csv/__init__.pyi +0 -0
  54. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/env/__init__.py +0 -0
  55. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/env/__init__.pyi +0 -0
  56. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/errors/__init__.py +0 -0
  57. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/errors/__init__.pyi +0 -0
  58. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/fs/__init__.py +0 -0
  59. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/fs/__init__.pyi +0 -0
  60. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/future/__init__.py +0 -0
  61. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/future/__init__.pyi +0 -0
  62. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/glob/__init__.py +0 -0
  63. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/glob/__init__.pyi +0 -0
  64. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/hash/__init__.py +0 -0
  65. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/hash/__init__.pyi +0 -0
  66. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/host/__init__.py +0 -0
  67. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/host/__init__.pyi +0 -0
  68. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/http/__init__.py +0 -0
  69. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/http/__init__.pyi +0 -0
  70. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/io/__init__.py +0 -0
  71. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/io/__init__.pyi +0 -0
  72. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/iter/__init__.py +0 -0
  73. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/iter/__init__.pyi +0 -0
  74. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/json/__init__.py +0 -0
  75. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/json/__init__.pyi +0 -0
  76. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/media/__init__.py +0 -0
  77. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/media/__init__.pyi +0 -0
  78. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/net/__init__.py +0 -0
  79. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/net/__init__.pyi +0 -0
  80. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/ops/__init__.py +0 -0
  81. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/ops/__init__.pyi +0 -0
  82. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/panics/__init__.py +0 -0
  83. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/panics/__init__.pyi +0 -0
  84. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/random/__init__.py +0 -0
  85. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/random/__init__.pyi +0 -0
  86. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/regex/__init__.py +0 -0
  87. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/regex/__init__.pyi +0 -0
  88. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/sap/__init__.py +0 -0
  89. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/sap/__init__.pyi +0 -0
  90. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/spawn/__init__.py +0 -0
  91. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/spawn/__init__.pyi +0 -0
  92. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/sys/__init__.py +0 -0
  93. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/sys/__init__.pyi +0 -0
  94. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/time/__init__.py +0 -0
  95. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/time/__init__.pyi +0 -0
  96. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/toml/__init__.py +0 -0
  97. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/toml/__init__.pyi +0 -0
  98. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/ws/__init__.py +0 -0
  99. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/ws/__init__.pyi +0 -0
  100. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/yaml/__init__.py +0 -0
  101. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/baml/yaml/__init__.pyi +0 -0
  102. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/experimental/__init__.py +0 -0
  103. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/experimental/__init__.pyi +0 -0
  104. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/py.typed +0 -0
  105. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/__init__.py +0 -0
  106. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/__init__.pyi +0 -0
  107. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/class_/__init__.py +0 -0
  108. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/class_/__init__.pyi +0 -0
  109. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/enum/__init__.py +0 -0
  110. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/enum/__init__.pyi +0 -0
  111. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/errors/__init__.py +0 -0
  112. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/errors/__init__.pyi +0 -0
  113. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/function/__init__.py +0 -0
  114. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/function/__init__.pyi +0 -0
  115. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/interface/__init__.py +0 -0
  116. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/reflect/interface/__init__.pyi +0 -0
  117. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/__init__.py +0 -0
  118. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/__init__.pyi +0 -0
  119. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/anthropic/__init__.py +0 -0
  120. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/anthropic/__init__.pyi +0 -0
  121. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/anthropic/internal/__init__.py +0 -0
  122. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/anthropic/internal/__init__.pyi +0 -0
  123. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/assert_/__init__.py +0 -0
  124. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/assert_/__init__.pyi +0 -0
  125. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/aws/__init__.py +0 -0
  126. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/aws/__init__.pyi +0 -0
  127. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/aws/internal/__init__.py +0 -0
  128. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/aws/internal/__init__.pyi +0 -0
  129. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/claude_code/__init__.py +0 -0
  130. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/claude_code/__init__.pyi +0 -0
  131. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/claude_code/internal/__init__.py +0 -0
  132. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/claude_code/internal/__init__.pyi +0 -0
  133. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/google/__init__.py +0 -0
  134. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/google/__init__.pyi +0 -0
  135. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/google/internal/__init__.py +0 -0
  136. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/google/internal/__init__.pyi +0 -0
  137. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/openai/__init__.py +0 -0
  138. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/openai/__init__.pyi +0 -0
  139. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/openai/internal/__init__.py +0 -0
  140. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/openai/internal/__init__.pyi +0 -0
  141. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/openai/internal/decisions/__init__.py +0 -0
  142. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/openai/internal/decisions/__init__.pyi +0 -0
  143. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/testing/__init__.py +0 -0
  144. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/testing/__init__.pyi +0 -0
  145. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/trace/__init__.py +0 -0
  146. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/trace/__init__.pyi +0 -0
  147. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/typesafeai/__init__.py +0 -0
  148. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/typesafeai/__init__.pyi +0 -0
  149. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/typesafeai/internal/__init__.py +0 -0
  150. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/typesafeai/internal/__init__.pyi +0 -0
  151. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/vercel/__init__.py +0 -0
  152. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/vercel/__init__.pyi +0 -0
  153. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/vercel/internal/__init__.py +0 -0
  154. {ebaml-0.3.1 → ebaml-0.3.3}/src/baml_sdk/vendor/vercel/internal/__init__.pyi +0 -0
  155. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/benchmark.py +0 -0
  156. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/core/__init__.py +0 -0
  157. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/core/custom_types.py +0 -0
  158. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/graphs/__init__.py +0 -0
  159. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/graphs/ebm_graph.py +0 -0
  160. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/graphs/graph_text.py +0 -0
  161. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/graphs/model_kinds.py +0 -0
  162. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/graphs/terms.py +0 -0
  163. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/llm/__init__.py +0 -0
  164. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/llm/provider_errors.py +0 -0
  165. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/llm/retry.py +0 -0
  166. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/llm/sdk_setup.py +0 -0
  167. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/local/__init__.py +0 -0
  168. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/local/audience.py +0 -0
  169. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/local/fact_text.py +0 -0
  170. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/local/facts.py +0 -0
  171. {ebaml-0.3.1 → ebaml-0.3.3}/src/ebaml/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ebaml
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: BAML for Explainable Boosting Machines: talk to your EBM.
5
5
  Keywords: baml,llm,explainable-ai,explainable-boosting-machine,interpretml
6
6
  Author: Johnny Godoy
@@ -17,7 +17,10 @@ Requires-Dist: attrs>=26.1.0
17
17
  Requires-Dist: baml-bridge>=0.23.0
18
18
  Requires-Dist: beartype>=0.23.1
19
19
  Requires-Dist: interpret>=0.7.8
20
+ Requires-Dist: numpy>=2.5.4
20
21
  Requires-Dist: orjson>=3.13.0
22
+ Requires-Dist: pandas>=3.0.6
23
+ Requires-Dist: scipy>=1.18.1
21
24
  Requires-Dist: structlog>=26.1.0
22
25
  Requires-Python: >=3.13
23
26
  Project-URL: Documentation, https://johnny-godoy.github.io/EBaMl/
@@ -121,10 +124,10 @@ baml generate
121
124
  This writes the `src/baml_sdk/` package from `baml_src/`, next to `ebaml`, so it imports wherever the project is
122
125
  installed. Rerun it every time a `.baml` file changes, including when you change the provider.
123
126
 
124
- If `src/baml_sdk/` does not exist, `ebaml.llm.descriptors` runs `baml generate` when you import it. If the package was
125
- generated by another BAML toolchain than the one that `baml-bridge` expects (a version skew), the import runs
126
- `baml toolchain use <version>` and `baml generate`. If the agent skill check stops `baml generate`, the import runs it
127
- again with `--agent-skill-check off`. If none of this works, `SDKUnavailableError` lists the steps that fix the cause.
127
+ If `src/baml_sdk/` does not exist, the first use of `describe_graph`, `describe_ebm` or `explain_instance` runs
128
+ `baml generate`. `import ebaml` alone does not run it. If the package was generated by another BAML toolchain than the one
129
+ that `baml-bridge` expects (a version skew), the first use runs `baml toolchain use <version>` and `baml generate`. If
130
+ the agent skill check stops `baml generate`, the first use runs it again with `--agent-skill-check off`. If none of this works, `SDKUnavailableError` lists the steps that fix the cause.
128
131
 
129
132
  ### 5. Check the setup
130
133
 
@@ -166,8 +169,8 @@ It fits a small EBM, runs the three-turn chain directly and checks that the prov
166
169
  ```python
167
170
  from interpret.glassbox import ExplainableBoostingClassifier
168
171
 
169
- from ebaml.llm.descriptors import describe_ebm, describe_graph
170
- from ebaml.llm.options import PromptOptions
172
+ from ebaml import describe_ebm, describe_graph
173
+ from ebaml import PromptOptions
171
174
 
172
175
  ebm = ExplainableBoostingClassifier().fit(X, y)
173
176
 
@@ -181,7 +184,7 @@ embedded in a longer prompt. It needs the confidence bounds, and it only reads c
181
184
  Three keyword-only arguments set the options. `graph=GraphOptions(...)` sets the options of `EBMGraph.from_ebm` and
182
185
  `EBMGraph.to_text`, for example `max_tokens`. `prompt=PromptOptions(...)` sets the descriptions that the prompts use
183
186
  (`expert_description`, `graph_description`, `dataset_description` and `task_description`). `model=` selects the LLM, see
184
- "Choosing the model". The classes are in `ebaml.llm.options`. Token usage reported by the provider is logged at `INFO` on the `ebaml.llm.descriptors` logger.
187
+ "Choosing the model". `GraphOptions`, `PromptOptions` and `ModelOptions` are importable from `ebaml`. Token usage reported by the provider is logged at `INFO` on the `ebaml.llm.descriptors` logger.
185
188
 
186
189
  A multiclass classifier has one graph series per class. `GraphOptions(classes=[...])` selects the classes to describe,
187
190
  because the text of a model with many classes is long. In every bin, the scores have the same mean over all the classes
@@ -196,7 +199,7 @@ y_multiclass = np.select([X["age"] < 30, X["age"] < 60], ["young", "middle"], "o
196
199
  -->
197
200
 
198
201
  ```python
199
- from ebaml.llm.options import GraphOptions
202
+ from ebaml import GraphOptions
200
203
 
201
204
  multiclass = ExplainableBoostingClassifier(interactions=0).fit(X, y_multiclass)
202
205
  print(describe_graph(multiclass, feature_index=0, graph=GraphOptions(classes=["young", "old"])))
@@ -205,7 +208,7 @@ print(describe_graph(multiclass, feature_index=0, graph=GraphOptions(classes=["y
205
208
  ### Explaining one prediction
206
209
 
207
210
  ```python
208
- from ebaml.llm.descriptors import describe_ebm, explain_instance
211
+ from ebaml import describe_ebm, explain_instance
209
212
 
210
213
  ebm = ExplainableBoostingClassifier(interactions=0).fit(X, y) # binary classifier, no interactions
211
214
  global_explanation = describe_ebm(ebm) # computed once, prepended to every local prompt
@@ -241,6 +244,7 @@ of `ebaml` apart from the errors of other code. Each error for a bad value also
241
244
  | `EBMGraphShapeError` | yes | The bins of a graph do not fit its scores, the scores and the standard deviations have different shapes, or a boolean format gets more than two bins. |
242
245
  | `EBMGraphTokenLimitError` | no | The text of a graph is over the token budget, and its format cannot be simplified. |
243
246
  | `EBMGraphSimplificationError` | no | The text of a graph is still over the token budget at the largest simplification. |
247
+ | `TokenFitError` | yes | The token weights cannot be fitted from an empty list of samples, or a weight is negative or not finite. |
244
248
  | `SDKUnavailableError` | no | `baml_sdk` is missing, and `ebaml` cannot run `baml generate`. The error also derives from `ImportError`. |
245
249
  | `LLMRequestError` | no | The base class of the errors of a provider. Its message lists the steps that fix the cause. |
246
250
  | `MissingAPIKeyError` | no | A provider needs an API key and the environment has none. |
@@ -248,8 +252,7 @@ of `ebaml` apart from the errors of other code. Each error for a bad value also
248
252
  | `RateLimitedError` | no | A provider limits the rate of the requests. |
249
253
  | `ProviderUnreachableError` | no | A request does not reach the provider. |
250
254
 
251
- `EBMGraphShapeError`, `EBMGraphTokenLimitError` and `EBMGraphSimplificationError` derive from `EBMGraphError`. The four provider errors derive from `LLMRequestError`. All classes are in `ebaml.core.exceptions`, and `ebaml` exports
252
- them too.
255
+ `EBMGraphShapeError`, `EBMGraphTokenLimitError` and `EBMGraphSimplificationError` derive from `EBMGraphError`. The four provider errors derive from `LLMRequestError`. `ebaml` exports all of these classes.
253
256
 
254
257
  <!-- --8<-- [end:usage] -->
255
258
  ## How it works
@@ -279,11 +282,19 @@ them too.
279
282
  rejects are not retried.
280
283
  - **Concurrency:** `describe_ebm` describes features concurrently, at most `max_concurrency` at a time (default 8).
281
284
  Free models are rate limited, so lower it (`describe_ebm(ebm, max_concurrency=2)`) if you see rate-limit errors.
282
- - **Token budget:** there is no tokenizer before a call, so the check uses a rough estimate (about 3 characters per
283
- token). Going a little over `max_tokens` only warns. Going more than `overbudget_percent` (default 50) over makes
284
- `to_text` simplify the graph, or raise if it cannot. The provider's own error is the real limit. The functions in
285
- `ebaml.llm.descriptors` pass the check. A direct call of `EBMGraph.to_text` checks nothing, unless you pass
286
- `check_budget`, for example `ebaml.graphs.token_budget.check_token_budget`. That check needs no LLM and no key.
285
+ - **Token budget:** there is no tokenizer before a call, so the check estimates the tokens of a graph text from its
286
+ words and its digits. The default weights are 4.13 tokens for each word and 0.27 for each digit. They come from 100
287
+ graph texts that one current model counted. The estimate has a margin above the fit, so it is more often too high
288
+ than too low. Other models count other numbers of tokens, so the estimate is a guide. Going a little over
289
+ `max_tokens` only warns. Going more than `overbudget_percent` (default 50) over makes `to_text` simplify the graph, or
290
+ raise if it cannot. The provider's own error is the real limit. `describe_graph`, `describe_ebm` and `explain_instance` pass the
291
+ check. A direct call of `EBMGraph.to_text` checks nothing, unless you pass `check_budget`, for example
292
+ `ebaml.check_token_budget`. That check needs no LLM and no key. To choose the weights, pass a
293
+ `TokenEstimator` instead. To use the weights of each model and to learn them, pass
294
+ `GraphOptions(token_learner=TokenLearner(learning=True))`. The learner starts each model at the weights of a table
295
+ that ships with the package. Then it moves them toward the tokens of the graphs in your real calls. The weights
296
+ persist in `~/.cache/ebaml/token_weights.json`. Learning is off by default, because learned weights change the graph
297
+ text from one call to the next. `scripts/fit_token_weights.py` adds the weights of a new model to the table.
287
298
 
288
299
  <!-- --8<-- [end:behaviour] -->
289
300
  ## Notebook
@@ -356,7 +367,7 @@ request of that call to that model. You do not change the package.
356
367
  Pass the shorthand `"provider/model"`:
357
368
 
358
369
  ```python
359
- from ebaml.llm.descriptors import describe_ebm
370
+ from ebaml import describe_ebm
360
371
 
361
372
  print(describe_ebm(ebm, model="anthropic/claude-haiku-4-5"))
362
373
  ```
@@ -364,7 +375,7 @@ print(describe_ebm(ebm, model="anthropic/claude-haiku-4-5"))
364
375
  Pass `ModelOptions` to set more:
365
376
 
366
377
  ```python
367
- from ebaml.llm.options import ModelOptions
378
+ from ebaml import ModelOptions
368
379
 
369
380
  model = ModelOptions(provider="anthropic", model="claude-haiku-4-5", temperature=0.2, max_output_tokens=8000)
370
381
  print(describe_ebm(ebm, model=model))
@@ -93,10 +93,10 @@ baml generate
93
93
  This writes the `src/baml_sdk/` package from `baml_src/`, next to `ebaml`, so it imports wherever the project is
94
94
  installed. Rerun it every time a `.baml` file changes, including when you change the provider.
95
95
 
96
- If `src/baml_sdk/` does not exist, `ebaml.llm.descriptors` runs `baml generate` when you import it. If the package was
97
- generated by another BAML toolchain than the one that `baml-bridge` expects (a version skew), the import runs
98
- `baml toolchain use <version>` and `baml generate`. If the agent skill check stops `baml generate`, the import runs it
99
- again with `--agent-skill-check off`. If none of this works, `SDKUnavailableError` lists the steps that fix the cause.
96
+ If `src/baml_sdk/` does not exist, the first use of `describe_graph`, `describe_ebm` or `explain_instance` runs
97
+ `baml generate`. `import ebaml` alone does not run it. If the package was generated by another BAML toolchain than the one
98
+ that `baml-bridge` expects (a version skew), the first use runs `baml toolchain use <version>` and `baml generate`. If
99
+ the agent skill check stops `baml generate`, the first use runs it again with `--agent-skill-check off`. If none of this works, `SDKUnavailableError` lists the steps that fix the cause.
100
100
 
101
101
  ### 5. Check the setup
102
102
 
@@ -138,8 +138,8 @@ It fits a small EBM, runs the three-turn chain directly and checks that the prov
138
138
  ```python
139
139
  from interpret.glassbox import ExplainableBoostingClassifier
140
140
 
141
- from ebaml.llm.descriptors import describe_ebm, describe_graph
142
- from ebaml.llm.options import PromptOptions
141
+ from ebaml import describe_ebm, describe_graph
142
+ from ebaml import PromptOptions
143
143
 
144
144
  ebm = ExplainableBoostingClassifier().fit(X, y)
145
145
 
@@ -153,7 +153,7 @@ embedded in a longer prompt. It needs the confidence bounds, and it only reads c
153
153
  Three keyword-only arguments set the options. `graph=GraphOptions(...)` sets the options of `EBMGraph.from_ebm` and
154
154
  `EBMGraph.to_text`, for example `max_tokens`. `prompt=PromptOptions(...)` sets the descriptions that the prompts use
155
155
  (`expert_description`, `graph_description`, `dataset_description` and `task_description`). `model=` selects the LLM, see
156
- "Choosing the model". The classes are in `ebaml.llm.options`. Token usage reported by the provider is logged at `INFO` on the `ebaml.llm.descriptors` logger.
156
+ "Choosing the model". `GraphOptions`, `PromptOptions` and `ModelOptions` are importable from `ebaml`. Token usage reported by the provider is logged at `INFO` on the `ebaml.llm.descriptors` logger.
157
157
 
158
158
  A multiclass classifier has one graph series per class. `GraphOptions(classes=[...])` selects the classes to describe,
159
159
  because the text of a model with many classes is long. In every bin, the scores have the same mean over all the classes
@@ -168,7 +168,7 @@ y_multiclass = np.select([X["age"] < 30, X["age"] < 60], ["young", "middle"], "o
168
168
  -->
169
169
 
170
170
  ```python
171
- from ebaml.llm.options import GraphOptions
171
+ from ebaml import GraphOptions
172
172
 
173
173
  multiclass = ExplainableBoostingClassifier(interactions=0).fit(X, y_multiclass)
174
174
  print(describe_graph(multiclass, feature_index=0, graph=GraphOptions(classes=["young", "old"])))
@@ -177,7 +177,7 @@ print(describe_graph(multiclass, feature_index=0, graph=GraphOptions(classes=["y
177
177
  ### Explaining one prediction
178
178
 
179
179
  ```python
180
- from ebaml.llm.descriptors import describe_ebm, explain_instance
180
+ from ebaml import describe_ebm, explain_instance
181
181
 
182
182
  ebm = ExplainableBoostingClassifier(interactions=0).fit(X, y) # binary classifier, no interactions
183
183
  global_explanation = describe_ebm(ebm) # computed once, prepended to every local prompt
@@ -213,6 +213,7 @@ of `ebaml` apart from the errors of other code. Each error for a bad value also
213
213
  | `EBMGraphShapeError` | yes | The bins of a graph do not fit its scores, the scores and the standard deviations have different shapes, or a boolean format gets more than two bins. |
214
214
  | `EBMGraphTokenLimitError` | no | The text of a graph is over the token budget, and its format cannot be simplified. |
215
215
  | `EBMGraphSimplificationError` | no | The text of a graph is still over the token budget at the largest simplification. |
216
+ | `TokenFitError` | yes | The token weights cannot be fitted from an empty list of samples, or a weight is negative or not finite. |
216
217
  | `SDKUnavailableError` | no | `baml_sdk` is missing, and `ebaml` cannot run `baml generate`. The error also derives from `ImportError`. |
217
218
  | `LLMRequestError` | no | The base class of the errors of a provider. Its message lists the steps that fix the cause. |
218
219
  | `MissingAPIKeyError` | no | A provider needs an API key and the environment has none. |
@@ -220,8 +221,7 @@ of `ebaml` apart from the errors of other code. Each error for a bad value also
220
221
  | `RateLimitedError` | no | A provider limits the rate of the requests. |
221
222
  | `ProviderUnreachableError` | no | A request does not reach the provider. |
222
223
 
223
- `EBMGraphShapeError`, `EBMGraphTokenLimitError` and `EBMGraphSimplificationError` derive from `EBMGraphError`. The four provider errors derive from `LLMRequestError`. All classes are in `ebaml.core.exceptions`, and `ebaml` exports
224
- them too.
224
+ `EBMGraphShapeError`, `EBMGraphTokenLimitError` and `EBMGraphSimplificationError` derive from `EBMGraphError`. The four provider errors derive from `LLMRequestError`. `ebaml` exports all of these classes.
225
225
 
226
226
  <!-- --8<-- [end:usage] -->
227
227
  ## How it works
@@ -251,11 +251,19 @@ them too.
251
251
  rejects are not retried.
252
252
  - **Concurrency:** `describe_ebm` describes features concurrently, at most `max_concurrency` at a time (default 8).
253
253
  Free models are rate limited, so lower it (`describe_ebm(ebm, max_concurrency=2)`) if you see rate-limit errors.
254
- - **Token budget:** there is no tokenizer before a call, so the check uses a rough estimate (about 3 characters per
255
- token). Going a little over `max_tokens` only warns. Going more than `overbudget_percent` (default 50) over makes
256
- `to_text` simplify the graph, or raise if it cannot. The provider's own error is the real limit. The functions in
257
- `ebaml.llm.descriptors` pass the check. A direct call of `EBMGraph.to_text` checks nothing, unless you pass
258
- `check_budget`, for example `ebaml.graphs.token_budget.check_token_budget`. That check needs no LLM and no key.
254
+ - **Token budget:** there is no tokenizer before a call, so the check estimates the tokens of a graph text from its
255
+ words and its digits. The default weights are 4.13 tokens for each word and 0.27 for each digit. They come from 100
256
+ graph texts that one current model counted. The estimate has a margin above the fit, so it is more often too high
257
+ than too low. Other models count other numbers of tokens, so the estimate is a guide. Going a little over
258
+ `max_tokens` only warns. Going more than `overbudget_percent` (default 50) over makes `to_text` simplify the graph, or
259
+ raise if it cannot. The provider's own error is the real limit. `describe_graph`, `describe_ebm` and `explain_instance` pass the
260
+ check. A direct call of `EBMGraph.to_text` checks nothing, unless you pass `check_budget`, for example
261
+ `ebaml.check_token_budget`. That check needs no LLM and no key. To choose the weights, pass a
262
+ `TokenEstimator` instead. To use the weights of each model and to learn them, pass
263
+ `GraphOptions(token_learner=TokenLearner(learning=True))`. The learner starts each model at the weights of a table
264
+ that ships with the package. Then it moves them toward the tokens of the graphs in your real calls. The weights
265
+ persist in `~/.cache/ebaml/token_weights.json`. Learning is off by default, because learned weights change the graph
266
+ text from one call to the next. `scripts/fit_token_weights.py` adds the weights of a new model to the table.
259
267
 
260
268
  <!-- --8<-- [end:behaviour] -->
261
269
  ## Notebook
@@ -328,7 +336,7 @@ request of that call to that model. You do not change the package.
328
336
  Pass the shorthand `"provider/model"`:
329
337
 
330
338
  ```python
331
- from ebaml.llm.descriptors import describe_ebm
339
+ from ebaml import describe_ebm
332
340
 
333
341
  print(describe_ebm(ebm, model="anthropic/claude-haiku-4-5"))
334
342
  ```
@@ -336,7 +344,7 @@ print(describe_ebm(ebm, model="anthropic/claude-haiku-4-5"))
336
344
  Pass `ModelOptions` to set more:
337
345
 
338
346
  ```python
339
- from ebaml.llm.options import ModelOptions
347
+ from ebaml import ModelOptions
340
348
 
341
349
  model = ModelOptions(provider="anthropic", model="claude-haiku-4-5", temperature=0.2, max_output_tokens=8000)
342
350
  print(describe_ebm(ebm, model=model))
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ebaml"
3
- version = "0.3.1"
3
+ version = "0.3.3"
4
4
  description = "BAML for Explainable Boosting Machines: talk to your EBM."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -26,7 +26,10 @@ dependencies = [
26
26
  "baml-bridge>=0.23.0",
27
27
  "beartype>=0.23.1",
28
28
  "interpret>=0.7.8",
29
+ "numpy>=2.5.4",
29
30
  "orjson>=3.13.0",
31
+ "pandas>=3.0.6",
32
+ "scipy>=1.18.1",
30
33
  "structlog>=26.1.0",
31
34
  ]
32
35
 
@@ -51,9 +54,6 @@ override-dependencies = [
51
54
  "opentelemetry-instrumentation-threading>=0.66b0",
52
55
  ]
53
56
 
54
- [tool.uv.exclude-newer-package]
55
- baml-bridge = false
56
-
57
57
  [tool.uv.build-backend]
58
58
  module-name = [
59
59
  "ebaml",
@@ -254,6 +254,12 @@ entry_title_template = "[{{ version }}] - {{ date.strftime('%Y-%m-%d') }}"
254
254
  [tool.commitizen]
255
255
  name = "cz_conventional_commits"
256
256
 
257
+ [tool.deptry]
258
+ known_first_party = [
259
+ "ebaml",
260
+ "baml_sdk",
261
+ ]
262
+
257
263
  [build-system]
258
264
  requires = ["uv_build>=0.12.3,<0.13.0"]
259
265
  build-backend = "uv_build"
@@ -261,6 +267,7 @@ build-backend = "uv_build"
261
267
  [dependency-groups]
262
268
  dev = [
263
269
  "cosmic-ray>=8.7.0",
270
+ "deptry>=0.25.1",
264
271
  "hypothesis>=6.170.1",
265
272
  "import-linter>=2.15",
266
273
  "marimo>=0.25.1",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ebaml"
3
- version = "0.3.1"
3
+ version = "0.3.3"
4
4
  description = "BAML for Explainable Boosting Machines: talk to your EBM."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -23,7 +23,10 @@ dependencies = [
23
23
  "baml-bridge>=0.23.0",
24
24
  "beartype>=0.23.1",
25
25
  "interpret>=0.7.8",
26
+ "numpy>=2.5.4",
26
27
  "orjson>=3.13.0",
28
+ "pandas>=3.0.6",
29
+ "scipy>=1.18.1",
27
30
  "structlog>=26.1.0",
28
31
  ]
29
32
 
@@ -36,10 +39,6 @@ Changelog = "https://github.com/johnny-godoy/EBaMl/blob/main/CHANGELOG.md"
36
39
  [tool.uv]
37
40
  # A relative span keeps the cutoff 7 days behind today, so uv never picks a release that is less than 7 days old.
38
41
  exclude-newer = "7 days"
39
- # reason: baml-bridge must match the BAML toolchain that generates src/baml_sdk, or the SDK fails at start with a version
40
- # skew error. CI installs the newest toolchain, and toolchain 0.23.0 changed the ai.Client interface, so the repository
41
- # needs baml-bridge 0.23.0 at once. Remove the entry once 0.23.0 is more than 7 days old.
42
- exclude-newer-package = { baml-bridge = false }
43
42
  # reason: semgrep 1.182.1 pins mcp==1.29.0 and opentelemetry-api~=1.37.0, which have 5 known CVEs fixed in mcp 1.30.0
44
43
  # and opentelemetry-api 1.45.1. Dependabot cannot update them, so the override forces the fixed releases. The
45
44
  # opentelemetry packages must move together, because semgrep fails to import with opentelemetry-api 1.45 and the older
@@ -137,6 +136,7 @@ select = ["ALL"]
137
136
  [dependency-groups]
138
137
  dev = [
139
138
  "cosmic-ray>=8.7.0",
139
+ "deptry>=0.25.1",
140
140
  "hypothesis>=6.170.1",
141
141
  "import-linter>=2.15",
142
142
  "marimo>=0.25.1",
@@ -297,3 +297,8 @@ entry_title_template = "[{{ version }}] - {{ date.strftime('%Y-%m-%d') }}"
297
297
  # version, so `cz bump` and `cz changelog` are not used.
298
298
  [tool.commitizen]
299
299
  name = "cz_conventional_commits"
300
+
301
+ [tool.deptry]
302
+ # reason: baml_sdk is generated into src/ and gitignored, and the build backend ships it with ebaml (module-name), so
303
+ # deptry cannot see it as part of this project without a hint.
304
+ known_first_party = ["ebaml", "baml_sdk"]
@@ -7,15 +7,15 @@
7
7
  },
8
8
  {
9
9
  "relative_path": "__init__.py",
10
- "sha256": "cd987ae33762c18e019c2740a626191acca2454e7a35fd52cd6063b6e5d5c42d"
10
+ "sha256": "11cf64083463a9485f91b97d373f878b5ff4a21d9f5f589fd725fd862da9e795"
11
11
  },
12
12
  {
13
13
  "relative_path": "__init__.pyi",
14
- "sha256": "d68b10a3c05704baf4a241201249b88bdf4f074927a3fe044c2ecd948b78ff45"
14
+ "sha256": "2adc45c6784bc52f6d387b8926e100b389042d141371497b0be8ab13ca932e6a"
15
15
  },
16
16
  {
17
17
  "relative_path": "_baml_sources.py",
18
- "sha256": "89bee5a4d1cefe54e077aff3b3bc5b32671d534a73f2babdeff6aa57d63a0fe3"
18
+ "sha256": "8e45b190c4b11962a079e69e3ef56aa96b5f0e923d146252aa21856ce1c69d4c"
19
19
  },
20
20
  {
21
21
  "relative_path": "_function_registry.py",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  {
25
25
  "relative_path": "_inlinedbaml.py",
26
- "sha256": "a627d0980e34c1c28a38c927a23b3fa6f01ad6db8aa2d9eeb127d8ac6af048e9"
26
+ "sha256": "5dcca56a5ab2bd2fa238ab2d055e5951308c865381f7cced2b8d149a8e748a96"
27
27
  },
28
28
  {
29
29
  "relative_path": "_invocation_types.py",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  {
37
37
  "relative_path": "_typemap.py",
38
- "sha256": "9d0cd9e6eaebf67d231d0f54c4f43f24a70a307632c7ca8ebd738023e24191c8"
38
+ "sha256": "df5ba3535ab9a4b8521541e49409c61c5c2600ff4bd6855ead4fb3f138506540"
39
39
  },
40
40
  {
41
41
  "relative_path": "ai/__init__.py",
@@ -534,46 +534,53 @@ EbmSummaryShorten_stream_async.__doc__ = """Raises:
534
534
  CompilationError, SpanError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
535
535
 
536
536
 
537
- class TokenUsage(pydantic.BaseModel):
537
+ class TokenSample(pydantic.BaseModel):
538
538
  model_config = pydantic.ConfigDict(
539
539
  arbitrary_types_allowed=True,
540
540
  extra="ignore",
541
541
  populate_by_name=True,
542
542
  )
543
+ provider: str
544
+ model: str
545
+ body: str
543
546
  input_tokens: int
544
- output_tokens: int
545
547
 
546
548
 
547
- class Counted(pydantic.BaseModel):
549
+ class TokenUsage(pydantic.BaseModel):
548
550
  model_config = pydantic.ConfigDict(
549
551
  arbitrary_types_allowed=True,
550
552
  extra="ignore",
551
553
  populate_by_name=True,
552
554
  )
553
- text: str
554
- usage: TokenUsage
555
+ input_tokens: int
556
+ output_tokens: int
557
+ samples: typing.List[TokenSample]
555
558
 
556
559
 
557
- class TokenBudget(pydantic.BaseModel):
560
+ class Counted(pydantic.BaseModel):
558
561
  model_config = pydantic.ConfigDict(
559
562
  arbitrary_types_allowed=True,
560
563
  extra="ignore",
561
564
  populate_by_name=True,
562
565
  )
563
- estimated_tokens: int
564
- status: typing.Union[typing.Literal["ok"], typing.Literal["warn"], typing.Literal["over"]]
566
+ text: str
567
+ usage: TokenUsage
565
568
 
566
569
 
567
570
  add_usage = _define_function("user.add_usage", "sync", ["a", "b"], binding_name="add_usage", binding_qualname="add_usage", binding_module=__name__)
568
571
  add_usage_async = _define_function("user.add_usage", "async", ["a", "b"], binding_name="add_usage_async", binding_qualname="add_usage_async", binding_module=__name__)
569
572
 
570
573
 
571
- estimate_tokens = _define_function("user.estimate_tokens", "sync", ["text"], binding_name="estimate_tokens", binding_qualname="estimate_tokens", binding_module=__name__)
572
- estimate_tokens_async = _define_function("user.estimate_tokens", "async", ["text"], binding_name="estimate_tokens_async", binding_qualname="estimate_tokens_async", binding_module=__name__)
574
+ input_total = _define_function("user.input_total", "sync", ["usage"], binding_name="input_total", binding_qualname="input_total", binding_module=__name__)
575
+ input_total_async = _define_function("user.input_total", "async", ["usage"], binding_name="input_total_async", binding_qualname="input_total_async", binding_module=__name__)
576
+
577
+
578
+ sample_of = _define_function("user.sample_of", "sync", ["call"], binding_name="sample_of", binding_qualname="sample_of", binding_module=__name__)
579
+ sample_of_async = _define_function("user.sample_of", "async", ["call"], binding_name="sample_of_async", binding_qualname="sample_of_async", binding_module=__name__)
573
580
 
574
581
 
575
- check_token_budget = _define_function("user.check_token_budget", "sync", ["text", "max_tokens", "overbudget_percent"], binding_name="check_token_budget", binding_qualname="check_token_budget", binding_module=__name__)
576
- check_token_budget_async = _define_function("user.check_token_budget", "async", ["text", "max_tokens", "overbudget_percent"], binding_name="check_token_budget_async", binding_qualname="check_token_budget_async", binding_module=__name__)
582
+ samples_of = _define_function("user.samples_of", "sync", ["events"], binding_name="samples_of", binding_qualname="samples_of", binding_module=__name__)
583
+ samples_of_async = _define_function("user.samples_of", "async", ["events"], binding_name="samples_of_async", binding_qualname="samples_of_async", binding_module=__name__)
577
584
 
578
585
 
579
586
  run_counted = _define_function("user.run_counted", "sync", ["spec"], ["client"], binding_name="run_counted", binding_qualname="run_counted", binding_module=__name__)
@@ -584,6 +591,14 @@ run_counted_async.__doc__ = """Raises:
584
591
  CompilationError, InvalidArgument, Timeout, UnknownError"""
585
592
 
586
593
 
594
+ sample_graph_tokens = _define_function("user.sample_graph_tokens", "sync", ["graph", "opts"], ["client", "model"], binding_name="sample_graph_tokens", binding_qualname="sample_graph_tokens", binding_module=__name__)
595
+ sample_graph_tokens.__doc__ = """Raises:
596
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
597
+ sample_graph_tokens_async = _define_function("user.sample_graph_tokens", "async", ["graph", "opts"], ["client", "model"], binding_name="sample_graph_tokens_async", binding_qualname="sample_graph_tokens_async", binding_module=__name__)
598
+ sample_graph_tokens_async.__doc__ = """Raises:
599
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
600
+
601
+
587
602
  describe_graph_cot = _define_function("user.describe_graph_cot", "sync", ["graph", "num_sentences", "opts"], ["client", "model"], binding_name="describe_graph_cot", binding_qualname="describe_graph_cot", binding_module=__name__)
588
603
  describe_graph_cot.__doc__ = """Raises:
589
604
  CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
@@ -719,6 +734,31 @@ class SummaryEchoClient(pydantic.BaseModel):
719
734
  )
720
735
 
721
736
 
737
+ usage_with = _define_function("user.usage_with", "sync", ["input_tokens", "uncached", "cached", "written"], binding_name="usage_with", binding_qualname="usage_with", binding_module=__name__)
738
+ usage_with_async = _define_function("user.usage_with", "async", ["input_tokens", "uncached", "cached", "written"], binding_name="usage_with_async", binding_qualname="usage_with_async", binding_module=__name__)
739
+
740
+
741
+ call_with = _define_function("user.call_with", "sync", ["model", "body", "usage"], binding_name="call_with", binding_qualname="call_with", binding_module=__name__)
742
+ call_with_async = _define_function("user.call_with", "async", ["model", "body", "usage"], binding_name="call_with_async", binding_qualname="call_with_async", binding_module=__name__)
743
+
744
+
745
+ class SampledClient(pydantic.BaseModel):
746
+ model_config = pydantic.ConfigDict(
747
+ arbitrary_types_allowed=True,
748
+ extra="ignore",
749
+ populate_by_name=True,
750
+ )
751
+
752
+
753
+ class FailingClient(pydantic.BaseModel):
754
+ model_config = pydantic.ConfigDict(
755
+ arbitrary_types_allowed=True,
756
+ extra="ignore",
757
+ populate_by_name=True,
758
+ )
759
+ cut_off: bool
760
+
761
+
722
762
  __all__ = [
723
763
  "benchmark_sample",
724
764
  "benchmark_sample_async",
@@ -871,17 +911,21 @@ __all__ = [
871
911
  "EbmSummaryShorten_spec_async",
872
912
  "EbmSummaryShorten_stream",
873
913
  "EbmSummaryShorten_stream_async",
914
+ "TokenSample",
874
915
  "TokenUsage",
875
916
  "Counted",
876
- "TokenBudget",
877
917
  "add_usage",
878
918
  "add_usage_async",
879
- "estimate_tokens",
880
- "estimate_tokens_async",
881
- "check_token_budget",
882
- "check_token_budget_async",
919
+ "input_total",
920
+ "input_total_async",
921
+ "sample_of",
922
+ "sample_of_async",
923
+ "samples_of",
924
+ "samples_of_async",
883
925
  "run_counted",
884
926
  "run_counted_async",
927
+ "sample_graph_tokens",
928
+ "sample_graph_tokens_async",
885
929
  "describe_graph_cot",
886
930
  "describe_graph_cot_async",
887
931
  "summarize_ebm",
@@ -917,6 +961,12 @@ __all__ = [
917
961
  "text_turn_async",
918
962
  "TaggedEchoClient",
919
963
  "SummaryEchoClient",
964
+ "usage_with",
965
+ "usage_with_async",
966
+ "call_with",
967
+ "call_with_async",
968
+ "SampledClient",
969
+ "FailingClient",
920
970
  ]
921
971
 
922
972
  # BEP-066 host reflection surface.