Skip to content

base

Base classes for retrieval.

Classes:

RetrievalBase

RetrievalBase(
    source: Any,
    splitter: TextSplitterBase = LangChainTextSplitter(
        'RecursiveCharacterTextSplitter'
    ),
    api_key: str = '',
    cache: Optional[Cache] = None,
    logs: dict[str, Any] = DEFAULT_LOGS,
)

Bases: RagoBase

Base Retrieval class.

Methods:

  • get

    Get the data from the source.

Source code in src/rago/retrieval/base.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def __init__(
    self,
    source: Any,
    splitter: TextSplitterBase = LangChainTextSplitter(
        'RecursiveCharacterTextSplitter'
    ),
    api_key: str = '',
    cache: Optional[Cache] = None,
    logs: dict[str, Any] = DEFAULT_LOGS,
) -> None:
    """Initialize the Retrieval class."""
    if logs is DEFAULT_LOGS:
        logs = {}
    super().__init__(api_key=api_key, cache=cache, logs=logs)
    self.source = source
    self.splitter = splitter

    self._validate()
    self._setup()

get abstractmethod

get(query: str = '') -> Iterable[str]

Get the data from the source.

Source code in src/rago/retrieval/base.py
56
57
58
59
@abstractmethod
def get(self, query: str = '') -> Iterable[str]:
    """Get the data from the source."""
    return []

StringRet

StringRet(
    source: Any,
    splitter: TextSplitterBase = LangChainTextSplitter(
        'RecursiveCharacterTextSplitter'
    ),
    api_key: str = '',
    cache: Optional[Cache] = None,
    logs: dict[str, Any] = DEFAULT_LOGS,
)

Bases: RetrievalBase

String Retrieval class.

This is a very generic class that assumes that the input (source) is already a list of strings.

Methods:

  • get

    Get the data from the sources.

Source code in src/rago/retrieval/base.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def __init__(
    self,
    source: Any,
    splitter: TextSplitterBase = LangChainTextSplitter(
        'RecursiveCharacterTextSplitter'
    ),
    api_key: str = '',
    cache: Optional[Cache] = None,
    logs: dict[str, Any] = DEFAULT_LOGS,
) -> None:
    """Initialize the Retrieval class."""
    if logs is DEFAULT_LOGS:
        logs = {}
    super().__init__(api_key=api_key, cache=cache, logs=logs)
    self.source = source
    self.splitter = splitter

    self._validate()
    self._setup()

get

get(query: str = '') -> Iterable[str]

Get the data from the sources.

Source code in src/rago/retrieval/base.py
71
72
73
def get(self, query: str = '') -> Iterable[str]:
    """Get the data from the sources."""
    return cast(list[str], self.source)