Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/anthropic/lib/bedrock/_stream_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self) -> None:
self.parser = EventStreamJSONParser()

def iter_bytes(self, iterator: Iterator[bytes]) -> Iterator[ServerSentEvent]:
"""Given an iterator that yields lines, iterate over it & yield every event encountered"""
"""Given an iterator that yields lines, iterate over it & yield every event encountered."""
from botocore.eventstream import EventStreamBuffer

event_stream_buffer = EventStreamBuffer()
Expand All @@ -40,7 +40,7 @@ def iter_bytes(self, iterator: Iterator[bytes]) -> Iterator[ServerSentEvent]:
yield ServerSentEvent(data=message, event="completion")

async def aiter_bytes(self, iterator: AsyncIterator[bytes]) -> AsyncIterator[ServerSentEvent]:
"""Given an async iterator that yields lines, iterate over it & yield every event encountered"""
"""Given an async iterator that yields lines, iterate over it & yield every event encountered."""
from botocore.eventstream import EventStreamBuffer

event_stream_buffer = EventStreamBuffer()
Expand Down
4 changes: 2 additions & 2 deletions src/anthropic/lib/streaming/_beta_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_final_text(self) -> str:
return "".join(text_blocks)

def until_done(self) -> None:
"""Blocks until the stream has been consumed"""
"""Blocks until the stream has been consumed."""
consume_sync_iterator(self)

# properties
Expand Down Expand Up @@ -248,7 +248,7 @@ async def get_final_text(self) -> str:
return "".join(text_blocks)

async def until_done(self) -> None:
"""Waits until the stream has been consumed"""
"""Waits until the stream has been consumed."""
await consume_async_iterator(self)

# properties
Expand Down
17 changes: 8 additions & 9 deletions src/anthropic/lib/streaming/_beta_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,51 @@ class BetaTextEvent(BaseModel):
type: Literal["text"]

text: str
"""The text delta"""
"""The text delta."""

snapshot: str
"""The entire accumulated text"""
"""The entire accumulated text."""


class BetaCitationEvent(BaseModel):
type: Literal["citation"]

citation: Citation
"""The new citation"""
"""The new citation."""

snapshot: List[Citation]
"""All of the accumulated citations"""
"""All of the accumulated citations."""


class BetaThinkingEvent(BaseModel):
type: Literal["thinking"]

thinking: str
"""The thinking delta"""
"""The thinking delta."""

snapshot: str
"""The accumulated thinking so far"""
"""The accumulated thinking so far."""


class BetaSignatureEvent(BaseModel):
type: Literal["signature"]

signature: str
"""The signature of the thinking block"""
"""The signature of the thinking block."""


class BetaInputJsonEvent(BaseModel):
type: Literal["input_json"]

partial_json: str
"""A partial JSON string delta
"""A partial JSON string delta.

e.g. `'"San Francisco,'`
"""

snapshot: object
"""The currently accumulated parsed object.


e.g. `{'location': 'San Francisco, CA'}`
"""

Expand Down
4 changes: 2 additions & 2 deletions src/anthropic/lib/streaming/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_final_text(self) -> str:
return "".join(text_blocks)

def until_done(self) -> None:
"""Blocks until the stream has been consumed"""
"""Blocks until the stream has been consumed."""
consume_sync_iterator(self)

# properties
Expand Down Expand Up @@ -246,7 +246,7 @@ async def get_final_text(self) -> str:
return "".join(text_blocks)

async def until_done(self) -> None:
"""Waits until the stream has been consumed"""
"""Waits until the stream has been consumed."""
await consume_async_iterator(self)

# properties
Expand Down
17 changes: 8 additions & 9 deletions src/anthropic/lib/streaming/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,51 @@ class TextEvent(BaseModel):
type: Literal["text"]

text: str
"""The text delta"""
"""The text delta."""

snapshot: str
"""The entire accumulated text"""
"""The entire accumulated text."""


class CitationEvent(BaseModel):
type: Literal["citation"]

citation: Citation
"""The new citation"""
"""The new citation."""

snapshot: List[Citation]
"""All of the accumulated citations"""
"""All of the accumulated citations."""


class ThinkingEvent(BaseModel):
type: Literal["thinking"]

thinking: str
"""The thinking delta"""
"""The thinking delta."""

snapshot: str
"""The accumulated thinking so far"""
"""The accumulated thinking so far."""


class SignatureEvent(BaseModel):
type: Literal["signature"]

signature: str
"""The signature of the thinking block"""
"""The signature of the thinking block."""


class InputJsonEvent(BaseModel):
type: Literal["input_json"]

partial_json: str
"""A partial JSON string delta
"""A partial JSON string delta.

e.g. `'"San Francisco,'`
"""

snapshot: object
"""The currently accumulated parsed object.


e.g. `{'location': 'San Francisco, CA'}`
"""

Expand Down