Skip to content
Merged
Changes from 1 commit
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
Next Next commit
docs: adding field descriptions to predefined text document
Signed-off-by: punndcoder28 <[email protected]>
  • Loading branch information
punndcoder28 committed Sep 14, 2023
commit 9a872cddf177eb6e3b91a0fb26039db29aed9d2f
26 changes: 22 additions & 4 deletions docarray/documents/text.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Any, Optional, Type, TypeVar, Union

from pydantic import Field

from docarray.base_doc import BaseDoc
from docarray.typing import TextUrl
from docarray.typing.tensor.embedding import AnyEmbedding
Expand Down Expand Up @@ -102,10 +104,26 @@ class MultiModalDoc(BaseDoc):

"""

text: Optional[str] = None
url: Optional[TextUrl] = None
embedding: Optional[AnyEmbedding] = None
bytes_: Optional[bytes] = None
text: Optional[str] = Field(
description='The text content stored in the document',
example='This is an example text content of the document',
)
url: Optional[TextUrl] = Field(
description='''The url of the text content. When text content is too long
to be stored inline or in a file, the remote url can be used to load the
text content''',
example='https://www.w3.org/History/19921103-hypertext/hypertext/README.html',
)
embedding: Optional[AnyEmbedding] = Field(
description='''Embedding field is used to store tensor objects of type
Tensorflow, PyTorch, and NumPy''',
example='''np.zeros((3, 64, 64))''',
)
bytes_: Optional[bytes] = Field(
description='''The bytes of image or video content that can be loaded
into an image or video tensor object''',
example='',
)

def __init__(self, text: Optional[str] = None, **kwargs):
if 'text' not in kwargs:
Expand Down