Skip to content

Commit 1e8e7d1

Browse files
committed
fix(pydantic v1): avoid warnings error
1 parent 45315a7 commit 1e8e7d1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/openai/_compat.py

+2
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,14 @@ def model_dump(
136136
exclude: IncEx = None,
137137
exclude_unset: bool = False,
138138
exclude_defaults: bool = False,
139+
warnings: bool = True,
139140
) -> dict[str, Any]:
140141
if PYDANTIC_V2:
141142
return model.model_dump(
142143
exclude=exclude,
143144
exclude_unset=exclude_unset,
144145
exclude_defaults=exclude_defaults,
146+
warnings=warnings,
145147
)
146148
return cast(
147149
"dict[str, Any]",

src/openai/lib/streaming/_assistants.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import httpx
99

1010
from ..._utils import is_dict, is_list, consume_sync_iterator, consume_async_iterator
11+
from ..._compat import model_dump
1112
from ..._models import construct_type
1213
from ..._streaming import Stream, AsyncStream
1314
from ...types.beta import AssistantStreamEvent
@@ -906,11 +907,11 @@ def accumulate_run_step(
906907
merged = accumulate_delta(
907908
cast(
908909
"dict[object, object]",
909-
snapshot.model_dump(exclude_unset=True, warnings=False),
910+
model_dump(snapshot, exclude_unset=True, warnings=False),
910911
),
911912
cast(
912913
"dict[object, object]",
913-
data.delta.model_dump(exclude_unset=True, warnings=False),
914+
model_dump(data.delta, exclude_unset=True, warnings=False),
914915
),
915916
)
916917
run_step_snapshots[snapshot.id] = cast(RunStep, construct_type(type_=RunStep, value=merged))
@@ -948,7 +949,7 @@ def accumulate_event(
948949
construct_type(
949950
# mypy doesn't allow Content for some reason
950951
type_=cast(Any, MessageContent),
951-
value=content_delta.model_dump(exclude_unset=True, warnings=False),
952+
value=model_dump(content_delta, exclude_unset=True, warnings=False),
952953
),
953954
),
954955
)
@@ -957,11 +958,11 @@ def accumulate_event(
957958
merged = accumulate_delta(
958959
cast(
959960
"dict[object, object]",
960-
block.model_dump(exclude_unset=True, warnings=False),
961+
model_dump(block, exclude_unset=True, warnings=False),
961962
),
962963
cast(
963964
"dict[object, object]",
964-
content_delta.model_dump(exclude_unset=True, warnings=False),
965+
model_dump(content_delta, exclude_unset=True, warnings=False),
965966
),
966967
)
967968
current_message_snapshot.content[content_delta.index] = cast(

0 commit comments

Comments
 (0)