antimatter.handlers.langchain#

Module Contents#

Classes#

EmbeddingClient

BaseDocument

BaseDocument is a wrapper around the langchain Document.

LangchainHandler

The LangchainHandler DataHandler supports an implementation of a langchain

class antimatter.handlers.langchain.EmbeddingClient#
OPEN_AI = 'openai'#
HUGGING_FACE = 'huggingface'#
class antimatter.handlers.langchain.BaseDocument#

BaseDocument is a wrapper around the langchain Document. It is used to store the page content of the document.

content: Any#
embedding: List[float]#
class antimatter.handlers.langchain.LangchainHandler#

Bases: antimatter.handlers.DataHandler

The LangchainHandler DataHandler supports an implementation of a langchain Retriever. This handler assumes that the underlying data is a list of two-dimensional data.

from_generic(cols: List[str], generic_data: List[List[bytes]], extra: Dict[str, Any]) Any#

from_generic loads the generic data into an implementation of a langchain Retriever with langchain Embeddings.

Parameters:
  • cols – the column names for the underlying data

  • generic_data – the capsule’s generic data format that is loaded into a langchain Retriever

  • extra – extra data for the DataHandler, containing information for the Embeddings

Returns:

the langchain Retriever built with the dataset

to_generic(data: Any) Tuple[List[str], List[List[bytes]], Dict[str, Any]]#

to_generic converts a langchain Retriever with langchain Embeddings into the generic data format.

Parameters:

data – the langchain Retriever

Returns:

the data in its generic format