|
|
|
|
|
by hellovai
735 days ago
|
|
we recently added dynamic type support with this snippet! (docs coming soon!) Python:
https://github.com/BoundaryML/baml/blob/413fdf12a0c8c1ebb75c... Typescript:
https://github.com/BoundaryML/baml/blob/413fdf12a0c8c1ebb75c... Snippet: async def test_dynamic(): tb = TypeBuilder()
tb.Person.add_property("last_name", tb.string().list())
tb.Person.add_property("height", tb.float().optional()).description(
"Height in meters"
)
tb.Hobby.add_value("chess")
for name, val in tb.Hobby.list_values():
val.alias(name.lower())
tb.Person.add_property("hobbies", tb.Hobby.type().list()).description(
"Some suggested hobbies they might be good at"
)
# no_tb_res = await b.ExtractPeople("My name is Harrison. My hair is black and I'm 6 feet tall.")
tb_res = await b.ExtractPeople(
"My name is Harrison. My hair is black and I'm 6 feet tall. I'm pretty good around the hoop.",
{"tb": tb},
)
assert len(tb_res) > 0, "Expected non-empty result but got empty."
for r in tb_res:
print(r.model_dump())
|
|