MCPcopy Create free account
hub / github.com/OpenRaiser/NanoResearch / save

Method save

nanoresearch/feishu_bot.py:115–131  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

113 pass
114
115 def save(self) -> None:
116 if self._invalidated:
117 return
118 _CHAT_MEMORY_DIR.mkdir(parents=True, exist_ok=True)
119 data = {
120 "chat_id": self.chat_id,
121 "summary": self._summary,
122 "messages": self._messages[-self.MAX_MESSAGES:],
123 "facts": self._facts[-50:],
124 }
125 try:
126 self._path.write_text(
127 json.dumps(data, ensure_ascii=False, indent=2),
128 encoding="utf-8",
129 )
130 except OSError as e:
131 logger.warning("保存记忆失败: %s", e)
132
133 @property
134 def summary(self) -> str:

Callers 5

shutdownMethod · 0.80
_handle_chat_asyncMethod · 0.80
_start_pipelineMethod · 0.80
_deterministic_trimMethod · 0.80
_save_figure_filesMethod · 0.80

Calls 1

write_textMethod · 0.80

Tested by

no test coverage detected