MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / from_dict

Method from_dict

src/knowledge/graph.py:91–105  ·  view source on GitHub ↗
(cls, data: dict)

Source from the content-addressed store, hash-verified

89
90 @classmethod
91 def from_dict(cls, data: dict) -> "KnowledgeGraph":
92 g = cls()
93 for e in data.get("entities", []) or []:
94 try:
95 ent = Entity(
96 name=str(e["name"]),
97 type=str(e.get("type", "")),
98 count=int(e.get("count", 1)),
99 last_seen=float(e.get("last_seen", 0.0)),
100 attributes=dict(e.get("attributes", {})),
101 )
102 g.entities[cls._key(ent.name, ent.type)] = ent
103 except Exception: # noqa: BLE001 - skip malformed entries
104 continue
105 return g
106
107 def save(self, path: Path | None = None) -> None:
108 p = path or default_graph_path()

Callers 1

loadMethod · 0.45

Calls 3

EntityClass · 0.85
_keyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected