forked from mem0ai/mem0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: url metadata for all datatypes (mem0ai#613)
- Loading branch information
Showing
4 changed files
with
116 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,47 @@ | ||
from enum import Enum | ||
|
||
|
||
class DataType(Enum): | ||
class DirectDataType(Enum): | ||
""" | ||
DirectDataType enum contains data types that contain raw data directly. | ||
""" | ||
|
||
TEXT = "text" | ||
|
||
|
||
class IndirectDataType(Enum): | ||
""" | ||
IndirectDataType enum contains data types that contain references to data stored elsewhere. | ||
""" | ||
|
||
YOUTUBE_VIDEO = "youtube_video" | ||
PDF_FILE = "pdf_file" | ||
WEB_PAGE = "web_page" | ||
SITEMAP = "sitemap" | ||
DOCX = "docx" | ||
DOCS_SITE = "docs_site" | ||
TEXT = "text" | ||
QNA_PAIR = "qna_pair" | ||
NOTION = "notion" | ||
CSV = "csv" | ||
MDX = "mdx" | ||
|
||
|
||
class SpecialDataType(Enum): | ||
""" | ||
SpecialDataType enum contains data types that are neither direct nor indirect, or simply require special attention. | ||
""" | ||
|
||
QNA_PAIR = "qna_pair" | ||
|
||
|
||
class DataType(Enum): | ||
TEXT = DirectDataType.TEXT.value | ||
YOUTUBE_VIDEO = IndirectDataType.YOUTUBE_VIDEO.value | ||
PDF_FILE = IndirectDataType.PDF_FILE.value | ||
WEB_PAGE = IndirectDataType.WEB_PAGE.value | ||
SITEMAP = IndirectDataType.SITEMAP.value | ||
DOCX = IndirectDataType.DOCX.value | ||
DOCS_SITE = IndirectDataType.DOCS_SITE.value | ||
NOTION = IndirectDataType.NOTION.value | ||
CSV = IndirectDataType.CSV.value | ||
MDX = IndirectDataType.MDX.value | ||
QNA_PAIR = SpecialDataType.QNA_PAIR.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
|
||
from embedchain.models.data_type import (DataType, DirectDataType, | ||
IndirectDataType, SpecialDataType) | ||
|
||
|
||
class TestDataTypeEnums(unittest.TestCase): | ||
def test_subclass_types_in_data_type(self): | ||
"""Test that all data type category subclasses are contained in the composite data type""" | ||
# Check if DirectDataType values are in DataType | ||
for data_type in DirectDataType: | ||
self.assertIn(data_type.value, DataType._value2member_map_) | ||
|
||
# Check if IndirectDataType values are in DataType | ||
for data_type in IndirectDataType: | ||
self.assertIn(data_type.value, DataType._value2member_map_) | ||
|
||
# Check if SpecialDataType values are in DataType | ||
for data_type in SpecialDataType: | ||
self.assertIn(data_type.value, DataType._value2member_map_) | ||
|
||
def test_data_type_in_subclasses(self): | ||
"""Test that all data types in the composite data type are categorized in a subclass""" | ||
for data_type in DataType: | ||
if data_type.value in DirectDataType._value2member_map_: | ||
self.assertIn(data_type.value, DirectDataType._value2member_map_) | ||
elif data_type.value in IndirectDataType._value2member_map_: | ||
self.assertIn(data_type.value, IndirectDataType._value2member_map_) | ||
elif data_type.value in SpecialDataType._value2member_map_: | ||
self.assertIn(data_type.value, SpecialDataType._value2member_map_) | ||
else: | ||
self.fail(f"{data_type.value} not found in any subclass enums") |