Skip to content

Class swarmauri_core.document_stores.IDocumentRetrieve.IDocumentRetrieve

swarmauri_core.document_stores.IDocumentRetrieve.IDocumentRetrieve

Bases: ABC

Abstract base class for document retrieval operations.

This class defines the interface for retrieving documents based on a query or other criteria. Implementations may use various indexing or search technologies to fulfill these retrievals.

retrieve abstractmethod

retrieve(query, top_k=5)

Retrieve the most relevant documents based on the given query.

PARAMETER DESCRIPTION
query

The query string used for document retrieval.

TYPE: str

top_k

The number of top relevant documents to retrieve.

TYPE: int DEFAULT: 5

RETURNS DESCRIPTION
List[IDocument]

List[Document]: A list of the top_k most relevant documents.

Source code in swarmauri_core/document_stores/IDocumentRetrieve.py
14
15
16
17
18
19
20
21
22
23
24
25
26
@abstractmethod
def retrieve(self, query: str, top_k: int = 5) -> List[IDocument]:
    """
    Retrieve the most relevant documents based on the given query.

    Parameters:
        query (str): The query string used for document retrieval.
        top_k (int): The number of top relevant documents to retrieve.

    Returns:
        List[Document]: A list of the top_k most relevant documents.
    """
    pass