From 9683fa8e54473edc0859f349c137962b647c6fbc Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Sun, 6 Jul 2025 22:52:52 +0800 Subject: [PATCH] =?UTF-8?q?better=EF=BC=9A=E4=BC=98=E5=8C=96person=5Finfo?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/person_info/relationship_manager.py | 46 ++++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/person_info/relationship_manager.py b/src/person_info/relationship_manager.py index 4b139a6d7..a60b424ea 100644 --- a/src/person_info/relationship_manager.py +++ b/src/person_info/relationship_manager.py @@ -124,6 +124,31 @@ class RelationshipManager: if not person_name or person_name == "none": return "" short_impression = await person_info_manager.get_value(person_id, "short_impression") + + current_points = await person_info_manager.get_value(person_id, "points") or [] + if isinstance(current_points, str): + try: + current_points = json.loads(current_points) + except json.JSONDecodeError: + logger.error(f"解析points JSON失败: {current_points}") + current_points = [] + elif not isinstance(current_points, list): + current_points = [] + + # 按时间排序forgotten_points + current_points.sort(key=lambda x: x[2]) + # 按权重加权随机抽取3个points,point[1]的值在1-10之间,权重越高被抽到概率越大 + if len(current_points) > 3: + # point[1] 取值范围1-10,直接作为权重 + weights = [max(1, min(10, int(point[1]))) for point in current_points] + points = random.choices(current_points, weights=weights, k=3) + else: + points = current_points + + # 构建points文本 + points_text = "\n".join( + [f"{point[2]}:{point[0]}\n" for point in points] + ) nickname_str = await person_info_manager.get_value(person_id, "nickname") platform = await person_info_manager.get_value(person_id, "platform") @@ -137,7 +162,10 @@ class RelationshipManager: relation_prompt = f"'{person_name}' ,ta在{platform}上的昵称是{nickname_str}。" if short_impression: - relation_prompt += f"你对ta的印象是:{short_impression}。" + relation_prompt += f"你对ta的印象是:{short_impression}。\n" + + if points_text: + relation_prompt += f"你记得ta最近做的事:{points_text}" return relation_prompt @@ -241,16 +269,16 @@ class RelationshipManager: "weight": 10 }}, {{ - "point": "我让{person_name}帮我写作业,他拒绝了", - "weight": 4 + "point": "我让{person_name}帮我写化学作业,他拒绝了,我感觉他对我有意见,或者ta不喜欢我", + "weight": 3 }}, {{ - "point": "{person_name}居然搞错了我的名字,生气了", + "point": "{person_name}居然搞错了我的名字,我感到生气了,之后不理ta了", "weight": 8 }}, {{ - "point": "{person_name}喜欢吃辣,我和她关系不错", - "weight": 8 + "point": "{person_name}喜欢吃辣,具体来说,没有辣的食物ta都不喜欢吃,可能是因为ta是湖南人。", + "weight": 7 }} }} @@ -456,7 +484,7 @@ class RelationshipManager: 你对{person_name}的了解是: {compressed_summary} -请你用一句话概括你对{person_name}的了解。突出: +请你概括你对{person_name}的了解。突出: 1.对{person_name}的直观印象 2.{global_config.bot.nickname}与{person_name}的关系 3.{person_name}的关键信息 @@ -487,8 +515,8 @@ class RelationshipManager: 2. **好感度 (liking_value)**: 0-100的整数,表示这些信息让你对ta的喜。 - 0: 非常厌恶 - 25: 有点反感 - - 50: 中立/无感 - - 75: 有点喜欢 + - 50: 中立/无感(或者文本中无法明显看出) + - 75: 喜欢这个人 - 100: 非常喜欢/开心对这个人 请严格按照json格式输出,不要有其他多余内容: