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

Method load_from_file

tutorials/02_session_and_messages.py:250–257  ·  view source on GitHub ↗

从 JSON 文件加载(读档)

(cls, path: str)

Source from the content-addressed store, hash-verified

248
249 @classmethod
250 def load_from_file(cls, path: str) -> "Session":
251 """从 JSON 文件加载(读档)"""
252 with open(path, "r", encoding="utf-8") as f:
253 data = json.load(f)
254 session = cls(version=data["version"])
255 for msg_data in data["messages"]:
256 session.messages.append(cls._dict_to_message(msg_data))
257 return session
258
259 @staticmethod
260 def _message_to_dict(msg: ConversationMessage) -> dict:

Callers 1

mainFunction · 0.80

Calls 3

appendMethod · 0.80
_dict_to_messageMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected