Liking cljdoc? Tell your friends :D

im.ttalk.agent.filter.memory

Memory Filter - 按 conversation-id 读写历史

以 around-chat filter 形态挂进 chat-client 的 filter 链:

  • req 段:把本次入参(delta)存入 store,再用完整历史替换发给 LLM 的 messages
  • resp 段:把 LLM 的 assistant 回复(可能含 tool-calls)存入 store

conversation-id 从 ChatRequest 的 :context(扁平 map)读取;为空时整体 no-op (保留一次性/无记忆调用)。store 是 filter 的私有闭包,chat-client 对其无感知。

用法: (build-chat-client {:chat-model cm :tools tools :filters [(memory-filter store)]})

Memory Filter - 按 conversation-id 读写历史

以 around-chat filter 形态挂进 chat-client 的 filter 链:

- req 段:把本次入参(delta)存入 store,再用完整历史替换发给 LLM 的 messages
- resp 段:把 LLM 的 assistant 回复(可能含 tool-calls)存入 store

conversation-id 从 ChatRequest 的 :context(扁平 map)读取;为空时整体 no-op
(保留一次性/无记忆调用)。store 是 filter 的私有闭包,chat-client 对其无感知。

用法:
(build-chat-client {:chat-model cm
                    :tools tools
                    :filters [(memory-filter store)]})
raw docstring

memory-filterclj

(memory-filter store)

构造按 conversation-id 读写历史的 around-chat filter,闭包绑定 store。

应作为 filters vector 的第一个元素注册,确保其他 filter 看到完整对话历史。

构造按 conversation-id 读写历史的 around-chat filter,闭包绑定 store。

应作为 filters vector 的第一个元素注册,确保其他 filter 看到完整对话历史。
sourceraw docstring

notes-messageclj

(notes-message notes)

本轮临时提醒 → 一条 <system-reminder> 包装的 user 消息(designs/runtime-borrow.md §0 挂点 1)。只拼进本次发给模型的消息,不进 ChatMemory。

本轮临时提醒 → 一条 `<system-reminder>` 包装的 user 消息(designs/runtime-borrow.md
§0 挂点 1)。只拼进**本次**发给模型的消息,不进 ChatMemory。
sourceraw docstring

response->neutralclj

(response->neutral response)

把归一化响应(ILLMResponse)转成中立 assistant 消息。 归一化响应的 tool-calls 已与中立形状同构({:id :name(字符串) :args}, v0.2 统一后不再需要 :input→:args 换名),仅经 msg/tool-call 复位形状。

:replay-blocks(provider 经 IReplayableResponse 抽出的不透明载荷)必须 随消息进历史:它是「原样带回下一轮」的唯一载体,在这里丢掉,下一轮 wire 层 就再也拿不回来了——这正是 P3 修的那个洞(docs/provider-variant-design.md §1.3;实测代价:M3 正确率 100%→82.5%)。本函数不解释它,只搬运。

把归一化响应(ILLMResponse)转成中立 assistant 消息。
归一化响应的 tool-calls 已与中立形状同构({:id :name(字符串) :args},
v0.2 统一后不再需要 :input→:args 换名),仅经 msg/tool-call 复位形状。

:replay-blocks(provider 经 IReplayableResponse 抽出的不透明载荷)**必须**
随消息进历史:它是「原样带回下一轮」的唯一载体,在这里丢掉,下一轮 wire 层
就再也拿不回来了——这正是 P3 修的那个洞(docs/provider-variant-design.md
§1.3;实测代价:M3 正确率 100%→82.5%)。本函数不解释它,只搬运。
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