Summary
Add native async support for prompt loading in the Python SDK via an `aload_prompt()` function, allowing users to load multiple prompts in parallel using `asyncio.gather` without blocking.
Context
-
Use case: Users running async applications (e.g., with `asyncio.gather`) find that `load_prompt()` blocks, causing sequential execution when loading multiple prompts. This adds latency in production scenarios where prompts need to be fetched at request time.
-
Current workaround: Use `run_in_executor` to wrap the sync call:
loop = asyncio.get_event_loop()
prompt = await loop.run_in_executor(
None,
lambda: braintrust.load_prompt(project=project, slug=slug)
)
-
Component: Python SDK
Prior Work
A prototype was built on branch async-load-prompt with usage:
await braintrust.aload_prompt(project="...", slug="...")
This was not merged at the time, but multiple customers have since requested async support.
Requirements
Must have:
aload_prompt() function with same parameters as load_prompt()
- Works with
asyncio.gather for parallel prompt loading
- Consistent behavior with sync version (caching, fallback, etc.)
Related
Summary
Add native async support for prompt loading in the Python SDK via an `aload_prompt()` function, allowing users to load multiple prompts in parallel using `asyncio.gather` without blocking.
Context
Use case: Users running async applications (e.g., with `asyncio.gather`) find that `load_prompt()` blocks, causing sequential execution when loading multiple prompts. This adds latency in production scenarios where prompts need to be fetched at request time.
Current workaround: Use `run_in_executor` to wrap the sync call:
Component: Python SDK
Prior Work
A prototype was built on branch
async-load-promptwith usage:This was not merged at the time, but multiple customers have since requested async support.
Requirements
Must have:
aload_prompt()function with same parameters asload_prompt()asyncio.gatherfor parallel prompt loadingRelated