mirror of
https://github.com/hwchase17/langchain.git
synced 2025-10-08 13:50:00 +00:00
this will break atm but wanted to get thoughts on implementation. 1. should add() be on docstore interface? 2. should InMemoryDocstore change to take a list of documents as init? (makes this slightly easier to implement in FAISS -- if we think it is less clean then could expose a method to get the number of documents currently in the dict, and perform the logic of creating the necessary dictionary in the FAISS.add_texts method. Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
26 lines
700 B
Python
26 lines
700 B
Python
"""Interface to access to place that stores documents."""
|
|
from abc import ABC, abstractmethod
|
|
from typing import Dict, Union
|
|
|
|
from langchain.docstore.document import Document
|
|
|
|
|
|
class Docstore(ABC):
|
|
"""Interface to access to place that stores documents."""
|
|
|
|
@abstractmethod
|
|
def search(self, search: str) -> Union[str, Document]:
|
|
"""Search for document.
|
|
|
|
If page exists, return the page summary, and a Document object.
|
|
If page does not exist, return similar entries.
|
|
"""
|
|
|
|
|
|
class AddableMixin(ABC):
|
|
"""Mixin class that supports adding texts."""
|
|
|
|
@abstractmethod
|
|
def add(self, texts: Dict[str, Document]) -> None:
|
|
"""Add more documents."""
|