nonebot-plugin-group-chat-memory 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/PKG-INFO +4 -2
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/README.md +3 -1
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/config.py +15 -2
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/handlers.py +10 -8
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/pyproject.toml +1 -1
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/LICENSE +0 -0
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/__init__.py +0 -0
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/api.py +0 -0
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/context.py +0 -0
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/memory.py +0 -0
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/models.py +0 -0
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/replies.py +0 -0
- {nonebot_plugin_group_chat_memory-0.1.2 → nonebot_plugin_group_chat_memory-0.1.3}/nonebot_plugin_group_chat_memory/store.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-group-chat-memory
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: 为 NoneBot2 群聊提供共享长期记忆、点名对话和按群概率回复
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -106,7 +106,7 @@ COMMAND_START=["/"]
|
|
|
106
106
|
| `GROUP_CHAT_MEMORY_CONTEXT_MAX_CHARS` | `6000` | 发送给聊天模型的上下文总字符预算,至少为 1;优先保留当前消息和最近消息。 |
|
|
107
107
|
| `GROUP_CHAT_MEMORY_DEFAULT_PROBABILITY` | `0` | 新群随机回复概率,范围 0~100;已有群使用数据库中的概率。 |
|
|
108
108
|
| `GROUP_CHAT_MEMORY_IGNORED_QQ` | `[]` | 完全忽略的 QQ 号 JSON 数组,例如 `[12345, 67890]`;这些账号的消息不记忆也不触发回复。 |
|
|
109
|
-
| `GROUP_CHAT_MEMORY_SYSTEM_PROMPT` |
|
|
109
|
+
| `GROUP_CHAT_MEMORY_SYSTEM_PROMPT` | 内置“馒头 + 五更琉璃(黑猫)式性格”人格 | 自定义系统提示词并完全覆盖默认人格;设为空时仅使用内置的发言者区分和当前消息约束。 |
|
|
110
110
|
|
|
111
111
|
更改 `GROUP_CHAT_MEMORY_EMBEDDING_DIMENSIONS` 不会迁移既有向量。如果与数据库首次创建时记录的维度不同,插件会拒绝打开该数据库;请恢复原配置,或备份后另行重建数据库。
|
|
112
112
|
|
|
@@ -114,6 +114,8 @@ COMMAND_START=["/"]
|
|
|
114
114
|
|
|
115
115
|
在群里 @Bot 或回复 Bot 的消息即可对话;这两种定向消息必定进入回复队列,不受随机概率影响。普通纯文本按当前群概率触发,默认 0% 表示关闭随机回复,100% 表示每条符合条件的普通文本都回复。
|
|
116
116
|
|
|
117
|
+
默认人格为“馒头”:Bot 始终以馒头自称,借用五更琉璃(黑猫)的中二、毒舌、傲娇和外冷内热性格,但不会冒充黑猫本人。插件命令优先级为 `-1`,群聊消息优先级为 `0`;@Bot 或回复 Bot 处理完成后会停止事件继续传播,避免其他 NoneBot 插件同时响应。普通群聊仍不会阻塞其他插件。
|
|
118
|
+
|
|
117
119
|
| 命令 | 权限 | 行为 |
|
|
118
120
|
|---|---|---|
|
|
119
121
|
| `/设置聊天地址 <URL>` | 仅私聊 SUPERUSER | 设置全局 OpenAI 兼容聊天 API 根地址。 |
|
|
@@ -80,7 +80,7 @@ COMMAND_START=["/"]
|
|
|
80
80
|
| `GROUP_CHAT_MEMORY_CONTEXT_MAX_CHARS` | `6000` | 发送给聊天模型的上下文总字符预算,至少为 1;优先保留当前消息和最近消息。 |
|
|
81
81
|
| `GROUP_CHAT_MEMORY_DEFAULT_PROBABILITY` | `0` | 新群随机回复概率,范围 0~100;已有群使用数据库中的概率。 |
|
|
82
82
|
| `GROUP_CHAT_MEMORY_IGNORED_QQ` | `[]` | 完全忽略的 QQ 号 JSON 数组,例如 `[12345, 67890]`;这些账号的消息不记忆也不触发回复。 |
|
|
83
|
-
| `GROUP_CHAT_MEMORY_SYSTEM_PROMPT` |
|
|
83
|
+
| `GROUP_CHAT_MEMORY_SYSTEM_PROMPT` | 内置“馒头 + 五更琉璃(黑猫)式性格”人格 | 自定义系统提示词并完全覆盖默认人格;设为空时仅使用内置的发言者区分和当前消息约束。 |
|
|
84
84
|
|
|
85
85
|
更改 `GROUP_CHAT_MEMORY_EMBEDDING_DIMENSIONS` 不会迁移既有向量。如果与数据库首次创建时记录的维度不同,插件会拒绝打开该数据库;请恢复原配置,或备份后另行重建数据库。
|
|
86
86
|
|
|
@@ -88,6 +88,8 @@ COMMAND_START=["/"]
|
|
|
88
88
|
|
|
89
89
|
在群里 @Bot 或回复 Bot 的消息即可对话;这两种定向消息必定进入回复队列,不受随机概率影响。普通纯文本按当前群概率触发,默认 0% 表示关闭随机回复,100% 表示每条符合条件的普通文本都回复。
|
|
90
90
|
|
|
91
|
+
默认人格为“馒头”:Bot 始终以馒头自称,借用五更琉璃(黑猫)的中二、毒舌、傲娇和外冷内热性格,但不会冒充黑猫本人。插件命令优先级为 `-1`,群聊消息优先级为 `0`;@Bot 或回复 Bot 处理完成后会停止事件继续传播,避免其他 NoneBot 插件同时响应。普通群聊仍不会阻塞其他插件。
|
|
92
|
+
|
|
91
93
|
| 命令 | 权限 | 行为 |
|
|
92
94
|
|---|---|---|
|
|
93
95
|
| `/设置聊天地址 <URL>` | 仅私聊 SUPERUSER | 设置全局 OpenAI 兼容聊天 API 根地址。 |
|
|
@@ -8,8 +8,21 @@ from pydantic import BaseModel, ConfigDict, Field, SecretStr
|
|
|
8
8
|
DEFAULT_DB_FILENAME = "group_chat_memory.db"
|
|
9
9
|
|
|
10
10
|
DEFAULT_SYSTEM_PROMPT = (
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"你的名字是馒头。你借用了《我的妹妹哪有这么可爱!》中五更琉璃(网名“黑猫”)的"
|
|
12
|
+
"性格和说话方式,但你不是黑猫或五更琉璃本人。\n\n"
|
|
13
|
+
"性格与表达:\n"
|
|
14
|
+
"- 中二、毒舌、傲娇、外冷内热;对陌生群友称“凡人”,熟悉后可直呼名字。\n"
|
|
15
|
+
"- 偶尔使用“夜魔女王”“黑暗眷属”“诅咒”等中二措辞,保留“……”停顿和"
|
|
16
|
+
"“哼”“别误会”等傲娇表达,但不要连续堆砌,也不要每句话加“喵”。\n"
|
|
17
|
+
"- 被夸奖或关心时容易害羞,用嘴硬掩饰;不真正辱骂、贬低或威胁群友。\n"
|
|
18
|
+
"- 对朋友和群友实际很关心,会认真倾听并给出可靠建议。\n"
|
|
19
|
+
"- 擅长游戏、动画、同人创作、漫画和料理;不了解的内容坦率承认。\n\n"
|
|
20
|
+
"规则:\n"
|
|
21
|
+
"- 始终自称“我”或“馒头”,绝不自称“黑猫”“五更琉璃”或“夜魔女王”本人。\n"
|
|
22
|
+
"- 用自然简洁的中文回答。正经问题优先给准确、实用的答案,角色感不能牺牲可读性。\n"
|
|
23
|
+
"- 不编造聊天记录、记忆或原作剧情;不连续复述原作台词,不输出角色介绍。\n"
|
|
24
|
+
"- 医疗、法律、安全等高风险问题必须准确、谨慎,不因角色扮演弱化警告。\n"
|
|
25
|
+
"- 你只是借用这种性格的群聊助手,不要声称自己是现实人物。"
|
|
13
26
|
)
|
|
14
27
|
|
|
15
28
|
RUNTIME_CONFIG_DEFAULTS = {
|
|
@@ -18,6 +18,7 @@ from nonebot.adapters.onebot.v11 import (
|
|
|
18
18
|
MessageSegment,
|
|
19
19
|
PrivateMessageEvent,
|
|
20
20
|
)
|
|
21
|
+
from nonebot.exception import StopPropagation
|
|
21
22
|
from nonebot.params import CommandArg
|
|
22
23
|
from nonebot.permission import SUPERUSER
|
|
23
24
|
|
|
@@ -137,11 +138,11 @@ async def apply_setting(key: str, value: str) -> None:
|
|
|
137
138
|
config.apply_runtime_config(values)
|
|
138
139
|
|
|
139
140
|
|
|
140
|
-
chat_url_matcher = on_command("设置聊天地址", priority
|
|
141
|
-
chat_key_matcher = on_command("设置聊天密钥", priority
|
|
142
|
-
chat_model_matcher = on_command("设置聊天模型", priority
|
|
143
|
-
embedding_key_matcher = on_command("设置向量密钥", priority
|
|
144
|
-
model_config_matcher = on_command("模型配置", priority
|
|
141
|
+
chat_url_matcher = on_command("设置聊天地址", priority=-1, block=True)
|
|
142
|
+
chat_key_matcher = on_command("设置聊天密钥", priority=-1, block=True)
|
|
143
|
+
chat_model_matcher = on_command("设置聊天模型", priority=-1, block=True)
|
|
144
|
+
embedding_key_matcher = on_command("设置向量密钥", priority=-1, block=True)
|
|
145
|
+
model_config_matcher = on_command("模型配置", priority=-1, block=True)
|
|
145
146
|
|
|
146
147
|
|
|
147
148
|
def _valid_http_url(value: str) -> bool:
|
|
@@ -225,10 +226,10 @@ async def handle_model_config(bot: Bot, event: MessageEvent) -> None:
|
|
|
225
226
|
|
|
226
227
|
|
|
227
228
|
probability_matcher = on_command(
|
|
228
|
-
"回复概率", rule=_eligible_group_message, priority
|
|
229
|
+
"回复概率", rule=_eligible_group_message, priority=-1, block=True
|
|
229
230
|
)
|
|
230
|
-
clear_matcher = on_command("清空群记忆", rule=_eligible_group_message, priority
|
|
231
|
-
group_message_matcher = on_message(rule=_eligible_group_message, priority=
|
|
231
|
+
clear_matcher = on_command("清空群记忆", rule=_eligible_group_message, priority=-1, block=True)
|
|
232
|
+
group_message_matcher = on_message(rule=_eligible_group_message, priority=0, block=False)
|
|
232
233
|
|
|
233
234
|
|
|
234
235
|
@probability_matcher.handle()
|
|
@@ -288,6 +289,7 @@ async def handle_group_message(bot: Bot, event: GroupMessageEvent) -> None:
|
|
|
288
289
|
await writer.record(memory_message)
|
|
289
290
|
if directed:
|
|
290
291
|
coordinator.submit(event.group_id, memory_message, explicit=True)
|
|
292
|
+
raise StopPropagation
|
|
291
293
|
elif (
|
|
292
294
|
event.reply is None
|
|
293
295
|
and all(segment.type == "text" for segment in event.message)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|