Vector Stores Module

The Vector Stores Module provides a standardized interface for managing document embeddings and similarity searches. It allows users to add documents to a vector store, retrieve context based on queries, and manage collections across different providers. The module supports providers such as Pinecone and OpenAI through dedicated manager implementations.

Module Components

  • VectorStoreInterface: An abstract base class that defines the required methods for vector store implementations.

  • Service Implementations: Concrete classes that implement vector store functionality. For example:

    • PineconeManager: Manages vector store operations using Pinecone.

    • OpenAIManager: (Implementation not shown) Manages vector store operations using OpenAI.

  • VectorStoreAdapter: An adapter that creates a vector store manager instance based on backend configuration.


1. Vector Store Interface

Defines the required methods that all vector store implementations must provide.

File: autoppia_sdk/src/vectorstores/interface.py

pythonCopiarfrom abc import ABC, abstractmethod

class VectorStoreInterface(ABC):
    """Interface for vector store implementations.
    
    Defines the required methods that all vector store implementations must provide.
    """

    @abstractmethod
    def get_or_create_collection(self, collection_name):
        """Get an existing collection or create a new one if it doesn't exist.
        
        Args:
            collection_name (str): Name of the collection to get or create
            
        Returns:
            Any: The vector store collection instance
        """
        pass

    @abstractmethod
    def add_document(self, document):
        """Add a document to the vector store.
        
        Args:
            document: Document to be added to the vector store
        """
        pass

    @abstractmethod
    def get_context(self, query):
        """Retrieve relevant context based on a query.
        
        Args:
            query (str): The search query
            
        Returns:
            str: Retrieved context based on the query
        """
        pass

2. Vector Store Adapter

The adapter converts backend configuration into a concrete vector store manager instance. It handles provider-specific initialization and validates required credentials.

File: autoppia_sdk/src/vectorstores/adapter.py


3. Pinecone Manager Implementation

The PineconeManager class is a concrete implementation of the VectorStoreInterface that uses Pinecone for managing document embeddings and performing similarity searches. It also leverages external document loaders and text splitters for processing various file types.

File: autoppia_sdk/src/vectorstores/implementations/pinecone_manager.py

Last updated