dspy.asyncify
dspy.asyncify(program: Module) -> Callable[[Any, Any], Awaitable[Any]]
Wraps a DSPy program so that it can be called asynchronously. This is useful for running a program in parallel with another task (e.g., another DSPy program).
This implementation propagates the current thread's configuration context to the worker thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
program
|
Module
|
The DSPy program to be wrapped for asynchronous execution. |
required |
Returns:
Type | Description |
---|---|
Callable[[Any, Any], Awaitable[Any]]
|
An async function: An async function that, when awaited, runs the program in a worker thread. The current thread's configuration context is inherited for each call. |