Spaces:
Running
Running
Download src/vectorstores/base_vectorstore.py from TalatMasud/chatbot-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/spaces/TalatMasud/chatbot-backend/resolve/main/src/vectorstores/base_vectorstore.py
- Command line
-
hf download hf://spaces/TalatMasud/chatbot-backend/src/vectorstores/base_vectorstore.py
-
curl -L -o base_vectorstore.py https://huggingface.co/spaces/TalatMasud/chatbot-backend/resolve/main/src/vectorstores/base_vectorstore.py
1.62 kB
| # src/vectorstores/base_vectorstore.py | |
| from abc import ABC, abstractmethod | |
| from typing import List, Callable, Any, Dict, Optional | |
| class BaseVectorStore(ABC): | |
| 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 | |
| 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 | |
| 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 |