Skip to content

Policy Types

AbstractPolicy

Bases: Generic[E, N, P], ABC

A pair of a search policy and of an inner policy.

More preciely, a policy for trees with effects N (contravariant) gathers a search policy handling N along with an inner policy object of type P (covariant).

Source code in src/delphyne/core/policies.py
18
19
20
21
22
23
24
25
26
27
28
29
30
class AbstractPolicy(Generic[E, N, P], ABC):
    """
    A pair of a search policy and of an inner policy.

    More preciely, a policy for trees with effects `N` (contravariant)
    gathers a search policy handling `N` along with an inner policy
    object of type `P` (covariant).
    """

    @property
    def search(self) -> "AbstractSearchPolicy[E, N]": ...
    @property
    def inner(self) -> P: ...

AbstractSearchPolicy

Bases: Generic[E, N], Protocol

A search policy takes as arguments a tree with a given signature (covariant type parameter N), a global policy environment, and an inner policy with appropriate type, and returns a search stream.

Source code in src/delphyne/core/policies.py
33
34
35
36
37
38
39
40
41
42
class AbstractSearchPolicy(Generic[E, N], Protocol):
    """
    A search policy takes as arguments a tree with a given signature
    (covariant type parameter `N`), a global policy environment, and an
    inner policy with appropriate type, and returns a search stream.
    """

    def __call__[P, T](
        self, tree: "Tree[N, P, T]", env: E, policy: P
    ) -> AbstractStream[T]: ...

AbstractPromptingPolicy

Bases: Generic[E], Protocol

A prompting policy takes as arguments a query (attached to a specific node) and a global policy environment, and returns a search stream.

Source code in src/delphyne/core/policies.py
45
46
47
48
49
50
51
52
53
54
class AbstractPromptingPolicy(Generic[E], Protocol):
    """
    A prompting policy takes as arguments a query (attached to a
    specific node) and a global policy environment, and returns a search
    stream.
    """

    def __call__[T](
        self, query: AttachedQuery[T], env: E
    ) -> AbstractStream[T]: ...