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

Function async_requester

tests/utils.py:260–275  ·  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

258
259
260def async_requester(
261 client: AsyncAnthropic, body: Body, *, stream_cls: type[AsyncStream[object]] = AsyncStream[object]
262) -> AsyncRequest:
263 """A method shaped like a generated streaming method, whose response is `body`."""
264 client = client.with_options(http_client=httpx2.AsyncClient(transport=body.transport()))
265
266 async def request(*, extra_headers: Headers | None = None) -> AsyncStream[object]:
267 return await client.get(
268 "/stream",
269 cast_to=object,
270 options=make_request_options(extra_headers=extra_headers),
271 stream=True,
272 stream_cls=stream_cls,
273 )
274
275 return request
276
277
278@contextlib.contextmanager

Calls 1

transportMethod · 0.80