@agenttool/sdk 0.2.5 → 0.2.7
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 +9 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,17 +43,13 @@ import { AgentTool } from "@agenttool/sdk";
|
|
|
43
43
|
const at = new AgentTool(); // reads AT_API_KEY from env
|
|
44
44
|
|
|
45
45
|
// Store a memory
|
|
46
|
-
const memory = await at.memory.store(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
46
|
+
const memory = await at.memory.store(
|
|
47
|
+
"The user prefers dark mode and concise responses",
|
|
48
|
+
{ agent_id: "my-assistant", key: "preferences" }
|
|
49
|
+
);
|
|
51
50
|
|
|
52
51
|
// Retrieve it later (semantic search)
|
|
53
|
-
const results = await at.memory.search({
|
|
54
|
-
query: "what does the user prefer?",
|
|
55
|
-
limit: 5,
|
|
56
|
-
});
|
|
52
|
+
const results = await at.memory.search("what does the user prefer?", { limit: 5 });
|
|
57
53
|
|
|
58
54
|
for (const r of results) {
|
|
59
55
|
console.log(`${r.score.toFixed(2)} ${r.content}`);
|
|
@@ -68,10 +64,10 @@ for (const r of results) {
|
|
|
68
64
|
const at = new AgentTool({ apiKey: "at_..." }); // or use AT_API_KEY env var
|
|
69
65
|
|
|
70
66
|
// Store
|
|
71
|
-
const mem = await at.memory.store(
|
|
67
|
+
const mem = await at.memory.store("User is in London, timezone Europe/London");
|
|
72
68
|
|
|
73
69
|
// Semantic search
|
|
74
|
-
const results = await at.memory.search(
|
|
70
|
+
const results = await at.memory.search("where is the user?", { limit: 5 });
|
|
75
71
|
|
|
76
72
|
// Retrieve by ID
|
|
77
73
|
const mem = await at.memory.get("mem_abc123");
|
|
@@ -189,7 +185,7 @@ const tools = {
|
|
|
189
185
|
description: "Store a memory for later retrieval",
|
|
190
186
|
parameters: z.object({ content: z.string() }),
|
|
191
187
|
execute: async ({ content }) => {
|
|
192
|
-
const mem = await at.memory.store(
|
|
188
|
+
const mem = await at.memory.store(content, { agent_id: "my-agent" });
|
|
193
189
|
return `Stored memory ${mem.id}`;
|
|
194
190
|
},
|
|
195
191
|
}),
|
|
@@ -197,7 +193,7 @@ const tools = {
|
|
|
197
193
|
description: "Search past memories by semantic similarity",
|
|
198
194
|
parameters: z.object({ query: z.string() }),
|
|
199
195
|
execute: async ({ query }) => {
|
|
200
|
-
const results = await at.memory.search(
|
|
196
|
+
const results = await at.memory.search(query, { limit: 3 });
|
|
201
197
|
return results.map((r) => r.content).join("\n");
|
|
202
198
|
},
|
|
203
199
|
}),
|