MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / async_requester

Function async_requester

tests/utils.py:242–257  ·  view source on GitHub ↗

A method shaped like a generated streaming method, whose response is `body`.

(
    client: AsyncAnthropic, body: Body, *, stream_cls: type[AsyncStream[object]] = AsyncStream[object]
)

Source from the content-addressed store, hash-verified

240
241
242def async_requester(
243 client: AsyncAnthropic, body: Body, *, stream_cls: type[AsyncStream[object]] = AsyncStream[object]
244) -> AsyncRequest:
245 """A method shaped like a generated streaming method, whose response is `body`."""
246 client = client.with_options(http_client=httpx2.AsyncClient(transport=body.transport()))
247
248 async def request(*, extra_headers: Headers | None = None) -> AsyncStream[object]:
249 return await client.get(
250 "/stream",
251 cast_to=object,
252 options=make_request_options(extra_headers=extra_headers),
253 stream=True,
254 stream_cls=stream_cls,
255 )
256
257 return request
258
259
260@contextlib.contextmanager

Calls 2

with_optionsMethod · 0.80
transportMethod · 0.80