Find answers from the community

Updated 5 months ago

Example notebook for parallel function calling in workflow

At a glance

The community members are discussing parallel function calling in a workflow. One community member suggests that if functions are properly implemented with async, they can be executed concurrently. If not, they can use asyncio.to_thread(..) to make them async and then execute them in an asyncio.gather() call.

Another community member is specifically interested in setting allow_parallel_tool_calls = True for a function calling a Large Language Model (LLM), and how that works alongside parallel execution via increasing the num_workers in a workflow step and gathering tool calls. They are looking at Anthropic specifically.

The community members discuss that if there is a step for calling tools, you can emit a number of events to trigger that step, and num_workers will control how many can run at a given time. However, the caveat is that this is async, not multiprocessing, so if something blocks the event loop, it will run sequentially. They suggest using asyncio.to_thread(..) if the tools are not async.

Hey all, is there an example notebook where parallel function calling is being used in a workflow?
L
D
6 comments
Probably depends on what you mean by "parallel function calling"

If functions are properly implemented with async, you can easily execute them concurrently

If they aren't, you can just do asyncio.to_thread(..) to make it async, and then execute them in an asyncio.gather() call
In this case I actually just mean setting allow_parallel_tool_calls = True for a function calling LLM, curious how that works alongside parallel execution via increasing the num_workers in a workflow step and gathering tool calls
Here I'm looking at Anthropic specifically
yea, for example if you have a step for specifically calling tools, you can emit X number of events to trigger that step, and num_workers will control how many can run at a given time
The caveat here is that this is async, not multiprocessing, so if something blocks the event loop, it will run sequentially
(hence the tip to use asyncio.to_thread if your tools aren't async)
Add a reply
Sign up and join the conversation on Discord