Skip to content

Commit 5abf976

Browse files
authored
fix: allow adding RAG source content from valid URLs (#3831)
1 parent 3295671 commit 5abf976

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/crewai-tools/src/crewai_tools/adapters/crewai_rag_adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def add(self, *args: ContentItem, **kwargs: Unpack[AddDocumentParams]) -> None:
229229
continue
230230
else:
231231
metadata: dict[str, Any] = base_metadata.copy()
232+
source_content = SourceContent(source_ref)
232233

233234
if data_type in [
234235
DataType.PDF_FILE,
@@ -239,13 +240,12 @@ def add(self, *args: ContentItem, **kwargs: Unpack[AddDocumentParams]) -> None:
239240
DataType.XML,
240241
DataType.MDX,
241242
]:
242-
if not os.path.isfile(source_ref):
243+
if not source_content.is_url() and not source_content.path_exists():
243244
raise FileNotFoundError(f"File does not exist: {source_ref}")
244245

245246
loader = data_type.get_loader()
246247
chunker = data_type.get_chunker()
247248

248-
source_content = SourceContent(source_ref)
249249
loader_result: LoaderResult = loader.load(source_content)
250250

251251
chunks = chunker.chunk(loader_result.content)

0 commit comments

Comments
 (0)