处理关系的prompt
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user