kotaemon/knowledgehub/storages/docstores/base.py
Duc Nguyen (john) 37c744b616 Add file-based document store and vector store (#96)
* Modify docstore and vectorstore objects to be reconstructable
* Simplify the file docstore
* Use the simple file docstore and vector store in MVP
2023-12-04 17:46:00 +07:00

48 lines
1.1 KiB
Python

from abc import ABC, abstractmethod
from typing import List, Optional, Union
from kotaemon.base import Document
class BaseDocumentStore(ABC):
"""A document store is in charged of storing and managing documents"""
@abstractmethod
def __init__(self, *args, **kwargs):
...
@abstractmethod
def add(
self,
docs: Union[Document, List[Document]],
ids: Optional[Union[List[str], str]] = None,
**kwargs,
):
"""Add document into document store
Args:
docs: Document or list of documents
ids: List of ids of the documents. Optional, if not set will use doc.doc_id
"""
...
@abstractmethod
def get(self, ids: Union[List[str], str]) -> List[Document]:
"""Get document by id"""
...
@abstractmethod
def get_all(self) -> List[Document]:
"""Get all documents"""
...
@abstractmethod
def count(self) -> int:
"""Count number of documents"""
...
@abstractmethod
def delete(self, ids: Union[List[str], str]):
"""Delete document by id"""
...