Skip to content

Commit

Permalink
chore(types): consistent naming for text block types (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Apr 4, 2024
1 parent 2422008 commit a5064eb
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ from anthropic.types import (
MessageStopEvent,
MessageStreamEvent,
TextBlock,
TextBlockParam,
TextDelta,
Usage,
)
Expand Down
3 changes: 1 addition & 2 deletions src/anthropic/lib/streaming/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import httpx

from ...types import Message, MessageStreamEvent
from ...types import Message, ContentBlock, MessageStreamEvent
from ..._utils import consume_sync_iterator, consume_async_iterator
from ..._streaming import Stream, AsyncStream
from ...types.message import ContentBlock

if TYPE_CHECKING:
from ..._client import Anthropic, AsyncAnthropic
Expand Down
1 change: 1 addition & 0 deletions src/anthropic/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .usage import Usage as Usage
from .message import Message as Message
from .completion import Completion as Completion
from .text_block import TextBlock as TextBlock
from .text_delta import TextDelta as TextDelta
from .content_block import ContentBlock as ContentBlock
from .message_param import MessageParam as MessageParam
Expand Down
10 changes: 2 additions & 8 deletions src/anthropic/types/content_block.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing_extensions import Literal

from .._models import BaseModel

__all__ = ["ContentBlock"]
from .text_block import TextBlock


class ContentBlock(BaseModel):
text: str

type: Literal["text"]
ContentBlock = TextBlock
5 changes: 3 additions & 2 deletions src/anthropic/types/content_block_start_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from typing_extensions import Literal

from .._models import BaseModel
from .content_block import ContentBlock
from .text_block import TextBlock
from .content_block import ContentBlock as ContentBlock

__all__ = ["ContentBlockStartEvent"]


class ContentBlockStartEvent(BaseModel):
content_block: ContentBlock
content_block: TextBlock

index: int

Expand Down
5 changes: 3 additions & 2 deletions src/anthropic/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from .usage import Usage
from .._models import BaseModel
from .content_block import ContentBlock
from .text_block import TextBlock
from .content_block import ContentBlock as ContentBlock

__all__ = ["Message"]

Expand All @@ -17,7 +18,7 @@ class Message(BaseModel):
The format and length of IDs may change over time.
"""

content: List[ContentBlock]
content: List[TextBlock]
"""Content generated by the model.
This is an array of content blocks, each of which has a `type` that determines
Expand Down
13 changes: 13 additions & 0 deletions src/anthropic/types/text_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing_extensions import Literal

from .._models import BaseModel

__all__ = ["TextBlock"]


class TextBlock(BaseModel):
text: str

type: Literal["text"]

0 comments on commit a5064eb

Please sign in to comment.