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

Method from_dict

entity/messages.py:125–140  ·  view source on GitHub ↗
(cls, data: Dict[str, Any])

Source from the content-addressed store, hash-verified

123
124 @classmethod
125 def from_dict(cls, data: Dict[str, Any]) -> "MessageBlock":
126 raw_type = data.get("type") or MessageBlockType.TEXT.value
127 try:
128 block_type = MessageBlockType(raw_type)
129 except ValueError:
130 block_type = MessageBlockType.DATA
131 attachment_data = data.get("attachment")
132 attachment = None
133 if isinstance(attachment_data, dict):
134 attachment = AttachmentRef.from_dict(attachment_data)
135 return cls(
136 type=block_type,
137 text=data.get("text"),
138 attachment=attachment,
139 data=data.get("data") or {},
140 )
141
142 @classmethod
143 def text_block(cls, text: str) -> "MessageBlock":

Callers

nothing calls this directly

Calls 3

MessageBlockTypeClass · 0.85
getMethod · 0.45
from_dictMethod · 0.45

Tested by

no test coverage detected