Skip to content

Commit 54cd62d

Browse files
zerone0xclaude
andcommitted
fix(memos-local-openclaw): use limit and minScore query params in Viewer search API
Read limit and minScore from query params instead of ignoring them. Use minScore as the semantic threshold instead of hardcoded 0.64. Truncate results by limit and include both params in the response. Fixes #1372 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 27c9e71 commit 54cd62d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • apps/memos-local-openclaw/src/viewer

apps/memos-local-openclaw/src/viewer/server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,9 @@ export class ViewerServer {
770770
const q = url.searchParams.get("q") ?? "";
771771
if (!q.trim()) { this.jsonResponse(res, { results: [], query: q }); return; }
772772

773+
const limit = Math.min(100, Math.max(1, Number(url.searchParams.get("limit")) || 20));
774+
const minScore = Math.max(0.35, Math.min(1, Number(url.searchParams.get("minScore")) || 0.64));
775+
773776
const role = url.searchParams.get("role") ?? undefined;
774777
const session = url.searchParams.get("session") ?? undefined;
775778
const owner = url.searchParams.get("owner") ?? undefined;
@@ -810,7 +813,7 @@ export class ViewerServer {
810813
}
811814
}
812815

813-
const SEMANTIC_THRESHOLD = 0.64;
816+
const SEMANTIC_THRESHOLD = minScore;
814817
const VECTOR_TIMEOUT_MS = 8000;
815818
let vectorResults: any[] = [];
816819
let scoreMap = new Map<string, number>();
@@ -849,7 +852,7 @@ export class ViewerServer {
849852
if (!seenIds.has(r.id)) { seenIds.add(r.id); merged.push(r); }
850853
}
851854

852-
const results = merged.length > 0 ? merged : ftsResults.slice(0, 20);
855+
const results = (merged.length > 0 ? merged : ftsResults.slice(0, limit)).slice(0, limit);
853856

854857
this.store.recordViewerEvent("search");
855858
this.jsonResponse(res, {
@@ -858,6 +861,8 @@ export class ViewerServer {
858861
vectorCount: vectorResults.length,
859862
ftsCount: ftsResults.length,
860863
total: results.length,
864+
limit,
865+
minScore,
861866
});
862867
}
863868

0 commit comments

Comments
 (0)