ebaml 0.6.2__tar.gz → 0.6.4__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 (181) hide show
  1. {ebaml-0.6.2 → ebaml-0.6.4}/PKG-INFO +1 -1
  2. {ebaml-0.6.2 → ebaml-0.6.4}/pyproject.toml +1 -1
  3. {ebaml-0.6.2 → ebaml-0.6.4}/pyproject.toml.orig +1 -1
  4. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/.baml-generator-output.json +6 -6
  5. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/__init__.py +91 -0
  6. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/__init__.pyi +81 -0
  7. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/_baml_sources.py +2 -0
  8. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/_function_registry.py +10 -0
  9. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/_inlinedbaml.py +1 -1
  10. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/_typemap.py +2 -0
  11. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/ebm_graph.py +6 -5
  12. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/facts.py +9 -2
  13. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/local_kinds.py +3 -3
  14. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/mcp/read_tools.py +1 -1
  15. {ebaml-0.6.2 → ebaml-0.6.4}/LICENSE +0 -0
  16. {ebaml-0.6.2 → ebaml-0.6.4}/README.md +0 -0
  17. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/.baml-generator-output-root +0 -0
  18. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/_invocation_types.py +0 -0
  19. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/_invocation_types.pyi +0 -0
  20. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/__init__.py +0 -0
  21. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/__init__.pyi +0 -0
  22. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/clients/__init__.py +0 -0
  23. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/clients/__init__.pyi +0 -0
  24. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/content/__init__.py +0 -0
  25. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/content/__init__.pyi +0 -0
  26. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/errors/__init__.py +0 -0
  27. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/errors/__init__.pyi +0 -0
  28. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/events/__init__.py +0 -0
  29. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/events/__init__.pyi +0 -0
  30. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/internal/__init__.py +0 -0
  31. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/internal/__init__.pyi +0 -0
  32. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/mcp/__init__.py +0 -0
  33. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/mcp/__init__.pyi +0 -0
  34. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/stream/__init__.py +0 -0
  35. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/stream/__init__.pyi +0 -0
  36. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/tools/__init__.py +0 -0
  37. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/tools/__init__.pyi +0 -0
  38. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/wire/__init__.py +0 -0
  39. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/ai/wire/__init__.pyi +0 -0
  40. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/__init__.py +0 -0
  41. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/__init__.pyi +0 -0
  42. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/crypto/__init__.py +0 -0
  43. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/crypto/__init__.pyi +0 -0
  44. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/csv/__init__.py +0 -0
  45. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/csv/__init__.pyi +0 -0
  46. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/env/__init__.py +0 -0
  47. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/env/__init__.pyi +0 -0
  48. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/errors/__init__.py +0 -0
  49. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/errors/__init__.pyi +0 -0
  50. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/fs/__init__.py +0 -0
  51. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/fs/__init__.pyi +0 -0
  52. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/future/__init__.py +0 -0
  53. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/future/__init__.pyi +0 -0
  54. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/glob/__init__.py +0 -0
  55. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/glob/__init__.pyi +0 -0
  56. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/hash/__init__.py +0 -0
  57. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/hash/__init__.pyi +0 -0
  58. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/host/__init__.py +0 -0
  59. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/host/__init__.pyi +0 -0
  60. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/http/__init__.py +0 -0
  61. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/http/__init__.pyi +0 -0
  62. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/io/__init__.py +0 -0
  63. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/io/__init__.pyi +0 -0
  64. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/iter/__init__.py +0 -0
  65. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/iter/__init__.pyi +0 -0
  66. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/json/__init__.py +0 -0
  67. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/json/__init__.pyi +0 -0
  68. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/media/__init__.py +0 -0
  69. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/media/__init__.pyi +0 -0
  70. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/net/__init__.py +0 -0
  71. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/net/__init__.pyi +0 -0
  72. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/ops/__init__.py +0 -0
  73. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/ops/__init__.pyi +0 -0
  74. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/panics/__init__.py +0 -0
  75. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/panics/__init__.pyi +0 -0
  76. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/random/__init__.py +0 -0
  77. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/random/__init__.pyi +0 -0
  78. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/regex/__init__.py +0 -0
  79. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/regex/__init__.pyi +0 -0
  80. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/sap/__init__.py +0 -0
  81. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/sap/__init__.pyi +0 -0
  82. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/spawn/__init__.py +0 -0
  83. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/spawn/__init__.pyi +0 -0
  84. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/sys/__init__.py +0 -0
  85. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/sys/__init__.pyi +0 -0
  86. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/time/__init__.py +0 -0
  87. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/time/__init__.pyi +0 -0
  88. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/toml/__init__.py +0 -0
  89. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/toml/__init__.pyi +0 -0
  90. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/ws/__init__.py +0 -0
  91. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/ws/__init__.pyi +0 -0
  92. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/yaml/__init__.py +0 -0
  93. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/baml/yaml/__init__.pyi +0 -0
  94. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/experimental/__init__.py +0 -0
  95. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/experimental/__init__.pyi +0 -0
  96. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/py.typed +0 -0
  97. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/__init__.py +0 -0
  98. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/__init__.pyi +0 -0
  99. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/class_/__init__.py +0 -0
  100. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/class_/__init__.pyi +0 -0
  101. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/enum/__init__.py +0 -0
  102. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/enum/__init__.pyi +0 -0
  103. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/errors/__init__.py +0 -0
  104. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/errors/__init__.pyi +0 -0
  105. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/function/__init__.py +0 -0
  106. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/function/__init__.pyi +0 -0
  107. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/interface/__init__.py +0 -0
  108. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/reflect/interface/__init__.pyi +0 -0
  109. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/__init__.py +0 -0
  110. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/__init__.pyi +0 -0
  111. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/anthropic/__init__.py +0 -0
  112. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/anthropic/__init__.pyi +0 -0
  113. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/anthropic/internal/__init__.py +0 -0
  114. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/anthropic/internal/__init__.pyi +0 -0
  115. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/assert_/__init__.py +0 -0
  116. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/assert_/__init__.pyi +0 -0
  117. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/aws/__init__.py +0 -0
  118. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/aws/__init__.pyi +0 -0
  119. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/aws/internal/__init__.py +0 -0
  120. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/aws/internal/__init__.pyi +0 -0
  121. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/claude_code/__init__.py +0 -0
  122. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/claude_code/__init__.pyi +0 -0
  123. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/claude_code/internal/__init__.py +0 -0
  124. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/claude_code/internal/__init__.pyi +0 -0
  125. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/google/__init__.py +0 -0
  126. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/google/__init__.pyi +0 -0
  127. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/google/internal/__init__.py +0 -0
  128. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/google/internal/__init__.pyi +0 -0
  129. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/openai/__init__.py +0 -0
  130. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/openai/__init__.pyi +0 -0
  131. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/openai/internal/__init__.py +0 -0
  132. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/openai/internal/__init__.pyi +0 -0
  133. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/openai/internal/decisions/__init__.py +0 -0
  134. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/openai/internal/decisions/__init__.pyi +0 -0
  135. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/testing/__init__.py +0 -0
  136. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/testing/__init__.pyi +0 -0
  137. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/trace/__init__.py +0 -0
  138. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/trace/__init__.pyi +0 -0
  139. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/typesafeai/__init__.py +0 -0
  140. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/typesafeai/__init__.pyi +0 -0
  141. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/typesafeai/internal/__init__.py +0 -0
  142. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/typesafeai/internal/__init__.pyi +0 -0
  143. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/vercel/__init__.py +0 -0
  144. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/vercel/__init__.pyi +0 -0
  145. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/vercel/internal/__init__.py +0 -0
  146. {ebaml-0.6.2 → ebaml-0.6.4}/src/baml_sdk/vendor/vercel/internal/__init__.pyi +0 -0
  147. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/__init__.py +0 -0
  148. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/benchmark.py +0 -0
  149. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/core/__init__.py +0 -0
  150. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/core/custom_types.py +0 -0
  151. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/core/exceptions.py +0 -0
  152. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/__init__.py +0 -0
  153. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/graph_text.py +0 -0
  154. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/model_kinds.py +0 -0
  155. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/request_text.py +0 -0
  156. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/terms.py +0 -0
  157. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/token_budget.py +0 -0
  158. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/graphs/token_weights.py +0 -0
  159. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/__init__.py +0 -0
  160. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/descriptors.py +0 -0
  161. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/options.py +0 -0
  162. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/provider_errors.py +0 -0
  163. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/retry.py +0 -0
  164. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/sdk_setup.py +0 -0
  165. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/token_learning.py +0 -0
  166. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/llm/token_weights.json +0 -0
  167. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/__init__.py +0 -0
  168. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/audience.py +0 -0
  169. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/covering_backend.py +0 -0
  170. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/covering_greedy.py +0 -0
  171. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/covering_problem.py +0 -0
  172. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/covering_solvers.py +0 -0
  173. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/decisions.py +0 -0
  174. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/fact_text.py +0 -0
  175. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/local/ortools_backend.py +0 -0
  176. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/mcp/__init__.py +0 -0
  177. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/mcp/explain_tools.py +0 -0
  178. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/mcp/llm_tools.py +0 -0
  179. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/mcp/model_store.py +0 -0
  180. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/mcp/server.py +0 -0
  181. {ebaml-0.6.2 → ebaml-0.6.4}/src/ebaml/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ebaml
3
- Version: 0.6.2
3
+ Version: 0.6.4
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.6.2"
3
+ version = "0.6.4"
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.6.2"
3
+ version = "0.6.4"
4
4
  description = "BAML for Explainable Boosting Machines: talk to your EBM."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -7,23 +7,23 @@
7
7
  },
