mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-20 05:18:16 +00:00
Fix: Implement add() method in BaseFileKnowledgeSource to solve PDFKnowledgeSource instantiation error
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -64,6 +64,16 @@ class BaseFileKnowledgeSource(BaseKnowledgeSource, ABC):
|
||||
"""Save the documents to the storage."""
|
||||
self.storage.save(self.chunks)
|
||||
|
||||
def add(self) -> None:
|
||||
"""
|
||||
Process content from files, chunk it, compute embeddings, and save them.
|
||||
This method is called after content is loaded from files.
|
||||
"""
|
||||
for _, text in self.content.items():
|
||||
new_chunks = self._chunk_text(text)
|
||||
self.chunks.extend(new_chunks)
|
||||
self._save_documents()
|
||||
|
||||
def convert_to_path(self, path: Union[Path, str]) -> Path:
|
||||
"""Convert a path to a Path object."""
|
||||
return Path(KNOWLEDGE_DIRECTORY + "/" + path) if isinstance(path, str) else path
|
||||
|
||||
Reference in New Issue
Block a user