Liking cljdoc? Tell your friends :D

im.ttalk.agent.memory

ChatMemory - 按 conversation-id 管理中立消息历史

这是 Memory Filter 的后端存储。只存中立消息(见 core/llm/message)。 替代了旧 clj-agent-memory 模块中庞大的快照/时间线/多后端体系, 这里只保留对话历史所需的极小子集。

协议:

  • mem-get [store conv-id] -> [中立消息 ...]
  • mem-add [store conv-id msgs] 追加
  • mem-clear [store conv-id]

实现:

  • (in-memory-store) atom 后端
  • (windowed store opts) 在 get 时按窗口裁剪(非破坏,底层仍存完整历史)
ChatMemory - 按 conversation-id 管理中立消息历史

这是 Memory Filter 的后端存储。只存中立消息(见 core/llm/message)。
替代了旧 clj-agent-memory 模块中庞大的快照/时间线/多后端体系,
这里只保留对话历史所需的极小子集。

协议:
- mem-get   [store conv-id]        -> [中立消息 ...]
- mem-add   [store conv-id msgs]   追加
- mem-clear [store conv-id]

实现:
- (in-memory-store)            atom 后端
- (windowed store opts)        在 get 时按窗口裁剪(非破坏,底层仍存完整历史)
raw docstring

ChatMemorycljprotocol

mem-addclj

(mem-add this conv-id msgs)

追加中立消息列表。实现方要给消息补 :id(msg/ensure-id)—— 落库是消息获得身份的时刻,跨快照的稳定 id 全靠这一步(见 message ns)。

追加中立消息列表。**实现方要给消息补 `:id`**(`msg/ensure-id`)——
落库是消息获得身份的时刻,跨快照的稳定 id 全靠这一步(见 message ns)。

mem-clearclj

(mem-clear this conv-id)

清空该会话

清空该会话

mem-getclj

(mem-get this conv-id)

返回该会话的中立消息列表(无则 [])

返回该会话的中立消息列表(无则 [])
source

in-memory-storeclj

(in-memory-store)

创建 atom 后端的 ChatMemory

创建 atom 后端的 ChatMemory
sourceraw docstring

windowedclj

(windowed store {:keys [max-messages]})

包装一个 store,使 mem-get 只返回尾部 max-messages 条(pairing-safe)。 底层仍保留完整历史。

参数:

  • store: 被包装的 ChatMemory
  • opts: {:max-messages N}
包装一个 store,使 mem-get 只返回尾部 max-messages 条(pairing-safe)。
底层仍保留完整历史。

参数:
- store: 被包装的 ChatMemory
- opts:  {:max-messages N}
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close