8
8
  {
9
9
  "relative_path": "__init__.py",
10
- "sha256": "3fa1b50531b06929e83abaa9a7ac714f2d804054898eae01c603bc0729ebe9f7"
10
+ "sha256": "0bbf7c907e4c63e9b29f1e827ec3e26170af4e31861ed865584ffdd62a042f3c"
11
11
  },
12
12
  {
13
13
  "relative_path": "__init__.pyi",
14
- "sha256": "c4ba115c3f7307a0f78496062880f7865f0125a3b71e4a67815785504857a8d3"
14
+ "sha256": "3202a3791d3f050b4fc0640ec6789b5f01baca2d40accba66cdff91fc1e9b4e4"
15
15
  },
16
16
  {
17
17
  "relative_path": "_baml_sources.py",
18
- "sha256": "ba9f5190befeaa8831ec31ac2cb8d22178efd980789699a59e6ebe29c7fed7b7"
18
+ "sha256": "9d0621d8451225470506369882b4d993a8806e0384194840753b584c8042a760"
19
19
  },
20
20
  {
21
21
  "relative_path": "_function_registry.py",
22
- "sha256": "bfd61b0ec6debc62549fd028799695ae67cd4358b27413daf120af31a8a9bbaf"
22
+ "sha256": "bbb9b083bc7ef90560e04aa5a3b3638044e4fbcb0568a6ce4b70c660810e4fb4"
23
23
  },
24
24
  {
25
25
  "relative_path": "_inlinedbaml.py",
26
- "sha256": "77c812814604fb77b3c8ed6b7054e616a9a6261c19c8f75e06379eb778a88b10"
26
+ "sha256": "3a178c7d8ae88aadf1d886d739de432ac2e81286b4fbb6e93b5ab58fb552e17c"
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": "df5ba3535ab9a4b8521541e49409c61c5c2600ff4bd6855ead4fb3f138506540"
38
+ "sha256": "a203f97384f3ed1e21027042340bc454c77e844169a6172b538305f089ebbe9a"
39
39
  },
