@mcp-abap-adt/qdrant-rag 26.0.0 → 28.0.0
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 +22 -0
- package/dist/__tests__/catalog.test.d.ts +2 -0
- package/dist/__tests__/catalog.test.d.ts.map +1 -0
- package/dist/__tests__/catalog.test.js +241 -0
- package/dist/__tests__/catalog.test.js.map +1 -0
- package/dist/__tests__/credential.test.d.ts +2 -0
- package/dist/__tests__/credential.test.d.ts.map +1 -0
- package/dist/__tests__/credential.test.js +93 -0
- package/dist/__tests__/credential.test.js.map +1 -0
- package/dist/__tests__/qdrant-stub.d.ts +52 -0
- package/dist/__tests__/qdrant-stub.d.ts.map +1 -0
- package/dist/__tests__/qdrant-stub.js +206 -0
- package/dist/__tests__/qdrant-stub.js.map +1 -0
- package/dist/__tests__/rag-filter-conformance.test.d.ts +2 -0
- package/dist/__tests__/rag-filter-conformance.test.d.ts.map +1 -0
- package/dist/__tests__/rag-filter-conformance.test.js +25 -0
- package/dist/__tests__/rag-filter-conformance.test.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/qdrant-rag-provider.d.ts +41 -11
- package/dist/qdrant-rag-provider.d.ts.map +1 -1
- package/dist/qdrant-rag-provider.js +296 -29
- package/dist/qdrant-rag-provider.js.map +1 -1
- package/dist/qdrant-rag-provider.test.js +0 -11
- package/dist/qdrant-rag-provider.test.js.map +1 -1
- package/dist/qdrant-rag.d.ts +23 -2
- package/dist/qdrant-rag.d.ts.map +1 -1
- package/dist/qdrant-rag.js +45 -19
- package/dist/qdrant-rag.js.map +1 -1
- package/dist/qdrant-rag.test.js +51 -3
- package/dist/qdrant-rag.test.js.map +1 -1
- package/package.json +5 -4
|
@@ -1,50 +1,168 @@
|
|
|
1
|
-
import { AbstractRagProvider as BaseRagProvider, RagError, } from '@mcp-abap-adt/llm-agent';
|
|
2
|
-
import { QdrantRag } from './qdrant-rag.js';
|
|
1
|
+
import { AbstractRagProvider as BaseRagProvider, CatalogRecordDeleteError, DuplicateCollectionError, describeRagCatalogRows, encodeRagAttributes, OrphanStoreError, RagError, ragOwnerKeys, validateRagOwner, } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { deterministicUUID, QdrantRag } from './qdrant-rag.js';
|
|
3
|
+
/** The collection a QdrantRagProvider keeps one point per collection in, by default. */
|
|
4
|
+
export const DEFAULT_CATALOG_COLLECTION = 'rag_collection_catalog';
|
|
5
|
+
/** Embedded once per collection created, to learn the size Qdrant fixes at creation. */
|
|
6
|
+
const DIMENSION_PROBE = 'dimension probe';
|
|
7
|
+
const SCROLL_PAGE = 256;
|
|
3
8
|
export class QdrantRagProvider extends BaseRagProvider {
|
|
4
9
|
name;
|
|
5
10
|
kind = 'vector';
|
|
6
11
|
editable;
|
|
7
12
|
supportedScopes;
|
|
8
13
|
url;
|
|
9
|
-
|
|
14
|
+
credential;
|
|
10
15
|
embedder;
|
|
11
16
|
timeoutMs;
|
|
17
|
+
catalog;
|
|
18
|
+
catalogReady;
|
|
12
19
|
constructor(cfg) {
|
|
13
20
|
super();
|
|
14
21
|
this.name = cfg.name;
|
|
15
22
|
this.url = cfg.url.replace(/\/+$/, '');
|
|
16
|
-
this.
|
|
23
|
+
this.credential = cfg.credential;
|
|
17
24
|
this.embedder = cfg.embedder;
|
|
18
25
|
this.timeoutMs = cfg.timeoutMs;
|
|
19
26
|
this.editable = cfg.editable ?? true;
|
|
20
27
|
this.supportedScopes = cfg.supportedScopes ?? ['session', 'user', 'global'];
|
|
28
|
+
this.catalog = cfg.catalogCollection ?? DEFAULT_CATALOG_COLLECTION;
|
|
21
29
|
if (cfg.idStrategyFactory)
|
|
22
30
|
this.idStrategyFactory = cfg.idStrategyFactory;
|
|
23
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates the collection — sized by one probe embedding — with a request that
|
|
34
|
+
* fails if it exists, then commits the creation by writing the record last,
|
|
35
|
+
* create-if-absent (§6.3).
|
|
36
|
+
*/
|
|
24
37
|
async createCollection(name, opts) {
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
return
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const checked = this.checkCreateOptions(opts);
|
|
39
|
+
if (!checked.ok)
|
|
40
|
+
return checked;
|
|
41
|
+
const refused = this.refuseCatalogName(name);
|
|
42
|
+
if (refused)
|
|
43
|
+
return refused;
|
|
44
|
+
try {
|
|
45
|
+
await this.ensureCatalog();
|
|
46
|
+
if (await this.readRecord(name))
|
|
47
|
+
return this.duplicate(name, opts);
|
|
48
|
+
if (opts.adoptExisting === true) {
|
|
49
|
+
if (!(await this.collectionExists(name))) {
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
error: new RagError(`Qdrant collection '${name}' does not exist; adoptExisting takes over an existing store and creates nothing`, 'RAG_CREATE_ERROR'),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const created = await this.createStore(name, opts);
|
|
58
|
+
if (!created.ok)
|
|
59
|
+
return created;
|
|
60
|
+
}
|
|
61
|
+
const recorded = await this.writeRecord({
|
|
62
|
+
...checked.value,
|
|
63
|
+
storeName: name,
|
|
64
|
+
name: opts.collectionName ?? name,
|
|
65
|
+
attributes: opts.attributes,
|
|
66
|
+
}, opts);
|
|
67
|
+
if (!recorded.ok)
|
|
68
|
+
return recorded;
|
|
69
|
+
return { ok: true, value: this.handles(name, checked.value) };
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
error: err instanceof RagError
|
|
75
|
+
? err
|
|
76
|
+
: new RagError(String(err), 'RAG_CREATE_ERROR'),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** The catalog, paged and read back through the shared row check. Creates nothing. */
|
|
81
|
+
async describeCollections() {
|
|
82
|
+
try {
|
|
83
|
+
if (!(await this.collectionExists(this.catalog))) {
|
|
84
|
+
return { ok: true, value: { records: [], rejected: [] } };
|
|
85
|
+
}
|
|
86
|
+
const rows = [];
|
|
87
|
+
let offset = null;
|
|
88
|
+
do {
|
|
89
|
+
const res = await this.request(`/collections/${this.catalog}/points/scroll`, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
body: JSON.stringify({
|
|
92
|
+
limit: SCROLL_PAGE,
|
|
93
|
+
with_payload: true,
|
|
94
|
+
with_vector: false,
|
|
95
|
+
...(offset === null ? {} : { offset }),
|
|
96
|
+
}),
|
|
97
|
+
});
|
|
98
|
+
if (!res.ok) {
|
|
99
|
+
throw new RagError(`Qdrant catalog scroll failed: HTTP ${res.status} ${await res.text()}`, 'RAG_LIST_ERROR');
|
|
100
|
+
}
|
|
101
|
+
const json = (await res.json());
|
|
102
|
+
for (const point of json.result?.points ?? []) {
|
|
103
|
+
const p = point.payload ?? {};
|
|
104
|
+
rows.push({
|
|
105
|
+
storeName: p.store_name,
|
|
106
|
+
name: p.collection_name,
|
|
107
|
+
scope: p.scope,
|
|
108
|
+
userId: p.user_id,
|
|
109
|
+
sessionId: p.session_id,
|
|
110
|
+
attributesJson: p.attributes_json,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
offset = json.result?.next_page_offset ?? null;
|
|
114
|
+
} while (offset !== null);
|
|
115
|
+
return { ok: true, value: describeRagCatalogRows(rows) };
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
return {
|
|
119
|
+
ok: false,
|
|
120
|
+
error: err instanceof RagError
|
|
121
|
+
? err
|
|
122
|
+
: new RagError(String(err), 'RAG_LIST_ERROR'),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
37
125
|
}
|
|
126
|
+
/** Handles for a collection that exists. Issues no request, and the handles never create. */
|
|
127
|
+
async openCollection(record) {
|
|
128
|
+
const owner = validateRagOwner(record);
|
|
129
|
+
if (!owner.ok)
|
|
130
|
+
return owner;
|
|
131
|
+
try {
|
|
132
|
+
return { ok: true, value: this.handles(record.storeName, owner.value) };
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
return { ok: false, error: new RagError(String(err), 'RAG_OPEN_ERROR') };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** The record first, then the collection (§6.3). */
|
|
38
139
|
async deleteCollection(name) {
|
|
140
|
+
const refused = this.refuseCatalogName(name);
|
|
141
|
+
if (refused)
|
|
142
|
+
return refused;
|
|
39
143
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
144
|
+
if (await this.collectionExists(this.catalog)) {
|
|
145
|
+
const res = await this.request(`/collections/${this.catalog}/points/delete?wait=true`, {
|
|
146
|
+
method: 'POST',
|
|
147
|
+
body: JSON.stringify({ points: [await deterministicUUID(name)] }),
|
|
148
|
+
});
|
|
149
|
+
if (!res.ok) {
|
|
150
|
+
return {
|
|
151
|
+
ok: false,
|
|
152
|
+
error: new CatalogRecordDeleteError(name, `HTTP ${res.status} ${await res.text()}`),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
return {
|
|
159
|
+
ok: false,
|
|
160
|
+
error: new CatalogRecordDeleteError(name, String(err)),
|
|
42
161
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const res = await
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const res = await this.request(`/collections/${name}`, {
|
|
46
165
|
method: 'DELETE',
|
|
47
|
-
headers,
|
|
48
166
|
});
|
|
49
167
|
if (!res.ok) {
|
|
50
168
|
const body = await res.text();
|
|
@@ -64,12 +182,7 @@ export class QdrantRagProvider extends BaseRagProvider {
|
|
|
64
182
|
}
|
|
65
183
|
async listCollections() {
|
|
66
184
|
try {
|
|
67
|
-
const
|
|
68
|
-
'Content-Type': 'application/json',
|
|
69
|
-
};
|
|
70
|
-
if (this.apiKey)
|
|
71
|
-
headers['api-key'] = this.apiKey;
|
|
72
|
-
const res = await fetch(`${this.url}/collections`, { headers });
|
|
185
|
+
const res = await this.request('/collections');
|
|
73
186
|
if (!res.ok) {
|
|
74
187
|
const body = await res.text();
|
|
75
188
|
return {
|
|
@@ -79,7 +192,7 @@ export class QdrantRagProvider extends BaseRagProvider {
|
|
|
79
192
|
}
|
|
80
193
|
const json = (await res.json());
|
|
81
194
|
const names = json.result?.collections?.map((c) => c.name) ?? [];
|
|
82
|
-
return { ok: true, value: names };
|
|
195
|
+
return { ok: true, value: names.filter((n) => n !== this.catalog) };
|
|
83
196
|
}
|
|
84
197
|
catch (err) {
|
|
85
198
|
return {
|
|
@@ -88,5 +201,159 @@ export class QdrantRagProvider extends BaseRagProvider {
|
|
|
88
201
|
};
|
|
89
202
|
}
|
|
90
203
|
}
|
|
204
|
+
async createStore(name, opts) {
|
|
205
|
+
// Qdrant fixes a collection's vector size at creation and IEmbedder
|
|
206
|
+
// declares none, so one probe embedding learns it — once per collection
|
|
207
|
+
// created, none per write.
|
|
208
|
+
const { vector } = await this.embedder.embed(DIMENSION_PROBE);
|
|
209
|
+
const res = await this.request(`/collections/${name}`, {
|
|
210
|
+
method: 'PUT',
|
|
211
|
+
body: JSON.stringify({
|
|
212
|
+
vectors: { size: vector.length, distance: 'Cosine' },
|
|
213
|
+
}),
|
|
214
|
+
});
|
|
215
|
+
if (res.ok)
|
|
216
|
+
return { ok: true, value: undefined };
|
|
217
|
+
const body = await res.text();
|
|
218
|
+
if (!(await this.collectionExists(name))) {
|
|
219
|
+
return {
|
|
220
|
+
ok: false,
|
|
221
|
+
error: new RagError(`Qdrant create collection failed: ${body}`, 'RAG_CREATE_ERROR'),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
if (await this.readRecord(name))
|
|
225
|
+
return this.duplicate(name, opts);
|
|
226
|
+
return {
|
|
227
|
+
ok: false,
|
|
228
|
+
error: new OrphanStoreError(name, 'it exists without a record; another session may be creating or deleting this collection, so retry later, or take it over with adoptExisting, or remove it'),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
async writeRecord(record, opts) {
|
|
232
|
+
const { userId, sessionId } = ragOwnerKeys(record);
|
|
233
|
+
const writeId = crypto.randomUUID();
|
|
234
|
+
const payload = {
|
|
235
|
+
store_name: record.storeName,
|
|
236
|
+
collection_name: record.name,
|
|
237
|
+
scope: record.scope,
|
|
238
|
+
...(userId === undefined ? {} : { user_id: userId }),
|
|
239
|
+
...(sessionId === undefined ? {} : { session_id: sessionId }),
|
|
240
|
+
attributes_json: encodeRagAttributes(record.attributes),
|
|
241
|
+
write_id: writeId,
|
|
242
|
+
};
|
|
243
|
+
let failure;
|
|
244
|
+
try {
|
|
245
|
+
const res = await this.request(`/collections/${this.catalog}/points?wait=true`, {
|
|
246
|
+
method: 'PUT',
|
|
247
|
+
body: JSON.stringify({
|
|
248
|
+
points: [
|
|
249
|
+
{
|
|
250
|
+
id: await deterministicUUID(record.storeName),
|
|
251
|
+
vector: [1],
|
|
252
|
+
payload,
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
update_mode: 'insert_only',
|
|
256
|
+
}),
|
|
257
|
+
});
|
|
258
|
+
if (!res.ok)
|
|
259
|
+
failure = `HTTP ${res.status} ${await res.text()}`;
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
failure = String(err);
|
|
263
|
+
}
|
|
264
|
+
// insert_only IGNORES a write whose point exists (Qdrant ≥ 1.17), so the
|
|
265
|
+
// outcome is read back: the record is this call's only if it carries this
|
|
266
|
+
// call's write id.
|
|
267
|
+
const stored = await this.readRecord(record.storeName).catch(() => undefined);
|
|
268
|
+
if (stored?.write_id === writeId)
|
|
269
|
+
return { ok: true, value: undefined };
|
|
270
|
+
if (stored)
|
|
271
|
+
return this.duplicate(record.storeName, opts);
|
|
272
|
+
// Never removed: another registry may adopt the collection and record it
|
|
273
|
+
// before a removal could run (§6.3).
|
|
274
|
+
return {
|
|
275
|
+
ok: false,
|
|
276
|
+
error: new OrphanStoreError(record.storeName, `its record could not be written (${failure ?? 'the write was accepted, but no record was found'}); the collection is left in place until it is adopted with adoptExisting or removed`),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
handles(storeName, owner) {
|
|
280
|
+
const rag = new QdrantRag({
|
|
281
|
+
url: this.url,
|
|
282
|
+
credential: this.credential,
|
|
283
|
+
embedder: this.embedder,
|
|
284
|
+
collectionName: storeName,
|
|
285
|
+
timeoutMs: this.timeoutMs,
|
|
286
|
+
autoCreateCollection: false,
|
|
287
|
+
});
|
|
288
|
+
return { rag, editor: this.buildEditor(rag, this.pickIdStrategy(owner)) };
|
|
289
|
+
}
|
|
290
|
+
duplicate(storeName, opts) {
|
|
291
|
+
return {
|
|
292
|
+
ok: false,
|
|
293
|
+
error: new DuplicateCollectionError(opts.collectionName ?? storeName, `collection '${storeName}' already has a record`),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
refuseCatalogName(name) {
|
|
297
|
+
if (name !== this.catalog)
|
|
298
|
+
return undefined;
|
|
299
|
+
return {
|
|
300
|
+
ok: false,
|
|
301
|
+
error: new RagError(`'${name}' is this provider's catalog collection, not a collection`, 'INVALID_COLLECTION_NAME'),
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
ensureCatalog() {
|
|
305
|
+
this.catalogReady ??= (async () => {
|
|
306
|
+
if (await this.collectionExists(this.catalog))
|
|
307
|
+
return;
|
|
308
|
+
const res = await this.request(`/collections/${this.catalog}`, {
|
|
309
|
+
method: 'PUT',
|
|
310
|
+
body: JSON.stringify({ vectors: { size: 1, distance: 'Dot' } }),
|
|
311
|
+
});
|
|
312
|
+
if (res.ok)
|
|
313
|
+
return;
|
|
314
|
+
const body = await res.text();
|
|
315
|
+
// Another process may have created it between the check and here.
|
|
316
|
+
if (!(await this.collectionExists(this.catalog))) {
|
|
317
|
+
throw new RagError(`Qdrant could not create the catalog collection '${this.catalog}': ${body}`, 'RAG_CREATE_ERROR');
|
|
318
|
+
}
|
|
319
|
+
})().catch((err) => {
|
|
320
|
+
this.catalogReady = undefined;
|
|
321
|
+
throw err;
|
|
322
|
+
});
|
|
323
|
+
return this.catalogReady;
|
|
324
|
+
}
|
|
325
|
+
async collectionExists(name) {
|
|
326
|
+
const res = await this.request(`/collections/${name}`);
|
|
327
|
+
if (res.ok)
|
|
328
|
+
return true;
|
|
329
|
+
if (res.status === 404)
|
|
330
|
+
return false;
|
|
331
|
+
throw new RagError(`Qdrant could not say whether collection '${name}' exists: HTTP ${res.status} ${await res.text()}`, 'RAG_BACKEND_ERROR');
|
|
332
|
+
}
|
|
333
|
+
/** The catalog point's payload, or undefined when there is none (or no catalog yet). */
|
|
334
|
+
async readRecord(storeName) {
|
|
335
|
+
const res = await this.request(`/collections/${this.catalog}/points`, {
|
|
336
|
+
method: 'POST',
|
|
337
|
+
body: JSON.stringify({
|
|
338
|
+
ids: [await deterministicUUID(storeName)],
|
|
339
|
+
with_payload: true,
|
|
340
|
+
}),
|
|
341
|
+
});
|
|
342
|
+
if (res.status === 404)
|
|
343
|
+
return undefined;
|
|
344
|
+
if (!res.ok) {
|
|
345
|
+
throw new RagError(`Qdrant catalog read failed: HTTP ${res.status} ${await res.text()}`, 'RAG_BACKEND_ERROR');
|
|
346
|
+
}
|
|
347
|
+
const json = (await res.json());
|
|
348
|
+
return json.result?.[0]?.payload;
|
|
349
|
+
}
|
|
350
|
+
async request(path, init = {}) {
|
|
351
|
+
const headers = {
|
|
352
|
+
'Content-Type': 'application/json',
|
|
353
|
+
};
|
|
354
|
+
if (this.credential)
|
|
355
|
+
headers['api-key'] = await this.credential.secret();
|
|
356
|
+
return fetch(`${this.url}${path}`, { ...init, headers });
|
|
357
|
+
}
|
|
91
358
|
}
|
|
92
359
|
//# sourceMappingURL=qdrant-rag-provider.js.map
|
|
@@ -1 +1 @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AC;YACZ,MAAM,IAAI,QAAQ,CAChB,oCAAoC,GAAG,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,EACpE,mBAAmB,CACpB,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAE7B,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;IACnC,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,IAAY,EACZ,OAAoB,EAAE;QAEtB,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;SACnC,CAAC;QACF,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -2,7 +2,6 @@ import assert from 'node:assert/strict';
|
|
|
2
2
|
import http from 'node:http';
|
|
3
3
|
import { after, before, describe, it } from 'node:test';
|
|
4
4
|
import { UnsupportedScopeError } from '@mcp-abap-adt/llm-agent';
|
|
5
|
-
import { QdrantRag } from './qdrant-rag.js';
|
|
6
5
|
import { QdrantRagProvider } from './qdrant-rag-provider.js';
|
|
7
6
|
function makeEmbedder(dim = 3) {
|
|
8
7
|
return {
|
|
@@ -107,16 +106,6 @@ describe('QdrantRagProvider', () => {
|
|
|
107
106
|
'user',
|
|
108
107
|
]);
|
|
109
108
|
});
|
|
110
|
-
it('creates a QdrantRag targeting the collection name', async () => {
|
|
111
|
-
const p = new QdrantRagProvider({
|
|
112
|
-
name: 'qdrant',
|
|
113
|
-
url: baseUrl,
|
|
114
|
-
embedder: makeEmbedder(),
|
|
115
|
-
});
|
|
116
|
-
const res = await p.createCollection('test-a', { scope: 'global' });
|
|
117
|
-
assert.ok(res.ok);
|
|
118
|
-
assert.ok(res.value.rag instanceof QdrantRag);
|
|
119
|
-
});
|
|
120
109
|
it('rejects unsupported scope when supportedScopes is restricted', async () => {
|
|
121
110
|
const p = new QdrantRagProvider({
|
|
122
111
|
name: 'q',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qdrant-rag-provider.test.js","sourceRoot":"","sources":["../src/qdrant-rag-provider.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"qdrant-rag-provider.test.js","sourceRoot":"","sources":["../src/qdrant-rag-provider.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,SAAS,YAAY,CAAC,GAAG,GAAG,CAAC;IAC3B,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,IAAY;YACtB,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,KAAK,MAAM,EAAE,IAAI,IAAI;gBAAE,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACjE,OAAO;gBACL,MAAM,EAAE,KAAK,CAAC,IAA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EAAE,GAAG;YACT,GAAG,EAAE,OAAO;YACZ,QAAQ,EAAE,YAAY,EAAE;SACzB,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACnB,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/qdrant-rag.d.ts
CHANGED
|
@@ -1,22 +1,43 @@
|
|
|
1
|
+
import type { IApiKeyCredential } from '@mcp-abap-adt/interfaces-auth';
|
|
1
2
|
import type { IEmbedder, IQueryEmbedding, IRag, IRagBackendWriter } from '@mcp-abap-adt/llm-agent';
|
|
2
3
|
import { type CallOptions, RagError, type RagMetadata, type RagResult, type Result } from '@mcp-abap-adt/llm-agent';
|
|
4
|
+
/**
|
|
5
|
+
* Derive a deterministic UUID from a stable string key using SHA-256.
|
|
6
|
+
* The first 16 bytes of the hash are formatted as a UUID v5-style string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deterministicUUID(key: string): Promise<string>;
|
|
3
9
|
export interface QdrantRagConfig {
|
|
4
10
|
url: string;
|
|
5
11
|
collectionName: string;
|
|
6
12
|
embedder: IEmbedder;
|
|
7
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Asked for fresh on every request — never cached — so a rotating key
|
|
15
|
+
* rotates and a resolved-once secret is never frozen for this object's
|
|
16
|
+
* lifetime. Optional: an unauthenticated Qdrant deployment works today
|
|
17
|
+
* without one.
|
|
18
|
+
*/
|
|
19
|
+
credential?: IApiKeyCredential;
|
|
8
20
|
/**
|
|
9
21
|
* Per-request timeout in ms. **No default** — unset, a request is bounded
|
|
10
22
|
* only by the caller's own signal.
|
|
11
23
|
*/
|
|
12
24
|
timeoutMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Create the collection on the first write when it is missing, sized from
|
|
27
|
+
* that write's vector. Default `true` — a store configured directly relies on
|
|
28
|
+
* it. `QdrantRagProvider` passes `false`: its collections are created by
|
|
29
|
+
* `createCollection` only, so a handle whose collection is gone fails instead
|
|
30
|
+
* of recreating it without a catalog record (§6.3).
|
|
31
|
+
*/
|
|
32
|
+
autoCreateCollection?: boolean;
|
|
13
33
|
}
|
|
14
34
|
export declare class QdrantRag implements IRag {
|
|
15
35
|
private readonly url;
|
|
16
36
|
private readonly collectionName;
|
|
17
37
|
private readonly embedder;
|
|
18
|
-
private readonly
|
|
38
|
+
private readonly credential?;
|
|
19
39
|
private readonly timeoutMs;
|
|
40
|
+
private readonly autoCreateCollection;
|
|
20
41
|
private collectionEnsured;
|
|
21
42
|
constructor(config: QdrantRagConfig);
|
|
22
43
|
private _headers;
|
package/dist/qdrant-rag.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qdrant-rag.d.ts","sourceRoot":"","sources":["../src/qdrant-rag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,IAAI,EACJ,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,WAAW,EAEhB,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"qdrant-rag.d.ts","sourceRoot":"","sources":["../src/qdrant-rag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,IAAI,EACJ,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,WAAW,EAEhB,QAAQ,EACR,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ACT,SAAS,EAAE,eAAe,EAC1B,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,CAAC,CAAC;IAiGnC,OAAO,CACX,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC;IAyCxC,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IA4BzE,MAAM,IAAI,iBAAiB;CAmH5B"}
|
package/dist/qdrant-rag.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FallbackQueryEmbedding, RagError, } from '@mcp-abap-adt/llm-agent';
|
|
1
|
+
import { FallbackQueryEmbedding, RagError, ragIdentityFilter, } from '@mcp-abap-adt/llm-agent';
|
|
2
2
|
/**
|
|
3
3
|
* Derive a deterministic UUID from a stable string key using SHA-256.
|
|
4
4
|
* The first 16 bytes of the hash are formatted as a UUID v5-style string.
|
|
5
5
|
*/
|
|
6
|
-
async function deterministicUUID(key) {
|
|
6
|
+
export async function deterministicUUID(key) {
|
|
7
7
|
const data = new TextEncoder().encode(key);
|
|
8
8
|
const hashBuffer = await globalThis.crypto.subtle.digest('SHA-256', data);
|
|
9
9
|
const bytes = new Uint8Array(hashBuffer, 0, 16);
|
|
@@ -14,20 +14,22 @@ export class QdrantRag {
|
|
|
14
14
|
url;
|
|
15
15
|
collectionName;
|
|
16
16
|
embedder;
|
|
17
|
-
|
|
17
|
+
credential;
|
|
18
18
|
timeoutMs;
|
|
19
|
+
autoCreateCollection;
|
|
19
20
|
collectionEnsured = false;
|
|
20
21
|
constructor(config) {
|
|
21
22
|
this.url = config.url.replace(/\/+$/, '');
|
|
22
23
|
this.collectionName = config.collectionName;
|
|
23
24
|
this.embedder = config.embedder;
|
|
24
|
-
this.
|
|
25
|
+
this.credential = config.credential;
|
|
25
26
|
this.timeoutMs = config.timeoutMs;
|
|
27
|
+
this.autoCreateCollection = config.autoCreateCollection ?? true;
|
|
26
28
|
}
|
|
27
|
-
_headers() {
|
|
29
|
+
async _headers() {
|
|
28
30
|
const h = { 'Content-Type': 'application/json' };
|
|
29
|
-
if (this.
|
|
30
|
-
h['api-key'] = this.
|
|
31
|
+
if (this.credential)
|
|
32
|
+
h['api-key'] = await this.credential.secret();
|
|
31
33
|
return h;
|
|
32
34
|
}
|
|
33
35
|
async _fetch(path, init, signal) {
|
|
@@ -48,7 +50,7 @@ export class QdrantRag {
|
|
|
48
50
|
return await fetch(`${this.url}${path}`, {
|
|
49
51
|
...init,
|
|
50
52
|
signal: ctrl.signal,
|
|
51
|
-
headers: { ...this._headers(), ...(init.headers ?? {}) },
|
|
53
|
+
headers: { ...(await this._headers()), ...(init.headers ?? {}) },
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
finally {
|
|
@@ -98,7 +100,9 @@ export class QdrantRag {
|
|
|
98
100
|
}
|
|
99
101
|
async upsertKnownVector(text, vector, metadata, options) {
|
|
100
102
|
try {
|
|
101
|
-
|
|
103
|
+
if (this.autoCreateCollection) {
|
|
104
|
+
await this._ensureCollection(vector.length, options?.signal);
|
|
105
|
+
}
|
|
102
106
|
const pointId = metadata?.id
|
|
103
107
|
? await deterministicUUID(metadata.id)
|
|
104
108
|
: crypto.randomUUID();
|
|
@@ -166,20 +170,40 @@ export class QdrantRag {
|
|
|
166
170
|
limit: k,
|
|
167
171
|
with_payload: true,
|
|
168
172
|
};
|
|
173
|
+
// The session/user scope. upsert spreads metadata flat into the
|
|
174
|
+
// payload, so `sessionId` / `userId` are top-level payload keys. A point
|
|
175
|
+
// without the key does not match a `match` condition, so an unowned
|
|
176
|
+
// point is never returned to a scoped query. Qdrant applies the filter
|
|
177
|
+
// inside the search, so `limit: k` counts only matching points.
|
|
178
|
+
const identity = ragIdentityFilter(options);
|
|
179
|
+
const identityMust = [];
|
|
180
|
+
if (identity?.sessionId !== undefined) {
|
|
181
|
+
identityMust.push({
|
|
182
|
+
key: 'sessionId',
|
|
183
|
+
match: { value: identity.sessionId },
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (identity?.userId !== undefined) {
|
|
187
|
+
identityMust.push({ key: 'userId', match: { value: identity.userId } });
|
|
188
|
+
}
|
|
169
189
|
if (must.length > 0) {
|
|
170
190
|
body.filter = {
|
|
191
|
+
// Top-level `must` is ANDed with the `should` below (at least one
|
|
192
|
+
// of which must hold), so the identity scope applies to both the
|
|
193
|
+
// TTL-bearing and the TTL-less branch.
|
|
194
|
+
...(identityMust.length > 0 ? { must: identityMust } : {}),
|
|
171
195
|
should: [
|
|
172
196
|
{ must },
|
|
173
|
-
//
|
|
197
|
+
// Points with NO ttl field. `is_empty`, not "no ttl >= 0": that
|
|
198
|
+
// let a negative ttl — a time in the past, so expired — through
|
|
199
|
+
// as if it had none (PR #308 review).
|
|
174
200
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
: {}),
|
|
201
|
+
must: [
|
|
202
|
+
{ is_empty: { key: 'ttl' } },
|
|
203
|
+
...(targetNamespace !== undefined
|
|
204
|
+
? [{ key: 'namespace', match: { value: targetNamespace } }]
|
|
205
|
+
: []),
|
|
206
|
+
],
|
|
183
207
|
},
|
|
184
208
|
],
|
|
185
209
|
};
|
|
@@ -323,7 +347,9 @@ export class QdrantRag {
|
|
|
323
347
|
if (items.length === 0)
|
|
324
348
|
return { ok: true, value: undefined };
|
|
325
349
|
try {
|
|
326
|
-
|
|
350
|
+
if (this.autoCreateCollection) {
|
|
351
|
+
await this._ensureCollection(items[0].vector.length, options?.signal);
|
|
352
|
+
}
|
|
327
353
|
const points = await Promise.all(items.map(async ({ id, text, vector, metadata }) => ({
|
|
328
354
|
id: await deterministicUUID(id),
|
|
329
355
|
vector,
|