File size: 1,622 Bytes
640b1c8
 
d161383
640b1c8
 
 
 
 
 
d161383
640b1c8
 
 
 
 
 
d161383
 
640b1c8
 
 
 
 
 
 
d161383
 
640b1c8
 
 
 
 
 
 
d161383
640b1c8
 
 
 
d161383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640b1c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# src/vectorstores/base_vectorstore.py
from abc import ABC, abstractmethod
from typing import List, Callable, Any, Dict, Optional

class BaseVectorStore(ABC):
    @abstractmethod
    def add_documents(
        self, 
        documents: List[str], 
        embeddings: Optional[List[List[float]]] = None
    ) -> None:
        """
        Add documents to the vector store
        
        Args:
            documents (List[str]): List of document texts
            embeddings (Optional[List[List[float]]]): Corresponding embeddings. 
                If not provided, they will be generated using the embedding function.
        """
        pass
    
    @abstractmethod
    def similarity_search(
        self, 
        query_embedding: List[float], 
        top_k: int = 3,
        **kwargs
    ) -> List[str]:
        """
        Perform similarity search
        
        Args:
            query_embedding (List[float]): Embedding of the query
            top_k (int): Number of top similar documents to retrieve
            **kwargs: Additional search parameters
        
        Returns:
            List[str]: List of most similar documents
        """
        pass

    @abstractmethod
    def get_all_documents(
        self,
        include_embeddings: bool = False
    ) -> List[Dict[str, Any]]:
        """
        Retrieve all documents from the vector store
        
        Args:
            include_embeddings (bool): Whether to include embeddings in the response
        
        Returns:
            List[Dict[str, Any]]: List of documents with their IDs and optionally embeddings
        """
        pass