amrita_plugin_memory 0.2.3__tar.gz → 0.2.5__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.
Files changed (26) hide show
  1. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/PKG-INFO +1 -1
  2. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/runner.py +9 -3
  3. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/tools.py +27 -9
  4. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/workflow.py +5 -10
  5. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/tools.py +12 -4
  6. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory.egg-info/PKG-INFO +1 -1
  7. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/pyproject.toml +1 -1
  8. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/LICENSE +0 -0
  9. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/README.md +0 -0
  10. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/__init__.py +0 -0
  11. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/config.py +0 -0
  12. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/embed.py +0 -0
  13. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/matchers.py +0 -0
  14. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/__init__.py +0 -0
  15. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/_state.py +0 -0
  16. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/backend.py +0 -0
  17. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/consts.py +0 -0
  18. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/hooks.py +0 -0
  19. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/nodes.py +0 -0
  20. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/rethinking/schemas.py +0 -0
  21. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory/vector.py +0 -0
  22. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory.egg-info/SOURCES.txt +0 -0
  23. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory.egg-info/dependency_links.txt +0 -0
  24. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory.egg-info/requires.txt +0 -0
  25. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/amrita_plugin_memory.egg-info/top_level.txt +0 -0
  26. {amrita_plugin_memory-0.2.3 → amrita_plugin_memory-0.2.5}/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
3
+ Version: 0.2.5
4
4
  Summary: Amrita长期记忆插件
5
5
  Requires-Python: <3.14,>=3.10
6
6
  Description-Content-Type: text/markdown
@@ -170,7 +170,9 @@ class SubconsciousRunner:
170
170
  chat_obj.begin()
171
171
  await chat_obj
172
172
  except Exception as e:
173
- logger.error(f"[EXP Subconscious] Error: {e}", exc_info=True)
173
+ logger.opt(exception=e, colors=True, raw=True).exception(
174
+ f"[EXP Subconscious] Error: {e}"
175
+ )
174
176
  finally:
175
177
  self._chat_obj = None
176
178
  self._is_running = False
@@ -314,7 +316,9 @@ class SubconsciousRunner:
314
316
  )
315
317
  await repo.update_memory_data(mem)
316
318
  except Exception as e:
317
- logger.error(f"[EXP Subconscious] Save to repo failed: {e}")
319
+ logger.opt(exception=e, colors=True, raw=True).exception(
320
+ f"[EXP Subconscious] Save to repo failed: {e}"
321
+ )
318
322
 
319
323
  async def _save_pending_to_repo(self) -> None:
320
324
  """持久化待发送消息到 CachedUserDataRepository 的 extra_prompt 中。"""
@@ -331,7 +335,9 @@ class SubconsciousRunner:
331
335
  mem.extra_prompt = json.dumps(existing, ensure_ascii=False)
332
336
  await repo.update_memory_data(mem)
333
337
  except Exception as e:
334
- logger.error(f"[EXP Subconscious] Save pending failed: {e}")
338
+ logger.opt(exception=e, colors=True, raw=True).exception(
339
+ f"[EXP Subconscious] Save pending failed: {e}"
340
+ )
335
341
 
336
342
  # Prompt 加载
337
343
 
@@ -81,7 +81,9 @@ async def subconscious_read_memory(data: dict[str, Any]) -> str:
81
81
  )
82
82
  return json.dumps(result, ensure_ascii=False, indent=2, default=str)
83
83
  except Exception as e:
84
- logger.error(f"subconscious_read_memory error: {e}")
84
+ logger.opt(exception=e, colors=True, raw=True).exception(
85
+ f"subconscious_read_memory error: {e}"
86
+ )
85
87
  return _tools_err(str(e))
86
88
 
87
89
 
@@ -99,7 +101,9 @@ async def subconscious_write_memory(data: dict[str, Any]) -> str:
99
101
  await ope.add_note(pid, str(data["content"]), metadata=meta)
100
102
  return _tools_ok(id=meta.memory_id)
101
103
  except Exception as e:
102
- logger.error(f"subconscious_write_memory error: {e}")
104
+ logger.opt(exception=e, colors=True, raw=True).exception(
105
+ f"subconscious_write_memory error: {e}"
106
+ )
103
107
  return _tools_err(str(e))
104
108
 
105
109
 
@@ -146,7 +150,9 @@ async def subconscious_update_memory(data: dict[str, Any]) -> str:
146
150
  await ope.update_note(pid, new_content, metadata=meta)
147
151
  return _tools_ok(message="记忆更新成功", id=mem_id)
148
152
  except Exception as e:
149
- logger.error(f"subconscious_update_memory error: {e}")
153
+ logger.opt(exception=e, colors=True, raw=True).exception(
154
+ f"subconscious_update_memory error: {e}"
155
+ )
150
156
  return _tools_err(str(e))
151
157
 
152
158
 
@@ -166,7 +172,9 @@ async def subconscious_delete_memory(data: dict[str, Any]) -> str:
166
172
  await ope.delete_note(pid, mem_id)
167
173
  return _tools_ok(message="记忆删除成功", id=mem_id)
168
174
  except Exception as e:
169
- logger.error(f"subconscious_delete_memory error: {e}")
175
+ logger.opt(exception=e, colors=True, raw=True).exception(
176
+ f"subconscious_delete_memory error: {e}"
177
+ )
170
178
  return _tools_err(str(e))
171
179
 
172
180
 
@@ -203,7 +211,9 @@ async def subconscious_list_memory(data: dict[str, Any]) -> str:
203
211
  )
204
212
  return _tools_ok(memories=memories, total=len(ids))
205
213
  except Exception as e:
206
- logger.error(f"subconscious_list_memory error: {e}")
214
+ logger.opt(exception=e, colors=True, raw=True).exception(
215
+ f"subconscious_list_memory error: {e}"
216
+ )
207
217
  return _tools_err(str(e))
208
218
 
209
219
 
@@ -236,7 +246,9 @@ async def subconscious_send_to_user(data: dict[str, Any]) -> str:
236
246
  try:
237
247
  content = await _generate_send_content(intent, memory_context)
238
248
  except Exception as e:
239
- logger.error(f"[EXP Subconscious] Generate send content failed: {e}")
249
+ logger.opt(exception=e, colors=True, raw=True).exception(
250
+ f"[EXP Subconscious] Generate send content failed: {e}"
251
+ )
240
252
  return _tools_err(str(e))
241
253
  ts = datetime.now(timezone.utc).isoformat()
242
254
  pending = _state.get_pending()
@@ -272,7 +284,9 @@ async def subconscious_read_chat_context(data: dict[str, Any]) -> str:
272
284
  indent=2,
273
285
  )
274
286
  except Exception as e:
275
- logger.error(f"subconscious_read_chat_context error: {e}")
287
+ logger.opt(exception=e, colors=True, raw=True).exception(
288
+ f"subconscious_read_chat_context error: {e}"
289
+ )
276
290
  return _tools_err(str(e))
277
291
 
278
292
 
@@ -386,7 +400,9 @@ async def subconscious_duplicate_helper(data: dict[str, Any]) -> str:
386
400
  memories=items,
387
401
  )
388
402
  except Exception as e:
389
- logger.error(f"subconscious_duplicate_helper error: {e}")
403
+ logger.opt(exception=e, colors=True, raw=True).exception(
404
+ f"subconscious_duplicate_helper error: {e}"
405
+ )
390
406
  return _tools_err(str(e))
391
407
 
392
408
 
@@ -444,5 +460,7 @@ async def subconscious_get_memory_stats(data: dict[str, Any]) -> str:
444
460
  avg_length=total_length // len(ids) if ids else 0,
445
461
  )
446
462
  except Exception as e:
447
- logger.error(f"subconscious_get_memory_stats error: {e}")
463
+ logger.opt(exception=e, colors=True, raw=True).exception(
464
+ f"subconscious_get_memory_stats error: {e}"
465
+ )
448
466
  return _tools_err(str(e))
