Release8 days ago4 min read
BAML 0.18.0
Granular LLM call introspection, async Python streams, execution trace queries, expanded reflection, and a faster compiler and stream parser.
Features
- Add
on_eventto enable granular LLM call introspection (#4570) - aaronvg - In Python, allow using
async forto iterate over LLM streams (#4604) - aaronvg - Implement
baml queryto allow querying historical BAML program execution traces, and allow exploring them using the playground (#4548; #4563; #4578) - rossirpaulo - Improve Python SDK compatibility with BAML v0: allow previewing prompts without requiring secrets, add
FinishReasonError, expose OpenAI/Anthropic/Vertex-specific response metadata, and more (#4459) - aaronvg - Add
baml.io.Readandbaml.io.Writeinterfaces and make all stdlib I/O abstractions implement them (#4606) - Avery Townsend - Allow using
baml.json.to_stringandto_jsonwithunknown. (#4601) - Antonio Sarosi - Expanded reflection API: add
reflect.AnyClass,reflect.call_any, allowunreflect(expr)in any type position (#4491; #4493; #4519; #4574; #4600) - Antonio Sarosi - Allow truthiness conversions, e.g.
if (0)is now allowed; also improve type narrowing inifblocks (#4498) - Avery Townsend - Make more interface member projections work:
(Type as Interface).memberandInterface.instance_method(instance)(#4500) - 2kai2kai2 - Improve lambda type inference: allow using invocations of a lambda to infer its arg types, when the lambda is defined without them (#4599) - Avery Townsend
- Add
baml.errors.UnknownErrorfor wrapping errors while preserving original cause and stack trace (#4441) - Avery Townsend - Add lazy iterator primitives:
take,skip,take_while, andskip_while. (#4510) - Ritunjay - Add an optional
rngparameter toint.random(),float.random(),bool.random(), andbigint.random()(#4135) - 2kai2kai2 - Make
baml runandbaml testrespectBAML_LOGand--log <LEVEL>(#4408; #4409) - Sam Lijin
Breaking and compatibility changes
- Continue stabilizing the
ai.Runnerinterface (#4604) - aaronvg - Reflection types and methods are now consolidated into
reflect.*: we now havereflect.Type,reflect.AnyClass,reflect.AnyFunction, and everything frombaml.reflect.*has also been migrated (#4543; #4580) - Antonio Sarosi, 2kai2kai2 - Delete
baml.json.encode, which is redundant withbaml.json.to_string<unknown>()(#4601) - Antonio Sarosi - Drop support for Jinja template literals
#"..."#; LLM functions must now use BAML-native template literals${ipsum()} dolorinstead (#4565) - Avery Townsend - Drop support for BAML v0 test blocks
test ClassifyMessage { functions [Classify1, Classify2] ... }; tests must now be declared with BAML v1 expression bodiestest "my test case" { assert.equal(a, b) }(#4602) - Avery Townsend ctx.output_formatis now a callable API and must be written asctx.output_format(). (#4567) - Avery Townsendbaml_sdkis now generated in the same directory asbaml.toml, instead of the parent directory (#4522) - Sam Lijin- The generated C# client is now generated as
baml_sdkinstead ofbaml_client(#4535) - Sam Lijin
Fixes
- Improve LLM response parsing behavior when an optional field is omitted (#4612) - Sam Lijin
- Make HTTP operations in the playground work again (#4609) - hellovai
- Preserve errors thrown by code executed by
eval()(#4583) - Antonio Sarosi - Preserve type definition values at runtime, instead of dropping them or passing them around as strings (#4501; #4516; #4536; #4577) - Antonio Sarosi
- Make
unreflectsafe: define its compile-time and runtime behavior, and emit compiler diagnostics in disallowed scenarios (#4518; #4530) - Antonio Sarosi - Fix stack-carry compiler optimizations (#4508; #4544) - Sam Lijin, Antonio Sarosi
- Make match arms for
T[]match correctly (#4547) - Avery Townsend - Made literal patterns use type-membership semantics instead of value equality. (#4478) - Avery Townsend
- Prevent compiler crashes on
forloops over joined map union arms and onIterable-bounded generics. (#4490) - Avery Townsend - Raise compile errors for empty arrays and maps whose element types cannot be inferred. (#4573) - Avery Townsend
- Raise compile errors for non-data LLM output schemas instead of crashing or silently erroring. (#4470) - Antonio Sarosi
- Bring
ctx.output_format()to feature parity with BAML v0 (#4567) - Avery Townsend - When mutating an object in a called function or a loop, make sure the mutation persists when exiting the context. (#4467) - Antonio Sarosi
- Fix
x?.m<T>()syntax form: thread type args through optional chaining (#4495) - Antonio Sarosi - Return a compiler diagnostic when attempting to resolve member variables or call member functions on
unknown(#4466) - Antonio Sarosi - Return a reflection error, instead of silently failing, when attempting to resolve a generic function defined at runtime (#4473) - Antonio Sarosi
- Return a compiler diagnostic instead of crashing when type-checking functions with references to undefined types (#4566) - Avery Townsend
- Enforce runtime type checking of return values when calling functions with
reflect.call_any. (#4600) - Antonio Sarosi - Emit an error instead of crashing when
naming_convention = "language". (#4526) - Sam Lijin baml fmtnow removes redundant parentheses. (#4489; #4541) - Avery Townsend, aaronvg- Make BAML compile faster: stdlib is now precompiled. (#4453; #4458; #4461; #4463) - Antonio Sarosi
- LLM stream parsing is now faster: parsing is run on delta batches, instead of per-delta (#4604) - aaronvg