MCPcopy Create free account
hub / github.com/Louisym/MiniCC / to_dict

Method to_dict

tutorials/02_session_and_messages.py:237–242  ·  view source on GitHub ↗

把 Session 变成字典(方便转 JSON)

(self)

Source from the content-addressed store, hash-verified

235 # 反序列化就是反过来,从文件读取并还原成 Python 对象。
236
237 def to_dict(self) -> dict:
238 """把 Session 变成字典(方便转 JSON)"""
239 return {
240 "version": self.version,
241 "messages": [self._message_to_dict(msg) for msg in self.messages],
242 }
243
244 def save_to_file(self, path: str) -> None:
245 """保存到 JSON 文件(存档)"""

Callers 1

save_to_fileMethod · 0.95

Calls 1

_message_to_dictMethod · 0.95

Tested by

no test coverage detected