mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-15 19:18:30 +00:00
- Implement ElasticsearchClient with full sync/async operations - Add ElasticsearchConfig with connection and embedding options - Create factory pattern following ChromaDB/Qdrant conventions - Add comprehensive test suite with 26 passing tests (100% coverage) - Support both sync and async Elasticsearch operations - Include proper error handling and edge case coverage - Update type system and factory to support Elasticsearch provider - Follow existing RAG patterns for consistency Resolves #3404 Co-Authored-By: João <joao@crewai.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Protocol definitions for RAG factory modules."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Protocol, TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from crewai.rag.chromadb.client import ChromaDBClient
|
|
from crewai.rag.chromadb.config import ChromaDBConfig
|
|
from crewai.rag.qdrant.client import QdrantClient
|
|
from crewai.rag.qdrant.config import QdrantConfig
|
|
from crewai.rag.elasticsearch.client import ElasticsearchClient
|
|
from crewai.rag.elasticsearch.config import ElasticsearchConfig
|
|
|
|
|
|
class ChromaFactoryModule(Protocol):
|
|
"""Protocol for ChromaDB factory module."""
|
|
|
|
def create_client(self, config: ChromaDBConfig) -> ChromaDBClient:
|
|
"""Creates a ChromaDB client from configuration."""
|
|
...
|
|
|
|
|
|
class QdrantFactoryModule(Protocol):
|
|
"""Protocol for Qdrant factory module."""
|
|
|
|
def create_client(self, config: QdrantConfig) -> QdrantClient:
|
|
"""Creates a Qdrant client from configuration."""
|
|
...
|
|
|
|
|
|
class ElasticsearchFactoryModule(Protocol):
|
|
"""Protocol for Elasticsearch factory module."""
|
|
|
|
def create_client(self, config: ElasticsearchConfig) -> ElasticsearchClient:
|
|
"""Creates an Elasticsearch client from configuration."""
|
|
...
|