From 2d9a9f470330b8d0b9ab6cac722e7c2e9b0d45a1 Mon Sep 17 00:00:00 2001 From: Konnor Young Date: Wed, 20 Nov 2024 11:17:59 -0700 Subject: [PATCH 1/3] made pydantic change --- src/openai/_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openai/_models.py b/src/openai/_models.py index 20cd4c29bc..a9669c40ef 100644 --- a/src/openai/_models.py +++ b/src/openai/_models.py @@ -362,7 +362,7 @@ def model_dump_json( """ if round_trip != False: raise ValueError("round_trip is only supported in Pydantic v2") - if warnings != True: + if warnings == True: raise ValueError("warnings is only supported in Pydantic v2") if context is not None: raise ValueError("context is only supported in Pydantic v2") From 6fa9330bff3b8a4465bace117bc5e9f94e8a8cfd Mon Sep 17 00:00:00 2001 From: konnor-young Date: Wed, 5 Mar 2025 10:36:35 -0700 Subject: [PATCH 2/3] updated _models line 655 to prevent ModelInput error --- src/openai/_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openai/_models.py b/src/openai/_models.py index f49f70704b..7805c26c5a 100644 --- a/src/openai/_models.py +++ b/src/openai/_models.py @@ -652,8 +652,8 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, # Note: if one variant defines an alias then they all should discriminator_alias = field_info.alias - if field_info.annotation and is_literal_type(field_info.annotation): - for entry in get_args(field_info.annotation): + if (annotation := getattr(field_info, 'annotation', None)) and is_literal_type(annotation): + for entry in get_args(annotation): if isinstance(entry, str): mapping[entry] = variant From 5796b24a8e42af7e70014bf5896884197d6d4c8f Mon Sep 17 00:00:00 2001 From: konnor-young Date: Wed, 5 Mar 2025 10:46:50 -0700 Subject: [PATCH 3/3] updated _models line 655 to prevent ModelInput error --- src/openai/_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openai/_models.py b/src/openai/_models.py index 7805c26c5a..3161e84f28 100644 --- a/src/openai/_models.py +++ b/src/openai/_models.py @@ -363,7 +363,7 @@ def model_dump_json( """ if round_trip != False: raise ValueError("round_trip is only supported in Pydantic v2") - if warnings == True: + if warnings != True: raise ValueError("warnings is only supported in Pydantic v2") if context is not None: raise ValueError("context is only supported in Pydantic v2")