MCPcopy
hub / github.com/OpenBMB/ChatDev / from_mapping

Method from_mapping

utils/schema_exporter.py:27–38  ·  view source on GitHub ↗
(cls, data: Mapping[str, Any])

Source from the content-addressed store, hash-verified

25
26 @classmethod
27 def from_mapping(cls, data: Mapping[str, Any]) -> "Breadcrumb":
28 node = str(data.get("node")) if data.get("node") else ""
29 if not node:
30 raise SchemaResolutionError("breadcrumb entry missing 'node'")
31 field = data.get("field")
32 if field is not None:
33 field = str(field)
34 index = data.get("index")
35 if index is not None and not isinstance(index, int):
36 raise SchemaResolutionError("breadcrumb 'index' must be integer when provided")
37 value = data.get("value")
38 return cls(node=node, field=field, value=value)
39
40 def to_json(self) -> Dict[str, Any]:
41 payload: Dict[str, Any] = {"node": self.node}

Callers 1

_normalize_breadcrumbsFunction · 0.80

Calls 2

getMethod · 0.45

Tested by

no test coverage detected