Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d0de8e5

Browse files
authoredJan 17, 2025··
chore(types): add more discriminator metadata (#825)
1 parent 483cc27 commit d0de8e5

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed
 

‎src/anthropic/lib/streaming/_beta_types.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Union
2-
from typing_extensions import Literal
2+
from typing_extensions import Literal, Annotated
33

44
from ..._models import BaseModel
55
from ...types.beta import (
@@ -12,6 +12,7 @@
1212
BetaRawContentBlockDeltaEvent,
1313
BetaRawContentBlockStartEvent,
1414
)
15+
from ..._utils._transform import PropertyInfo
1516

1617

1718
class BetaTextEvent(BaseModel):
@@ -53,13 +54,16 @@ class BetaContentBlockStopEvent(BetaRawContentBlockStopEvent):
5354
content_block: BetaContentBlock
5455

5556

56-
BetaMessageStreamEvent = Union[
57-
BetaTextEvent,
58-
BetaInputJsonEvent,
59-
BetaRawMessageStartEvent,
60-
BetaRawMessageDeltaEvent,
61-
BetaMessageStopEvent,
62-
BetaRawContentBlockStartEvent,
63-
BetaRawContentBlockDeltaEvent,
64-
BetaContentBlockStopEvent,
57+
BetaMessageStreamEvent = Annotated[
58+
Union[
59+
BetaTextEvent,
60+
BetaInputJsonEvent,
61+
BetaRawMessageStartEvent,
62+
BetaRawMessageDeltaEvent,
63+
BetaMessageStopEvent,
64+
BetaRawContentBlockStartEvent,
65+
BetaRawContentBlockDeltaEvent,
66+
BetaContentBlockStopEvent,
67+
],
68+
PropertyInfo(discriminator="type"),
6569
]

‎src/anthropic/lib/streaming/_types.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Union
2-
from typing_extensions import Literal
2+
from typing_extensions import Literal, Annotated
33

44
from ...types import (
55
Message,
@@ -12,6 +12,7 @@
1212
RawContentBlockStopEvent,
1313
)
1414
from ..._models import BaseModel
15+
from ..._utils._transform import PropertyInfo
1516

1617

1718
class TextEvent(BaseModel):
@@ -53,13 +54,16 @@ class ContentBlockStopEvent(RawContentBlockStopEvent):
5354
content_block: ContentBlock
5455

5556

56-
MessageStreamEvent = Union[
57-
TextEvent,
58-
InputJsonEvent,
59-
RawMessageStartEvent,
60-
RawMessageDeltaEvent,
61-
MessageStopEvent,
62-
RawContentBlockStartEvent,
63-
RawContentBlockDeltaEvent,
64-
ContentBlockStopEvent,
57+
MessageStreamEvent = Annotated[
58+
Union[
59+
TextEvent,
60+
InputJsonEvent,
61+
RawMessageStartEvent,
62+
RawMessageDeltaEvent,
63+
MessageStopEvent,
64+
RawContentBlockStartEvent,
65+
RawContentBlockDeltaEvent,
66+
ContentBlockStopEvent,
67+
],
68+
PropertyInfo(discriminator="type"),
6569
]

‎src/anthropic/resources/beta/messages/messages.py

-1
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,6 @@ def stream(
983983
stream_cls=Stream[BetaRawMessageStreamEvent],
984984
)
985985
return BetaMessageStreamManager(make_request)
986-
987986

988987
def count_tokens(
989988
self,

‎src/anthropic/types/tool_param.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class InputSchemaTyped(TypedDict, total=False):
1616

1717
properties: Optional[object]
1818

19+
1920
set_pydantic_config(InputSchemaTyped, {"extra": "allow"})
2021

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

0 commit comments

Comments
 (0)
Please sign in to comment.