Debian Codegraph @

src/anthropic/lib/bedrock/_stream.py

raw
1 from __future__ import annotations
2
3 from typing import TypeVar
4
5 import httpx2
6
7 from ..._client import Anthropic, AsyncAnthropic
8 from ..._streaming import Stream, AsyncStream
9 from ._stream_decoder import AWSEventStreamDecoder
10
11 _T = TypeVar("_T")
12
13
14 class BedrockStream(Stream[_T]):
15 def __init__(
16 self,
17 *,
18 cast_to: type[_T],
19 response: httpx2.Response,
20 client: Anthropic,
21 ) -> None:
22 super().__init__(cast_to=cast_to, response=response, client=client)
23
24 self._decoder = AWSEventStreamDecoder()
25
26
27 class AsyncBedrockStream(AsyncStream[_T]):
28 def __init__(
29 self,
30 *,
31 cast_to: type[_T],
32 response: httpx2.Response,
33 client: AsyncAnthropic,
34 ) -> None:
35 super().__init__(cast_to=cast_to, response=response, client=client)
36
37 self._decoder = AWSEventStreamDecoder()