mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 16:48:30 +00:00
feat: add RAG system foundation with generic vector store support - Add BaseClient protocol for vector stores - Move BaseRAGStorage to rag/core - Centralize embedding types in embeddings/types.py - Remove unused storage models
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""Base provider protocol for vector database client creation."""
|
|
|
|
from abc import ABC
|
|
from typing import Any, Protocol, runtime_checkable, Union
|
|
from pydantic import BaseModel, Field
|
|
|
|
from crewai.rag.types import EmbeddingFunction
|
|
from crewai.rag.embeddings.types import EmbeddingOptions
|
|
|
|
|
|
class BaseProviderOptions(BaseModel, ABC):
|
|
"""Base configuration for all provider options."""
|
|
|
|
client_type: str = Field(..., description="Type of client to create")
|
|
embedding_config: Union[EmbeddingOptions, EmbeddingFunction, None] = Field(
|
|
default=None,
|
|
description="Embedding configuration - either options for built-in providers or a custom function",
|
|
)
|
|
options: Any = Field(
|
|
default=None, description="Additional provider-specific options"
|
|
)
|
|
|
|
|
|
@runtime_checkable
|
|
class BaseProvider(Protocol):
|
|
"""Protocol for vector database client providers."""
|
|
|
|
def __call__(self, options: BaseProviderOptions) -> Any:
|
|
"""Create and return a configured client instance."""
|
|
...
|