Download src/sgjm/graph/node.py from adampippert/SGJM: direct link, hf CLI and curl.
- Browser
- Download file 833 Bytes
-
https://huggingface.co/adampippert/SGJM/resolve/main/src/sgjm/graph/node.py
- Command line
-
hf download hf://adampippert/SGJM/src/sgjm/graph/node.py
-
curl -L -o node.py https://huggingface.co/adampippert/SGJM/resolve/main/src/sgjm/graph/node.py
833 Bytes
| from __future__ import annotations | |
| from dataclasses import dataclass, field | |
| from enum import Enum | |
| from typing import Sequence | |
| from sgjm.graph.address import Address, Signature | |
| class NodeStatus(str, Enum): | |
| DRAFT = "draft" | |
| ACCEPTED = "accepted" | |
| REJECTED = "rejected" | |
| COMMITTED = "committed" | |
| MERGED = "merged" | |
| class Node: | |
| address: Address | |
| parents: tuple[Address, ...] | |
| tokens: tuple[int, ...] | |
| signature: Signature | |
| latent: tuple[float, ...] = () | |
| status: NodeStatus = NodeStatus.DRAFT | |
| score: float = 0.0 | |
| depth: int = 0 | |
| metadata: dict = field(default_factory=dict) | |
| def is_root(self) -> bool: | |
| return not self.parents | |
| def is_terminal(self) -> bool: | |
| return self.status in (NodeStatus.COMMITTED, NodeStatus.REJECTED) | |