@199-bio/engram 0.5.0 → 0.5.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidator.d.ts","sourceRoot":"","sources":["../../src/consolidation/consolidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAU,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"consolidator.d.ts","sourceRoot":"","sources":["../../src/consolidation/consolidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAU,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA8CxE,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,EAAE,CAAiB;gBAEf,EAAE,EAAE,cAAc;IAS9B,YAAY,IAAI,OAAO;IAIvB;;;OAGG;IACG,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC;QAC3D,cAAc,EAAE,MAAM,CAAC;QACvB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;IAwEF;;OAEG;YACW,gBAAgB;IAoE9B;;OAEG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAuHjE;;OAEG;IACH,SAAS,IAAI;QACX,UAAU,EAAE,OAAO,CAAC;QACpB,sBAAsB,EAAE,MAAM,CAAC;QAC/B,YAAY,EAAE,MAAM,CAAC;QACrB,wBAAwB,EAAE,MAAM,CAAC;KAClC;CAYF"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -14,30 +14,40 @@
|
|
|
14
14
|
import Anthropic from "@anthropic-ai/sdk";
|
|
15
15
|
import { EngramDatabase, Memory, Digest } from "../storage/database.js";
|
|
16
16
|
|
|
17
|
-
const CONSOLIDATION_SYSTEM = `You are a memory consolidation system. Your
|
|
17
|
+
const CONSOLIDATION_SYSTEM = `You are a high-quality memory consolidation system for a personal AI assistant. Your goal is to create comprehensive, nuanced digests that preserve the richness of human experience and relationships.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Your Tasks
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
1. **CONSOLIDATE**: Synthesize memories into a detailed digest that:
|
|
22
|
+
- Preserves ALL specific facts: names, dates, numbers, locations, preferences
|
|
23
|
+
- Captures relationships, emotions, context, and nuance
|
|
24
|
+
- Maintains chronological awareness (what happened when)
|
|
25
|
+
- Notes patterns, recurring themes, and changes over time
|
|
26
|
+
- Includes direct quotes when they reveal personality or important details
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
2. **DETECT CONTRADICTIONS**: Flag genuinely conflicting information:
|
|
29
|
+
- Different dates/times for the same event
|
|
30
|
+
- Conflicting facts about the same person/thing
|
|
31
|
+
- Changed preferences or circumstances (note if this might be natural evolution vs. error)
|
|
32
|
+
|
|
33
|
+
## Output Format (JSON)
|
|
24
34
|
{
|
|
25
|
-
"digest": "
|
|
26
|
-
"topic": "
|
|
35
|
+
"digest": "Comprehensive summary preserving all important details, context, and nuance. Multiple paragraphs are fine for complex topics.",
|
|
36
|
+
"topic": "Short topic label (2-5 words)",
|
|
27
37
|
"contradictions": [
|
|
28
38
|
{
|
|
29
|
-
"description": "
|
|
39
|
+
"description": "Precise description of the conflict",
|
|
30
40
|
"memory_ids": ["id1", "id2"]
|
|
31
41
|
}
|
|
32
42
|
]
|
|
33
43
|
}
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
45
|
+
## Quality Standards
|
|
46
|
+
- NEVER sacrifice important details for brevity
|
|
47
|
+
- Include temporal context (when things happened/changed)
|
|
48
|
+
- Preserve personality, preferences, and relationship dynamics
|
|
49
|
+
- If memories span different time periods, note the evolution
|
|
50
|
+
- Only flag true contradictions, not incomplete information or natural life changes`;
|
|
41
51
|
|
|
42
52
|
interface ConsolidationResult {
|
|
43
53
|
digest: string;
|
|
@@ -166,20 +176,28 @@ export class Consolidator {
|
|
|
166
176
|
)
|
|
167
177
|
.join("\n\n");
|
|
168
178
|
|
|
169
|
-
const userPrompt = `
|
|
179
|
+
const userPrompt = `Synthesize these ${memories.length} memories into a comprehensive digest.
|
|
180
|
+
|
|
181
|
+
Think deeply about:
|
|
182
|
+
- What are the key facts, events, and details?
|
|
183
|
+
- Who are the people involved and how do they relate?
|
|
184
|
+
- What preferences, opinions, or patterns emerge?
|
|
185
|
+
- Is there a chronological narrative or timeline?
|
|
186
|
+
- Are there any contradictions between memories?
|
|
170
187
|
|
|
171
188
|
MEMORIES:
|
|
172
189
|
${memoriesText}
|
|
173
190
|
|
|
174
|
-
Respond with JSON only.`;
|
|
191
|
+
Create a detailed digest that preserves all important information. Respond with JSON only.`;
|
|
175
192
|
|
|
176
193
|
try {
|
|
177
194
|
const response = await this.client.messages.create({
|
|
178
195
|
model: "claude-opus-4-5-20251101",
|
|
179
196
|
max_tokens: 16000,
|
|
197
|
+
temperature: 1, // Required for extended thinking
|
|
180
198
|
thinking: {
|
|
181
199
|
type: "enabled",
|
|
182
|
-
budget_tokens:
|
|
200
|
+
budget_tokens: 10000, // High budget for thorough analysis
|
|
183
201
|
},
|
|
184
202
|
messages: [
|
|
185
203
|
{
|
|
@@ -246,20 +264,29 @@ Respond with JSON only.`;
|
|
|
246
264
|
)
|
|
247
265
|
.join("\n\n");
|
|
248
266
|
|
|
249
|
-
const userPrompt = `Create a comprehensive profile for
|
|
267
|
+
const userPrompt = `Create a comprehensive, detailed profile for "${entity.name}" (${entity.type}).
|
|
268
|
+
|
|
269
|
+
This profile will serve as the authoritative reference for everything known about this ${entity.type}. Include:
|
|
270
|
+
- All biographical/descriptive facts
|
|
271
|
+
- Relationships with other people/entities
|
|
272
|
+
- Preferences, opinions, personality traits
|
|
273
|
+
- Timeline of events and changes over time
|
|
274
|
+
- Notable quotes or characteristic expressions
|
|
275
|
+
- Any context that helps understand this ${entity.type}
|
|
250
276
|
|
|
251
277
|
MEMORIES ABOUT ${entity.name}:
|
|
252
278
|
${memoriesText}
|
|
253
279
|
|
|
254
|
-
Respond with JSON only.`;
|
|
280
|
+
Create a rich, detailed profile. Do not summarize away important nuances. Respond with JSON only.`;
|
|
255
281
|
|
|
256
282
|
try {
|
|
257
283
|
const response = await this.client.messages.create({
|
|
258
284
|
model: "claude-opus-4-5-20251101",
|
|
259
285
|
max_tokens: 16000,
|
|
286
|
+
temperature: 1, // Required for extended thinking
|
|
260
287
|
thinking: {
|
|
261
288
|
type: "enabled",
|
|
262
|
-
budget_tokens:
|
|
289
|
+
budget_tokens: 16000, // Maximum thinking for entity profiles
|
|
263
290
|
},
|
|
264
291
|
messages: [
|
|
265
292
|
{
|