v0.2,支持保存/读取上下文

This commit is contained in:
2024-10-03 15:16:32 +08:00
parent aa605afc9e
commit e4facb65f7
6 changed files with 57 additions and 24 deletions

View File

@ -13,7 +13,7 @@ class MarshoContext:
def _get_target_dict(self, is_private):
return self.contents["private"] if is_private else self.contents["non-private"]
def append(self, content, target_id, is_private):
def append(self, content, target_id: str, is_private: bool):
"""
往上下文中添加消息
"""
@ -22,14 +22,21 @@ class MarshoContext:
target_dict[target_id] = []
target_dict[target_id].append(content)
def reset(self, target_id, is_private):
def set_context(self, contexts, target_id: str, is_private: bool):
"""
设置上下文
"""
target_dict = self._get_target_dict(is_private)
target_dict[target_id] = contexts
def reset(self, target_id: str, is_private: bool):
"""
重置上下文
"""
target_dict = self._get_target_dict(is_private)
target_dict[target_id].clear()
def build(self, target_id, is_private):
def build(self, target_id: str, is_private: bool) -> list:
"""
构建返回的上下文,其中包括系统消息
"""