Async Operations¶
Optimize performance with asynchronous operations for large-scale prompt evaluations and batch processing
elluminate supports asynchronous operations for improved performance when working with multiple prompts or evaluations. This is particularly useful when:
- Batch Processing - Handling multiple prompts or responses simultaneously
- Performance Optimization - Reducing overall execution time for large-scale evaluations
- Resource Efficiency - Better utilization of system resources during I/O operations
The following example demonstrates how to use async operations with collections in elluminate:
-
Async methods in elluminate are prefixed with
a. For example,aget_or_create_collectioninstead ofget_or_create_collection. -
Using
asyncio.gatherallows for concurrent execution of multiple async operations, significantly improving performance when adding multiple entries.
Most elluminate SDK operations have async counterparts, making it easy to convert existing synchronous code to async. Simply:
- Prefix method calls with
a(e.g.,arateinstead ofrate) - Use
awaitwith async method calls - Wrap your code in an async function
- Use
asyncio.run()to execute the async function
When working with multiple independent async operations, consider using asyncio.gather() to run them concurrently. Although this example runs tasks sequentially for clarity, you can parallelize multiple async calls for improved performance.