LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmith_openapi_client_responseasync_to_custom_streamed_response_wrapper
Function●Since v0.8

async_to_custom_streamed_response_wrapper

Copy
async_to_custom_streamed_response_wrapper(
  func: Callable[P, Awaitable[object]],
  response_cls: type[_AsyncAPIResponseT]
) ->
View source on GitHub
Callable
[
P
,
AsyncResponseContextManager
[
_AsyncAPIResponseT
]
]

Higher order function that takes one of our bound API methods and an APIResponse class and wraps the method to support streaming and returning the given response class directly.

Note: the given response_cls must be concrete, e.g. class BinaryAPIResponse(APIResponse[bytes])