Skip to content

mytypes

langroid/mytypes.py

Entity

Bases: str, Enum

Enum for the different types of entities that can respond to the current message.

DocMetaData

Bases: BaseModel

Metadata for a document.

dict_bool_int(*args, **kwargs)

Special dict method to convert bool fields to int, to appease some downstream libraries, e.g. Chroma which complains about bool fields in metadata.

Source code in langroid/mytypes.py
def dict_bool_int(self, *args: Any, **kwargs: Any) -> Dict[str, Any]:
    """
    Special dict method to convert bool fields to int, to appease some
    downstream libraries,  e.g. Chroma which complains about bool fields in
    metadata.
    """
    original_dict = super().dict(*args, **kwargs)

    for key, value in original_dict.items():
        if isinstance(value, bool):
            original_dict[key] = 1 * value

    return original_dict

Document

Bases: BaseModel

Interface for interacting with a document.