Skip to content

Commit

Permalink
docs: adding field descriptions to predefined text document (#1770)
Browse files Browse the repository at this point in the history
Signed-off-by: punndcoder28 <puneethk.2899@gmail.com>
  • Loading branch information
punndcoder28 committed Sep 14, 2023
1 parent 441db26 commit 68cc142
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 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,25 @@ 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',
default=None,
)
url: Optional[TextUrl] = Field(
description='URL to a (potentially remote) text file that can be loaded',
example='https://www.w3.org/History/19921103-hypertext/hypertext/README.html',
default=None,
)
embedding: Optional[AnyEmbedding] = Field(
description='Store an embedding: a vector representation of the text',
example=[1, 0, 1],
default=None,
)
bytes_: Optional[bytes] = Field(
description='Bytes representation of the text',
default=None,
)

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

0 comments on commit 68cc142

Please sign in to comment.