Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docarray/document/pydantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def _blob2base64(cls, v):
else:
raise ValueError('must be bytes')

class Config:
smart_union = True


PydanticDocument.update_forward_refs()

Expand Down
8 changes: 7 additions & 1 deletion tests/unit/test_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ def test_with_embedding_no_tensor():

@pytest.mark.parametrize(
'tag_value, tag_type',
[(3, float), (3.4, float), ('hello', str), (True, bool), (False, bool)],
[
(3.0, float),
('hello', str),
('1', str),
(True, bool),
(False, bool),
],
)
@pytest.mark.parametrize('protocol', ['protobuf', 'jsonschema'])
def test_tags_int_float_str_bool(tag_type, tag_value, protocol):
Expand Down