Fix #2755: Add support for custom knowledge storage with pre-existing embeddings

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-05-05 13:58:37 +00:00
parent 409892d65f
commit 51439c3c0a
3 changed files with 161 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
from typing import Optional
from pydantic import Field
from crewai.knowledge.source.base_knowledge_source import BaseKnowledgeSource
from crewai.knowledge.storage.knowledge_storage import KnowledgeStorage
class CustomStorageKnowledgeSource(BaseKnowledgeSource):
"""A knowledge source that uses a pre-existing storage with embeddings."""
collection_name: Optional[str] = Field(default=None)
def validate_content(self):
"""No content to validate as we're using pre-existing storage."""
pass
def add(self) -> None:
"""No need to add content as we're using pre-existing storage."""
pass