@elizaos/plugin-knowledge 1.5.10 → 1.5.12
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 +111 -10
- package/dist/.vite/manifest.json +2 -2
- package/dist/assets/index-DtOcbZ9V.js +169 -0
- package/dist/assets/index-crC0VS8M.css +1 -0
- package/dist/index.d.ts +204 -3
- package/dist/index.html +2 -2
- package/dist/index.js +332 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/assets/index-B5VEkqpw.css +0 -1
- package/dist/assets/index-C_sAxTPC.js +0 -169
package/README.md
CHANGED
|
@@ -2,6 +2,67 @@
|
|
|
2
2
|
|
|
3
3
|
Give your AI agent the ability to learn from documents and answer questions based on that knowledge. Works out of the box with zero configuration!
|
|
4
4
|
|
|
5
|
+
## 📦 Installation Modes
|
|
6
|
+
|
|
7
|
+
The Knowledge plugin supports multiple deployment modes to fit your use case:
|
|
8
|
+
|
|
9
|
+
### **Full Mode** (Default - With UI & Routes)
|
|
10
|
+
|
|
11
|
+
Perfect for standard deployments with the full web interface:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { knowledgePlugin } from '@elizaos/plugin-knowledge';
|
|
15
|
+
// or
|
|
16
|
+
import knowledgePlugin from '@elizaos/plugin-knowledge';
|
|
17
|
+
|
|
18
|
+
export const character = {
|
|
19
|
+
plugins: [knowledgePlugin],
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### **Headless Mode** (Service + Provider + Actions, No UI)
|
|
24
|
+
|
|
25
|
+
For server deployments without frontend:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { knowledgePluginHeadless } from '@elizaos/plugin-knowledge';
|
|
29
|
+
|
|
30
|
+
export const character = {
|
|
31
|
+
plugins: [knowledgePluginHeadless],
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### **Core Mode** (Service + Provider Only)
|
|
36
|
+
|
|
37
|
+
For cloud runtimes or minimal deployments (no routes, no UI, no actions):
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { knowledgePluginCore } from '@elizaos/plugin-knowledge';
|
|
41
|
+
|
|
42
|
+
export const character = {
|
|
43
|
+
plugins: [knowledgePluginCore],
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### **Custom Configuration**
|
|
48
|
+
|
|
49
|
+
Create your own configuration:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { createKnowledgePlugin } from '@elizaos/plugin-knowledge';
|
|
53
|
+
|
|
54
|
+
const customPlugin = createKnowledgePlugin({
|
|
55
|
+
enableUI: false, // Disable frontend UI
|
|
56
|
+
enableRoutes: false, // Disable HTTP routes
|
|
57
|
+
enableActions: true, // Keep actions enabled
|
|
58
|
+
enableTests: false, // Disable tests
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const character = {
|
|
62
|
+
plugins: [customPlugin],
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
5
66
|
## 🚀 Getting Started (Beginner-Friendly)
|
|
6
67
|
|
|
7
68
|
### Step 1: Add the Plugin
|
|
@@ -14,7 +75,7 @@ export const character = {
|
|
|
14
75
|
name: 'MyAgent',
|
|
15
76
|
plugins: [
|
|
16
77
|
'@elizaos/plugin-openai', // ← Make sure you have this
|
|
17
|
-
'@elizaos/plugin-knowledge', // ← Add this line
|
|
78
|
+
'@elizaos/plugin-knowledge', // ← Add this line (full mode)
|
|
18
79
|
// ... your other plugins
|
|
19
80
|
],
|
|
20
81
|
// ... rest of your character config
|
|
@@ -192,28 +253,68 @@ MAX_OUTPUT_TOKENS=4096 # Response size limit
|
|
|
192
253
|
```typescript
|
|
193
254
|
import { KnowledgeService } from '@elizaos/plugin-knowledge';
|
|
194
255
|
|
|
256
|
+
// Get the service from runtime
|
|
257
|
+
const knowledgeService = runtime.getService<KnowledgeService>(KnowledgeService.serviceType);
|
|
258
|
+
|
|
195
259
|
// Add knowledge programmatically
|
|
196
260
|
const result = await knowledgeService.addKnowledge({
|
|
197
|
-
|
|
261
|
+
agentId: runtime.agentId,
|
|
262
|
+
clientDocumentId: '' as UUID, // Auto-generated based on content
|
|
198
263
|
content: documentContent, // Base64 for PDFs, plain text for others
|
|
199
264
|
contentType: 'application/pdf',
|
|
200
265
|
originalFilename: 'document.pdf',
|
|
201
|
-
worldId: runtime.
|
|
202
|
-
roomId: runtime.
|
|
203
|
-
entityId: runtime.
|
|
266
|
+
worldId: runtime.agentId,
|
|
267
|
+
roomId: runtime.agentId,
|
|
268
|
+
entityId: runtime.agentId,
|
|
204
269
|
metadata: {
|
|
205
|
-
// Optional
|
|
270
|
+
// Optional custom metadata
|
|
206
271
|
source: 'upload',
|
|
207
272
|
author: 'John Doe',
|
|
208
273
|
},
|
|
209
274
|
});
|
|
210
275
|
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
276
|
+
// The provider automatically retrieves relevant knowledge during conversations
|
|
277
|
+
// But you can also search directly:
|
|
278
|
+
const knowledgeItems = await knowledgeService.getKnowledge(
|
|
279
|
+
message, // The message/query
|
|
280
|
+
{
|
|
281
|
+
roomId: runtime.agentId,
|
|
282
|
+
worldId: runtime.agentId,
|
|
283
|
+
entityId: runtime.agentId,
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Cloud/Custom Runtime Usage
|
|
289
|
+
|
|
290
|
+
For cloud deployments or custom runtimes, use the core mode and access the service directly:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
import { knowledgePluginCore, KnowledgeService } from '@elizaos/plugin-knowledge';
|
|
294
|
+
|
|
295
|
+
// In your cloud runtime setup
|
|
296
|
+
const runtime = await createRuntime({
|
|
297
|
+
// ... your runtime config
|
|
298
|
+
plugins: [knowledgePluginCore], // Core mode: no routes, no UI
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// Access the service
|
|
302
|
+
const knowledgeService = runtime.getService<KnowledgeService>(KnowledgeService.serviceType);
|
|
303
|
+
|
|
304
|
+
// Add documents
|
|
305
|
+
await knowledgeService.addKnowledge({
|
|
214
306
|
agentId: runtime.agentId,
|
|
215
|
-
|
|
307
|
+
clientDocumentId: '' as UUID,
|
|
308
|
+
content: base64Content,
|
|
309
|
+
contentType: 'application/pdf',
|
|
310
|
+
originalFilename: 'company-docs.pdf',
|
|
311
|
+
worldId: runtime.agentId,
|
|
312
|
+
roomId: runtime.agentId,
|
|
313
|
+
entityId: runtime.agentId,
|
|
216
314
|
});
|
|
315
|
+
|
|
316
|
+
// The knowledge provider will automatically inject relevant context
|
|
317
|
+
// into the agent's conversations based on the query
|
|
217
318
|
```
|
|
218
319
|
|
|
219
320
|
</details>
|
package/dist/.vite/manifest.json
CHANGED