mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 23:58:34 +00:00
* feat: add crewai-tools workspace structure * Squashed 'temp-crewai-tools/' content from commit 9bae5633 git-subtree-dir: temp-crewai-tools git-subtree-split: 9bae56339096cb70f03873e600192bd2cd207ac9 * feat: configure crewai-tools workspace package with dependencies * fix: apply ruff auto-formatting to crewai-tools code * chore: update lockfile * fix: don't allow tool tests yet * fix: comment out extra pytest flags for now * fix: remove conflicting conftest.py from crewai-tools tests * fix: resolve dependency conflicts and test issues - Pin vcrpy to 7.0.0 to fix pytest-recording compatibility - Comment out types-requests to resolve urllib3 conflict - Update requests requirement in crewai-tools to >=2.32.0
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
from crewai_tools.rag.base_loader import BaseLoader, LoaderResult
|
|
from crewai_tools.rag.source_content import SourceContent
|
|
|
|
|
|
class TextFileLoader(BaseLoader):
|
|
def load(self, source_content: SourceContent, **kwargs) -> LoaderResult:
|
|
source_ref = source_content.source_ref
|
|
if not source_content.path_exists():
|
|
raise FileNotFoundError(
|
|
f"The following file does not exist: {source_content.source}"
|
|
)
|
|
|
|
with open(source_content.source, "r", encoding="utf-8") as file:
|
|
content = file.read()
|
|
|
|
return LoaderResult(
|
|
content=content,
|
|
source=source_ref,
|
|
doc_id=self.generate_doc_id(source_ref=source_ref, content=content),
|
|
)
|
|
|
|
|
|
class TextLoader(BaseLoader):
|
|
def load(self, source_content: SourceContent, **kwargs) -> LoaderResult:
|
|
return LoaderResult(
|
|
content=source_content.source,
|
|
source=source_content.source_ref,
|
|
doc_id=self.generate_doc_id(content=source_content.source),
|
|
)
|