ebaml 0.7.1__tar.gz → 0.7.2__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 (203) hide show
  1. {ebaml-0.7.1 → ebaml-0.7.2}/PKG-INFO +1 -1
  2. {ebaml-0.7.1 → ebaml-0.7.2}/pyproject.toml +1 -1
  3. {ebaml-0.7.1 → ebaml-0.7.2}/pyproject.toml.orig +1 -1
  4. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/__init__.py +2 -2
  5. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/descriptors.py +2 -1
  6. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/requests.py +1 -1
  7. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/audience.py +1 -1
  8. ebaml-0.7.2/src/ebaml/local/completions.py +101 -0
  9. ebaml-0.7.2/src/ebaml/local/counterfactuals.py +281 -0
  10. ebaml-0.7.2/src/ebaml/local/fact_features.py +329 -0
  11. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/fact_text.py +1 -1
  12. ebaml-0.7.2/src/ebaml/local/fact_types.py +230 -0
  13. ebaml-0.7.2/src/ebaml/local/facts.py +179 -0
  14. ebaml-0.7.2/src/ebaml/local/sufficient_reasons.py +207 -0
  15. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/mcp/explain_tools.py +2 -1
  16. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/mcp/server.py +31 -4
  17. ebaml-0.7.1/src/ebaml/local/facts.py +0 -1274
  18. {ebaml-0.7.1 → ebaml-0.7.2}/LICENSE +0 -0
  19. {ebaml-0.7.1 → ebaml-0.7.2}/README.md +0 -0
  20. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/.baml-generator-output-root +0 -0
  21. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/.baml-generator-output.json +0 -0
  22. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/__init__.py +0 -0
  23. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/__init__.pyi +0 -0
  24. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/_baml_sources.py +0 -0
  25. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/_function_registry.py +0 -0
  26. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/_inlinedbaml.py +0 -0
  27. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/_invocation_types.py +0 -0
  28. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/_invocation_types.pyi +0 -0
  29. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/_typemap.py +0 -0
  30. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/__init__.py +0 -0
  31. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/__init__.pyi +0 -0
  32. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/clients/__init__.py +0 -0
  33. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/clients/__init__.pyi +0 -0
  34. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/content/__init__.py +0 -0
  35. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/content/__init__.pyi +0 -0
  36. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/errors/__init__.py +0 -0
  37. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/errors/__init__.pyi +0 -0
  38. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/events/__init__.py +0 -0
  39. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/events/__init__.pyi +0 -0
  40. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/internal/__init__.py +0 -0
  41. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/internal/__init__.pyi +0 -0
  42. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/mcp/__init__.py +0 -0
  43. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/mcp/__init__.pyi +0 -0
  44. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/stream/__init__.py +0 -0
  45. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/stream/__init__.pyi +0 -0
  46. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/tools/__init__.py +0 -0
  47. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/tools/__init__.pyi +0 -0
  48. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/wire/__init__.py +0 -0
  49. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/ai/wire/__init__.pyi +0 -0
  50. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/__init__.py +0 -0
  51. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/__init__.pyi +0 -0
  52. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/crypto/__init__.py +0 -0
  53. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/crypto/__init__.pyi +0 -0
  54. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/csv/__init__.py +0 -0
  55. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/csv/__init__.pyi +0 -0
  56. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/env/__init__.py +0 -0
  57. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/env/__init__.pyi +0 -0
  58. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/errors/__init__.py +0 -0
  59. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/errors/__init__.pyi +0 -0
  60. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/fs/__init__.py +0 -0
  61. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/fs/__init__.pyi +0 -0
  62. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/future/__init__.py +0 -0
  63. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/future/__init__.pyi +0 -0
  64. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/glob/__init__.py +0 -0
  65. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/glob/__init__.pyi +0 -0
  66. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/hash/__init__.py +0 -0
  67. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/hash/__init__.pyi +0 -0
  68. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/host/__init__.py +0 -0
  69. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/host/__init__.pyi +0 -0
  70. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/http/__init__.py +0 -0
  71. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/http/__init__.pyi +0 -0
  72. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/io/__init__.py +0 -0
  73. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/io/__init__.pyi +0 -0
  74. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/iter/__init__.py +0 -0
  75. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/iter/__init__.pyi +0 -0
  76. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/json/__init__.py +0 -0
  77. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/json/__init__.pyi +0 -0
  78. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/media/__init__.py +0 -0
  79. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/media/__init__.pyi +0 -0
  80. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/net/__init__.py +0 -0
  81. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/net/__init__.pyi +0 -0
  82. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/ops/__init__.py +0 -0
  83. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/ops/__init__.pyi +0 -0
  84. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/panics/__init__.py +0 -0
  85. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/panics/__init__.pyi +0 -0
  86. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/random/__init__.py +0 -0
  87. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/random/__init__.pyi +0 -0
  88. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/regex/__init__.py +0 -0
  89. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/regex/__init__.pyi +0 -0
  90. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/sap/__init__.py +0 -0
  91. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/sap/__init__.pyi +0 -0
  92. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/spawn/__init__.py +0 -0
  93. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/spawn/__init__.pyi +0 -0
  94. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/sys/__init__.py +0 -0
  95. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/sys/__init__.pyi +0 -0
  96. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/time/__init__.py +0 -0
  97. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/time/__init__.pyi +0 -0
  98. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/toml/__init__.py +0 -0
  99. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/toml/__init__.pyi +0 -0
  100. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/ws/__init__.py +0 -0
  101. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/ws/__init__.pyi +0 -0
  102. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/yaml/__init__.py +0 -0
  103. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/baml/yaml/__init__.pyi +0 -0
  104. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/experimental/__init__.py +0 -0
  105. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/experimental/__init__.pyi +0 -0
  106. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/py.typed +0 -0
  107. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/__init__.py +0 -0
  108. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/__init__.pyi +0 -0
  109. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/class_/__init__.py +0 -0
  110. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/class_/__init__.pyi +0 -0
  111. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/enum/__init__.py +0 -0
  112. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/enum/__init__.pyi +0 -0
  113. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/errors/__init__.py +0 -0
  114. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/errors/__init__.pyi +0 -0
  115. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/function/__init__.py +0 -0
  116. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/function/__init__.pyi +0 -0
  117. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/interface/__init__.py +0 -0
  118. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/reflect/interface/__init__.pyi +0 -0
  119. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/__init__.py +0 -0
  120. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/__init__.pyi +0 -0
  121. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/anthropic/__init__.py +0 -0
  122. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/anthropic/__init__.pyi +0 -0
  123. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/anthropic/internal/__init__.py +0 -0
  124. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/anthropic/internal/__init__.pyi +0 -0
  125. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/assert_/__init__.py +0 -0
  126. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/assert_/__init__.pyi +0 -0
  127. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/aws/__init__.py +0 -0
  128. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/aws/__init__.pyi +0 -0
  129. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/aws/internal/__init__.py +0 -0
  130. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/aws/internal/__init__.pyi +0 -0
  131. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/claude_code/__init__.py +0 -0
  132. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/claude_code/__init__.pyi +0 -0
  133. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/claude_code/internal/__init__.py +0 -0
  134. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/claude_code/internal/__init__.pyi +0 -0
  135. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/google/__init__.py +0 -0
  136. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/google/__init__.pyi +0 -0
  137. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/google/internal/__init__.py +0 -0
  138. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/google/internal/__init__.pyi +0 -0
  139. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/openai/__init__.py +0 -0
  140. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/openai/__init__.pyi +0 -0
  141. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/openai/internal/__init__.py +0 -0
  142. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/openai/internal/__init__.pyi +0 -0
  143. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/openai/internal/decisions/__init__.py +0 -0
  144. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/openai/internal/decisions/__init__.pyi +0 -0
  145. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/testing/__init__.py +0 -0
  146. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/testing/__init__.pyi +0 -0
  147. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/trace/__init__.py +0 -0
  148. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/trace/__init__.pyi +0 -0
  149. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/typesafeai/__init__.py +0 -0
  150. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/typesafeai/__init__.pyi +0 -0
  151. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/typesafeai/internal/__init__.py +0 -0
  152. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/typesafeai/internal/__init__.pyi +0 -0
  153. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/vercel/__init__.py +0 -0
  154. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/vercel/__init__.pyi +0 -0
  155. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/vercel/internal/__init__.py +0 -0
  156. {ebaml-0.7.1 → ebaml-0.7.2}/src/baml_sdk/vendor/vercel/internal/__init__.pyi +0 -0
  157. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/benchmark.py +0 -0
  158. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/core/__init__.py +0 -0
  159. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/core/beartype_hook.py +0 -0
  160. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/core/custom_types.py +0 -0
  161. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/core/ebm_classes.py +0 -0
  162. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/core/exceptions.py +0 -0
  163. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/__init__.py +0 -0
  164. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/edit_records.py +0 -0
  165. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/edit_report.py +0 -0
  166. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/edit_session.py +0 -0
  167. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/edits.py +0 -0
  168. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/history.py +0 -0
  169. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/model_view.py +0 -0
  170. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/model_write.py +0 -0
  171. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/revision_ids.py +0 -0
  172. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/edit/selections.py +0 -0
  173. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/__init__.py +0 -0
  174. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/ebm_graph.py +0 -0
  175. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/graph_text.py +0 -0
  176. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/model_kinds.py +0 -0
  177. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/request_text.py +0 -0
  178. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/terms.py +0 -0
  179. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/token_budget.py +0 -0
  180. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/graphs/token_weights.py +0 -0
  181. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/__init__.py +0 -0
  182. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/options.py +0 -0
  183. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/progress_bars.py +0 -0
  184. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/provider_errors.py +0 -0
  185. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/retry.py +0 -0
  186. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/sdk_setup.py +0 -0
  187. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/token_learning.py +0 -0
  188. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/llm/token_weights.json +0 -0
  189. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/__init__.py +0 -0
  190. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/covering_backend.py +0 -0
  191. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/covering_greedy.py +0 -0
  192. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/covering_problem.py +0 -0
  193. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/covering_solvers.py +0 -0
  194. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/decisions.py +0 -0
  195. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/local_kinds.py +0 -0
  196. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/minimality.py +0 -0
  197. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/local/ortools_backend.py +0 -0
  198. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/mcp/__init__.py +0 -0
  199. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/mcp/chat.py +0 -0
  200. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/mcp/llm_tools.py +0 -0
  201. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/mcp/model_store.py +0 -0
  202. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/mcp/read_tools.py +0 -0
  203. {ebaml-0.7.1 → ebaml-0.7.2}/src/ebaml/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ebaml
