feat(memory): add operator retrieval plugin (#736)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/publish Pipeline was successful

This commit was merged in pull request #736.
This commit is contained in:
2026-07-13 12:44:31 +00:00
parent 76325ca3f2
commit 2363f155b4
8 changed files with 380 additions and 6 deletions

View File

@@ -132,19 +132,23 @@ export class KeywordAdapter implements MemoryAdapter {
opts?: { limit?: number; embedding?: number[] },
): Promise<InsightSearchResult[]> {
const limit = opts?.limit ?? 10;
const words = query
.toLowerCase()
.split(/\s+/)
.filter((w) => w.length > 0);
const normalizedQuery = query.trim();
const matchAll = normalizedQuery === '*';
const words = matchAll
? []
: normalizedQuery
.toLowerCase()
.split(/\s+/)
.filter((word) => word.length > 0);
if (words.length === 0) return [];
if (words.length === 0 && !matchAll) return [];
const rows = await this.storage.find<InsightRecord>(INSIGHTS, { userId });
const scored: InsightSearchResult[] = [];
for (const row of rows) {
const content = row.content.toLowerCase();
let score = 0;
let score = matchAll ? 1 : 0;
for (const word of words) {
if (content.includes(word)) score++;
}