@cogitator-ai/memory 0.4.1 → 0.4.2
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.
|
@@ -207,6 +207,7 @@ export declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
207
207
|
text: z.ZodString;
|
|
208
208
|
timestamp: z.ZodDate;
|
|
209
209
|
}, "strip", z.ZodTypeAny, {
|
|
210
|
+
text: string;
|
|
210
211
|
entities: {
|
|
211
212
|
confidence: number;
|
|
212
213
|
type: "object" | "custom" | "person" | "organization" | "location" | "concept" | "event";
|
|
@@ -225,9 +226,9 @@ export declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
225
226
|
weight?: number | undefined;
|
|
226
227
|
bidirectional?: boolean | undefined;
|
|
227
228
|
}[];
|
|
228
|
-
text: string;
|
|
229
229
|
timestamp: Date;
|
|
230
230
|
}, {
|
|
231
|
+
text: string;
|
|
231
232
|
entities: {
|
|
232
233
|
confidence: number;
|
|
233
234
|
type: "object" | "custom" | "person" | "organization" | "location" | "concept" | "event";
|
|
@@ -246,7 +247,6 @@ export declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
246
247
|
weight?: number | undefined;
|
|
247
248
|
bidirectional?: boolean | undefined;
|
|
248
249
|
}[];
|
|
249
|
-
text: string;
|
|
250
250
|
timestamp: Date;
|
|
251
251
|
}>;
|
|
252
252
|
export declare const NodeQuerySchema: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-counter.d.ts","sourceRoot":"","sources":["../src/token-counter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhD;
|
|
1
|
+
{"version":3,"file":"token-counter.d.ts","sourceRoot":"","sources":["../src/token-counter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhD;AAeD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAE/D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAQxE"}
|
package/dist/token-counter.js
CHANGED
|
@@ -14,11 +14,23 @@ export function countTokens(text) {
|
|
|
14
14
|
return 0;
|
|
15
15
|
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Extract text content from a message
|
|
19
|
+
*/
|
|
20
|
+
function getTextContent(content) {
|
|
21
|
+
if (typeof content === 'string') {
|
|
22
|
+
return content;
|
|
23
|
+
}
|
|
24
|
+
return content
|
|
25
|
+
.filter((part) => part.type === 'text')
|
|
26
|
+
.map((part) => part.text)
|
|
27
|
+
.join(' ');
|
|
28
|
+
}
|
|
17
29
|
/**
|
|
18
30
|
* Estimate token count for a message (includes overhead)
|
|
19
31
|
*/
|
|
20
32
|
export function countMessageTokens(message) {
|
|
21
|
-
return countTokens(message.content) + MESSAGE_OVERHEAD;
|
|
33
|
+
return countTokens(getTextContent(message.content)) + MESSAGE_OVERHEAD;
|
|
22
34
|
}
|
|
23
35
|
/**
|
|
24
36
|
* Estimate token count for an array of messages
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-counter.js","sourceRoot":"","sources":["../src/token-counter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,gBAAgB,GAAG,CAAC,CAAC;A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AAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,SAAiB;IAC9D,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,SAAS,GAAG,eAAe,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogitator-ai/memory",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Memory adapters for Cogitator AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"@types/pg": "^8.10.9",
|
|
20
20
|
"nanoid": "^5.0.4",
|
|
21
21
|
"zod": "^3.22.4",
|
|
22
|
-
"@cogitator-ai/
|
|
23
|
-
"@cogitator-ai/
|
|
22
|
+
"@cogitator-ai/redis": "0.2.5",
|
|
23
|
+
"@cogitator-ai/types": "0.8.0"
|
|
24
24
|
},
|
|
25
25
|
"optionalDependencies": {
|
|
26
26
|
"ioredis": "^5.3.2",
|