https://www.boundaryml.com logo
baml dynamic schemas
# suggestions
v
Hey there, is it possible to adjust BAML dynamic schema based on partial outputs in the stream of tokens? If not, that’s my suggestion! 😄
b
not something we support, but I have no idea what you’re imagining here
union types + asserts kind of imply this
can you give an example of what you’d want to be possible?
v
Toy scenario: if the first output token is ´cat’ then the following tokens should be parsed in accordance with schema Cat, but if the first token is ´dog’ then the following tokens should be parsed in accordance with schema Dog. (These two schemas have quite different fields.)
Union types and asserts sound reasonable, would you know if there is an example out there? I expected that dynamic schemas would achieve exactly this, but then looking at the docs didn’t make me much wiser.
Btw thx for your answer, sam!
b
Play around with union types! We support TS-style unions which allows parsing of { type: cat, cat_details: … }|{ type: dog, dog_details: … }
Dynamic types come into play when you need to do something like load a different document format per user
v
Got it. I will follow your advice, thx!