chatluna-plugin-livingmemory 0.0.4 → 0.0.6
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.
- package/README.md +16 -14
- package/client/guide-panel.tsx +60 -37
- package/client/locales/en.yml +15 -6
- package/client/locales/zh.yml +21 -12
- package/client/page.tsx +41 -14
- package/client/preset-actions.tsx +120 -120
- package/dist/.vite/manifest.json +1 -1
- package/dist/client.css +1 -1
- package/dist/client.js +1 -1
- package/dist/page-EGG2hcC3.js +3 -0
- package/lib/contracts/memory.d.ts +12 -4
- package/lib/contracts/memory.d.ts.map +1 -1
- package/lib/contracts/webui.d.ts +3 -2
- package/lib/contracts/webui.d.ts.map +1 -1
- package/lib/contracts/workflows.d.ts +5 -17
- package/lib/contracts/workflows.d.ts.map +1 -1
- package/lib/index.js +620 -479
- package/lib/index.js.map +1 -1
- package/lib/routing.d.ts +2 -0
- package/lib/routing.d.ts.map +1 -1
- package/lib/service/app/admin_service.d.ts +10 -2
- package/lib/service/app/admin_service.d.ts.map +1 -1
- package/lib/service/app/mutation_service.d.ts +1 -2
- package/lib/service/app/mutation_service.d.ts.map +1 -1
- package/lib/service/app/query_projections.d.ts +2 -2
- package/lib/service/app/query_projections.d.ts.map +1 -1
- package/lib/service/app/webui.d.ts.map +1 -1
- package/lib/service/chat_history.d.ts +13 -7
- package/lib/service/chat_history.d.ts.map +1 -1
- package/lib/service/conversation_hooks.d.ts +25 -14
- package/lib/service/conversation_hooks.d.ts.map +1 -1
- package/lib/service/logging/logger.d.ts +2 -4
- package/lib/service/logging/logger.d.ts.map +1 -1
- package/lib/service/logging/model_calls.d.ts +11 -0
- package/lib/service/logging/model_calls.d.ts.map +1 -1
- package/lib/service/memory/conversation_sources.d.ts +20 -0
- package/lib/service/memory/conversation_sources.d.ts.map +1 -0
- package/lib/service/memory/helpers.d.ts +7 -8
- package/lib/service/memory/helpers.d.ts.map +1 -1
- package/lib/service/memory/tools/index.d.ts +2 -2
- package/lib/service/memory/tools/index.d.ts.map +1 -1
- package/lib/service/memory/tools/memory_tools.d.ts +2 -1
- package/lib/service/memory/tools/memory_tools.d.ts.map +1 -1
- package/lib/service/memory/tools/search_memory_tool.d.ts +2 -2
- package/lib/service/memory/tools/search_memory_tool.d.ts.map +1 -1
- package/lib/service/memory/tools/tool_runtime.d.ts +13 -1
- package/lib/service/memory/tools/tool_runtime.d.ts.map +1 -1
- package/lib/service/persistence/entries.d.ts +12 -10
- package/lib/service/persistence/entries.d.ts.map +1 -1
- package/lib/service/persistence/normalizers.d.ts.map +1 -1
- package/lib/service/persistence/repository.d.ts +22 -14
- package/lib/service/persistence/repository.d.ts.map +1 -1
- package/lib/service/persistence/source_migration.d.ts +6 -0
- package/lib/service/persistence/source_migration.d.ts.map +1 -0
- package/lib/service/persistence/tables.d.ts +3 -1
- package/lib/service/persistence/tables.d.ts.map +1 -1
- package/lib/service/prompts/dream.d.ts +2 -2
- package/lib/service/prompts/dream.d.ts.map +1 -1
- package/lib/service/prompts/memory_entries.d.ts +5 -13
- package/lib/service/prompts/memory_entries.d.ts.map +1 -1
- package/lib/service/prompts/user_profile.d.ts +2 -3
- package/lib/service/prompts/user_profile.d.ts.map +1 -1
- package/lib/service/shared/utils.d.ts +0 -4
- package/lib/service/shared/utils.d.ts.map +1 -1
- package/lib/service/transcript/header.d.ts +4 -0
- package/lib/service/transcript/header.d.ts.map +1 -0
- package/lib/service/user_profile.d.ts.map +1 -1
- package/lib/service/workflows/dream/session/history.d.ts +4 -4
- package/lib/service/workflows/dream/session/history.d.ts.map +1 -1
- package/lib/service/workflows/dream/session/runner.d.ts.map +1 -1
- package/lib/service/workflows/extraction/coordinator.d.ts.map +1 -1
- package/lib/service/workflows/extraction/extractor.d.ts +0 -4
- package/lib/service/workflows/extraction/extractor.d.ts.map +1 -1
- package/lib/service/workflows/recall/coordinator.d.ts +2 -2
- package/lib/service/workflows/recall/coordinator.d.ts.map +1 -1
- package/lib/service/workflows/structured_output.d.ts +10 -14
- package/lib/service/workflows/structured_output.d.ts.map +1 -1
- package/lib/service/workflows/tool_loop.d.ts +10 -21
- package/lib/service/workflows/tool_loop.d.ts.map +1 -1
- package/lib/service.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/contracts/memory.ts +14 -4
- package/src/contracts/webui.ts +3 -2
- package/src/contracts/workflows.ts +17 -16
- package/dist/page-CQcDlyjD.js +0 -3
- package/lib/service/transcript/origin_context.d.ts +0 -17
- package/lib/service/transcript/origin_context.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -24,20 +24,20 @@ yarn build
|
|
|
24
24
|
|
|
25
25
|
在 **对话规则 → 能力 → LivingMemory** 设置全局默认值,或为指定群、频道单独配置。私聊可按频道或路由 ID 配置。
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
如果只想在指定群自动提取记忆,把全局的「从聊天中提取记忆的间隔」设为 `0`,再为这些群设置需要的消息条数。
|
|
28
28
|
|
|
29
|
-
|
|
|
29
|
+
| 配置项 | 配置键 | 默认值 | 说明 |
|
|
30
30
|
| --- | --- | --- | --- |
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
| `recallIntervalMessages` |
|
|
35
|
-
| `recallHistoryMessages` |
|
|
36
|
-
| `snapshotScope` |
|
|
37
|
-
| `snapshotMaxLines` |
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
31
|
+
| 从聊天中提取记忆的间隔 | `extractionWindowMessages` | `60` | 按未提取的聊天消息条数计算(0—360);`0` 关闭自动提取。 |
|
|
32
|
+
| 允许群友闲聊触发记忆提取 | `extractionIncludeOverheard` | `false` | 开启后,群友闲聊达到设定条数就能触发提取;关闭时,等 bot 回复后再检查。 |
|
|
33
|
+
| 是否在提取新记忆后进行 Dream 整理 | `enableAutoDream` | `true` | 自动提取保存新记忆后,由 Dream 检查是否需要整理。 |
|
|
34
|
+
| 记忆自动召回的间隔 | `recallIntervalMessages` | `20` | bot 被唤醒时按新增聊天条数判断是否召回;`0` 关闭自动召回。 |
|
|
35
|
+
| 用于召回记忆的聊天消息数 | `recallHistoryMessages` | `20` | 召回时最多读取多少条最近的聊天消息;画像注入也使用这段聊天记录。 |
|
|
36
|
+
| 记忆快照的使用范围 | `snapshotScope` | `conversation` | 每一个会话拥有独立记忆快照(`conversation`)或所有会话共享一个记忆快照(`preset`)。开启「会话记忆隔离」时使用独立快照。 |
|
|
37
|
+
| 记忆快照的最大行数 | `snapshotMaxLines` | `5` | 可设为 5—50 行。 |
|
|
38
|
+
| 会话记忆隔离 | `enableConversationIsolation` | `false` | 召回和检索工具只查当前会话的记忆和全局记忆。 |
|
|
39
|
+
| 向 bot 注入记忆快照 | `enableSnapshotInjection` | `true` | 在对话中提供已召回的记忆。 |
|
|
40
|
+
| 向 bot 注入用户画像 | `enableUserProfileInjection` | `false` | 在对话中提供最近聊天里发言人的已有画像。 |
|
|
41
41
|
|
|
42
42
|
## 插件配置
|
|
43
43
|
|
|
@@ -49,13 +49,13 @@ yarn build
|
|
|
49
49
|
|
|
50
50
|
| Key | Type | Default | Description |
|
|
51
51
|
| --- | --- | --- | --- |
|
|
52
|
-
| `debug` | boolean | `false` |
|
|
52
|
+
| `debug` | boolean | `false` | 记录 LivingMemory 每次调用对话模型时的提示词、消息和模型响应 |
|
|
53
53
|
|
|
54
54
|
### 模型配置
|
|
55
55
|
|
|
56
56
|
| Key | Type | Default | Description |
|
|
57
57
|
| --- | --- | --- | --- |
|
|
58
|
-
| `mainModel` | string | `无` |
|
|
58
|
+
| `mainModel` | string | `无` | 主模型:提取记忆、运行 Dream、更新人物画像和人设卡。需支持工具调用 |
|
|
59
59
|
| `subModel` | string | `无` | 子 LLM:召回记忆 |
|
|
60
60
|
| `embeddingModel` | string | `无` | 嵌入模型:将记忆和查询文本转换为向量,用于检索与 Dream |
|
|
61
61
|
| `rerankModel` | string | `无` | 重排序模型(可选):按候选记忆与查询的相关性重新排序 |
|
|
@@ -96,3 +96,5 @@ yarn build
|
|
|
96
96
|
可逐条勾选记忆,也可全选当前筛选的所有结果(含其他页)。永久删除选中记忆前需要确认;清空整个预设时,需输入弹窗中包含预设名的完整短语。
|
|
97
97
|
|
|
98
98
|
要迁移记忆,在原实例选好预设后点「导出记忆」。在目标实例选好预设,点「导入记忆」,选择 LivingMemory v1 或 v2 导出的 JSON 文件并确认。目标实例还没有预设时,使用文件中的预设名。
|
|
99
|
+
|
|
100
|
+
导入时,能对应到本实例会话的记忆保留其会话归属;找不到对应会话的记忆改为该预设内全局可见,来源显示为 `unknown`。已导入的旧来源在插件下次启动时按同一规则转换。
|
package/client/guide-panel.tsx
CHANGED
|
@@ -1,45 +1,68 @@
|
|
|
1
|
-
import { Button } from '@chatluna/ui-kit'
|
|
2
1
|
import { useTranslate } from '@chatluna/ui-client/client'
|
|
2
|
+
import { Button } from '@chatluna/ui-kit'
|
|
3
|
+
|
|
4
|
+
const chapters = [
|
|
5
|
+
{ key: 'start', topics: ['models', 'rules', 'check'] },
|
|
6
|
+
{ key: 'timing', topics: ['overheard', 'interval'] },
|
|
7
|
+
{ key: 'context', topics: ['sharing', 'profiles'] },
|
|
8
|
+
{ key: 'dream', topics: ['dream.auto', 'dream.manual', 'dream.result'] }
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
function goToChapter(key: string) {
|
|
12
|
+
const heading = document.getElementById(`livingmemory-guide-${key}`)
|
|
13
|
+
if (!heading) return
|
|
14
|
+
heading.focus({ preventScroll: true })
|
|
15
|
+
heading.scrollIntoView({ block: 'start' })
|
|
16
|
+
}
|
|
3
17
|
|
|
4
18
|
export function GuidePanel({ onOpenSettings }: { onOpenSettings(): void }) {
|
|
5
19
|
const t = useTranslate('livingmemory')
|
|
6
20
|
return (
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
<div className="@container w-full">
|
|
22
|
+
<div className="mx-auto grid max-w-5xl gap-y-7 pb-12 pt-3 @3xl:grid-cols-[minmax(0,1fr)_11rem] @3xl:gap-x-12 @3xl:pt-6">
|
|
23
|
+
<header className="@3xl:col-start-1">
|
|
24
|
+
<h1 className="text-3xl font-bold tracking-tight">{t('tab.guide')}</h1>
|
|
25
|
+
<p className="mt-3 max-w-prose leading-7 text-muted-foreground">{t('guide.intro')}</p>
|
|
26
|
+
</header>
|
|
27
|
+
<nav aria-label={t('guide.contents')} className="border-l border-border pl-4 @3xl:sticky @3xl:top-5 @3xl:col-start-2 @3xl:row-span-2 @3xl:row-start-1 @3xl:self-start">
|
|
28
|
+
<p className="mb-2 text-sm font-semibold">{t('guide.contents')}</p>
|
|
29
|
+
<ul className="flex flex-wrap gap-x-4 gap-y-1 @3xl:flex-col">
|
|
30
|
+
{chapters.map(({ key }) => (
|
|
31
|
+
<li key={key}>
|
|
32
|
+
<button type="button" onClick={() => goToChapter(key)} className="block py-1 text-left text-sm text-muted-foreground hover:text-foreground hover:underline">
|
|
33
|
+
{t(`guide.${key}`)}
|
|
34
|
+
</button>
|
|
35
|
+
</li>
|
|
36
|
+
))}
|
|
37
|
+
</ul>
|
|
38
|
+
</nav>
|
|
39
|
+
<article className="min-w-0 space-y-9 @3xl:col-start-1">
|
|
40
|
+
{chapters.map(({ key, topics }) => (
|
|
41
|
+
<section key={key} className="border-t border-border pt-6">
|
|
42
|
+
<h2 id={`livingmemory-guide-${key}`} tabIndex={-1} className="scroll-mt-5 text-xl font-semibold tracking-tight">
|
|
43
|
+
{t(`guide.${key}`)}
|
|
44
|
+
</h2>
|
|
45
|
+
{key === 'dream' && <p className="mt-3 leading-7">{t('guide.dream.intro')}</p>}
|
|
46
|
+
{topics.map((topic, index) => (
|
|
47
|
+
<div key={topic} className="mt-5">
|
|
48
|
+
<h3 className="font-semibold">
|
|
49
|
+
{key === 'start' && <span className="mr-2 text-muted-foreground">{index + 1}.</span>}
|
|
50
|
+
{t(`guide.${topic}.title`)}
|
|
51
|
+
</h3>
|
|
52
|
+
<p className="mt-1.5 leading-7">{t(`guide.${topic}.text`)}</p>
|
|
53
|
+
{topic === 'models' && <Button variant="outline" className="mt-3" onClick={onOpenSettings}>{t('guide.openSettings')}</Button>}
|
|
54
|
+
</div>
|
|
55
|
+
))}
|
|
56
|
+
{key === 'timing' && (
|
|
57
|
+
<aside className="mt-5 rounded-lg bg-muted px-5 py-4">
|
|
58
|
+
<h3 className="font-semibold">{t('guide.buffer.title')}</h3>
|
|
59
|
+
<p className="mt-1.5 leading-7">{t('guide.buffer.text')}</p>
|
|
60
|
+
</aside>
|
|
61
|
+
)}
|
|
62
|
+
</section>
|
|
40
63
|
))}
|
|
41
|
-
</
|
|
42
|
-
</
|
|
43
|
-
</
|
|
64
|
+
</article>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
44
67
|
)
|
|
45
68
|
}
|
package/client/locales/en.yml
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
preset.placeholder: Select a preset
|
|
2
|
+
nativeMemory.title: The built-in memory plugin is also running
|
|
3
|
+
nativeMemory.description: LivingMemory and the built-in memory plugin have similar features. We recommend enabling only one.
|
|
4
|
+
nativeMemory.risk: Running both may use extra tokens or cause unexpected issues.
|
|
5
|
+
nativeMemory.close: Dismiss for now
|
|
6
|
+
nativeMemory.neverShow: Got it, don’t show this again
|
|
2
7
|
transfer.export: Export memories
|
|
3
8
|
transfer.import: Import memories
|
|
4
9
|
transfer.confirmTitle: 'Import into “{target}”?'
|
|
5
10
|
transfer.preview: 'Export from “{source}”: {entries} memories, {profiles} profiles and {speakers} speakers.'
|
|
6
11
|
transfer.merge: Memories with matching IDs and profiles for the same speaker will be replaced. Other memories are kept.
|
|
7
12
|
transfer.confirm: Confirm import
|
|
8
|
-
transfer.invalid: Choose a JSON file exported by LivingMemory (format versions 1–
|
|
13
|
+
transfer.invalid: Choose a JSON file exported by LivingMemory (format versions 1–6).
|
|
9
14
|
transfer.imported: 'Imported into “{target}”: {entries} memories, {profiles} profiles and {speakers} speakers.'
|
|
10
15
|
empty.noPreset: No preset data yet. Create your first memory or import a file.
|
|
11
16
|
|
|
@@ -64,7 +69,6 @@ field.status: Status
|
|
|
64
69
|
field.sentiment: Sentiment
|
|
65
70
|
field.importance: Importance
|
|
66
71
|
field.speakers: Linked users
|
|
67
|
-
field.source: Source
|
|
68
72
|
field.createdAt: Created
|
|
69
73
|
field.updatedAt: Updated
|
|
70
74
|
field.content: Content
|
|
@@ -130,23 +134,28 @@ tab.navigation: Memory management
|
|
|
130
134
|
tab.settings: Plugin configuration
|
|
131
135
|
tab.guide: Plugin guide
|
|
132
136
|
guide.start: Getting started
|
|
137
|
+
guide.intro: Choose your models and conversations, then try a search with one memory. The following sections explain when the bot saves and recalls memories, how to use profiles, and how Dream organizes existing memories.
|
|
138
|
+
guide.contents: On this page
|
|
133
139
|
guide.models.title: Choose your models
|
|
134
|
-
guide.models.text: Under Plugin configuration → Model configuration, choose
|
|
140
|
+
guide.models.text: Under Plugin configuration → Model configuration, choose a main model that supports tool calls. It extracts and organizes memories and updates user profiles and persona cards. The recall model decides whether to look up memories. The embedding model converts memories and queries into vectors so the plugin can compare their meanings. An optional reranker reorders the candidate memories by their relevance to the query. Select Save settings to apply these choices to all presets in this plugin instance.
|
|
135
141
|
guide.openSettings: Open plugin configuration
|
|
136
142
|
guide.rules.title: Choose which conversations use automatic extraction
|
|
137
143
|
guide.rules.text: Open Conversation rules → Capabilities → LivingMemory and set the extraction interval. The default is 60 chat messages. To enable automatic extraction in just one group, set the global interval to 0 and that group’s interval to 60.
|
|
138
144
|
guide.check.title: Try a search with one memory
|
|
139
145
|
guide.check.text: Under Memories, select New memory, choose a preset, and save “I drink my coffee without sugar.” Under Recall test for the same preset, search for “How do I like my coffee?” to see the matches. The test leaves snapshots unchanged. Under Snapshots you can read the snapshot from an actual chat. Expand Recall details to see the search terms and matching memories.
|
|
140
|
-
guide.
|
|
146
|
+
guide.timing: When extraction and recall run
|
|
147
|
+
guide.buffer.title: Check the chat buffer before raising an interval
|
|
148
|
+
guide.buffer.text: In ChatLuna, open Plugins → Conversation and routing → @chatluna/chat-observer and adjust the buffer limit. Each channel keeps its latest 200 messages by default. Extraction and recall can only count chats still in that buffer. For example, a 300-message extraction interval can never be reached with a 200-message buffer. Even with a shorter interval, messages evicted between checks cannot be read later.
|
|
149
|
+
guide.context: Snapshots and user profiles
|
|
141
150
|
guide.interval.title: How does the recall interval differ from the history length?
|
|
142
|
-
guide.interval.text:
|
|
151
|
+
guide.interval.text: The interval tells the bot how many new messages to wait for between recalls when it wakes. Set it to 0 to disable automatic recall. The history length sets how many recent messages the bot reads for each recall. Both default to 20 messages.
|
|
143
152
|
guide.overheard.title: When can chat between group members trigger extraction?
|
|
144
153
|
guide.overheard.text: Overheard extraction is off by default. Group chatter alone will not trigger extraction. Once the bot replies, the plugin counts unprocessed messages up to that reply, including earlier chatter, and starts extraction if the interval has been reached. With overheard extraction on, group members can reach the threshold on their own without calling the bot or waiting for a reply.
|
|
145
154
|
guide.sharing.title: Can two groups using the same preset share a snapshot?
|
|
146
155
|
guide.sharing.text: Each conversation has its own snapshot by default. To share one between two groups using the same preset, select preset sharing in both groups’ conversation rules. The groups share recall results; each still reads its own chat history and tracks its own recall interval. A group with conversation isolation enabled always uses its own snapshot and searches only its own and global memories within the preset.
|
|
147
156
|
guide.profiles.title: How do I use existing user profiles in a chat?
|
|
148
157
|
guide.profiles.text: By default, profiles are updated after extraction or Dream, and each person needs at least three linked active memories. You can change these settings under Plugin configuration. To use existing profiles during a chat, enable profile injection in the conversation rule (off by default). The bot receives profiles for users who spoke in the recent messages covered by the recall history length.
|
|
149
|
-
guide.dream
|
|
158
|
+
guide.dream: How Dream organizes memories
|
|
150
159
|
guide.dream.intro: Dream uses the main model to compare memories and decide which to keep, update, merge, split, or archive. For example, “I take my coffee without sugar” and “I like unsweetened coffee” can become a single preference. Choose a main model with a context window of at least 200k tokens for Dream.
|
|
151
160
|
guide.dream.auto.title: Automatic runs start with newly extracted memories
|
|
152
161
|
guide.dream.auto.text: Conversation rules enable Dream after extraction by default. For each newly saved memory, Dream looks for related active memories already in the same preset and reviews them together. If it finds no related older memory, the new entry stays as it is.
|
package/client/locales/zh.yml
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
preset.placeholder: 选择预设
|
|
2
|
+
nativeMemory.title: 检测到您已同时启动原生 memory 插件
|
|
3
|
+
nativeMemory.description: LivingMemory 和原生 memory 插件在功能上较为相似,建议仅启用其中一个。
|
|
4
|
+
nativeMemory.risk: 否则可能会带来额外的 token 开销或其他未知问题。
|
|
5
|
+
nativeMemory.close: 本次关闭
|
|
6
|
+
nativeMemory.neverShow: 我知道了,且以后不再提示
|
|
2
7
|
preset.actions: 预设操作
|
|
3
8
|
tab.navigation: 记忆管理
|
|
4
9
|
transfer.export: 导出记忆
|
|
@@ -7,7 +12,7 @@ transfer.confirmTitle: 导入到「{target}」?
|
|
|
7
12
|
transfer.preview: 文件导出自「{source}」,包含 {entries} 条记忆、{profiles} 份画像和 {speakers} 位说话者。
|
|
8
13
|
transfer.merge: 相同 ID 的记忆和同一说话者的画像会被覆盖,其他记忆保留。
|
|
9
14
|
transfer.confirm: 确认导入
|
|
10
|
-
transfer.invalid: 无法识别该文件。请选择 LivingMemory 导出的 JSON 文件(格式版本 1–
|
|
15
|
+
transfer.invalid: 无法识别该文件。请选择 LivingMemory 导出的 JSON 文件(格式版本 1–6)。
|
|
11
16
|
transfer.imported: 已导入到「{target}」:{entries} 条记忆、{profiles} 份画像、{speakers} 位说话者。
|
|
12
17
|
empty.noPreset: 还没有预设数据。可以新建第一条记忆,也可以从文件导入。
|
|
13
18
|
|
|
@@ -15,26 +20,31 @@ tab.entries: 记忆
|
|
|
15
20
|
tab.settings: 插件配置
|
|
16
21
|
tab.guide: 插件指南
|
|
17
22
|
guide.start: 第一次使用
|
|
23
|
+
guide.intro: 先配置模型、选好要记录的对话,再用一条记忆试试检索。下面也说明了机器人何时提取记忆、何时想起它,以及 Dream 如何整理已有的记忆。
|
|
24
|
+
guide.contents: 本页目录
|
|
18
25
|
guide.models.title: 配置模型
|
|
19
|
-
guide.models.text: 在「插件配置 →
|
|
26
|
+
guide.models.text: 在「插件配置 → 模型配置」选择模型。主模型需要支持工具调用,用于提取和整理记忆、更新人物画像和人设卡。召回模型判断当前聊天是否需要查找记忆。嵌入模型将记忆和查询文本转换为向量,供插件比较语义相似度。重排序模型是可选的:它根据查询与每条候选记忆的相关性,重新排列检索结果。点「保存设置」后,这些选择对当前插件实例的所有预设生效。
|
|
20
27
|
guide.openSettings: 打开插件配置
|
|
21
28
|
guide.rules.title: 选择在哪些对话中自动提取记忆
|
|
22
|
-
guide.rules.text: 在「对话规则 → 能力 → LivingMemory
|
|
29
|
+
guide.rules.text: 在「对话规则 → 能力 → LivingMemory」设置「从聊天中提取记忆的间隔」,默认是 60 条聊天消息。要只在某个群自动提取,把全局间隔设为 0,再把该群规则的间隔设为 60。
|
|
23
30
|
guide.check.title: 用一条记忆试试检索
|
|
24
31
|
guide.check.text: 在「记忆」页点「新建记忆」,选好预设,写下“我喝咖啡不加糖”并保存。到同一预设的「召回测试」搜索“我喜欢喝什么咖啡”,查看检索结果。测试不会更新快照。实际聊天的快照正文在「快照」页查看,展开「召回详情」可以看到搜索词和命中的记忆。
|
|
25
|
-
guide.
|
|
26
|
-
guide.
|
|
27
|
-
guide.
|
|
32
|
+
guide.timing: 提取与召回的时机
|
|
33
|
+
guide.buffer.title: 调大间隔前,先看聊天缓存
|
|
34
|
+
guide.buffer.text: 在 ChatLuna 的「插件 → 对话与路由 → @chatluna/chat-observer → 缓存条数」调整。默认每个频道保留最近 200 条消息,提取和召回都只能统计还在缓存里的聊天。例如,缓存是 200 条,提取间隔设为 300 条,就永远凑不够。即使间隔较小,两次检查之间被挤出缓存的旧消息也不会补读。
|
|
35
|
+
guide.context: 快照与用户画像
|
|
36
|
+
guide.interval.title: 「记忆自动召回的间隔」和「用于召回记忆的聊天消息数」有什么区别?
|
|
37
|
+
guide.interval.text: 前者决定 bot 被唤醒时,隔多少条新消息召回一次;设为 0 会关闭自动召回。后者决定每次召回向前读多少条聊天。两项默认都是 20 条。
|
|
28
38
|
guide.overheard.title: 群友之间的闲聊什么时候会触发提取?
|
|
29
|
-
guide.overheard.text:
|
|
39
|
+
guide.overheard.text: 「允许群友闲聊触发记忆提取」默认关闭。等 bot 回复后,插件才检查未提取的消息是否达到设定条数,先前的闲聊也计入条数。开启后,即使 bot 没有参与,群友闲聊达到设定条数也会触发提取。
|
|
30
40
|
guide.sharing.title: 同一预设下的两个群能共用快照吗?
|
|
31
|
-
guide.sharing.text:
|
|
41
|
+
guide.sharing.text: 默认每个会话各用一份快照。要让同一预设下的两个群共用一份,在适用于这两个群的对话规则中,将「记忆快照的使用范围」设为「所有会话共享一个记忆快照」。两个群共享召回结果,仍各自读取聊天记录、计算召回间隔。开启「会话记忆隔离」后,这份规则涉及的会话各用独立快照。
|
|
32
42
|
guide.profiles.title: 已经生成了用户画像,怎样在聊天中使用?
|
|
33
|
-
guide.profiles.text: 默认在提取或 Dream 整理后更新画像,每位用户至少需要 3
|
|
34
|
-
guide.dream
|
|
43
|
+
guide.profiles.text: 默认在提取或 Dream 整理后更新画像,每位用户至少需要 3 条关联的活跃记忆。这些条件在「插件配置」中调整。要让机器人在聊天中使用已有画像,还需在对话规则中打开「向 bot 注入用户画像」(默认关闭)。注入哪些人的画像,取决于本次召回上下文里有哪些用户发过言。
|
|
44
|
+
guide.dream: Dream 如何整理记忆
|
|
35
45
|
guide.dream.intro: Dream 让主模型对照已有的记忆,决定哪些该保留、更新、合并、拆分或归档。例如,“我喝咖啡不加糖”和“我喜欢无糖咖啡”可以合并成一条偏好。使用 Dream 时,请选择上下文窗口至少为 200k tokens 的主模型。
|
|
36
46
|
guide.dream.auto.title: 自动整理:从刚提取的新记忆开始
|
|
37
|
-
guide.dream.auto.text:
|
|
47
|
+
guide.dream.auto.text: 对话规则中的「是否在提取新记忆后进行 Dream 整理」默认开启。每次自动提取保存新记忆后,Dream 会为每条新记忆查找同一预设下相关的活跃旧记忆,放在一起整理。找不到相关旧记忆时,新条目保持原样。
|
|
38
48
|
guide.dream.manual.title: 手动整理:检查整个预设
|
|
39
49
|
guide.dream.manual.text: 预设里至少有 30 条活跃记忆时,可以在「记忆」页选择该预设,点「运行 Dream」。Dream 会把活跃记忆按内容相关性分组,逐组检查。30 条的门槛只用于手动整理。
|
|
40
50
|
guide.dream.result.title: 查看整理结果
|
|
@@ -99,7 +109,6 @@ field.status: 状态
|
|
|
99
109
|
field.sentiment: 情绪
|
|
100
110
|
field.importance: 重要度
|
|
101
111
|
field.speakers: 关联用户
|
|
102
|
-
field.source: 来源
|
|
103
112
|
field.createdAt: 创建
|
|
104
113
|
field.updatedAt: 更新
|
|
105
114
|
field.content: 内容
|
package/client/page.tsx
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
useTranslate
|
|
31
31
|
} from '@chatluna/ui-client/client'
|
|
32
32
|
import type { Translate } from '@chatluna/ui-client/client'
|
|
33
|
+
import { useStored } from '@chatluna/ui-storage'
|
|
33
34
|
import { PresetActions } from './preset-actions.tsx'
|
|
34
35
|
import { SettingsPanel } from './settings-panel.tsx'
|
|
35
36
|
import { GuidePanel } from './guide-panel.tsx'
|
|
@@ -160,6 +161,7 @@ export function LivingMemoryPage() {
|
|
|
160
161
|
}} />
|
|
161
162
|
)}
|
|
162
163
|
<Warnings warnings={status.data?.warnings ?? []} />
|
|
164
|
+
<NativeMemoryNotice active={status.data?.nativeMemoryActive === true} />
|
|
163
165
|
<div ref={panel} className="flex min-h-0 min-w-0 flex-1 flex-col">
|
|
164
166
|
{renderPanel()}
|
|
165
167
|
<React.Activity mode={tab === 'settings' ? 'visible' : 'hidden'}>
|
|
@@ -170,6 +172,32 @@ export function LivingMemoryPage() {
|
|
|
170
172
|
)
|
|
171
173
|
}
|
|
172
174
|
|
|
175
|
+
function NativeMemoryNotice({ active }: { active: boolean }) {
|
|
176
|
+
const t = useT()
|
|
177
|
+
const [dismissed, setDismissed] = React.useState(false)
|
|
178
|
+
const [neverShow, setNeverShow] = useStored('livingmemory.hideNativeMemoryNotice', value => value === true)
|
|
179
|
+
if (!active || dismissed || neverShow) return null
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<Dialog open onOpenChange={open => { if (!open) setDismissed(true) }}>
|
|
183
|
+
<DialogContent showCloseButton={false} className="flex flex-col gap-0 p-0 sm:max-w-[31rem]">
|
|
184
|
+
<div className="px-5 pt-6 pb-5 sm:px-7 sm:pt-7 sm:pb-6">
|
|
185
|
+
<DialogTitle className="mb-3 text-xl leading-snug font-semibold text-balance">{t('nativeMemory.title')}</DialogTitle>
|
|
186
|
+
<DialogDescription className="text-sm leading-6 text-balance text-popover-foreground">
|
|
187
|
+
{t('nativeMemory.description')}
|
|
188
|
+
<span className="mt-1 block text-muted-foreground">{t('nativeMemory.risk')}</span>
|
|
189
|
+
</DialogDescription>
|
|
190
|
+
</div>
|
|
191
|
+
<div className="flex flex-col gap-2 border-t border-border bg-muted/30 px-5 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-7">
|
|
192
|
+
<Button size="lg" variant="ghost" onClick={() => setDismissed(true)}>{t('nativeMemory.close')}</Button>
|
|
193
|
+
<Button size="lg" className="bg-neutral-800 text-white hover:bg-neutral-700 active:bg-neutral-600 dark:bg-neutral-200 dark:text-neutral-900 dark:hover:bg-neutral-300 dark:active:bg-neutral-400"
|
|
194
|
+
onClick={() => setNeverShow(true)}>{t('nativeMemory.neverShow')}</Button>
|
|
195
|
+
</div>
|
|
196
|
+
</DialogContent>
|
|
197
|
+
</Dialog>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
173
201
|
function PresetPicker({
|
|
174
202
|
presets,
|
|
175
203
|
value,
|
|
@@ -450,20 +478,19 @@ function MemoryCard({ entry, names, selected, selecting, onSelect, onEdit, onArc
|
|
|
450
478
|
{entry.keywords.map(word => <li key={word} className="min-w-0 [overflow-wrap:anywhere]">#{word}</li>)}
|
|
451
479
|
</ul>
|
|
452
480
|
)}
|
|
453
|
-
<
|
|
454
|
-
<
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
</dl>
|
|
481
|
+
<div className="border-t border-border pt-2 text-xs leading-relaxed [overflow-wrap:anywhere]">
|
|
482
|
+
<dl className="grid grid-cols-[auto_1fr] items-baseline gap-x-3 gap-y-0.5">
|
|
483
|
+
<dt className="text-muted-foreground">{t('field.importance')}</dt>
|
|
484
|
+
<dd>{entry.importance ?? '—'}</dd>
|
|
485
|
+
{entry.sentiment && <>
|
|
486
|
+
<dt className="text-muted-foreground">{t('field.sentiment')}</dt>
|
|
487
|
+
<dd>{entry.sentiment}</dd>
|
|
488
|
+
</>}
|
|
489
|
+
<dt className="text-muted-foreground">{t('field.speakers')}</dt>
|
|
490
|
+
<dd>{speakers || t('entries.noSpeakers')}</dd>
|
|
491
|
+
</dl>
|
|
492
|
+
<p className="mt-0.5">{entry.sourceLabel}</p>
|
|
493
|
+
</div>
|
|
467
494
|
</div>
|
|
468
495
|
<footer className="row-start-4 flex flex-wrap items-center justify-between gap-2 rounded-b-xl border-t border-border bg-muted/30 px-3 py-1.5">
|
|
469
496
|
<span className="text-xs text-muted-foreground">{t('field.updatedAt')} {formatTime(entry.updatedAt)}</span>
|