fix: handle missing __validators__ (#68)

https://github.com/jina-ai/vectordb/issues/67

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
This commit is contained in:
Gabe Goodhart 2024-03-04 10:06:34 -07:00 committed by GitHub
parent 53cd4a54d8
commit f0200e5872
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -15,7 +15,8 @@ def create_output_doc_type(input_doc_type: Type['BaseDoc']):
return create_model( return create_model(
input_doc_type.__name__ + 'WithMatchesAndScores', input_doc_type.__name__ + 'WithMatchesAndScores',
__base__=input_doc_type, __base__=input_doc_type,
__validators__=input_doc_type.__validators__, # NOTE: With pydantic>=2, __validators__ does not exist
__validators__=getattr(input_doc_type, "__validators__", None),
matches=(DocList[input_doc_type], []), matches=(DocList[input_doc_type], []),
scores=(List[float], []) scores=(List[float], [])
) )