@tpsdev-ai/flair-client 0.4.1 → 0.4.3
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/dist/client.d.ts +2 -1
- package/dist/client.js +6 -4
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -45,13 +45,14 @@ declare class MemoryApi {
|
|
|
45
45
|
* is found (score >= threshold), returns it instead of creating a new one.
|
|
46
46
|
* Default: false (no dedup check). */
|
|
47
47
|
dedup?: boolean;
|
|
48
|
-
/** Similarity threshold for dedup. Default: 0.
|
|
48
|
+
/** Similarity threshold for dedup. Default: 0.95 */
|
|
49
49
|
dedupThreshold?: number;
|
|
50
50
|
}): Promise<Memory>;
|
|
51
51
|
/** Search memories by meaning. */
|
|
52
52
|
search(query: string, opts?: {
|
|
53
53
|
limit?: number;
|
|
54
54
|
minScore?: number;
|
|
55
|
+
scoring?: "composite" | "raw";
|
|
55
56
|
}): Promise<SearchResult[]>;
|
|
56
57
|
/** Get a memory by ID. */
|
|
57
58
|
get(id: string): Promise<Memory | null>;
|
package/dist/client.js
CHANGED
|
@@ -92,8 +92,10 @@ class MemoryApi {
|
|
|
92
92
|
// Near-duplicate check — skip for very short content where similarity
|
|
93
93
|
// is unreliable (e.g., "ok", "thanks" would match each other)
|
|
94
94
|
if (opts.dedup && content.length >= 20) {
|
|
95
|
-
const threshold = opts.dedupThreshold ?? 0.
|
|
96
|
-
|
|
95
|
+
const threshold = opts.dedupThreshold ?? 0.95;
|
|
96
|
+
// Use raw scoring to avoid retrieval-boost feedback loop where repeated
|
|
97
|
+
// dedup checks inflate scores above the threshold.
|
|
98
|
+
const existing = await this.search(content, { limit: 1, minScore: threshold, scoring: "raw" });
|
|
97
99
|
if (existing.length > 0) {
|
|
98
100
|
// Return the existing memory instead of creating a duplicate
|
|
99
101
|
const match = await this.get(existing[0].id);
|
|
@@ -101,7 +103,7 @@ class MemoryApi {
|
|
|
101
103
|
return match;
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
|
-
const id = opts.id ?? `${this.client.agentId}-${
|
|
106
|
+
const id = opts.id ?? `${this.client.agentId}-${crypto.randomUUID()}`;
|
|
105
107
|
const record = {
|
|
106
108
|
id,
|
|
107
109
|
agentId: this.client.agentId,
|
|
@@ -118,7 +120,7 @@ class MemoryApi {
|
|
|
118
120
|
}
|
|
119
121
|
/** Search memories by meaning. */
|
|
120
122
|
async search(query, opts = {}) {
|
|
121
|
-
const result = await this.client.request("POST", "/SemanticSearch", { agentId: this.client.agentId, q: query, limit: opts.limit ?? 5 });
|
|
123
|
+
const result = await this.client.request("POST", "/SemanticSearch", { agentId: this.client.agentId, q: query, limit: opts.limit ?? 5, scoring: opts.scoring });
|
|
122
124
|
const minScore = opts.minScore ?? 0;
|
|
123
125
|
return (result.results ?? [])
|
|
124
126
|
.map((r) => ({
|
package/package.json
CHANGED