@@ -8,8 +8,7 @@ from amrita_core.components.react import (
8
8
  REACT_COUNTER,
9
9
  SINGLE_STRATEGY_CALL,
10
10
  )
11
- from amrita_core.enums import BuiltinName
12
- from amrita_sense import ALIAS, GOTO, NOP, WHILE, NodeCompose
11
+ from amrita_sense import WHILE, NodeCompose
13
12
 
14
13
  from .nodes import LIMITING_MEMORY, STRATEGY_INIT
15
14
 
@@ -21,19 +20,15 @@ _workflow = None
21
20
  def build_workflow():
22
21
  global _workflow
23
22
  if _workflow is None:
24
- wf: NodeCompose = (
23
+ wf: NodeCompose = ( # A simple ReAct
25
24
  LOAD_STATE
26
25
  >> JINJA2_RENDER
27
26
  >> LIMITING_MEMORY
28
27
  >> BUILD_MESSAGE
29
28
  >> STRATEGY_INIT
30
- >> (
31
- GOTO(BuiltinName.STRATEGY_EOF)
32
- >> ALIAS(AGENT_ENTRY, BuiltinName.AGENT_STRATEGY)
33
- >> WHILE(_single_call).ACTION(REACT_COUNTER)
34
- >> AGENT_POST_PROCESS
35
- >> ALIAS(NOP, BuiltinName.STRATEGY_EOF)
36
- )
29
+ >> AGENT_ENTRY
30
+ >> WHILE(_single_call).ACTION(REACT_COUNTER)
31
+ >> AGENT_POST_PROCESS
37
32
  )
38
33
  _workflow = wf.render()
39
34
  return _workflow
@@ -245,7 +245,9 @@ async def r(ctx: ToolContext) -> str:
245
245
  )
246
246
  return json.dumps(res, ensure_ascii=False, indent=4)
247
247
  except Exception as e:
248
- logger.error(f"检索记忆时发生错误: {e}")
248
+ logger.opt(exception=e, colors=True, raw=True).exception(
249
+ f"检索记忆时发生错误: {e}"
250
+ )
249
251
  return _err(f"检索记忆失败: {e!s}")
250
252
 
251
253
 
@@ -317,7 +319,9 @@ async def update_memory(ctx: ToolContext) -> str:
317
319
 
318
320
  return _ok(message="记忆更新成功", id=ctx.data["id"])
319
321
  except Exception as e:
320
- logger.error(f"更新记忆时发生错误: {e}")
322
+ logger.opt(exception=e, colors=True, raw=True).exception(
323
+ f"更新记忆时发生错误: {e}"
324
+ )
321
325
  return _err(f"更新记忆失败: {e!s}")
322
326
 
323
327
 
@@ -349,7 +353,9 @@ async def delete_memory(ctx: ToolContext) -> str:
349
353
  await ope.delete_note(partition_id, ctx.data["id"])
350
354
  return _ok(message="记忆删除成功", id=ctx.data["id"])
351
355
  except Exception as e:
352
- logger.error(f"删除记忆时发生错误: {e}")
356
+ logger.opt(exception=e, colors=True, raw=True).exception(
357
+ f"删除记忆时发生错误: {e}"
358
+ )
353
359
  return _err(f"删除记忆失败: {e!s}")
354
360
 
355
361
 
@@ -400,5 +406,7 @@ async def list_memory(ctx: ToolContext) -> str:
400
406
 
401
407
  return _ok(memories=memories, total=len(ids))
402
408
  except Exception as e:
403
- logger.error(f"列出记忆时发生错误: {e}")
409
+ logger.opt(exception=e, colors=True, raw=True).exception(
410
+ f"列出记忆时发生错误: {e}"
411
+ )
404
412
  return _err(f"列出记忆失败: {e!s}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amrita_plugin_memory
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: Amrita长期记忆插件
5
5
  Requires-Python: <3.14,>=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "amrita_plugin_memory"
3
3
  description = "Amrita长期记忆插件"
4
- version = "0.2.3"
4
+ version = "0.2.5"
5
5
  dependencies = [
6
6
  "aiohttp>=3.13.3",
7
7
  "aiologic>=0.16.0",