File size: 1,119 Bytes
e885bfa | 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 | """Base vector store interface"""
from abc import ABC, abstractmethod
from typing import List, Dict, Optional
from src.rag.document_processing.models import DocumentChunk, RetrievalResult
class VectorStore(ABC):
"""Abstract base class for vector stores"""
@abstractmethod
def add_chunks(self, chunks: List[DocumentChunk]) -> None:
"""Add document chunks to the vector store"""
pass
@abstractmethod
def search(
self,
query_embedding: List[float],
top_k: int = 5,
) -> List[RetrievalResult]:
"""Search for similar chunks using embeddings"""
pass
@abstractmethod
def keyword_search(
self,
query: str,
top_k: int = 5,
) -> List[RetrievalResult]:
"""Keyword-based search (BM25 style)"""
pass
@abstractmethod
def delete_chunks(self, chunk_ids: List[str]) -> None:
"""Delete chunks by ID"""
pass
@abstractmethod
def get_chunk(self, chunk_id: str) -> Optional[DocumentChunk]:
"""Retrieve a specific chunk by ID"""
pass
|