Skip to content

ChoiceNode

Base classes

Name Children Inherits
NodeBase
promptantic.form.nodes
Common to all nodes.

⋔ Inheritance diagram

graph TD
  3931794821["nodes.ChoiceNode"]
  1324256109["nodes.NodeBase"]
  2751680898["builtins.object"]
  1324256109 --> 3931794821
  2751680898 --> 1324256109

🛈 DocStrings

Bases: NodeBase

One of a fixed set of values (enum, const, or oneOf of titled consts).

Source code in src/promptantic/form/nodes.py
@dataclass(frozen=True)
class ChoiceNode(NodeBase):
    """One of a fixed set of values (``enum``, ``const``, or ``oneOf`` of titled consts)."""

    kind: Literal["choice"] = "choice"
    choices: tuple[Choice, ...] = ()

    @property
    def fixed(self) -> bool:
        """Only one value is possible (``const``): nothing to ask."""
        return len(self.choices) == 1 and not self.nullable

fixed property

fixed: bool

Only one value is possible (const): nothing to ask.

:fa-brands-github: Show source on GitHub