better:优化工作记忆
This commit is contained in:
@@ -18,30 +18,28 @@ class WorkingMemoryInfo(InfoBase):
|
||||
self.data["talking_message"] = message
|
||||
|
||||
def set_working_memory(self, working_memory: List[str]) -> None:
|
||||
"""设置工作记忆
|
||||
"""设置工作记忆列表
|
||||
|
||||
Args:
|
||||
working_memory (str): 工作记忆内容
|
||||
working_memory (List[str]): 工作记忆内容列表
|
||||
"""
|
||||
self.data["working_memory"] = working_memory
|
||||
|
||||
def add_working_memory(self, working_memory: str) -> None:
|
||||
"""添加工作记忆
|
||||
"""添加一条工作记忆
|
||||
|
||||
Args:
|
||||
working_memory (str): 工作记忆内容
|
||||
working_memory (str): 工作记忆内容,格式为"记忆要点:xxx"
|
||||
"""
|
||||
working_memory_list = self.data.get("working_memory", [])
|
||||
# print(f"working_memory_list: {working_memory_list}")
|
||||
working_memory_list.append(working_memory)
|
||||
# print(f"working_memory_list: {working_memory_list}")
|
||||
self.data["working_memory"] = working_memory_list
|
||||
|
||||
def get_working_memory(self) -> List[str]:
|
||||
"""获取工作记忆
|
||||
"""获取所有工作记忆
|
||||
|
||||
Returns:
|
||||
List[str]: 工作记忆内容
|
||||
List[str]: 工作记忆内容列表,每条记忆格式为"记忆要点:xxx"
|
||||
"""
|
||||
return self.data.get("working_memory", [])
|
||||
|
||||
@@ -53,33 +51,32 @@ class WorkingMemoryInfo(InfoBase):
|
||||
"""
|
||||
return self.type
|
||||
|
||||
def get_data(self) -> Dict[str, str]:
|
||||
def get_data(self) -> Dict[str, List[str]]:
|
||||
"""获取所有信息数据
|
||||
|
||||
Returns:
|
||||
Dict[str, str]: 包含所有信息数据的字典
|
||||
Dict[str, List[str]]: 包含所有信息数据的字典
|
||||
"""
|
||||
return self.data
|
||||
|
||||
def get_info(self, key: str) -> Optional[str]:
|
||||
def get_info(self, key: str) -> Optional[List[str]]:
|
||||
"""获取特定属性的信息
|
||||
|
||||
Args:
|
||||
key: 要获取的属性键名
|
||||
|
||||
Returns:
|
||||
Optional[str]: 属性值,如果键不存在则返回 None
|
||||
Optional[List[str]]: 属性值,如果键不存在则返回 None
|
||||
"""
|
||||
return self.data.get(key)
|
||||
|
||||
def get_processed_info(self) -> Dict[str, str]:
|
||||
def get_processed_info(self) -> str:
|
||||
"""获取处理后的信息
|
||||
|
||||
Returns:
|
||||
Dict[str, str]: 处理后的信息数据
|
||||
str: 处理后的信息数据,所有记忆要点按行拼接
|
||||
"""
|
||||
all_memory = self.get_working_memory()
|
||||
# print(f"all_memory: {all_memory}")
|
||||
memory_str = ""
|
||||
for memory in all_memory:
|
||||
memory_str += f"{memory}\n"
|
||||
|
||||
Reference in New Issue
Block a user