baml
baml copied to clipboard
🐞🐍 [bug] broken `b.with_options(tb)`
Steps to reproduce
BAML
class Dynamic {
@@dynamic
}
function GetDynamic() -> Dynamic {
client Default
prompt #"{{ctx.output_format}}"#
}
Python
tb = TypeBuilder()
tb.Dynamic.add_property(
name="hello",
type=tb.string(),
)
print(await b.with_options(tb=tb).request.GetDynamic())
[...]
{
"type": "text",
"text": "Answer in JSON using this schema:\n{\n}"
}
[...]
print(await b.request.GetDynamic(baml_options={"tb": tb}))
[...]
{
"type": "text",
"text": "Answer in JSON using this schema:\n{\n hello: string,\n}"
}
[...]
Package version
from importlib.metadata import version
version("baml_py")
'0.84.3'
I confirmed this works on 0.207.0
it("should include dynamic enum values in RenderDynamicEnum request (withOptions default)", async () => {
const tb = new TypeBuilder();
tb.RenderTestEnum.addValue("CHRISTMAS_SLEIGH").alias("motorized two-wheeler");
const myB = b.withOptions({ tb });
const request = await myB.request.RenderDynamicEnum(
"BIKE",
"CHRISTMAS_SLEIGH"
);
const requestBody = request.body.json();
const messageContent = requestBody.messages[0].content[0].text;
console.log(messageContent);
expect(messageContent).toContain("Available dynamic enum values:");
expect(messageContent).toContain("CHRISTMAS_SLEIGH");
});