Skip to content

base

Promptable

Bases: ABC

Interface for objects that can be converted to a prompt string.

promptify

promptify(obj: Any) -> Any

Convert an object to a prompt object if it is promptable.

Source code in src/appl/core/promptable/base.py
def promptify(obj: Any) -> Any:
    """Convert an object to a prompt object if it is promptable."""
    if isinstance(obj, Promptable):
        s = obj.__prompt__()
        if isinstance(s, str):
            s = StringFuture(s)
        return s

    return StringFuture(str(obj))