MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / from_dict

Method from_dict

utils/attachments.py:36–48  ·  view source on GitHub ↗
(cls, data: Dict[str, Any])

Source from the content-addressed store, hash-verified

34
35 @classmethod
36 def from_dict(cls, data: Dict[str, Any]) -> "AttachmentRecord":
37 ref_data = data.get("ref") or {}
38 raw_kind = data.get("kind", MessageBlockType.FILE.value)
39 try:
40 kind = MessageBlockType(raw_kind)
41 except ValueError:
42 kind = MessageBlockType.FILE
43 return cls(
44 ref=AttachmentRef.from_dict(ref_data),
45 kind=kind,
46 description=data.get("description"),
47 extra=data.get("extra") or {},
48 )
49
50 def as_message_block(self) -> MessageBlock:
51 """Convert to a MessageBlock referencing this attachment."""

Callers 1

_load_manifestMethod · 0.45

Calls 2

MessageBlockTypeClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected