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

Method __decode__

src/anthropic/_decoders/jsonl.py:50–67  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48 self.http_response.close()
49
50 def __decode__(self) -> Iterator[_T]:
51 buf = b""
52 for chunk in self._raw_iterator:
53 for line in chunk.splitlines(keepends=True):
54 buf += line
55 if buf.endswith((b"\r", b"\n", b"\r\n")):
56 yield construct_type_unchecked(
57 value=json.loads(buf),
58 type_=self._line_type,
59 )
60 buf = b""
61
62 # flush
63 if buf:
64 yield construct_type_unchecked(
65 value=json.loads(buf),
66 type_=self._line_type,
67 )
68
69 def __next__(self) -> _T:
70 return self._iterator.__next__()

Callers 2

_iteratorMethod · 0.45
_iteratorMethod · 0.45

Calls 1

construct_type_uncheckedFunction · 0.85

Tested by

no test coverage detected