40
40
  {
41
41
  "relative_path": "ai/__init__.py",
@@ -229,6 +229,79 @@ explain_local_async.__doc__ = """Raises:
229
229
  CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
230
230
 
231
231
 
232
+ class McpAgentReport(pydantic.BaseModel):
233
+ model_config = pydantic.ConfigDict(
234
+ arbitrary_types_allowed=True,
235
+ extra="ignore",
236
+ populate_by_name=True,
237
+ )
238
+ report: str
239
+ tool_calls: typing.List[str]
240
+ usage: TokenUsage
241
+
242
+
243
+ mcp_agent_system_msg = _define_function("user.mcp_agent_system_msg", "sync", [], binding_name="mcp_agent_system_msg", binding_qualname="mcp_agent_system_msg", binding_module=__name__)
244
+ mcp_agent_system_msg_async = _define_function("user.mcp_agent_system_msg", "async", [], binding_name="mcp_agent_system_msg_async", binding_qualname="mcp_agent_system_msg_async", binding_module=__name__)
245
+
246
+
247
+ mcp_agent_user_msg = _define_function("user.mcp_agent_user_msg", "sync", ["question"], binding_name="mcp_agent_user_msg", binding_qualname="mcp_agent_user_msg", binding_module=__name__)
248
+ mcp_agent_user_msg_async = _define_function("user.mcp_agent_user_msg", "async", ["question"], binding_name="mcp_agent_user_msg_async", binding_qualname="mcp_agent_user_msg_async", binding_module=__name__)
249
+
250
+
251
+ McpExplainer = _define_function("user.McpExplainer", "sync", ["question"], ["on_event"], binding_name="McpExplainer", binding_qualname="McpExplainer", binding_module=__name__)
252
+ McpExplainer.__doc__ = """Raises:
253
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
254
+ McpExplainer_async = _define_function("user.McpExplainer", "async", ["question"], ["on_event"], binding_name="McpExplainer_async", binding_qualname="McpExplainer_async", binding_module=__name__)
255
+ McpExplainer_async.__doc__ = """Raises:
256
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
257
+ McpExplainer_spec = _define_function("user.McpExplainer@spec", "sync", ["question"], binding_name="McpExplainer_spec", binding_qualname="McpExplainer_spec", binding_module=__name__)
258
+ McpExplainer_spec.__doc__ = """Raises:
259
+ InvalidArgument, Io, ParseError, InvalidRequest"""
260
+ McpExplainer_spec_async = _define_function("user.McpExplainer@spec", "async", ["question"], binding_name="McpExplainer_spec_async", binding_qualname="McpExplainer_spec_async", binding_module=__name__)
261
+ McpExplainer_spec_async.__doc__ = """Raises:
262
+ InvalidArgument, Io, ParseError, InvalidRequest"""
263
+ McpExplainer_stream = _define_function("user.McpExplainer@stream", "sync", ["question"], ["on_event"], binding_name="McpExplainer_stream", binding_qualname="McpExplainer_stream", binding_module=__name__)
264
+ McpExplainer_stream.__doc__ = """Raises:
265
+ CompilationError, SpanError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
266
+ McpExplainer_stream_async = _define_function("user.McpExplainer@stream", "async", ["question"], ["on_event"], binding_name="McpExplainer_stream_async", binding_qualname="McpExplainer_stream_async", binding_module=__name__)
267
+ McpExplainer_stream_async.__doc__ = """Raises:
268
+ CompilationError, SpanError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
269
+
270
+
271
+ explain_with_tools = _define_function("user.explain_with_tools", "sync", ["question", "tools"], ["client", "model", "max_steps"], binding_name="explain_with_tools", binding_qualname="explain_with_tools", binding_module=__name__)
272
+ explain_with_tools.__doc__ = """Raises:
273
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
274
+ explain_with_tools_async = _define_function("user.explain_with_tools", "async", ["question", "tools"], ["client", "model", "max_steps"], binding_name="explain_with_tools_async", binding_qualname="explain_with_tools_async", binding_module=__name__)
275
+ explain_with_tools_async.__doc__ = """Raises:
276
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
277
+
278
+
279
+ explain_with_mcp = _define_function("user.explain_with_mcp", "sync", ["question", "command", "args"], ["client", "model", "max_steps"], binding_name="explain_with_mcp", binding_qualname="explain_with_mcp", binding_module=__name__)
280
+ explain_with_mcp.__doc__ = """Raises:
281
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError, SerializationError"""
282
+ explain_with_mcp_async = _define_function("user.explain_with_mcp", "async", ["question", "command", "args"], ["client", "model", "max_steps"], binding_name="explain_with_mcp_async", binding_qualname="explain_with_mcp_async", binding_module=__name__)
283
+ explain_with_mcp_async.__doc__ = """Raises:
284
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError, SerializationError"""
285
+
286
+
287
+ class ToolCallingClient(pydantic.BaseModel):
288
+ model_config = pydantic.ConfigDict(
289
+ arbitrary_types_allowed=True,
290
+ extra="ignore",
291
+ populate_by_name=True,
292
+ )
293
+ turns: int
294
+ seen_tools: typing.List[str]
295
+
296
+
297
+ fake_summary_tool = _define_function("user.fake_summary_tool", "sync", [], binding_name="fake_summary_tool", binding_qualname="fake_summary_tool", binding_module=__name__)
298
+ fake_summary_tool.__doc__ = """Raises:
299
+ InvalidArgument"""
300
+ fake_summary_tool_async = _define_function("user.fake_summary_tool", "async", [], binding_name="fake_summary_tool_async", binding_qualname="fake_summary_tool_async", binding_module=__name__)
301
+ fake_summary_tool_async.__doc__ = """Raises:
302
+ InvalidArgument"""
303
+
304
+
232
305
  class ModelSpec(pydantic.BaseModel):
233
306
  model_config = pydantic.ConfigDict(
234
307
  arbitrary_types_allowed=True,
@@ -812,6 +885,24 @@ __all__ = [
812
885
  "LocalCompletions_stream_async",
813
886
  "explain_local",
814
887
  "explain_local_async",
888
+ "McpAgentReport",
889
+ "mcp_agent_system_msg",
890
+ "mcp_agent_system_msg_async",
891
+ "mcp_agent_user_msg",
892
+ "mcp_agent_user_msg_async",
893
+ "McpExplainer",
894
+ "McpExplainer_async",
895
+ "McpExplainer_spec",
896
+ "McpExplainer_spec_async",
897
+ "McpExplainer_stream",
898
+ "McpExplainer_stream_async",
899
+ "explain_with_tools",
900
+ "explain_with_tools_async",
901
+ "explain_with_mcp",
902
+ "explain_with_mcp_async",
903
+ "ToolCallingClient",
904
+ "fake_summary_tool",
905
+ "fake_summary_tool_async",
815
906
  "ModelSpec",
816
907
  "CallDefaults",
817
908
  "short_defaults",
@@ -200,6 +200,69 @@ async def explain_local_async(global_explanation: str, facts: LocalFactTexts, au
200
200
  CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
201
201
 
202
202
 
203
+ class McpAgentReport(pydantic.BaseModel):
204
+ report: str
205
+ tool_calls: typing.List[str]
206
+ usage: TokenUsage
207
+
208
+
209
+ def mcp_agent_system_msg(*, _baml: _BamlOptions | None = None) -> str: ...
210
+ async def mcp_agent_system_msg_async(*, _baml: _BamlOptions | None = None) -> str: ...
211
+
212
+
213
+ def mcp_agent_user_msg(question: str, *, _baml: _BamlOptions | None = None) -> str: ...
214
+ async def mcp_agent_user_msg_async(question: str, *, _baml: _BamlOptions | None = None) -> str: ...
215
+
216
+
217
+ def McpExplainer(question: str, *, on_event: typing.Union[typing.Callable[[ai.events.Event], None], None, UNSET] = None, _baml: _BamlOptions | None = None) -> str:
218
+ """Raises:
219
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
220
+ async def McpExplainer_async(question: str, *, on_event: typing.Union[typing.Callable[[ai.events.Event], None], None, UNSET] = None, _baml: _BamlOptions | None = None) -> str:
221
+ """Raises:
222
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
223
+ def McpExplainer_spec(question: str, *, _baml: _BamlOptions | None = None) -> ai.FunctionSpec[str]:
224
+ """Raises:
225
+ InvalidArgument, Io, ParseError, InvalidRequest"""
226
+ async def McpExplainer_spec_async(question: str, *, _baml: _BamlOptions | None = None) -> ai.FunctionSpec[str]:
227
+ """Raises:
228
+ InvalidArgument, Io, ParseError, InvalidRequest"""
229
+ def McpExplainer_stream(question: str, *, on_event: typing.Union[typing.Callable[[ai.events.Event], None], None, UNSET] = None, _baml: _BamlOptions | None = None) -> _BamlStream[typing.Union[str, _BamlStreamDone], str, str]:
230
+ """Raises:
231
+ CompilationError, SpanError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
232
+ async def McpExplainer_stream_async(question: str, *, on_event: typing.Union[typing.Callable[[ai.events.Event], None], None, UNSET] = None, _baml: _BamlOptions | None = None) -> _BamlStream[typing.Union[str, _BamlStreamDone], str, str]:
233
+ """Raises:
234
+ CompilationError, SpanError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
235
+
236
+
237
+ def explain_with_tools(question: str, tools: typing.List[ai.tools.Tool], *, client: typing.Union[typing.Any, None, UNSET] = None, model: typing.Union[ModelSpec, None, UNSET] = None, max_steps: typing.Union[int, UNSET] = 12, _baml: _BamlOptions | None = None) -> McpAgentReport:
238
+ """Raises:
239
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
240
+ async def explain_with_tools_async(question: str, tools: typing.List[ai.tools.Tool], *, client: typing.Union[typing.Any, None, UNSET] = None, model: typing.Union[ModelSpec, None, UNSET] = None, max_steps: typing.Union[int, UNSET] = 12, _baml: _BamlOptions | None = None) -> McpAgentReport:
241
+ """Raises:
242
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError"""
243
+
244
+
245
+ def explain_with_mcp(question: str, command: str, args: typing.List[str], *, client: typing.Union[typing.Any, None, UNSET] = None, model: typing.Union[ModelSpec, None, UNSET] = None, max_steps: typing.Union[int, UNSET] = 12, _baml: _BamlOptions | None = None) -> McpAgentReport:
246
+ """Raises:
247
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError, SerializationError"""
248
+ async def explain_with_mcp_async(question: str, command: str, args: typing.List[str], *, client: typing.Union[typing.Any, None, UNSET] = None, model: typing.Union[ModelSpec, None, UNSET] = None, max_steps: typing.Union[int, UNSET] = 12, _baml: _BamlOptions | None = None) -> McpAgentReport:
249
+ """Raises:
250
+ CompilationError, InvalidArgument, Io, ParseError, Timeout, UnknownError, SerializationError"""
251
+
252
+
253
+ class ToolCallingClient(pydantic.BaseModel):
254
+ turns: int
255
+ seen_tools: typing.List[str]
256
+
257
+
258
+ def fake_summary_tool(*, _baml: _BamlOptions | None = None) -> ai.tools.Tool:
259
+ """Raises:
260
+ InvalidArgument"""
261
+ async def fake_summary_tool_async(*, _baml: _BamlOptions | None = None) -> ai.tools.Tool:
262
+ """Raises:
263
+ InvalidArgument"""
264
+
265
+
203
266
  class ModelSpec(pydantic.BaseModel):
204
267
  provider: str
205
268
  model: str
@@ -721,6 +784,24 @@ __all__ = [
721
784
  "LocalCompletions_stream_async",
722
785
  "explain_local",
723
786
  "explain_local_async",
787
+ "McpAgentReport",
788
+ "mcp_agent_system_msg",
789
+ "mcp_agent_system_msg_async",
790
+ "mcp_agent_user_msg",
791
+ "mcp_agent_user_msg_async",
792
+ "McpExplainer",
793
+ "McpExplainer_async",
794
+ "McpExplainer_spec",
795
+ "McpExplainer_spec_async",
796
+ "McpExplainer_stream",
797
+ "McpExplainer_stream_async",
798
+ "explain_with_tools",
799
+ "explain_with_tools_async",
800
+ "explain_with_mcp",
801
+ "explain_with_mcp_async",
802
+ "ToolCallingClient",
803
+ "fake_summary_tool",
804
+ "fake_summary_tool_async",
724
805
  "ModelSpec",
725
806
  "CallDefaults",
726
807
  "short_defaults",
@@ -24,6 +24,8 @@ from __future__ import annotations
24
24
  FILES: dict[str, str] = {
25
25
  "benchmark_tests.baml": "// Live benchmark tests: a fixed sample of the questions in benchmark/data/, asked through answer_benchmark_question.\n// Each question has one correct answer, so a failure means a wrong answer, not a strict check. The full benchmark\n// (benchmark/run.py) measures the accuracy over every question; these tests only catch a prompt change that breaks\n// the answers. The selector root::Live also matches the testset \"LiveBenchmark\", so offline runs exclude these tests\n// and live runs include them. `baml test` runs from the repository root, and the paths of the data files are relative\n// to it.\n//\n// The sample takes the first questions of each solution in the file, not the questions that a model answers well,\n// because a sample of easy wins cannot catch a regression. The answer formats and the parsers follow `_SPECS` in\n// src/ebaml/benchmark.py. Keep them equal, so that these tests score an answer as the benchmark does.\n\n// The questions of `task` at `indices`, as [question, solution] pairs.\nfunction benchmark_sample(task: string, indices: int[]) -> string[][] {\n let questions = baml.json.decode<string[][]>(baml.fs.read(`benchmark/data/${task}.json`));\n indices.map((i) -> {\n questions[i]\n })\n}\n\n// The letter of the chosen option, as `_parse_choice` reads it: \"a)\" anywhere, or a bare \"a\" at the start.\nfunction benchmark_choice(answer: string) -> string? {\n let lowered = answer.to_lower_case();\n let found = baml.regex.new(\"\\\\b([a-e])\\\\)\").match_once(lowered)\n ?? baml.regex.new(\"^\\\\W*([a-e])\\\\b\").match_once(lowered);\n if (found == null) {\n return null;\n };\n found.groups[1]?.text\n}\n\n// The monotonicity label, as `_parse_monotonicity` reads it. \"not monotone\" goes first, because an answer may say\n// \"not increasing\".\nfunction benchmark_monotonicity(answer: string) -> string? {\n let lowered = answer.to_lower_case();\n for (let label in [\"not monotone\", \"increasing\", \"decreasing\"]) {\n if (lowered.includes(label)) {\n return label;\n }\n }\n ;\n null\n}\n\n// The answer of the model to one question, or \"\" if the model stops without a finished answer, for example when a\n// reasoning model uses up the token limit. The question then counts as wrong, as an answer that the benchmark cannot\n// parse does, and the other questions of the sample still count. Other errors (a missing key, a rate limit) still fail\n// the test, because they say nothing about the answers.\nfunction benchmark_answer(question: string, answer_format: string, client: ai.Client?) -> string {\n answer_benchmark_question(question, answer_format, client = client).text catch (e) {\n ai.errors.FinishReasonError => \"\"\n }\n}\n\n// Asks every question of `sample`, two at a time to stay below the rate limit of the free router, and returns the\n// number of answers that `parse` reads as the solution. `client` serves the offline test; the live tests omit it.\nfunction benchmark_correct(\n sample: string[][],\n answer_format: string,\n parse: (string) -> string?,\n client: ai.Client? = null,\n) -> int {\n let correct = 0;\n let i = 0;\n while (i < sample.length()) {\n let batch = sample.slice(i, i + 2);\n let replies: string[] = await baml.future.all(batch.map((pair) => { spawn { benchmark_answer(pair[0], answer_format, client) } }));\n let j = 0;\n while (j < batch.length()) {\n let answer = replies[j];\n let ok = parse(answer) == parse(batch[j][1]);\n log.info(\n { \"answer\": answer, \"solution\": batch[j][1], \"correct\": ok },\n event_name = \"benchmark_answer\",\n );\n if (ok) {\n correct = correct + 1;\n };\n j = j + 1;\n }\n ;\n i = i + 2;\n }\n ;\n correct\n}\n\ntestset \"LiveBenchmark\" {\n // chance is 2 of 6 (three labels); 4 of 6 lets one or two hard questions fail\n test \"benchmark monotonicity: at least 4 of 6 sample questions are correct\" {\n // 2 \"Decreasing\", 2 \"Increasing\", 2 \"Not monotone\"\n let sample = benchmark_sample(\"monotonicity\", [17, 37, 4, 7, 0, 8]);\n let correct = benchmark_correct(sample, \"'Increasing', 'Decreasing' or 'Not monotone'\", benchmark_monotonicity);\n assert.is_true(correct >= 4)\n }\n\n // chance is about 1 of 6 (five options); 4 of 6 lets one or two hard questions fail\n test \"benchmark function recognition: at least 4 of 6 sample questions are correct\" {\n // the first question of each solution a) to e), and a second c)\n let sample = benchmark_sample(\"function-recognition\", [0, 1, 2, 7, 10, 14]);\n let correct = benchmark_correct(sample, \"the letter of the function, for example 'a)'\", benchmark_choice);\n assert.is_true(correct >= 4)\n }\n}\n\ntestset \"BenchmarkChecks\" {\n test \"benchmark_sample reads the question and the solution at each index\" {\n let sample = benchmark_sample(\"monotonicity\", [17, 4]);\n assert.equal(sample[0][1], \"Decreasing\");\n assert.equal(sample[1][1], \"Increasing\");\n assert.is_true(sample[0][0].includes(\"Think step by step.\"))\n }\n\n test \"benchmark_choice reads the letter like the benchmark scorer\" {\n assert.equal(benchmark_choice(\"**C)**\"), \"c\");\n assert.equal(benchmark_choice(\"(b)\"), \"b\");\n assert.equal(benchmark_choice(\"a\"), \"a\");\n assert.equal(benchmark_choice(\"none of them\"), null)\n }\n\n test \"benchmark_monotonicity reads the label like the benchmark scorer\" {\n assert.equal(benchmark_monotonicity(\"Not monotone.\"), \"not monotone\");\n assert.equal(benchmark_monotonicity(\"Monotone decreasing\"), \"decreasing\");\n assert.equal(benchmark_monotonicity(\"It goes up and down\"), null)\n }\n\n test \"benchmark_correct counts the answers that match the solution\" {\n // the sample holds 2 \"Decreasing\" questions and an odd count, so the last batch has one question\n let sample = benchmark_sample(\"monotonicity\", [17, 4, 0, 37, 7]);\n let correct = benchmark_correct(\n sample,\n \"'Increasing', 'Decreasing' or 'Not monotone'\",\n benchmark_monotonicity,\n client = ConstantClient { answer: \"Decreasing.\" },\n );\n assert.equal(correct, 2)\n }\n test \"benchmark_correct counts an answer that runs out of tokens as wrong\" {\n let sample = benchmark_sample(\"monotonicity\", [17, 37]);\n let correct = benchmark_correct(\n sample,\n \"'Increasing', 'Decreasing' or 'Not monotone'\",\n benchmark_monotonicity,\n client = ExhaustedClient {},\n );\n assert.equal(correct, 0)\n }\n}\n\n// Ends every call at the token limit with no text, as a reasoning model does when its reasoning uses up the limit.\nclass ExhaustedClient {\n implements ai.Client {\n function provider(self) -> string {\n \"exhausted\"\n }\n\n function requested_model(self) -> string {\n \"exhausted\"\n }\n\n function render(self, input: ai.ModelTurnInput) -> baml.http.Request {\n baml.http.Request.from_url(\"http://exhausted.invalid\")\n }\n\n function invoke(self, input: ai.ModelTurnInput) -> ai.ModelTurn {\n let turn = scripted_turn(\"\", 1, 1);\n turn.stop_reason = ai.content.StopReason.MaxTokens;\n turn\n }\n }\n}\n\n// Answers every call with `answer`, so the score of a sample is the number of questions with that solution.\nclass ConstantClient {\n answer: string,\n\n implements ai.Client {\n function provider(self) -> string {\n \"constant\"\n }\n\n function requested_model(self) -> string {\n \"constant\"\n }\n\n function render(self, input: ai.ModelTurnInput) -> baml.http.Request {\n baml.http.Request.from_url(\"http://constant.invalid\")\n }\n\n function invoke(self, input: ai.ModelTurnInput) -> ai.ModelTurn {\n scripted_turn(self.answer, 1, 1)\n }\n }\n}\n",
26
26
  "local_explanations.baml": "// Local explanations: Python computes the facts of one prediction deterministically (ebaml.local), BAML turns each\n// kind of fact into words. The three kinds are the explainability queries of Barceló et al., \"Model Interpretability\n// through the Lens of Computational Complexity\" (arXiv:2010.12265): minimum change required, sufficient reason and\n// count completions. The global explanation of the model (describe_ebm) is prepended to every prompt.\n\n// Facts of one prediction, one JSON text per kind of explanation.\nclass LocalFactTexts {\n prediction: string,\n counterfactual: string,\n sufficient_reason: string,\n completions: string,\n}\n\nclass LocalExplanationText {\n counterfactual: string,\n sufficient_reason: string,\n completions: string,\n usage: TokenUsage,\n}\n\nfunction local_system_msg(expert_description: string) -> string {\n `You are ${expert_description}. You explain individual predictions of a Generalized Additive Model (GAM). You receive an explanation of the whole model and facts about one prediction that were computed exactly from the model. State only effects, values and probabilities that appear in these facts, because the reader acts on your words and an invented number would mislead. A prediction is a class or a number. For a number, the facts name the decision as a question about the predicted value, such as \"above 10\", and a flip means that the value crosses the limit of the question. For a class, a flip means that another class becomes the predicted class, and \"after_the_changes\" names it. Answer in plain prose paragraphs, because a person reads your answer.`\n}\n\n// The guidance comes from the Audience of the Python caller (ebaml.local.audience), so a user can add an audience\n// without an edit here. It tells the model how to write for the reader, and why.\nfunction local_user_msg(\n global_explanation: string,\n prediction: string,\n question: string,\n facts: string,\n audience_guidance: string,\n dataset_description: string,\n language: string = \"English\",\n) -> string {\n let msg = `\n <global_explanation>\n ${global_explanation}\n </global_explanation>\n `\n + \"\\n\\n\";\n if (dataset_description.length() > 0) {\n msg = msg + `<dataset_description>\\n${dataset_description}\\n</dataset_description>\\n\\n`;\n };\n msg\n + `\n <prediction>\n ${prediction}\n </prediction>\n\n <facts>\n ${facts}\n </facts>\n\n <audience>\n ${audience_guidance}\n </audience>\n\n <language>\n Write the whole answer in ${language}, because the reader reads ${language}. Keep every number exactly as the facts give it, and translate the names of inputs and categories only where the reader needs them.\n </language>\n\n <question>\n ${question}\n </question>\n `\n}\n\nfunction counterfactual_question(num_sentences: int) -> string {\n `\n Explain, in at most ${num_sentences} sentences, what would have to change for the prediction to be different.\n The facts list a set of input changes that flips the prediction (a minimum change required), and whether the flip survives the model's uncertainty.\n If \"is_smallest_set\" is true, this is exact, not a guess: no smaller set of changes gives the new prediction, because the model adds up one independent effect per input and the computation proves the size.\n If \"is_smallest_set\" is false, the facts ask for a chosen class, and the search ended at its time limit or was a fast search, so it did not prove the size. Describe the set as a set of changes that reaches that class, and keep its size out of the answer, because any word about the size reads as a claim that the facts do not make.\n If the facts give \"smallest_possible_number_of_changes\", no set reaches the new prediction with fewer changes than that number. When \"is_smallest_set\" is false, you may state the gap between \"number_of_changes\" and that number, because the gap tells this reader how far the set can be from the smallest one.\n Only realistic alternative values were considered (rare extreme values are left out), and the flip holds even if the model's effects are at the unfavourable edge of their confidence interval.\n Suggest only the changes that the facts list, because they are the only ones that the model supports.\n If no change flips the prediction, say that no change within the realistic values flips it, because the search covered only those values and the facts make no claim about other values.\n `\n}\n\nfunction sufficient_reason_question(num_sentences: int) -> string {\n `\n Explain, in at most ${num_sentences} sentences, which inputs are enough to settle the prediction.\n The facts list a set of inputs (a sufficient reason) that fixes the prediction whatever the other inputs are. State clearly that the remaining inputs cannot change the outcome.\n If \"is_smallest_set\" is true, this is exact: no smaller set of inputs guarantees the outcome, because the model adds up one independent effect per input and the computation proves the size.\n If \"is_smallest_set\" is false, the search ended at its time limit or was a fast search, so it did not prove the size. Call the set a set of inputs that is enough, and keep its size out of the answer, because any word about the size reads as a claim that the facts do not make.\n If the facts give \"smallest_possible_number_of_features\", no set with fewer inputs than that number guarantees the outcome. When \"is_smallest_set\" is false, you may state the gap between the number of listed inputs and that number, because the gap tells this reader how far the set can be from the smallest one.\n The guarantee covers every realistic value of the other inputs (rare extreme values are left out) and holds even when the model's effects are at the unfavourable edge of their confidence interval.\n Present it as a statement about this model, not about the real world.\n If there is no such set, say that the search found no set of inputs that settles the prediction under these conditions, because that result does not show that each single input is needed.\n `\n}\n\nfunction completions_question(num_sentences: int) -> string {\n `\n Explain, in at most ${num_sentences} sentences, how the outcome gets more certain as the inputs become known.\n The facts give the share of people who would get the same prediction when only the first inputs are known and the rest are unknown (count completions).\n Describe how that share changes from step to step, and say so when it falls, because learning more inputs can lower the share and a sample adds noise. Name the inputs that make the biggest difference.\n Unlike the other two explanations, these shares are estimates from a large random sample that treats the unknown inputs as independent and distributed as in the training data. Describe them as approximate, because they are not guarantees.\n `\n}\n\nfunction LocalCounterfactual(\n global_explanation: string,\n facts: LocalFactTexts,\n audience_guidance: string,\n num_sentences: int,\n opts: GraphPromptOptions,\n language: string = \"English\",\n) -> string {\n client: Router\n prompt: `\n ${role(\"system\")}\n ${local_system_msg(opts.expert_description)}\n ${role(\"user\")}\n ${local_user_msg(global_explanation, facts.prediction, counterfactual_question(num_sentences), facts.counterfactual, audience_guidance, opts.dataset_description, language = language)}\n `\n}\n\nfunction LocalSufficientReason(\n global_explanation: string,\n facts: LocalFactTexts,\n audience_guidance: string,\n num_sentences: int,\n opts: GraphPromptOptions,\n language: string = \"English\",\n) -> string {\n client: Router\n prompt: `\n ${role(\"system\")}\n ${local_system_msg(opts.expert_description)}\n ${role(\"user\")}\n ${local_user_msg(global_explanation, facts.prediction, sufficient_reason_question(num_sentences), facts.sufficient_reason, audience_guidance, opts.dataset_description, language = language)}\n `\n}\n\nfunction LocalCompletions(\n global_explanation: string,\n facts: LocalFactTexts,\n audience_guidance: string,\n num_sentences: int,\n opts: GraphPromptOptions,\n language: string = \"English\",\n) -> string {\n client: Router\n prompt: `\n ${role(\"system\")}\n ${local_system_msg(opts.expert_description)}\n ${role(\"user\")}\n ${local_user_msg(global_explanation, facts.prediction, completions_question(num_sentences), facts.completions, audience_guidance, opts.dataset_description, language = language)}\n `\n}\n\n// Entry point called from Python: the three explanations are independent, so they run concurrently.\nfunction explain_local(\n global_explanation: string,\n facts: LocalFactTexts,\n audience_guidance: string,\n num_sentences: int,\n opts: GraphPromptOptions,\n language: string = \"English\",\n client: ai.Client? = null,\n model: ModelSpec? = null,\n) -> LocalExplanationText {\n let selected = select_client(client, model, short_defaults());\n let counterfactual = spawn {\n run_counted(\n LocalCounterfactual@spec(global_explanation, facts, audience_guidance, num_sentences, opts, language = language),\n client = selected,\n )\n };\n let sufficient = spawn {\n run_counted(\n LocalSufficientReason@spec(global_explanation, facts, audience_guidance, num_sentences, opts, language = language),\n client = selected,\n )\n };\n let completions = spawn {\n run_counted(\n LocalCompletions@spec(global_explanation, facts, audience_guidance, num_sentences, opts, language = language),\n client = selected,\n )\n };\n let done = await baml.future.all([counterfactual, sufficient, completions]);\n LocalExplanationText {\n counterfactual: done[0].text,\n sufficient_reason: done[1].text,\n completions: done[2].text,\n usage: add_usage(add_usage(done[0].usage, done[1].usage), done[2].usage),\n }\n}\n",
27
+ "mcp_agent.baml": "// An agent that explains an EBM through an MCP server. `explain_with_mcp` starts the server (the `ebaml-mcp` command),\n// offers its tools to the model, lets the model call them, and returns the final report with the list of calls.\n\n// What the agent returns: the answer, and the tools that it called, in order. A caller checks `tool_calls` to see\n// that the answer rests on tool results.\nclass McpAgentReport {\n report: string,\n tool_calls: string[],\n usage: TokenUsage,\n}\n\nfunction mcp_agent_system_msg() -> string {\n `You are a data scientist who explains a fitted Explainable Boosting Machine (EBM) to a colleague. An EBM is a sum of one graph per feature, so each graph shows exactly how one feature moves the prediction. You reach the model only through tools, and every tool result is exact. Quote only numbers, ranges and effects that a tool returned, because the colleague acts on your report and an invented number would mislead. Say when you did not check something.`\n}\n\nfunction mcp_agent_user_msg(question: string) -> string {\n `\n <instructions>\n 1. Call the tool that summarizes the model, then the tool that lists the features.\n 2. Read the graph of every feature that matters for the question, the most important first.\n 3. If the question concerns one prediction, call the tool that explains a prediction.\n 4. Write the report in plain prose paragraphs. Name the strongest effects with their ranges, and name any surprising or non-monotonic region, because the reader checks it against business knowledge.\n </instructions>\n\n <question>\n ${question}\n </question>\n `\n}\n\n// The agent loop. The model sees the system message and the question, and `ToolRequested` events fill `tool_calls`.\nfunction McpExplainer(question: string) -> string {\n client: Router\n prompt: `\n ${role(\"system\")}\n ${mcp_agent_system_msg()}\n ${role(\"user\")}\n ${mcp_agent_user_msg(question)}\n `\n}\n\n// The tool-calling loop on tools that the caller supplies. `explain_with_mcp` passes the tools of the server, and the\n// offline tests pass tools with fixed results.\nfunction explain_with_tools(\n question: string,\n tools: ai.tools.Tool[],\n client: ai.Client? = null,\n model: ModelSpec? = null,\n max_steps: int = 12,\n) -> McpAgentReport {\n let tool_calls: string[] = [];\n let samples: TokenSample[] = [];\n let agent = ai.Agent.new(max_steps = max_steps, client = select_client(client, model, short_defaults()), on_event = (\n event,\n ) -> {\n if let call: ai.events.ToolRequested = event {\n tool_calls.push(call.name);\n };\n if let model_call: ai.events.ModelCall = event {\n let sample = sample_of(model_call);\n if (sample != null) {\n samples.push(sample);\n };\n };\n });\n //# The spec carries the tools of the caller. The generated spec has none, because the tools are known at run time.\n let base = McpExplainer@spec(question);\n let spec = ai.FunctionSpec { ...base, toolbox: ai.tools.Toolbox.new(tools) };\n let result = agent.run(spec);\n let usage = TokenUsage { input_tokens: 0, output_tokens: 0, samples: samples };\n for (let entry in result.usage) {\n usage\n = add_usage(\n usage,\n TokenUsage {\n input_tokens: entry.usage.input_tokens ?? 0,\n output_tokens: entry.usage.output_tokens ?? 0,\n samples: [],\n },\n );\n }\n McpAgentReport { report: result.value, tool_calls: tool_calls, usage: usage }\n}\n\n// Entry point called from Python or the command line. `command` and `args` start the MCP server, for example\n// `ebaml-mcp` with `[\"--model\", \"model.skops\", \"--data\", \"train.csv\"]`. The connection closes on every path.\nfunction explain_with_mcp(\n question: string,\n command: string,\n args: string[],\n client: ai.Client? = null,\n model: ModelSpec? = null,\n max_steps: int = 12,\n) -> McpAgentReport {\n //# Start the server and read its tool catalog.\n let connection = ai.mcp.Connection.connect(\"ebaml\", command, args);\n defer { connection.close() }\n //# Let the model call the tools, then return its report.\n explain_with_tools(question, connection.tools(), client = client, model = model, max_steps = max_steps)\n}\n",
28
+ "mcp_agent_test.baml": "// Offline tests for mcp_agent.baml: a scripted model calls a fake tool, then answers.\n\n// Asks for `get_model_summary` on the first turn, then answers with a text that holds the tool result.\nclass ToolCallingClient {\n turns: int,\n seen_tools: string[],\n\n implements ai.Client {\n function provider(self) -> string {\n \"scripted\"\n }\n\n function requested_model(self) -> string {\n \"scripted\"\n }\n\n function render(self, input: ai.ModelTurnInput) -> baml.http.Request {\n baml.http.Request.from_url(\"http://scripted.invalid\")\n }\n\n function invoke(self, input: ai.ModelTurnInput) -> ai.ModelTurn {\n self.turns += 1;\n if (self.turns == 1) {\n let turn = scripted_turn(\"\", 10, 5);\n turn.content\n = [ai.content.ToolUse { id: \"call-1\", name: \"get_model_summary\", args: {} }];\n turn.stop_reason = ai.content.StopReason.ToolUse;\n return turn;\n };\n scripted_turn(\"Report: 2 features.\", 20, 8)\n }\n }\n}\n\nfunction fake_summary_tool() -> ai.tools.Tool {\n ai.tools.raw_tool(\"get_model_summary\", \"Summarize the model.\", { \"type\": \"object\", \"properties\": {} }, (\n args,\n ) -> {\n `{\"feature_count\": 2}`\n })\n}\n\ntest \"explain_with_tools runs the tool the model asks for and reports it\" {\n let scripted = ToolCallingClient { turns: 0, seen_tools: [] };\n let result = explain_with_tools(\"What matters?\", [fake_summary_tool()], client = scripted);\n assert.equal(result.report, \"Report: 2 features.\");\n assert.equal(result.tool_calls, [\"get_model_summary\"]);\n assert.equal(scripted.turns, 2);\n assert.equal(result.usage.input_tokens, 30)\n}\n\ntest \"the user message holds the question and the system message forbids invented numbers\" {\n assert.is_true(mcp_agent_user_msg(\"Why?\").includes(\"Why?\"));\n assert.is_true(mcp_agent_system_msg().includes(\"invented number\"))\n}\n",
27
29
  "model_spec.baml": "// A model chosen at run time. Python sends a `ModelSpec` (plain data) and BAML builds the client, because a client\n// object cannot cross the Python/BAML boundary.\n\nclass ModelSpec {\n provider: string,\n model: string,\n api_key_env: string?,\n base_url: string?,\n temperature: float?,\n max_output_tokens: int?,\n headers: map<string, string>?,\n}\n\n// The settings of one call: used for each field that the `ModelSpec` leaves null.\nclass CallDefaults {\n temperature: float,\n max_output_tokens: int,\n}\n\n// These three must equal the `temperature` and `max_tokens` of `RouterBase`, `RouterLongBase` and\n// `RouterBenchmarkBase` in talk_to_ebm.baml.\nfunction short_defaults() -> CallDefaults {\n CallDefaults { temperature: 0.7, max_output_tokens: 12000 }\n}\n\n// The first turn of each conversation allows a longer answer.\nfunction long_defaults() -> CallDefaults {\n CallDefaults { temperature: 0.7, max_output_tokens: 16000 }\n}\n\nfunction benchmark_defaults() -> CallDefaults {\n CallDefaults { temperature: 0.0, max_output_tokens: 16000 }\n}\n\n// A field that the user set wins. Otherwise the default of the call applies.\nfunction resolve_settings(spec: ModelSpec, defaults: CallDefaults) -> CallDefaults {\n CallDefaults {\n temperature: spec.temperature ?? defaults.temperature,\n max_output_tokens: spec.max_output_tokens ?? defaults.max_output_tokens,\n }\n}\n\n// The key is read from the environment when the request is sent. Null selects the default variable of the provider.\nfunction credential(name: string?) -> ai.Credential? {\n if (name == null) {\n return null;\n };\n baml.env.ref(name)\n}\n\nfunction build_openai(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n openai.ChatClient.new(\n model = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_tokens = settings.max_output_tokens,\n )\n}\n\nfunction build_openai_generic(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n openai.GenericClient.new(\n model = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_tokens = settings.max_output_tokens,\n )\n}\n\n// Azure serves deployments under names that the owner chose, so `model` names the deployment. `base_url` names it too\n// and wins. Without it, the deployment is built on the endpoint in `AZURE_OPENAI_ENDPOINT`.\nfunction build_azure(spec: ModelSpec, settings: CallDefaults) -> openai.AzureClient {\n openai.AzureClient.new(\n model = spec.model,\n deployment_id = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_tokens = settings.max_output_tokens,\n )\n}\n\nfunction build_openrouter(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n openai.OpenRouterClient.new(\n model = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_tokens = settings.max_output_tokens,\n )\n}\n\nfunction build_ollama(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n openai.OllamaClient.new(\n model = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_tokens = settings.max_output_tokens,\n )\n}\n\nfunction build_anthropic(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n anthropic.Client.new(\n model = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_tokens = settings.max_output_tokens,\n )\n}\n\n// Gemini names its output limit `max_output_tokens`.\nfunction build_google(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n google.GeminiClient.new(\n model = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_output_tokens = settings.max_output_tokens,\n )\n}\n\nfunction build_vertex(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n google.VertexClient.new(\n model = spec.model,\n api_key = credential(spec.api_key_env),\n base_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_output_tokens = settings.max_output_tokens,\n )\n}\n\n// Bedrock signs requests with AWS credentials, so `api_key_env` has no effect.\nfunction build_bedrock(spec: ModelSpec, settings: CallDefaults) -> ai.Client {\n aws.BedrockClient.new(\n model = spec.model,\n endpoint_url = spec.base_url,\n headers = spec.headers,\n temperature = settings.temperature,\n max_tokens = settings.max_output_tokens,\n )\n}\n\n// One row for each provider. A new provider is a new row. The keys are the BAML provider prefixes.\nfunction client_builders() -> map<string, (ModelSpec, CallDefaults) -> ai.Client throws never> {\n {\n \"openai\": build_openai,\n \"openai-generic\": build_openai_generic,\n \"azure\": build_azure,\n \"openrouter\": build_openrouter,\n \"ollama\": build_ollama,\n \"anthropic\": build_anthropic,\n \"google\": build_google,\n \"vertex\": build_vertex,\n \"bedrock\": build_bedrock,\n }\n}\n\n// The provider prefixes that `ModelSpec.provider` accepts, in table order.\nfunction supported_providers() -> string[] {\n client_builders().keys()\n}\n\n// Builds the client of `spec` with the retry policy of the default clients.\nfunction build_client(spec: ModelSpec, defaults: CallDefaults) -> ai.Client {\n let builders = client_builders();\n let build = builders.get(spec.provider);\n if (build == null) {\n throw baml.errors.InvalidArgument {\n message: `unknown provider \"${spec.provider}\"; supported providers: ${supported_providers().join(\", \")}`,\n };\n };\n ai.clients.Retry.new(inner = build(spec, resolve_settings(spec, defaults)), max_attempts = 3)\n}\n\n// Builds and discards the client, so that Python can reject a bad provider before the first paid call.\nfunction check_model(spec: ModelSpec) -> bool {\n build_client(spec, short_defaults());\n true\n}\n\n// Precedence: `client` (the test hook) > `model` > null, which selects the client declared by the function.\nfunction select_client(\n client: ai.Client?,\n model: ModelSpec?,\n defaults: CallDefaults,\n) -> ai.Client? {\n if (client != null) {\n return client;\n };\n if (model == null) {\n return null;\n };\n build_client(model, defaults)\n}\n",
28
30
  "model_spec_test.baml": "// Offline tests for model_spec.baml: building a client from a `ModelSpec` sends no request.\n\nfunction spec_for(provider: string) -> ModelSpec {\n ModelSpec {\n provider: provider,\n model: \"m\",\n api_key_env: null,\n base_url: null,\n temperature: null,\n max_output_tokens: null,\n headers: null,\n }\n}\n\ntest \"every provider of the table builds a client with no network access\" {\n let providers = client_builders().keys();\n assert.equal(providers.length(), 9);\n for (let provider in providers) {\n assert.equal(build_client(spec_for(provider), short_defaults()).requested_model(), \"m\");\n }\n}\n\ntest \"the table lists the BAML provider prefixes\" {\n let providers = supported_providers();\n for (\n let prefix in [\n \"openai\",\n \"openai-generic\",\n \"azure\",\n \"openrouter\",\n \"ollama\",\n \"anthropic\",\n \"google\",\n \"vertex\",\n \"bedrock\",\n ]\n ) {\n assert.is_true(providers.includes(prefix));\n }\n}\n\ntest \"a client with every optional field set builds\" {\n let spec = ModelSpec {\n provider: \"openai-generic\",\n model: \"m\",\n api_key_env: \"GATEWAY_KEY\",\n base_url: \"http://gateway.invalid/v1\",\n temperature: 0.2,\n max_output_tokens: 100,\n headers: { \"x-team\": \"ebm\" },\n };\n assert.equal(build_client(spec, short_defaults()).requested_model(), \"m\")\n}\n\ntest \"resolve_settings lets the user values win over the defaults of the call\" {\n let spec = ModelSpec {\n provider: \"openai\",\n model: \"m\",\n api_key_env: null,\n base_url: null,\n temperature: 0.1,\n max_output_tokens: 50,\n headers: null,\n };\n let settings = resolve_settings(spec, long_defaults());\n assert.equal(settings.temperature, 0.1);\n assert.equal(settings.max_output_tokens, 50)\n}\n\ntest \"resolve_settings takes the defaults of the call for null fields\" {\n let settings = resolve_settings(spec_for(\"openai\"), benchmark_defaults());\n assert.equal(settings.temperature, 0.0);\n assert.equal(settings.max_output_tokens, 16000)\n}\n\n// A reasoning model counts its hidden reasoning in the output limit. At 8000 tokens, live runs ended at the limit with\n// no answer, so the limits are 12000 and 16000.\ntest \"the call defaults differ by call as the declared clients do\" {\n assert.equal(short_defaults().max_output_tokens, 12000);\n assert.equal(long_defaults().max_output_tokens, 16000);\n assert.equal(benchmark_defaults().max_output_tokens, 16000);\n assert.equal(short_defaults().temperature, 0.7);\n assert.equal(benchmark_defaults().temperature, 0.0)\n}\n\n// The message of the error that `build_client` throws, or \"built\" if it throws none.\nfunction failure_message(provider: string) -> string {\n let built = build_client(spec_for(provider), short_defaults()) catch (e) {\n baml.errors.InvalidArgument => {\n return e.message;\n },\n };\n \"built\"\n}\n\n// The provider and the model that a client asks for, or \"null\".\nfunction client_id(client: ai.Client?) -> string {\n if (client == null) {\n return \"null\";\n };\n `${client.provider()}/${client.requested_model()}`\n}\n\ntest \"an unknown provider throws InvalidArgument that lists the supported providers\" {\n let message = failure_message(\"nope\");\n assert.is_true(message.includes(\"nope\"));\n assert.is_true(message.includes(\"anthropic\"));\n assert.is_true(message.includes(\"openai-generic\"))\n}\n\ntest \"a known provider throws no error\" {\n assert.equal(failure_message(\"ollama\"), \"built\")\n}\n\ntest \"check_model accepts a known provider and rejects an unknown one\" {\n assert.is_true(check_model(spec_for(\"ollama\")));\n let outcome = check_model(spec_for(\"nope\")) catch (e) {\n baml.errors.InvalidArgument => false,\n };\n assert.equal(outcome, false)\n}\n\ntest \"select_client prefers the client over the model\" {\n let scripted = ScriptedClient { calls: 0 };\n let selected = select_client(scripted, spec_for(\"ollama\"), short_defaults());\n assert.equal(client_id(selected), \"scripted/scripted\")\n}\n\ntest \"select_client builds the client of the model\" {\n let selected = select_client(null, spec_for(\"ollama\"), short_defaults());\n assert.equal(client_id(selected), \"ollama/m\")\n}\n\ntest \"select_client returns null with no client and no model, so the declared client runs\" {\n assert.equal(client_id(select_client(null, null, short_defaults())), \"null\")\n}\n\ntest \"describe_graph_cot sends every turn to the client when both client and model are set\" {\n let scripted = ScriptedClient { calls: 0 };\n let result = describe_graph_cot(\"G\", 7, default_graph_options(), client = scripted, model = spec_for(\"ollama\"));\n assert.equal(result.text, \"R\");\n assert.equal(scripted.calls, 3)\n}\n\ntest \"an Azure client without base_url names the deployment after the model\" {\n let azure = build_azure(spec_for(\"azure\"), short_defaults());\n assert.equal(azure.deployment_id, \"m\")\n}\n",
29
31
  "prompt_tests.baml": "// Live prompt tests: real requests to the default Router clients, so they need a real OPENROUTER_API_KEY.\n// They check properties that a good answer must have (no model numbers for a layperson, a sentence limit, the\n// requested answer format), not exact wording, because the free router is not deterministic. Each test logs the reply\n// of the model. If a test fails, read the reply and rerun the test before you change a prompt, because one failure can\n// be noise. Offline runs exclude them: `baml test -x root::Live`.\n\n// Number of sentences in `text`: a run of closing punctuation followed by a space or the end of the text ends a sentence.\n// The period of a decimal (0.62) and the abbreviations \"e.g.\" and \"i.e.\" do not end a sentence.\nfunction count_sentences(text: string) -> int {\n let ends = baml.regex.new(\"[.!?]+[\\\"')\\\\]]*(\\\\s|$)\").match_all(text.trim()).length();\n let abbreviations = baml.regex.new(\"(?i)\\\\b(e\\\\.g|i\\\\.e)\\\\.\\\\s\").match_all(text).length();\n ends - abbreviations\n}\n\n// True when one clause of `text` holds both `figure` and a word for the denial of the loan. A clause ends at a comma, a\n// semicolon or the end of a sentence. The probability of the class after the flip (0.82 for \"loan approved\") read as\n// the probability of a denial is the error this catches.\nfunction ties_figure_to_denial(text: string, figure: string) -> bool {\n let denial = baml.regex.new(\"(?i)\\\\bdeni\");\n for (let clause in baml.regex.new(\"[,;]|[.!?](\\\\s|$)\").split(text)) {\n if (clause.includes(figure) && denial.has_match(clause)) {\n return true;\n }\n }\n ;\n false\n}\n\ntestset \"PromptChecks\" {\n test \"count_sentences: the period of a decimal does not end a sentence\" {\n assert.equal(count_sentences(\"The debt ratio is 0.62. Income is low.\"), 2)\n }\n\n test \"count_sentences: an abbreviation does not end a sentence\" {\n assert.equal(\n count_sentences(\"Young people, e.g. those under 30, score higher. Older people score lower!\"),\n 2,\n )\n }\n\n test \"count_sentences: a closing quote or bracket after the end counts once\" {\n assert.equal(count_sentences(\"He said \\\"no.\\\" Then (later.) she left...\"), 3)\n }\n\n test \"count_sentences: text with no closing punctuation has no sentence end\" {\n assert.equal(count_sentences(\"Income matters most\"), 0);\n assert.equal(count_sentences(\"\"), 0)\n }\n\n test \"ties_figure_to_denial: catches the probability of the new class read as a denial\" {\n // the reply of a live run with the facts of the counterfactual in separate keys\n assert.is_true(\n ties_figure_to_denial(\n \"subtracting 2.91 log-odds from the model and reducing the denial probability to 0.82 (95% CI [0.74, 0.89]).\",\n \"0.82\",\n ),\n );\n assert.is_true(ties_figure_to_denial(\"a 0.82 chance of being denied\", \"0.82\"))\n }\n\n test \"ties_figure_to_denial: accepts the probability given to the new class\" {\n assert.is_true(\n !ties_figure_to_denial(\n \"The loan would be approved with probability 0.82, so the denial is overturned.\",\n \"0.82\",\n ),\n );\n assert.is_true(\n !ties_figure_to_denial(\"The prediction flips to loan approved (probability 0.82).\", \"0.82\"),\n )\n }\n}\n\n// The guidance of the two built-in audiences. A test in tests/unit/ebaml/local/test_audience.py checks that these texts\n// equal Layperson.guidance() and DataScientist.guidance(), so the live tests run the prompts that users get.\nfunction live_layperson_guidance() -> string {\n \"The reader is not technical and knows no statistics, so write in everyday words. Express strength and likelihood in plain words such as 'strongly', 'slightly', 'very likely' or 'about as likely as not'. Mention only values of the person's own inputs (for example their age), because model numbers (scores, log-odds, probabilities, percentages, intervals, standard deviations) mean nothing to this reader. The predicted value of a number prediction and the limits of the question are not model numbers: quote them as the facts give them, because the reader asked about them.\"\n}\n\nfunction live_data_scientist_guidance() -> string {\n \"The reader is a data scientist, so be precise. Quote the scores, the probabilities or predicted values, and the confidence intervals from the facts. Say how uncertain a statement is when the facts show wide confidence intervals.\"\n}\n\n// The facts of one loan prediction, as ebaml.local.fact_text.facts_to_texts renders them for each audience. A layperson\n// gets words in place of the model numbers, so the layperson prompts see no score, probability or share.\nfunction live_layperson_facts() -> LocalFactTexts {\n LocalFactTexts {\n prediction: `{\"predicted_class\": \"loan denied\", \"contributions_largest_first\": [{\"feature\": \"income\", \"value\": \"[1.8e+04, 2.4e+04)\", \"effect\": \"strongly towards this prediction\"}, {\"feature\": \"debt_ratio\", \"value\": \"[0.55, 0.7)\", \"effect\": \"moderately towards this prediction\"}, {\"feature\": \"age\", \"value\": \"[35, 42)\", \"effect\": \"slightly towards this prediction\"}], \"likelihood\": \"very likely\"}`,\n counterfactual: `{\"flip_possible\": true, \"changes\": [{\"feature\": \"income\", \"from\": \"[1.8e+04, 2.4e+04)\", \"to\": \"[4.5e+04, 5e+04)\"}], \"number_of_changes\": 1, \"is_smallest_set\": true, \"after_the_changes\": {\"predicted_class\": \"loan approved\", \"likelihood\": \"very likely\"}, \"flip_holds_even_if_the_model_is_somewhat_off\": true}`,\n sufficient_reason: `{\"exists\": true, \"features\": [\"income\", \"debt_ratio\"], \"features_not_needed\": [\"age\"]}`,\n completions: `{\"steps\": [{\"known_features\": [\"income\"], \"share_with_same_prediction\": \"likely\"}, {\"known_features\": [\"income\", \"debt_ratio\"], \"share_with_same_prediction\": \"almost certain\"}]}`,\n }\n}\n\nfunction live_data_scientist_facts() -> LocalFactTexts {\n LocalFactTexts {\n prediction: `{\"predicted_class\": \"loan denied\", \"contributions_largest_first\": [{\"feature\": \"income\", \"value\": \"[1.8e+04, 2.4e+04)\", \"score\": 1.12, \"std\": 0.15}, {\"feature\": \"debt_ratio\", \"value\": \"[0.55, 0.7)\", \"score\": 0.31, \"std\": 0.08}, {\"feature\": \"age\", \"value\": \"[35, 42)\", \"score\": 0.04, \"std\": 0.03}], \"probability\": 0.83, \"confidence_interval\": [0.74, 0.89], \"confidence_level\": 0.95, \"logit\": 1.37}`,\n counterfactual: `{\"flip_possible\": true, \"changes\": [{\"feature\": \"income\", \"from\": \"[1.8e+04, 2.4e+04)\", \"to\": \"[4.5e+04, 5e+04)\", \"score_change\": -2.91}], \"number_of_changes\": 1, \"is_smallest_set\": true, \"after_the_changes\": {\"predicted_class\": \"loan approved\", \"probability\": 0.82}, \"flip_holds_at_confidence\": 0.95}`,\n sufficient_reason: `{\"exists\": true, \"features\": [\"income\", \"debt_ratio\"], \"features_not_needed\": [\"age\"], \"guaranteed_margin_logit\": 0.42}`,\n completions: `{\"steps\": [{\"known_features\": [\"income\"], \"share_with_same_prediction\": 0.71}, {\"known_features\": [\"income\", \"debt_ratio\"], \"share_with_same_prediction\": 1.0}]}`,\n }\n}\n\n// The facts of one prediction of a regressor, for a layperson: the decision is a question about the predicted value.\nfunction live_regressor_facts() -> LocalFactTexts {\n LocalFactTexts {\n prediction: `{\"decision\": \"above 250000\", \"contributions_largest_first\": [{\"feature\": \"living_area\", \"value\": \"[160, 190)\", \"effect\": \"strongly towards this prediction\"}, {\"feature\": \"age_of_house\", \"value\": \"[5, 10)\", \"effect\": \"slightly towards this prediction\"}], \"predicted_value\": 312000.0}`,\n counterfactual: `{\"flip_possible\": true, \"changes\": [{\"feature\": \"living_area\", \"from\": \"[160, 190)\", \"to\": \"[60, 80)\"}], \"number_of_changes\": 1, \"is_smallest_set\": true, \"after_the_changes\": {\"decision\": \"at most 250000\", \"predicted_value\": 198000.0}, \"flip_holds_even_if_the_model_is_somewhat_off\": true}`,\n sufficient_reason: `{\"exists\": true, \"features\": [\"living_area\"], \"features_not_needed\": [\"age_of_house\"]}`,\n completions: `{\"steps\": [{\"known_features\": [\"living_area\"], \"share_with_same_prediction\": \"almost certain\"}]}`,\n }\n}\n\n// The facts of one prediction of a multiclass classifier, for a layperson: the counterfactual asks for a chosen class, and\n// the search did not prove that its set is the smallest.\nfunction live_multiclass_facts() -> LocalFactTexts {\n LocalFactTexts {\n prediction: `{\"predicted_class\": \"standard plan\", \"contributions_largest_first\": [{\"feature\": \"monthly_usage\", \"value\": \"[20, 30)\", \"effect\": \"strongly towards this prediction\"}, {\"feature\": \"contract_length\", \"value\": \"[1, 2)\", \"effect\": \"slightly towards this prediction\"}], \"likelihood\": \"likely\"}`,\n counterfactual: `{\"flip_possible\": true, \"changes\": [{\"feature\": \"monthly_usage\", \"from\": \"[20, 30)\", \"to\": \"[90, 100)\"}], \"number_of_changes\": 1, \"is_smallest_set\": false, \"after_the_changes\": {\"predicted_class\": \"premium plan\", \"likelihood\": \"very likely\"}, \"flip_holds_even_if_the_model_is_somewhat_off\": true}`,\n sufficient_reason: `{\"exists\": true, \"features\": [\"monthly_usage\"], \"is_smallest_set\": true, \"features_not_needed\": [\"contract_length\"]}`,\n completions: `{\"steps\": [{\"known_features\": [\"monthly_usage\"], \"share_with_same_prediction\": \"very likely\"}]}`,\n }\n}\n\n// Prints the reply of a live test. An assertion reports only \"expected true\", so the log is how a failed run shows\n// whether the model or the check is wrong.\nfunction log_reply(reply: string) -> null {\n log.info({ \"reply\": reply }, event_name = \"live_reply\")\n}\n\ntestset \"Live\" {\n test \"layperson counterfactual: no model numbers, within the sentence limit, names the input\" {\n let text = LocalCounterfactual(\n \"The model denies loans mainly because of low income and a high debt ratio.\",\n live_layperson_facts(),\n live_layperson_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(text);\n assert.is_true(text.includes(\"income\"));\n assert.is_true(!text.includes(\"0.83\") && !text.includes(\"1.37\") && !text.includes(\"2.91\"));\n assert.is_true(!text.includes(\"%\"));\n assert.is_true(count_sentences(text) <= 3)\n }\n\n test \"layperson sufficient reason: says the other inputs cannot change the outcome\" {\n let text = LocalSufficientReason(\n \"The model denies loans mainly because of low income and a high debt ratio.\",\n live_layperson_facts(),\n live_layperson_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(text);\n assert.is_true(text.to_lower_case().includes(\"income\"));\n assert.is_true(text.to_lower_case().includes(\"age\"));\n assert.is_true(!text.includes(\"0.04\"));\n assert.is_true(count_sentences(text) <= 3)\n }\n\n test \"layperson completions: approximate wording and no percentages\" {\n let text = LocalCompletions(\n \"The model denies loans mainly because of low income and a high debt ratio.\",\n live_layperson_facts(),\n live_layperson_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(text);\n assert.is_true(!text.includes(\"71\") && !text.includes(\"%\"));\n assert.is_true(count_sentences(text) <= 3)\n }\n\n test \"data scientist counterfactual: keeps the figures from the facts and gives 0.82 to the new class\" {\n let text = LocalCounterfactual(\n \"The model denies loans mainly because of low income and a high debt ratio.\",\n live_data_scientist_facts(),\n live_data_scientist_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(text);\n // the target bin \"[4.5e+04, 5e+04)\" may be written as \"45,000\", \"45 000\" or \"45k\"\n assert.is_true(baml.regex.new(\"2\\\\.91|4\\\\.5e\\\\+?04|45[,. ]?000|45k\").has_match(text));\n // 0.82 is the probability of \"loan approved\", the class after the changes\n assert.is_true(!ties_figure_to_denial(text, \"0.82\"))\n }\n\n test \"regressor counterfactual: names the input and the new value, and keeps the new value apart from the old one\" {\n let text = LocalCounterfactual(\n \"The model predicts the price of a house, mainly from its living area.\",\n live_regressor_facts(),\n live_layperson_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(text);\n assert.is_true(text.to_lower_case().includes(\"area\"));\n assert.is_true(baml.regex.new(\"198[,. ]?000|198k\").has_match(text));\n assert.is_true(count_sentences(text) <= 3)\n }\n\n test \"multiclass counterfactual of a target class: names the new class, and does not call the set the smallest\" {\n let text = LocalCounterfactual(\n \"The model recommends a plan to each customer, mainly from the monthly usage.\",\n live_multiclass_facts(),\n live_layperson_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(text);\n assert.is_true(text.to_lower_case().includes(\"premium\"));\n assert.is_true(text.to_lower_case().includes(\"usage\"));\n assert.is_true(\n !text.to_lower_case().includes(\"smallest\") && !text.to_lower_case().includes(\"fewest\"),\n );\n assert.is_true(count_sentences(text) <= 3)\n }\n\n test \"sufficient reason with no proof of its size: the set is not called the smallest\" {\n let facts = LocalFactTexts {\n prediction: live_regressor_facts().prediction,\n counterfactual: live_regressor_facts().counterfactual,\n sufficient_reason: `{\"exists\": true, \"features\": [\"living_area\", \"age_of_house\"], \"is_smallest_set\": false, \"features_not_needed\": [\"garage\"]}`,\n completions: live_regressor_facts().completions,\n };\n let text = LocalSufficientReason(\n \"The model predicts the price of a house, mainly from its living area.\",\n facts,\n live_layperson_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(text);\n assert.is_true(text.to_lower_case().includes(\"garage\"));\n assert.is_true(!text.to_lower_case().includes(\"smallest\"));\n assert.is_true(count_sentences(text) <= 3)\n }\n\n test \"explain_local: three explanations, each non-empty, usage reported\" {\n let result = explain_local(\n \"The model denies loans mainly because of low income and a high debt ratio.\",\n live_layperson_facts(),\n live_layperson_guidance(),\n 3,\n default_graph_options(),\n );\n log_reply(result.counterfactual);\n log_reply(result.sufficient_reason);\n log_reply(result.completions);\n assert.is_true(result.counterfactual.length() > 0);\n assert.is_true(result.sufficient_reason.length() > 0);\n assert.is_true(result.completions.length() > 0);\n assert.is_true(result.usage.input_tokens > 0);\n assert.is_true(result.usage.output_tokens > 0)\n }\n\n test \"describe_graph_cot: names the feature and respects the sentence limit\" {\n let graph = \"{\\\"feature_name\\\": \\\"age\\\", \\\"type\\\": \\\"continuous\\\", \\\"mean\\\": {\\\"18-30\\\": 0.8, \\\"30-50\\\": 0.0, \\\"50-90\\\": -0.6}}\";\n let result = describe_graph_cot(graph, 3, default_graph_options());\n log_reply(result.text);\n assert.is_true(result.text.to_lower_case().includes(\"age\"));\n assert.is_true(count_sentences(result.text) <= 4);\n assert.is_true(result.usage.input_tokens > 0)\n }\n\n test \"describe_graph_cot: a multiclass graph is read class against class\" {\n // \"young\" leads at low ages and \"old\" at high ages; a good answer names both classes and the change of lead\n let graph = \"Feature Name: age\\nFeature Type: continuous\\nClass: young\\nMeans: {\\\"(18, 30)\\\": 1.5, \\\"(30, 50)\\\": 0.0, \\\"(50, 90)\\\": -1.5}\\nClass: middle\\nMeans: {\\\"(18, 30)\\\": 0.0, \\\"(30, 50)\\\": 0.5, \\\"(50, 90)\\\": 0.0}\\nClass: old\\nMeans: {\\\"(18, 30)\\\": -1.5, \\\"(30, 50)\\\": -0.5, \\\"(50, 90)\\\": 1.5}\";\n let result = describe_graph_cot(graph, 4, default_graph_options());\n log_reply(result.text);\n let text = result.text.to_lower_case();\n assert.is_true(text.includes(\"young\") && text.includes(\"old\"));\n assert.is_true(count_sentences(result.text) <= 5)\n }\n\n test \"describe_graph_cot: a ModelSpec sends the requests to the chosen model\" {\n let graph = \"{\\\"feature_name\\\": \\\"age\\\", \\\"type\\\": \\\"continuous\\\", \\\"mean\\\": {\\\"18-30\\\": 0.8, \\\"30-50\\\": 0.0, \\\"50-90\\\": -0.6}}\";\n let model = ModelSpec {\n provider: \"openrouter\",\n model: \"openrouter/free\",\n api_key_env: \"OPENROUTER_API_KEY\",\n base_url: null,\n temperature: null,\n max_output_tokens: null,\n headers: null,\n };\n let result = describe_graph_cot(graph, 3, default_graph_options(), model = model);\n log_reply(result.text);\n assert.is_true(result.text.to_lower_case().includes(\"age\"));\n assert.is_true(result.usage.output_tokens > 0)\n }\n\n test \"answer_benchmark_question: the final turn follows the requested format\" {\n let question = \"A model's graph for feature x has mean value 2.0 for x < 5 and -1.0 for x >= 5. Is the function decreasing in x? Think step by step.\";\n let result = answer_benchmark_question(question, \"'yes' or 'no'\");\n log_reply(result.text);\n // The step function is decreasing but not strictly, so a careful model may answer either way. The LiveBenchmark\n // tests check the answers; this test checks only that the final turn is the bare answer.\n let answer = result.text.trim().to_lower_case();\n assert.is_true(baml.regex.new(\"^\\\\W*(yes|no)\\\\W*$\").has_match(answer))\n }\n}\n",
@@ -122,4 +122,14 @@ FUNCTIONS: dict[str, dict[str, object]] = {
122
122
  "stream": "LocalSufficientReason_stream",
123
123
  "stream_async": "LocalSufficientReason_stream_async",
124
124
  },
125
+ "user.McpExplainer": {
126
+ "module": "baml_sdk",
127
+ "type_params": (),
128
+ "direct": "McpExplainer",
129
+ "direct_async": "McpExplainer_async",
130
+ "spec": "McpExplainer_spec",
131
+ "spec_async": "McpExplainer_spec_async",
132
+ "stream": "McpExplainer_stream",
133
+ "stream_async": "McpExplainer_stream_async",
134
+ },
125
135
  }