Async Operations¶
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_collection
instead ofget_or_create_collection
. -
Using
asyncio.gather
allows 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.,arate
instead ofrate
) - Use
await
with async method calls - Wrap your code in an async function
- Use
asyncio.run()
to execute the async function
When working with multiple operations, consider using asyncio.gather()
to run them concurrently, as shown in the example above.