3
- Version: 0.7.1
3
+ Version: 0.7.2
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ebaml"
3
- version = "0.7.1"
3
+ version = "0.7.2"
4
4
  description = "BAML for Explainable Boosting Machines: talk to your EBM."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ebaml"
3
- version = "0.7.1"
3
+ version = "0.7.2"
4
4
  description = "BAML for Explainable Boosting Machines: talk to your EBM."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -102,7 +102,7 @@ from ebaml.local.covering_solvers import (
102
102
  )
103
103
  from ebaml.local.decisions import Decision, Interval, Threshold
104
104
  from ebaml.local.fact_text import FactTexts, facts_to_texts
105
- from ebaml.local.facts import (
105
+ from ebaml.local.fact_types import (
106
106
  Change,
107
107
  CompletionStep,
108
108
  Contribution,
@@ -111,8 +111,8 @@ from ebaml.local.facts import (
111
111
  LocalOptions,
112
112
  Prediction,
113
113
  SufficientReason,
114
- compute_local_facts,
115
114
  )
115
+ from ebaml.local.facts import compute_local_facts
116
116
  from ebaml.local.local_kinds import OutputKind
117
117
  from ebaml.local.minimality import MinimalityStatus
118
118
  from ebaml.local.ortools_backend import OrToolsBackend, OrToolsSolver
@@ -27,7 +27,8 @@ from ebaml.llm.retry import ShrinkingGraphCall, call_with_shrinking_graph
27
27
  from ebaml.llm.sdk_setup import ensure_sdk
28
28
  from ebaml.local.audience import resolve_audience
29
29
  from ebaml.local.fact_text import facts_to_texts
30
- from ebaml.local.facts import LocalFacts, compute_local_facts
30
+ from ebaml.local.fact_types import LocalFacts
31
+ from ebaml.local.facts import compute_local_facts
31
32
 
32
33
  # `baml_sdk` is generated and gitignored, so a checkout may lack it. Generate it before the import, or explain the fix.
33
34
  ensure_sdk()
@@ -12,7 +12,7 @@ import attrs
12
12
  from ebaml.core.custom_types import ExplainableBoostingModel, FeatureValue
13
13
  from ebaml.llm.options import GraphOptions, ModelOptions, PromptOptions
14
14
  from ebaml.local.audience import Audience
15
- from ebaml.local.facts import LocalOptions
15
+ from ebaml.local.fact_types import LocalOptions
16
16
 
17
17
 
18
18
  @attrs.frozen
@@ -21,7 +21,7 @@ from typing import override
21
21
 
22
22
  from ebaml.core.custom_types import JSONObject
23
23
  from ebaml.core.exceptions import InvalidOptionError
24
- from ebaml.local.facts import Change, Contribution, Prediction, SufficientReason
24
+ from ebaml.local.fact_types import Change, Contribution, Prediction, SufficientReason
25
25
  from ebaml.local.local_kinds import OutputKind
26
26
 
27
27
  _LIKELIHOOD_WORDS = (
@@ -0,0 +1,101 @@
1
+ """The completions of a partially known instance: the order that reveals features, and the share that agree."""
2
+
3
+ from collections.abc import Sequence
4
+
5
+ import numpy as np
6
+
7
+ from ebaml.local.fact_features import Feature
8
+ from ebaml.local.fact_types import CompletionStep, LocalOptions
9
+ from ebaml.local.sufficient_reasons import Bound, fixing_order, gain_table
10
+
11
+
12
+ def sample_completions(
13
+ features: Sequence[Feature],
14
+ order: Sequence[Feature],
15
+ bounds: Sequence[Bound],
16
+ options: LocalOptions,
17
+ ) -> list[CompletionStep]:
18
+ """Count completions, estimated by sampling the unknown features from their training bin weights.
19
+
20
+ The estimate has its own assumptions. The unknown features are independent. Each one takes every bin, also a bin
21
+ that ``min_support`` leaves out of the other two explanations, with the share of the training weight of the bin.
22
+ The scores are the fitted ones, so ``confidence_level`` does not change a share. One generator with the seed of
23
+ the options draws the bins once, and every step uses the same draws.
24
+
25
+ Parameters
26
+ ----------
27
+ features : Sequence[Feature]
28
+ The features.
29
+ order : Sequence[Feature]
30
+ The features in the order they are revealed.
31
+ bounds : Sequence[Bound]
32
+ The margins of the decision. A completion keeps the decision if every margin holds.
33
+ options : LocalOptions
34
+ Uses ``n_samples``, ``seed`` and ``max_steps``.
35
+
36
+ Returns
37
+ -------
38
+ list[CompletionStep]
39
+ The share of completions with the same prediction after revealing 0, 1, 2, ... features.
40
+
41
+ """
42
+ rng = np.random.default_rng(options.seed)
43
+ sampled_bins = {
44
+ f.name: rng.choice(len(f.weights), size=options.n_samples, p=f.weights / f.weights.sum()) for f in features
45
+ }
46
+ steps = []
47
+ for k in range(min(options.max_steps, len(order)) + 1):
48
+ known = {f.name for f in order[:k]}
49
+ holds = np.ones(options.n_samples, dtype=bool)
50
+ for bound in bounds:
51
+ views = [f.against(bound.columns) for f in features]
52
+ total = sum(v.current if v.name in known else v.scores[sampled_bins[v.name]] for v in views)
53
+ holds &= (bound.intercept + total > 0) == (bound.sign == 1)
54
+ steps.append(CompletionStep([f.name for f in order[:k]], float(np.mean(holds))))
55
+ return steps
56
+
57
+
58
+ def _by_smallest_gain(gains: Sequence[Sequence[float]]) -> list[int]:
59
+ """Order the features by the smallest gain over the margins, largest first.
60
+
61
+ A feature that helps one margin and does nothing for another one is no help for the claim, so the smallest gain is
62
+ the measure.
63
+
64
+ Parameters
65
+ ----------
66
+ gains : Sequence[Sequence[float]]
67
+ For each margin, the gain of each feature.
68
+
69
+ Returns
70
+ -------
71
+ list[int]
72
+ The positions of the features.
73
+
74
+ """
75
+ feature_count = len(gains[0])
76
+ return sorted(range(feature_count), key=lambda feature: -min(margin_gains[feature] for margin_gains in gains))
77
+
78
+
79
+ def reveal_order(features: Sequence[Feature], bounds: Sequence[Bound], z: float) -> list[Feature]:
80
+ """Order the features by how much knowing their value guarantees, largest first.
81
+
82
+ Parameters
83
+ ----------
84
+ features : Sequence[Feature]
85
+ The features to order.
86
+ bounds : Sequence[Bound]
87
+ The margins of the decision. A feature ranks by its smallest gain over these margins.
88
+ z : float
89
+ The number of standard deviations that each score moves against the claim.
90
+
91
+ Returns
92
+ -------
93
+ list[Feature]
94
+ The features in the order that the count-completions steps reveal them.
95
+
96
+ """
97
+ if len(bounds) == 1:
98
+ views = [f.against(bounds[0].columns) for f in features]
99
+ by_name = {f.name: f for f in features}
100
+ return [by_name[step.feature.name] for step in fixing_order(views, bounds[0].sign, z)]
101
+ return [features[index] for index in _by_smallest_gain(gain_table(features, bounds, z).gains)]
@@ -0,0 +1,281 @@
1
+ """The counterfactual of a prediction: the fewest changes that flip the decision, or reach a target class."""
2
+
3
+ import operator
4
+ from collections.abc import Callable, Sequence
5
+
6
+ import attrs
7
+ import numpy as np
8
+
9
+ from ebaml.local.covering_problem import CoveringProblem
10
+ from ebaml.local.decisions import Margin
11
+ from ebaml.local.fact_features import Feature, bin_label, robust_scores
12
+ from ebaml.local.fact_types import Change, Counterfactual, LocalOptions
13
+ from ebaml.local.local_kinds import LocalKind, Outcome, PredictionFrame
14
+ from ebaml.local.minimality import MinimalityStatus
15
+
16
+
17
+ def _counterfactual(
18
+ features: Sequence[Feature],
19
+ intercept: float,
20
+ sign: int,
21
+ z: float,
22
+ *,
23
+ after: Callable[[float, Sequence[tuple[Feature, int]]], Outcome],
24
+ ) -> Counterfactual | None:
25
+ """Minimum change required: the features with the largest possible drop in favour of the outcome, until it flips.
26
+
27
+ Parameters
28
+ ----------
29
+ features : Sequence[Feature]
30
+ The features.
31
+ intercept : float
32
+ The intercept of the model minus the threshold of the decision.
33
+ sign : int
34
+ ``1`` if the decision says that the score is high, ``-1`` otherwise.
35
+ z : float
36
+ Standard deviations to move the scores by.
37
+ after : Callable[[float, Sequence[tuple[Feature, int]]], Outcome]
38
+ The decision and the output of the model after the changes, from the margin after the changes and from each
39
+ changed feature with the bin that it takes.
40
+
41
+ Returns
42
+ -------
43
+ Counterfactual | None
44
+ The changes, or None if no changes flip the prediction.
45
+
46
+ """
47
+ margin = sign * intercept + sum(sign * f.current for f in features)
48
+ drops = []
49
+ for feature in features:
50
+ pessimistic = robust_scores(feature, sign, z, towards_outcome=False)
51
+ best = int(np.argmin(pessimistic))
52
+ drops.append((sign * feature.current - float(pessimistic[best]), best, feature))
53
+ ranked = sorted(drops, key=operator.itemgetter(0), reverse=True)
54
+ # the margin left after the first 1, 2, ... changes; the prediction flips at the first one below zero
55
+ flips = np.flatnonzero(margin - np.cumsum([drop for drop, _, _ in ranked]) < 0)
56
+ if not flips.size:
57
+ return None
58
+ changes = ranked[: flips[0] + 1]
59
+ new_margin = margin + sign * sum(float(f.scores[best]) - f.current for _, best, f in changes)
60
+ outcome = after(new_margin, [(f, best) for _, best, f in changes])
61
+ return Counterfactual(
62
+ changes=[
63
+ Change(f.name, f.label, bin_label(f.graph.x_vals[best]), float(f.scores[best]) - f.current)
64
+ for _, best, f in changes
65
+ ],
66
+ new_decision=outcome.decision,
67
+ new_output=outcome.output,
68
+ minimality=MinimalityStatus.SORTING_PROOF, # sorting finds the smallest set of one margin, as the paper proves
69
+ lower_bound=len(changes),
70
+ )
71
+
72
+
73
+ def _smallest_counterfactual(
74
+ features: Sequence[Feature],
75
+ frame: PredictionFrame,
76
+ scores: Sequence[float],
77
+ intercepts: Sequence[float],
78
+ z: float,
79
+ ) -> Counterfactual | None:
80
+ """Find the fewest changes after which one margin of the decision fails.
81
+
82
+ The decision fails when one margin fails, so the answer is the smallest of the answers for each margin. Each is a
83
+ problem with one margin, which sorting solves exactly.
84
+
85
+ Parameters
86
+ ----------
87
+ features : Sequence[Feature]
88
+ The features.
89
+ frame : PredictionFrame
90
+ The decision, with its margins.
91
+ scores : Sequence[float]
92
+ The score of each output of the model for the instance.
93
+ intercepts : Sequence[float]
94
+ The intercept of each output of the model.
95
+ z : float
96
+ Standard deviations to move the scores by.
97
+
98
+ Returns
99
+ -------
100
+ Counterfactual | None
101
+ The counterfactual with the fewest changes, the first one on a tie, or None if no margin can fail.
102
+
103
+ """
104
+ found = []
105
+ for margin in frame.side.margins:
106
+
107
+ def after(
108
+ _new_margin: float,
109
+ replaced: Sequence[tuple[Feature, int]],
110
+ margin: Margin = margin,
111
+ ) -> Outcome:
112
+ new_scores = np.array(scores, dtype=float)
113
+ for feature, bin_index in replaced:
114
+ new_scores += feature.outputs(bin_index) - feature.outputs(feature.bin_index)
115
+ return frame.after(margin, new_scores.tolist())
116
+
117
+ counterfactual = _counterfactual(
118
+ [feature.against(margin.columns) for feature in features],
119
+ margin.offset(intercepts),
120
+ margin.sign,
121
+ z,
122
+ after=after,
123
+ )
124
+ if counterfactual is not None:
125
+ found.append(counterfactual)
126
+ return min(found, key=lambda counterfactual: len(counterfactual.changes), default=None)
127
+
128
+
129
+ @attrs.frozen
130
+ class _Alternatives:
131
+ """The bins that one feature can move to, and how much each bin raises each margin of a target class."""
132
+
133
+ bins: list[int]
134
+ gains: list[list[float]]
135
+
136
+
137
+ def _alternatives(views: Sequence[Feature], z: float) -> _Alternatives:
138
+ """List the plausible bins of a feature, other than the bin of the instance, with their gains for each margin.
139
+
140
+ The scores of the new bin move by ``z`` deviations against the target class, as in ``_counterfactual``. A gain can
141
+ be negative: a bin that lowers one margin can still be part of the smallest set.
142
+
143
+ Parameters
144
+ ----------
145
+ views : Sequence[Feature]
146
+ The feature as seen by each margin of the target class.
147
+ z : float
148
+ Standard deviations to move the scores by.
149
+
150
+ Returns
151
+ -------
152
+ _Alternatives
153
+ The bins and, for each bin, its gain for each margin.
154
+
155
+ """
156
+ first = views[0]
157
+ bins = [int(bin_index) for bin_index in np.flatnonzero(first.plausible) if bin_index != first.bin_index]
158
+ gains = [
159
+ [float(view.scores[bin_index] - z * view.stds[bin_index] - view.current) for view in views]
160
+ for bin_index in bins
161
+ ]
162
+ return _Alternatives(bins, gains)
163
+
164
+
165
+ @attrs.frozen
166
+ class Totals:
167
+ """The score and the intercept of each output of the model for the instance, and the confidence factor ``z``."""
168
+
169
+ scores: list[float]
170
+ intercepts: list[float]
171
+ z: float
172
+
173
+
174
+ def _target_counterfactual(
175
+ features: Sequence[Feature],
176
+ frame: PredictionFrame,
177
+ margins: Sequence[Margin],
178
+ totals: Totals,
179
+ *,
180
+ options: LocalOptions,
181
+ ) -> Counterfactual | None:
182
+ """Find the fewest changes after which every margin of the target class holds.
183
+
184
+ Each feature is a group, and each of its plausible bins other than the bin of the instance is an alternative. A set
185
+ of changes moves each changed feature to one bin. ``options.search`` solves this covering problem over every choice
186
+ of bins.
187
+
188
+ Parameters
189
+ ----------
190
+ features : Sequence[Feature]
191
+ The features.
192
+ frame : PredictionFrame
193
+ The prediction.
194
+ margins : Sequence[Margin]
195
+ The margins of the target class against every other class.
196
+ totals : Totals
197
+ The scores and the intercepts of the instance, and the standard deviations to move the scores by.
198
+ options : LocalOptions
199
+ Uses ``search`` and ``seed``.
200
+
201
+ Returns
202
+ -------
203
+ Counterfactual | None
204
+ The changes, or None if the search proves that no choice of bins makes every margin hold.
205
+
206
+ """
207
+ target, _ = margins[0].columns or (0, 0)
208
+ views = [[feature.against(margin.columns) for feature in features] for margin in margins]
209
+ alternatives = [
210
+ _alternatives([margin_views[index] for margin_views in views], totals.z)
211
+ # nosemgrep: ebaml-no-range-len -- the index addresses the feature in the views of every margin
212
+ for index in range(len(features))
213
+ ]
214
+ worst = [
215
+ margin.offset(totals.intercepts) + sum(view.current for view in margin_views)
216
+ for margin, margin_views in zip(margins, views, strict=True)
217
+ ]
218
+ problem = CoveringProblem(worst, [feature_alternatives.gains for feature_alternatives in alternatives])
219
+ cover = options.search.solve(problem, seed=options.seed)
220
+ if cover is None:
221
+ return None
222
+ changed = [
223
+ (features[choice.group], alternatives[choice.group].bins[choice.alternative]) for choice in cover.choices
224
+ ]
225
+ new_scores = np.array(totals.scores, dtype=float)
226
+ for feature, bin_index in changed:
227
+ new_scores += feature.outputs(bin_index) - feature.outputs(feature.bin_index)
228
+ outcome = frame.after(margins[0], new_scores.tolist())
229
+ return Counterfactual(
230
+ changes=[
231
+ Change(
232
+ feature.name,
233
+ feature.label,
234
+ bin_label(feature.graph.x_vals[bin_index]),
235
+ float(
236
+ (feature.outputs(bin_index) - feature.outputs(feature.bin_index))[target]
237
+ - (feature.outputs(bin_index) - feature.outputs(feature.bin_index))[frame.column],
238
+ ),
239
+ )
240
+ for feature, bin_index in changed
241
+ ],
242
+ new_decision=outcome.decision,
243
+ new_output=outcome.output,
244
+ minimality=cover.minimality,
245
+ lower_bound=cover.lower_bound,
246
+ )
247
+
248
+
249
+ def choose_counterfactual(
250
+ features: Sequence[Feature],
251
+ frame: PredictionFrame,
252
+ totals: Totals,
253
+ *,
254
+ kind: LocalKind,
255
+ options: LocalOptions,
256
+ ) -> Counterfactual | None:
257
+ """Find the counterfactual that the options ask for: the target class if there is one, else the smallest.
258
+
259
+ Parameters
260
+ ----------
261
+ features : Sequence[Feature]
262
+ The features.
263
+ frame : PredictionFrame
264
+ The prediction.
265
+ totals : Totals
266
+ The scores and the intercepts of the instance, and the standard deviations to move the scores by.
267
+ kind : LocalKind
268
+ The kind of the model.
269
+ options : LocalOptions
270
+ Uses ``target_class``, ``search`` and ``seed``.
271
+
272
+ Returns
273
+ -------
274
+ Counterfactual | None
275
+ The counterfactual, or None if no change gives it.
276
+
277
+ """
278
+ if options.target_class is None:
279
+ return _smallest_counterfactual(features, frame, totals.scores, totals.intercepts, totals.z)
280
+ margins = kind.target_margins(options.target_class, frame)
281
+ return _target_counterfactual(features, frame, margins, totals, options=options)