BAML with Python/TS/Ruby

Concurrent function calls

We’ll use function ClassifyMessage(input: string) -> Category for our example:

You can make concurrent b.ClassifyMessage() calls like so:

main.py
1import asyncio
2
3from baml_client import b
4from baml_client.types import Category
5
6async def main():
7 await asyncio.gather(
8 b.ClassifyMessage("I want to cancel my order"),
9 b.ClassifyMessage("I want a refund")
10 )
11
12if __name__ == '__main__':
13 asyncio.run(main())