You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(knowledge-base): implement shared-table mode for knowledge bases
- Introduced shared-table mode allowing multiple knowledge bases to share the same underlying storage tables, reducing table proliferation.
- Added `ScopedTabularStorage` and `ScopedVectorStorage` wrappers to manage data access scoped by `kb_id`.
- Updated registration process to support shared table names and added utility functions for schema management.
- Enhanced documentation to include new shared-table mode features and usage examples.
awaittask.run({ knowledgeBase: "my-kb" }); // Resolved from registry
443
452
```
444
453
454
+
## Shared-Table Mode
455
+
456
+
### Overview
457
+
458
+
By default, each `KnowledgeBase` gets its own document table and chunk table. **Shared-table mode** lets multiple knowledge bases share the same underlying storage tables, partitioned by a `kb_id` column. This is useful when you have many knowledge bases and want to reduce table proliferation in your database.
The `KnowledgeBase` class itself is unchanged — shared-table mode is implemented via thin wrapper classes (`ScopedTabularStorage`, `ScopedVectorStorage`) that inject `kb_id` on writes and filter by `kb_id` on reads.
478
+
479
+
### Setting Up Shared Storage
480
+
481
+
Create the shared storage instances once, globally:
For SQL backends (SQLite, PostgreSQL), replace `InMemoryTabularStorage` / `InMemoryVectorStorage` with the appropriate implementations. The shared schemas include indexes on `kb_id` and `[kb_id, doc_id]` for efficient scoped queries.
511
+
512
+
### Scoped Wrappers
513
+
514
+
For each knowledge base, create scoped wrappers that filter to that KB's data:
Each `KnowledgeBase` instance works exactly the same as in default mode — all CRUD, search, and lifecycle operations are transparently scoped to the KB's data.
535
+
536
+
### Registering with Shared Tables
537
+
538
+
Pass `{ sharedTables: true }` when registering so that the metadata record uses the shared table names:
0 commit comments