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

Function async_stream_response

tests/lib/threads/helpers.py:437–454  ·  view source on GitHub ↗
(
    id: str,
    text: str = "Hello there!",
    *,
    tool_use_id: str | None = None,
    container: str | None = None,
    stop_reason: str | None = None,
    iterations: list[Any] | None = None,
)

Source from the content-addressed store, hash-verified

435
436
437def async_stream_response(
438 id: str,
439 text: str = "Hello there!",
440 *,
441 tool_use_id: str | None = None,
442 container: str | None = None,
443 stop_reason: str | None = None,
444 iterations: list[Any] | None = None,
445) -> httpx2.Response:
446 return httpx2.Response(
447 200,
448 headers={"content-type": "text/event-stream"},
449 content=to_async_iter(
450 _sse_body(
451 id, text, tool_use_id=tool_use_id, container=container, stop_reason=stop_reason, iterations=iterations
452 )
453 ),
454 )
455
456
457def partial_tool_use_stream_response(id: str, text: str, *, tool_use_id: str) -> httpx2.Response:

Calls 2

to_async_iterFunction · 0.85
_sse_bodyFunction · 0.85