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

Function stream_events

tests/test_open_telemetry.py:588–602  ·  view source on GitHub ↗
(*, index: object = 0)

Source from the content-addressed store, hash-verified

586
587
588def stream_events(*, index: object = 0) -> list[dict[str, Any]]:
589 start: dict[str, Any] = {
590 **MESSAGE,
591 "content": [],
592 "stop_reason": None,
593 "usage": {**MESSAGE["usage"], "output_tokens": 0},
594 }
595 return [
596 {"type": "message_start", "message": start},
597 {"type": "content_block_start", "index": index, "content_block": {"type": "text", "text": ""}},
598 {"type": "content_block_delta", "index": index, "delta": {"type": "text_delta", "text": "Hi there"}},
599 {"type": "content_block_stop", "index": index},
600 {"type": "message_delta", "delta": {"stop_reason": "end_turn"}, "usage": {"output_tokens": 5}},
601 {"type": "message_stop"},
602 ]
603
604
605def stream_response(events: Sequence[dict[str, Any]] | None = None) -> httpx2.Response:

Calls

no outgoing calls

Tested by

no test coverage detected