Skip to content

Commit 5bde572

Browse files
chore(internal): properly set __pydantic_private__ (#2144)
1 parent 3e69750 commit 5bde572

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/openai/_base_client.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
ModelBuilderProtocol,
6464
)
6565
from ._utils import SensitiveHeadersFilter, is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
66-
from ._compat import model_copy, model_dump
66+
from ._compat import PYDANTIC_V2, model_copy, model_dump
6767
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
6868
from ._response import (
6969
APIResponse,
@@ -209,6 +209,9 @@ def _set_private_attributes(
209209
model: Type[_T],
210210
options: FinalRequestOptions,
211211
) -> None:
212+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
213+
self.__pydantic_private__ = {}
214+
212215
self._model = model
213216
self._client = client
214217
self._options = options
@@ -294,6 +297,9 @@ def _set_private_attributes(
294297
client: AsyncAPIClient,
295298
options: FinalRequestOptions,
296299
) -> None:
300+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
301+
self.__pydantic_private__ = {}
302+
297303
self._model = model
298304
self._client = client
299305
self._options = options

0 commit comments

Comments
 (0)