Skip to content

Models

Classes:

  • ImmutableAttrAsDict

    ImmutableAttrAsDict is an abstract base class that provides dictionary-like access to its attributes.

  • FactMetaclass

    FactMetaclass is a metaclass that modifies the creation of new classes to automatically

  • Fact

    An abstract class that must be used to define rule engine fact schemas and instantiate data into working memory. Facts

  • Similarity
  • ProxyInitializationError

    Raised when a Proxy class is used without the proxy being initialized.

  • RetrieverAdapter

    A lazy lookup that uses the Chroma vector store to perform similarity searches using OpenAI embeddings.

ImmutableAttrAsDict

ImmutableAttrAsDict is an abstract base class that provides dictionary-like access to its attributes.

FactMetaclass

Bases: type

FactMetaclass is a metaclass that modifies the creation of new classes to automatically apply the dataclass decorator with kw_only=True and frozen=True options.

Methods:

  • __getattribute__

    Returns a {templated} representation of the Fact's public attributes for deferred use in fstrings. This is

__getattribute__(name)

Returns a {templated} representation of the Fact's public attributes for deferred use in fstrings. This is useful in rule clauses so that IDE autocomplete can be used in fstrings while deferring evaluation of the content.

Fact

Bases: ImmutableAttrAsDict

An abstract class that must be used to define rule engine fact schemas and instantiate data into working memory. Facts may be combined with partial facts of the same type using the | operator. This is useful for Actions that only need to update a portion of working memory.

Example: new_fact = Inventory(apples=1) | partial(Inventory, oranges=2)

Methods:

  • __or__

    If the right hand operand is a Fact, it is returned as-is. However, if it is a partial Fact, a copy of the

__or__(other: partial[Self] | Self) -> Self

If the right hand operand is a Fact, it is returned as-is. However, if it is a partial Fact, a copy of the lefthand operand is created with the partial Fact's keywords applied.

Similarity dataclass

Bases: Mapping[str, list[tuple[str, float]]]

Methods:

  • __getitem__

    Vectorizes key and performs similarity search returning a list of matching.

  • __contains__

    Vectorizes key and performs similarity search returning a boolean if there is at least one match.

__getitem__(key: str) -> list[str] abstractmethod

Vectorizes key and performs similarity search returning a list of matching.

__contains__(key: str) -> bool abstractmethod

Vectorizes key and performs similarity search returning a boolean if there is at least one match.

ProxyInitializationError

Bases: Exception

Raised when a Proxy class is used without the proxy being initialized.

RetrieverAdapter dataclass

Bases: Similarity

A lazy lookup that uses the Chroma vector store to perform similarity searches using OpenAI embeddings.

Methods:

  • __getitem__

    Vectorizes key and performs similarity search returning a list of matching content.

  • __contains__

    Vectorizes key and performs similarity search returning a boolean if there is at least one match.

__getitem__(key: str) -> list[str]

Vectorizes key and performs similarity search returning a list of matching content.

__contains__(key: str) -> bool

Vectorizes key and performs similarity search returning a boolean if there is at least one match.