-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.mjs
More file actions
42 lines (38 loc) · 995 Bytes
/
Copy pathindex.mjs
File metadata and controls
42 lines (38 loc) · 995 Bytes
1
2
3
4
5
6
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
40
41
42
import { pack } from "@context-engineering/core";
import { InMemoryStore } from "@context-engineering/memory";
import { OpenAIProvider } from "@context-engineering/providers";
const items = [
{
id: "system",
content: "You are a helpful assistant.",
priority: 10,
tokens: 12,
},
{
id: "policy",
content: "Always cite sources when available.",
priority: 6,
tokens: 10,
},
{
id: "notes",
content: "User prefers concise answers.",
priority: 4,
tokens: 8,
},
];
const packResult = pack(items, { maxTokens: 24 });
console.log("Pack result", packResult);
const memory = new InMemoryStore();
await memory.put({
id: "m1",
content: "Project uses PNPM",
createdAt: new Date().toISOString(),
});
console.log("Memory query", await memory.query());
try {
const provider = new OpenAIProvider();
console.log("Provider ready", provider ? "yes" : "no");
} catch {
console.log("Skipping LLM generation (set OPENAI_API_KEY to enable)");
}