处理关系的prompt

This commit is contained in:
meng_xi_pan
2025-04-02 02:50:48 +08:00
parent af6f23615e
commit 4cce44bced
3 changed files with 39 additions and 28 deletions

View File

@@ -149,7 +149,6 @@ def get_recent_group_speaker(chat_stream_id: int, sender, limit: int = 12) -> li
db.messages.find(
{"chat_id": chat_stream_id},
{
"chat_info": 1,
"user_info": 1,
},
)
@@ -160,20 +159,17 @@ def get_recent_group_speaker(chat_stream_id: int, sender, limit: int = 12) -> li
if not recent_messages:
return []
who_chat_in_group = [] # ChatStream列表
duplicate_removal = []
who_chat_in_group = []
for msg_db_data in recent_messages:
user_info = UserInfo.from_dict(msg_db_data["user_info"])
if (
(user_info.user_id, user_info.platform) != sender
and (user_info.user_id, user_info.platform) != (global_config.BOT_QQ, "qq")
and (user_info.user_id, user_info.platform) not in duplicate_removal
and len(duplicate_removal) < 5
(user_info.platform, user_info.user_id) != sender
and user_info.user_id != global_config.BOT_QQ
and (user_info.platform, user_info.user_id, user_info.user_nickname) not in who_chat_in_group
and len(who_chat_in_group) < 5
): # 排除重复排除消息发送者排除bot(此处bot的平台强制为了qq可能需要更改),限制加载的关系数目
duplicate_removal.append((user_info.user_id, user_info.platform))
chat_info = msg_db_data.get("chat_info", {})
who_chat_in_group.append(ChatStream.from_dict(chat_info))
who_chat_in_group.append((user_info.platform, user_info.user_id, user_info.user_nickname))
return who_chat_in_group