From 1ade9f0f78f21c77a45afd87b746ddada5b6000c Mon Sep 17 00:00:00 2001 From: Nilanjan De Date: Sat, 10 Aug 2024 21:36:15 +0530 Subject: [PATCH 1/2] Update pydantic_utilities.py --- src/cohere/core/pydantic_utilities.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cohere/core/pydantic_utilities.py b/src/cohere/core/pydantic_utilities.py index 0f24b0ea8..ec5cfa0fd 100644 --- a/src/cohere/core/pydantic_utilities.py +++ b/src/cohere/core/pydantic_utilities.py @@ -84,9 +84,11 @@ def to_jsonable_with_fallback( class UniversalBaseModel(pydantic.BaseModel): class Config: - populate_by_name = True - smart_union = True - allow_population_by_field_name = True + if IS_PYDANTIC_V2: + populate_by_name = True + else: + smart_union = True + allow_population_by_field_name = True json_encoders = {dt.datetime: serialize_datetime} def json(self, **kwargs: typing.Any) -> str: From 4f78b610f5fcb0964516eb34f216731119295c1e Mon Sep 17 00:00:00 2001 From: Nilanjan De Date: Sat, 10 Aug 2024 21:52:50 +0530 Subject: [PATCH 2/2] correct indentation --- src/cohere/core/pydantic_utilities.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cohere/core/pydantic_utilities.py b/src/cohere/core/pydantic_utilities.py index ec5cfa0fd..f02a5e0e4 100644 --- a/src/cohere/core/pydantic_utilities.py +++ b/src/cohere/core/pydantic_utilities.py @@ -85,10 +85,10 @@ def to_jsonable_with_fallback( class UniversalBaseModel(pydantic.BaseModel): class Config: if IS_PYDANTIC_V2: - populate_by_name = True - else: - smart_union = True - allow_population_by_field_name = True + populate_by_name = True + else: + smart_union = True + allow_population_by_field_name = True json_encoders = {dt.datetime: serialize_datetime} def json(self, **kwargs: typing.Any) -> str: