set_runtime_overrides(
aio_to_thread: Optional[AioToThread] = None,
) -> None| Name | Type | Description |
|---|---|---|
aio_to_thread | Optional[AioToThread] | Default: NoneCustom async function to run sync functions
asynchronously. Should have signature:
|
Set LangSmith runtime overrides.
This allows customizing LangSmith's async runtime behavior for environments
with constrained async runtimes (e.g., Temporal, which doesn't support
run_in_executor).
Example:
For Temporal or similar runtimes:
import langsmith
async def temporal_aio_to_thread(
default_aio_to_thread, ctx, func, /, *args, **kwargs
):
# Use the default implementation when not in a workflow
if not temporalio.workflow.in_workflow():
return await default_aio_to_thread(ctx, func, *args, **kwargs)
with temporalio.workflow.unsafe.sandbox_unrestricted():
return ctx.run(func, *args, **kwargs)
langsmith.set_runtime_overrides(aio_to_thread=temporal_aio_to_thread)
Reset to defaults:
langsmith.set_runtime_overrides()