-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
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 asload_prompt()- Works with
asyncio.gatherfor parallel prompt loading - Consistent behavior with sync version (caching, fallback, etc.)
Related
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels