amrita_plugin_memory 0.2.6__tar.gz → 0.2.8__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.
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/PKG-INFO +2 -1
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/__init__.py +1 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/__init__.py +1 -1
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/runner.py +13 -9
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/tools.py +2 -2
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/tools.py +1 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory.egg-info/PKG-INFO +2 -1
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory.egg-info/requires.txt +1 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/pyproject.toml +2 -1
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/LICENSE +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/README.md +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/config.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/embed.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/matchers.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/_state.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/backend.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/consts.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/hooks.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/nodes.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/schemas.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/workflow.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/vector.py +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory.egg-info/SOURCES.txt +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory.egg-info/dependency_links.txt +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory.egg-info/top_level.txt +0 -0
- {amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: amrita_plugin_memory
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Amrita长期记忆插件
|
|
5
5
|
Requires-Python: <3.14,>=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -10,6 +10,7 @@ Requires-Dist: aiologic>=0.16.0
|
|
|
10
10
|
Requires-Dist: amrita-core>=0.8.5
|
|
11
11
|
Requires-Dist: amrita>=1.3
|
|
12
12
|
Requires-Dist: chromadb>=1.5.8
|
|
13
|
+
Requires-Dist: nonebot-plugin-amrita>=0.2.2
|
|
13
14
|
Requires-Dist: nonebot-plugin-apscheduler>=0.5.0
|
|
14
15
|
Requires-Dist: nonebot-plugin-localstore>=0.7.4
|
|
15
16
|
Dynamic: license-file
|
|
@@ -2,6 +2,7 @@ from nonebot import require
|
|
|
2
2
|
|
|
3
3
|
require("nonebot_plugin_localstore")
|
|
4
4
|
require("nonebot_plugin_apscheduler")
|
|
5
|
+
require("nonebot_plugin_amrita")
|
|
5
6
|
require("amrita.plugins.chat")
|
|
6
7
|
require("amrita.plugins.menu")
|
|
7
8
|
from . import config, embed, matchers, rethinking, tools, vector
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/runner.py
RENAMED
|
@@ -9,9 +9,8 @@ import random
|
|
|
9
9
|
from datetime import datetime, timedelta, timezone
|
|
10
10
|
from typing import Any
|
|
11
11
|
|
|
12
|
-
from amrita.plugins.chat.utils.app import CachedUserDataRepository
|
|
13
12
|
from amrita.plugins.chat.utils.libchat import add_usage
|
|
14
|
-
from
|
|
13
|
+
from amrita_core import SuspendObjectStream
|
|
15
14
|
from amrita_core.base.backend import BackendSlots
|
|
16
15
|
from amrita_core.builtins.agent import ReActAgentStrategy
|
|
17
16
|
from amrita_core.chatmanager import ChatObject
|
|
@@ -20,10 +19,11 @@ from amrita_core.preset import ModelPreset
|
|
|
20
19
|
from amrita_core.types import Message, UniResponseUsage
|
|
21
20
|
from amrita_core.utils import gather_usage
|
|
22
21
|
from amrita_sense import WorkflowInterpreter
|
|
23
|
-
from amrita_sense.exceptions import InterruptKeepContext
|
|
24
22
|
from amrita_sense.runtime.types import InterpreterContext
|
|
25
23
|
from jinja2 import Template
|
|
26
24
|
from nonebot import logger
|
|
25
|
+
from nonebot_plugin_amrita.database import InsightsModel
|
|
26
|
+
from nonebot_plugin_amrita.memory import CachedUserDataRepository
|
|
27
27
|
from nonebot_plugin_apscheduler import scheduler
|
|
28
28
|
|
|
29
29
|
from ..config import DATA_PATH, SubconsciousConfig
|
|
@@ -40,12 +40,15 @@ from .workflow import build_workflow
|
|
|
40
40
|
_REPO_UID = "user_00000000"
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
async def _ign_cb(*_, **__): ...
|
|
44
|
+
|
|
45
|
+
|
|
43
46
|
class SubconsciousRunner:
|
|
44
47
|
"""常驻推理循环运行器。
|
|
45
48
|
|
|
46
49
|
使用 ChatObject 作为数据容器 + 标准 Agent 框架(ReActAgentStrategy)。
|
|
47
50
|
LIMITING_MEMORY 节点在 Agent Loop 之前运行 MemoryLimiter 压缩会话消息。
|
|
48
|
-
持久化使用 CachedUserDataRepository(
|
|
51
|
+
持久化使用 CachedUserDataRepository(user_00000000)。
|
|
49
52
|
"""
|
|
50
53
|
|
|
51
54
|
def __init__(self, config: SubconsciousConfig) -> None:
|
|
@@ -133,6 +136,8 @@ class SubconsciousRunner:
|
|
|
133
136
|
train = Message(role="system", content=prompt_text)
|
|
134
137
|
user_input = user_msg_text
|
|
135
138
|
|
|
139
|
+
io_stream = SuspendObjectStream(callback=_ign_cb)
|
|
140
|
+
|
|
136
141
|
chat_obj = ChatObject(
|
|
137
142
|
train=train,
|
|
138
143
|
user_input=user_input,
|
|
@@ -141,7 +146,7 @@ class SubconsciousRunner:
|
|
|
141
146
|
backend=BackendSlots(self._backend, self._backend),
|
|
142
147
|
config=get_config(),
|
|
143
148
|
agent_strategy=ReActAgentStrategy,
|
|
144
|
-
|
|
149
|
+
io_stream=io_stream,
|
|
145
150
|
)
|
|
146
151
|
self._chat_obj = chat_obj
|
|
147
152
|
|
|
@@ -152,7 +157,6 @@ class SubconsciousRunner:
|
|
|
152
157
|
chat_obj.io_stream,
|
|
153
158
|
extra_args=chat_obj._interpreter._ava_args[1:],
|
|
154
159
|
extra_kwargs=chat_obj._interpreter._ava_kwargs,
|
|
155
|
-
exception_ignored=chat_obj._interpreter._exc_ignored,
|
|
156
160
|
)
|
|
157
161
|
|
|
158
162
|
if self._saved_dump is not None:
|
|
@@ -264,7 +268,7 @@ class SubconsciousRunner:
|
|
|
264
268
|
"""从 CachedUserDataRepository 恢复状态。"""
|
|
265
269
|
try:
|
|
266
270
|
repo = CachedUserDataRepository()
|
|
267
|
-
mem = await repo.get_memory(
|
|
271
|
+
mem = await repo.get_memory(_REPO_UID)
|
|
268
272
|
# extra_prompt 存 JSON 元状态
|
|
269
273
|
if mem.extra_prompt:
|
|
270
274
|
data = json.loads(mem.extra_prompt)
|
|
@@ -297,7 +301,7 @@ class SubconsciousRunner:
|
|
|
297
301
|
"""保存状态到 CachedUserDataRepository。"""
|
|
298
302
|
try:
|
|
299
303
|
repo = CachedUserDataRepository()
|
|
300
|
-
mem = await repo.get_memory(
|
|
304
|
+
mem = await repo.get_memory(_REPO_UID)
|
|
301
305
|
latest_abstract = self._last_abstracts[-1] if self._last_abstracts else ""
|
|
302
306
|
mem.memory_json.abstract = latest_abstract
|
|
303
307
|
mem.extra_prompt = json.dumps(
|
|
@@ -318,7 +322,7 @@ class SubconsciousRunner:
|
|
|
318
322
|
"""持久化待发送消息到 CachedUserDataRepository 的 extra_prompt 中。"""
|
|
319
323
|
try:
|
|
320
324
|
repo = CachedUserDataRepository()
|
|
321
|
-
mem = await repo.get_memory(
|
|
325
|
+
mem = await repo.get_memory(_REPO_UID)
|
|
322
326
|
existing: dict[str, Any] = {}
|
|
323
327
|
if mem.extra_prompt:
|
|
324
328
|
try:
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/tools.py
RENAMED
|
@@ -268,10 +268,10 @@ async def subconscious_read_chat_context(data: dict[str, Any]) -> str:
|
|
|
268
268
|
return _tools_err(f"invalid target_user_id: {uid_str}")
|
|
269
269
|
limit = int(data.get("limit", 10))
|
|
270
270
|
try:
|
|
271
|
-
from
|
|
271
|
+
from nonebot_plugin_amrita.memory import CachedUserDataRepository
|
|
272
272
|
|
|
273
273
|
repo = CachedUserDataRepository()
|
|
274
|
-
mem = await repo.get_memory(user_id
|
|
274
|
+
mem = await repo.get_memory(f"user_{user_id}")
|
|
275
275
|
messages = mem.memory_json.messages
|
|
276
276
|
recent = messages[-limit:] if len(messages) > limit else messages
|
|
277
277
|
return json.dumps(
|
|
@@ -23,6 +23,7 @@ Scope = Literal["group", "user"] # type alias
|
|
|
23
23
|
|
|
24
24
|
def _get_event(ctx: ToolContext) -> OB11Event:
|
|
25
25
|
"""从 ToolContext 中提取 OneBot V11 原始事件"""
|
|
26
|
+
assert ctx.ctx.chat_object
|
|
26
27
|
amrictx: AmritaBotContext = ctx.ctx.chat_object._hook_kwargs["amrita"]
|
|
27
28
|
return amrictx["event"]
|
|
28
29
|
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: amrita_plugin_memory
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Amrita长期记忆插件
|
|
5
5
|
Requires-Python: <3.14,>=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -10,6 +10,7 @@ Requires-Dist: aiologic>=0.16.0
|
|
|
10
10
|
Requires-Dist: amrita-core>=0.8.5
|
|
11
11
|
Requires-Dist: amrita>=1.3
|
|
12
12
|
Requires-Dist: chromadb>=1.5.8
|
|
13
|
+
Requires-Dist: nonebot-plugin-amrita>=0.2.2
|
|
13
14
|
Requires-Dist: nonebot-plugin-apscheduler>=0.5.0
|
|
14
15
|
Requires-Dist: nonebot-plugin-localstore>=0.7.4
|
|
15
16
|
Dynamic: license-file
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "amrita_plugin_memory"
|
|
3
3
|
description = "Amrita长期记忆插件"
|
|
4
|
-
version = "0.2.
|
|
4
|
+
version = "0.2.8"
|
|
5
5
|
dependencies = [
|
|
6
6
|
"aiohttp>=3.13.3",
|
|
7
7
|
"aiologic>=0.16.0",
|
|
8
8
|
"amrita-core>=0.8.5",
|
|
9
9
|
"amrita>=1.3",
|
|
10
10
|
"chromadb>=1.5.8",
|
|
11
|
+
"nonebot-plugin-amrita>=0.2.2",
|
|
11
12
|
"nonebot-plugin-apscheduler>=0.5.0",
|
|
12
13
|
"nonebot-plugin-localstore>=0.7.4",
|
|
13
14
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/_state.py
RENAMED
|
File without changes
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/backend.py
RENAMED
|
File without changes
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/consts.py
RENAMED
|
File without changes
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/hooks.py
RENAMED
|
File without changes
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/nodes.py
RENAMED
|
File without changes
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory/rethinking/schemas.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{amrita_plugin_memory-0.2.6 → amrita_plugin_memory-0.2.8}/amrita_plugin_memory.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|