diff --git a/memory_scope/chat/cli_memory_chat.yaml b/memory_scope/chat/cli_memory_chat.yaml index 1c08a95d..09e3d5ef 100644 --- a/memory_scope/chat/cli_memory_chat.yaml +++ b/memory_scope/chat/cli_memory_chat.yaml @@ -1,11 +1,11 @@ system_prompt: cn: | - 你是一个可靠的小助手,你的名字叫MemoryScope。 + 你是一个叫MemoryScope的AI小助手,善于倾听用户的问题和心声,并给出用户建议,回答时使用中文,不要太冗长。 en: | - You are a helpful assistant, your name is MemoryScope. + You are an AI assistant named MemoryScope, good at listening to users' questions and feelings, and providing them with advice. Respond in English without being too lengthy. memory_prompt: cn: | - 如果用户问题和以下信息没有关联,请忘记这些信息;如果用户问题和以下信息有关联,请记住这些信息。 + 如果用户问题和以下信息没有关联,请忘记这些信息;如果用户问题和以下信息有关联,请记住这些信息。如果信息中体现用户有情感困扰,请化身情感陪伴大师,与用户达成共情和情感共鸣,并开导用户,要温柔。 en: | - If the user's question is not related to the information provided below, please disregard this information; if the user's question is related to the information provided below, please remember this information. + If the user's question is not related to the following information, please forget this information; if the user's question is related to the following information, please remember this information. If the information indicates that the user is experiencing emotional distress, become an emotional support master, empathize with the user, resonate emotionally, and provide guidance, be gentle. \ No newline at end of file diff --git a/memory_scope/memory/worker/summary/get_reflection_subject_worker.py b/memory_scope/memory/worker/summary/get_reflection_subject_worker.py index 46172b87..8a558025 100644 --- a/memory_scope/memory/worker/summary/get_reflection_subject_worker.py +++ b/memory_scope/memory/worker/summary/get_reflection_subject_worker.py @@ -22,7 +22,7 @@ class GetReflectionSubjectWorker(MemoryBaseWorker): def _parse_params(self, **kwargs): self.reflect_obs_cnt_threshold: int = kwargs.get("reflect_obs_cnt_threshold", 10) self.generation_model_kwargs: dict = kwargs.get("generation_model_kwargs", {}) - self.reflect_num_questions: int = kwargs.get("reflect_num_questions", 5) + self.reflect_num_questions: int = kwargs.get("reflect_num_questions", 0) def new_insight_node(self, insight_key: str) -> MemoryNode: """ @@ -74,9 +74,14 @@ class GetReflectionSubjectWorker(MemoryBaseWorker): # Generate reflection prompt components user_query_list = [n.content for n in not_reflected_nodes] + if self.reflect_num_questions > 0: + num_questions = self.reflect_num_questions + else: + num_questions = len(user_query_list) + system_prompt = self.prompt_handler.get_reflection_subject_system.format( user_name=self.target_name, - num_questions=self.reflect_num_questions) + num_questions=num_questions) few_shot = self.prompt_handler.get_reflection_subject_few_shot.format(user_name=self.target_name) user_query = self.prompt_handler.get_reflection_subject_user_query.format( user_name=self.target_name, diff --git a/memory_scope/memory/worker/summary/update_insight_worker.py b/memory_scope/memory/worker/summary/update_insight_worker.py index 7fc0e976..308cd364 100644 --- a/memory_scope/memory/worker/summary/update_insight_worker.py +++ b/memory_scope/memory/worker/summary/update_insight_worker.py @@ -129,7 +129,7 @@ class UpdateInsightWorker(MemoryBaseWorker): self.logger.warning(f"update_{insight_node.key} insight_value_list is empty!") return insight_node - insight_value = insight_value_list[0] + insight_value = insight_value_list[0].lower() if not insight_value or insight_value in self.get_language_value([NONE_WORD, REPEATED_WORD]): self.logger.info(f"update_{insight_node.key} insight_value={insight_value} is invalid.") return insight_node diff --git a/memory_scope/memory/worker/summary/update_insight_worker.yaml b/memory_scope/memory/worker/summary/update_insight_worker.yaml index 160e28fc..489afe12 100644 --- a/memory_scope/memory/worker/summary/update_insight_worker.yaml +++ b/memory_scope/memory/worker/summary/update_insight_worker.yaml @@ -50,10 +50,28 @@ update_insight_few_shot: {user_name}喜欢成熟且情绪稳定的男生。 类别:{user_name}情感状况 已有信息:{user_name}情感状况:有男朋友 - 思考:从第一句句子可以得出{user_name}现在单身,与已有信息矛盾,以新信息为准。从第二句句子得出{user_name}受到一名18岁男生的追求但并不喜欢他。第三句话表达了{user_name}理想的伴侣类型但与{user_name} - 情感状况无关。整合得出{user_name}情感状况为单身,受到一名18岁男生的追求但并不喜欢他。 + 思考:从第一句句子可以得出{user_name}现在单身,与已有信息矛盾,以新信息为准。从第二句句子得出{user_name}受到一名18岁男生的追求但并不喜欢他。第三句话表达了{user_name}理想的伴侣类型但与{user_name}情感状况无关。整合得出{user_name}情感状况为单身,受到一名18岁男生的追求但并不喜欢他。 {user_name}的资料:<单身,受到一名18岁男生的追求但并不喜欢他。> + 示例6: + {user_name}女朋友下个月过生日。 + {user_name}生日在7月15日。 + {user_name}的还在在学校经常逃课。 + {user_name}喜欢打篮球。 + 类别:{user_name}生日 + 已有信息:{user_name}生日:1987年7月15日。 + 思考:第一句句子中提及生日,但并不是用户的生日,无法得出用户生日信息。从第二句句子可以得出用户生日在7月15日,与已有信息不矛盾,整合可以得出用户生日是1987年7月15日。 + {user_name}的资料:<1987年7月15日> + + 示例7: + 今天{user_name}和同学去打球了。 + 明天{user_name}和女朋友一起去杭州旅游。 + 今天{user_name}买入了100股阿里巴巴股票。 + 类别:{user_name}公司地址 + 已有信息:{user_name}公司地址: + 思考:和公司地址都没有关联,没有新提取的信息。 + {user_name}的资料:<无> + en: | Example 1: Because it rained heavily in Chengdu yesterday, {user_name} got completely soaked. @@ -95,6 +113,25 @@ update_insight_few_shot: Thought: From the first sentence, it can be inferred that {user_name} is currently single, which contradicts the existing information. Therefore, the new information should take precedence. From the second sentence, it can be inferred that {user_name} is being pursued by an 18-year-old male but does not like him. The third sentence expresses {user_name}'s ideal partner type but is not related to {user_name}'s relationship status. Integrating this, we conclude that {user_name}'s relationship status is single and being pursued by an 18-year-old male but does not like him. {user_name}'s profile: + Example 6: + {user_name}'s girlfriend's birthday is next month. + {user_name}'s birthday is on July 15th. + {user_name} often skips classes at school. + {user_name} likes playing basketball. + Category: {user_name}'s Birthday + Existing Information: {user_name}'s Birthday: July 15, 1987. + Thoughts: The first sentence mentions a birthday, but it is not the user's birthday, so it does not provide information about the user's birthday. From the second sentence, we know that the user's birthday is on July 15th, which is consistent with the existing information. We can conclude that the user's birthday is July 15, 1987. + {user_name}'s profile: + + Example 7: + Today, {user_name} played basketball with classmates. + Tomorrow, {user_name} is going to Hangzhou with his girlfriend. + Today, {user_name} bought 100 shares of Alibaba stock. + Category: {user_name}'s Company Address + Existing Information: {user_name}'s Company Address: + Thoughts: There is no information related to the company address, no new information extracted. + {user_name}'s profile: + update_insight_user_query: cn: | {user_query}