Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

refactor: do not instantiate all loaders (#418)

cachhoa232d1b77980
diff --git a/embedchain/data_formatter/data_formatter.py b/embedchain/data_formatter/data_formatter.py
index 4edb0f69d..906c5a4e9 100644
--- a/embedchain/data_formatter/data_formatter.py
+++ b/embedchain/data_formatter/data_formatter.py
@@ -37,18 +37,20 @@ class DataFormatter:
:raises ValueError: If an unsupported data type is provided.
"""
loaders = {
- "youtube_video": YoutubeVideoLoader(),
- "pdf_file": PdfFileLoader(),
- "web_page": WebPageLoader(),
- "qna_pair": LocalQnaPairLoader(),
- "text": LocalTextLoader(),
- "docx": DocxFileLoader(),
- "sitemap": SitemapLoader(),
- "docs_site": DocsSiteLoader(),
+ "youtube_video": YoutubeVideoLoader,
+ "pdf_file": PdfFileLoader,
+ "web_page": WebPageLoader,
+ "qna_pair": LocalQnaPairLoader,
+ "text": LocalTextLoader,
+ "docx": DocxFileLoader,
+ "sitemap": SitemapLoader,
+ "docs_site": DocsSiteLoader,
}
lazy_loaders = ("notion",)
if data_type in loaders:
- return loaders[data_type]
+ loader_class = loaders[data_type]
+ loader = loader_class()
+ return loader
elif data_type in lazy_loaders:
if data_type == "notion":
from embedchain.loaders.notion import NotionLoader