@littlebigbrain/client 0.9.1 → 0.11.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 +12 -27
- package/dist/client.d.ts +15 -85
- package/dist/client.js +17 -152
- package/dist/index.d.ts +1 -1
- package/dist/namespaces.d.ts +6 -62
- package/dist/namespaces.js +10 -164
- package/dist/schema.d.ts +557 -5531
- package/dist/types.d.ts +6 -3
- package/package.json +1 -1
package/dist/namespaces.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { attributeFilter, firstPatternVariable, parseSparqlResults, } from "./types.js";
|
|
2
|
+
// SPARQL is the only query surface. The search, embedding, decode,
|
|
3
|
+
// groundability, and analytics operations were removed with their routes.
|
|
2
4
|
/** A5: fold read-consistency options into a request body's `consistency` /
|
|
3
5
|
* `min_indexed_seq` fields; a per-call value wins over the client default. */
|
|
4
6
|
function withReadConsistency(client, body, opts) {
|
|
@@ -13,20 +15,9 @@ function withReadConsistency(client, body, opts) {
|
|
|
13
15
|
}
|
|
14
16
|
return merged;
|
|
15
17
|
}
|
|
16
|
-
function transportOptions(options) {
|
|
17
|
-
return {
|
|
18
|
-
idempotencyKey: options.idempotencyKey,
|
|
19
|
-
timeoutMs: options.timeoutMs,
|
|
20
|
-
maxRetries: options.maxRetries,
|
|
21
|
-
retry: options.retry,
|
|
22
|
-
signal: options.signal,
|
|
23
|
-
headers: options.headers,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
18
|
export class GraphNamespace {
|
|
27
19
|
client;
|
|
28
20
|
facts;
|
|
29
|
-
context;
|
|
30
21
|
entities;
|
|
31
22
|
ontology;
|
|
32
23
|
query;
|
|
@@ -35,7 +26,6 @@ export class GraphNamespace {
|
|
|
35
26
|
constructor(client) {
|
|
36
27
|
this.client = client;
|
|
37
28
|
this.facts = new FactsNamespace(client);
|
|
38
|
-
this.context = client.context;
|
|
39
29
|
this.entities = client.entities;
|
|
40
30
|
this.ontology = client.ontology;
|
|
41
31
|
this.query = client.query;
|
|
@@ -63,63 +53,6 @@ export class GraphNamespace {
|
|
|
63
53
|
query: { confirm },
|
|
64
54
|
});
|
|
65
55
|
}
|
|
66
|
-
embeddingConfig(opts = {}) {
|
|
67
|
-
return this.client.request("GET", "/v1/graph/embedding", opts);
|
|
68
|
-
}
|
|
69
|
-
/** List the embedding models available on this deployment. */
|
|
70
|
-
embeddingModels(opts = {}) {
|
|
71
|
-
return this.client.request("GET", "/v1/graph/embedding/models", opts);
|
|
72
|
-
}
|
|
73
|
-
/** Choose the model used automatically for writes and vector queries. */
|
|
74
|
-
setEmbeddingModel(modelId, options = {}) {
|
|
75
|
-
const { autoEmbedQuery, ...request } = options;
|
|
76
|
-
return this.client.request("POST", "/v1/graph/embedding", {
|
|
77
|
-
...request,
|
|
78
|
-
body: {
|
|
79
|
-
model_id: modelId,
|
|
80
|
-
service: "open_router",
|
|
81
|
-
auto_embed_query: autoEmbedQuery ?? true,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/** Advanced configuration escape hatch. Prefer `setEmbeddingModel`. */
|
|
86
|
-
setEmbeddingConfig(body, opts = {}) {
|
|
87
|
-
return this.client.request("POST", "/v1/graph/embedding", {
|
|
88
|
-
...opts,
|
|
89
|
-
body,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
backfillEmbeddings(options = {}) {
|
|
93
|
-
return this.client.backfillEmbeddings({
|
|
94
|
-
batchSize: options.batchSize,
|
|
95
|
-
limit: options.limit,
|
|
96
|
-
full: options.full,
|
|
97
|
-
idempotencyKey: options.idempotencyKey,
|
|
98
|
-
timeoutMs: options.timeoutMs,
|
|
99
|
-
pollIntervalMs: options.pollIntervalMs,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
submitEmbeddingBackfill(options = {}) {
|
|
103
|
-
return this.client.submitEmbeddingBackfill({
|
|
104
|
-
batchSize: options.batchSize,
|
|
105
|
-
limit: options.limit,
|
|
106
|
-
full: options.full,
|
|
107
|
-
idempotencyKey: options.idempotencyKey,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
embeddingBackfillJob(jobId) {
|
|
111
|
-
return this.client.embeddingBackfillJob(jobId);
|
|
112
|
-
}
|
|
113
|
-
cancelEmbeddingBackfill(jobId) {
|
|
114
|
-
return this.client.cancelEmbeddingBackfill(jobId);
|
|
115
|
-
}
|
|
116
|
-
promoteEmbedding(options) {
|
|
117
|
-
const { runId, allowRegression, ...request } = options;
|
|
118
|
-
return this.client.request("POST", "/v1/graph/embedding/promote", {
|
|
119
|
-
...request,
|
|
120
|
-
query: { run_id: runId, allow_regression: allowRegression },
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
56
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
124
57
|
retract(body, opts = {}) {
|
|
125
58
|
return this.client.request("POST", "/v1/graph/retract", {
|
|
@@ -162,7 +95,7 @@ export class FactsNamespace {
|
|
|
162
95
|
* predicates and literal term details are preserved as edge metadata.
|
|
163
96
|
*/
|
|
164
97
|
importRdf(rdf, opts = {}) {
|
|
165
|
-
const { format = "ntriples", baseIri, graphUri, blankNodeScope, batch, strict, observedAt, resourceType, edgeIdempotency, ...request } = opts;
|
|
98
|
+
const { format = "ntriples", baseIri, graphUri, blankNodeScope, batch, strict, observedAt, resourceType, edgeIdempotency, build, ...request } = opts;
|
|
166
99
|
return this.client.request("POST", "/v1/graph/import/rdf", {
|
|
167
100
|
...request,
|
|
168
101
|
idempotencyKey: request.idempotencyKey ?? this.client.idempotencyKey("import-rdf"),
|
|
@@ -183,50 +116,20 @@ export class FactsNamespace {
|
|
|
183
116
|
blank_node_scope: blankNodeScope,
|
|
184
117
|
resource_type: resourceType,
|
|
185
118
|
edge_idempotency: edgeIdempotency,
|
|
119
|
+
build,
|
|
186
120
|
},
|
|
187
121
|
});
|
|
188
122
|
}
|
|
189
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Relevance-label storage. The query surfaces this namespace once fronted were
|
|
126
|
+
* removed with their routes; SPARQL is the only query path now.
|
|
127
|
+
*/
|
|
190
128
|
export class SearchNamespace {
|
|
191
129
|
client;
|
|
192
130
|
constructor(client) {
|
|
193
131
|
this.client = client;
|
|
194
132
|
}
|
|
195
|
-
hybrid(input, opts = {}) {
|
|
196
|
-
if (typeof input !== "string") {
|
|
197
|
-
const search = withReadConsistency(this.client, input.search ?? {}, {
|
|
198
|
-
consistency: opts.consistency,
|
|
199
|
-
minIndexedSeq: opts.minIndexedSeq,
|
|
200
|
-
});
|
|
201
|
-
return this.client.request("POST", "/v1/graph/search", {
|
|
202
|
-
...transportOptions(opts),
|
|
203
|
-
retry: opts.retry ?? true,
|
|
204
|
-
body: { ...input, search },
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
return this.client.request("GET", "/v1/search", {
|
|
208
|
-
...transportOptions(opts),
|
|
209
|
-
query: {
|
|
210
|
-
query: input,
|
|
211
|
-
top_k: opts.topK,
|
|
212
|
-
consistency: opts.consistency ?? this.client.defaultConsistency,
|
|
213
|
-
min_indexed_seq: opts.minIndexedSeq,
|
|
214
|
-
lexical: opts.lexical,
|
|
215
|
-
bm25: opts.bm25,
|
|
216
|
-
vector: opts.vector,
|
|
217
|
-
targets: opts.targets?.join(","),
|
|
218
|
-
profile: opts.profile,
|
|
219
|
-
log_impression: opts.logImpression,
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
multi(body, opts = {}) {
|
|
224
|
-
return this.client.request("POST", "/v1/search/multi", {
|
|
225
|
-
...opts,
|
|
226
|
-
retry: opts.retry ?? true,
|
|
227
|
-
body,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
133
|
feedback(body, opts = {}) {
|
|
231
134
|
return this.client.request("POST", "/v1/search/feedback", {
|
|
232
135
|
...opts,
|
|
@@ -239,20 +142,6 @@ export class SearchNamespace {
|
|
|
239
142
|
feedbackSummary(opts = {}) {
|
|
240
143
|
return this.client.request("GET", "/v1/search/feedback/summary", opts);
|
|
241
144
|
}
|
|
242
|
-
fullText(body, opts = {}) {
|
|
243
|
-
return this.client.request("POST", "/v1/search/full-text", {
|
|
244
|
-
...opts,
|
|
245
|
-
retry: opts.retry ?? true,
|
|
246
|
-
body: withReadConsistency(this.client, body, opts),
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
vector(body, opts = {}) {
|
|
250
|
-
return this.client.request("POST", "/v1/search/embedding", {
|
|
251
|
-
...opts,
|
|
252
|
-
retry: opts.retry ?? true,
|
|
253
|
-
body: withReadConsistency(this.client, body, opts),
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
145
|
}
|
|
257
146
|
export class EntityNamespace {
|
|
258
147
|
client;
|
|
@@ -261,8 +150,7 @@ export class EntityNamespace {
|
|
|
261
150
|
}
|
|
262
151
|
/**
|
|
263
152
|
* Return the exact type cardinality and a bounded deterministic sample from
|
|
264
|
-
* the
|
|
265
|
-
* family fails closed rather than falling back to an exhaustive scan.
|
|
153
|
+
* the Base family pinned by the published generation.
|
|
266
154
|
*/
|
|
267
155
|
sample(opts) {
|
|
268
156
|
return this.client.entityTypeSample(opts);
|
|
@@ -299,41 +187,6 @@ export class EntityNamespace {
|
|
|
299
187
|
});
|
|
300
188
|
}
|
|
301
189
|
}
|
|
302
|
-
/** Grounding operations over one pinned published vocabulary. */
|
|
303
|
-
export class ContextNamespace {
|
|
304
|
-
client;
|
|
305
|
-
constructor(client) {
|
|
306
|
-
this.client = client;
|
|
307
|
-
}
|
|
308
|
-
suggest(body, opts = {}) {
|
|
309
|
-
return this.client.request("POST", "/v1/search/suggest", {
|
|
310
|
-
...opts,
|
|
311
|
-
retry: opts.retry ?? true,
|
|
312
|
-
body,
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
resolve(body, opts = {}) {
|
|
316
|
-
return this.client.request("POST", "/v1/search/resolve-term", {
|
|
317
|
-
...opts,
|
|
318
|
-
retry: opts.retry ?? true,
|
|
319
|
-
body,
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
decode(body, opts = {}) {
|
|
323
|
-
return this.client.request("POST", "/v1/decode", {
|
|
324
|
-
...opts,
|
|
325
|
-
retry: opts.retry ?? true,
|
|
326
|
-
body,
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
groundability(options = {}) {
|
|
330
|
-
const { sample, ...request } = options;
|
|
331
|
-
return this.client.request("GET", "/v1/graph/groundability", {
|
|
332
|
-
...request,
|
|
333
|
-
query: sample === undefined ? undefined : { sample },
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
190
|
/** Active ontology/SHACL bundle metadata and atomic publication. */
|
|
338
191
|
export class SchemaNamespace {
|
|
339
192
|
client;
|
|
@@ -408,7 +261,7 @@ export class OntologyNamespace {
|
|
|
408
261
|
});
|
|
409
262
|
}
|
|
410
263
|
}
|
|
411
|
-
/** Structured
|
|
264
|
+
/** Structured and SPARQL-text query operations. */
|
|
412
265
|
export class QueryNamespace {
|
|
413
266
|
client;
|
|
414
267
|
constructor(client) {
|
|
@@ -445,11 +298,4 @@ export class QueryNamespace {
|
|
|
445
298
|
},
|
|
446
299
|
});
|
|
447
300
|
}
|
|
448
|
-
analytics(body, opts = {}) {
|
|
449
|
-
return this.client.request("POST", "/v1/query/analytics", {
|
|
450
|
-
...opts,
|
|
451
|
-
retry: opts.retry ?? true,
|
|
452
|
-
body,
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
301
|
}
|