langgoap.FunctionalConditionResolver

langgoap.FunctionalConditionResolver#

class FunctionalConditionResolver(name, fn)[source]#

Wrap a plain callable into a ConditionResolver.

The callable receives (key, world_state) and may return a ConditionStatus, a plain bool, or None (which maps to ConditionStatus.UNKNOWN). Coroutine callables are also supported — they are awaitable via aresolve().

Parameters:
  • name (str) – Human-readable resolver name.

  • fn (Callable[[str, dict[str, Any]], Any]) – (key: str, world_state: dict) -> ConditionStatus | bool | None A sync or async callable.

Example:

FunctionalConditionResolver(
    "stock_check",
    lambda key, ws: ConditionStatus.TRUE if ws.get("stock", 0) > 0
                    else ConditionStatus.FALSE,
)
__init__(name, fn)[source]#
Parameters:
  • name (str)

  • fn (Callable[[str, dict[str, Any]], Any])

Return type:

None

Methods

__init__(name, fn)

aresolve(key, world_state)

resolve(key, world_state)

Attributes

name