Skip to content

Commit

Permalink
chore(types): add more discriminator metadata (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored Jan 17, 2025
1 parent 483cc27 commit d0de8e5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
24 changes: 14 additions & 10 deletions src/anthropic/lib/streaming/_beta_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Union
from typing_extensions import Literal
from typing_extensions import Literal, Annotated

from ..._models import BaseModel
from ...types.beta import (
Expand All @@ -12,6 +12,7 @@
BetaRawContentBlockDeltaEvent,
BetaRawContentBlockStartEvent,
)
from ..._utils._transform import PropertyInfo


class BetaTextEvent(BaseModel):
Expand Down Expand Up @@ -53,13 +54,16 @@ class BetaContentBlockStopEvent(BetaRawContentBlockStopEvent):
content_block: BetaContentBlock


BetaMessageStreamEvent = Union[
BetaTextEvent,
BetaInputJsonEvent,
BetaRawMessageStartEvent,
BetaRawMessageDeltaEvent,
BetaMessageStopEvent,
BetaRawContentBlockStartEvent,
BetaRawContentBlockDeltaEvent,
BetaContentBlockStopEvent,
BetaMessageStreamEvent = Annotated[
Union[
BetaTextEvent,
BetaInputJsonEvent,
BetaRawMessageStartEvent,
BetaRawMessageDeltaEvent,
BetaMessageStopEvent,
BetaRawContentBlockStartEvent,
BetaRawContentBlockDeltaEvent,
BetaContentBlockStopEvent,
],
PropertyInfo(discriminator="type"),
]
24 changes: 14 additions & 10 deletions src/anthropic/lib/streaming/_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Union
from typing_extensions import Literal
from typing_extensions import Literal, Annotated

from ...types import (
Message,
Expand All @@ -12,6 +12,7 @@
RawContentBlockStopEvent,
)
from ..._models import BaseModel
from ..._utils._transform import PropertyInfo


class TextEvent(BaseModel):
Expand Down Expand Up @@ -53,13 +54,16 @@ class ContentBlockStopEvent(RawContentBlockStopEvent):
content_block: ContentBlock


MessageStreamEvent = Union[
TextEvent,
InputJsonEvent,
RawMessageStartEvent,
RawMessageDeltaEvent,
MessageStopEvent,
RawContentBlockStartEvent,
RawContentBlockDeltaEvent,
ContentBlockStopEvent,
MessageStreamEvent = Annotated[
Union[
TextEvent,
InputJsonEvent,
RawMessageStartEvent,
RawMessageDeltaEvent,
MessageStopEvent,
RawContentBlockStartEvent,
RawContentBlockDeltaEvent,
ContentBlockStopEvent,
],
PropertyInfo(discriminator="type"),
]
1 change: 0 additions & 1 deletion src/anthropic/resources/beta/messages/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,6 @@ def stream(
stream_cls=Stream[BetaRawMessageStreamEvent],
)
return BetaMessageStreamManager(make_request)


def count_tokens(
self,
Expand Down
1 change: 1 addition & 0 deletions src/anthropic/types/tool_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class InputSchemaTyped(TypedDict, total=False):

properties: Optional[object]


set_pydantic_config(InputSchemaTyped, {"extra": "allow"})

InputSchema: TypeAlias = Union[InputSchemaTyped, Dict[str, object]]
Expand Down

0 comments on commit d0de8e5

Please sign in to comment.