@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/README.md
CHANGED
|
@@ -36,11 +36,10 @@ await graph.facts.create(
|
|
|
36
36
|
const published = await lbb.readSnapshot();
|
|
37
37
|
console.log(published.snapshot.served_at_seq, published.query_lag_commits);
|
|
38
38
|
|
|
39
|
-
// 3.
|
|
40
|
-
const
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
);
|
|
39
|
+
// 3. Query the snapshot with SPARQL.
|
|
40
|
+
const rows = await lbb.sparqlRows({
|
|
41
|
+
query: "SELECT ?s ?o WHERE { ?s <policy:retention> ?o } LIMIT 10",
|
|
42
|
+
});
|
|
44
43
|
```
|
|
45
44
|
|
|
46
45
|
For hosted use, `baseUrl` is required and must be the exact `endpoint_url`
|
|
@@ -49,23 +48,6 @@ parameters; they are not encoded in the hostname.
|
|
|
49
48
|
|
|
50
49
|
## Examples
|
|
51
50
|
|
|
52
|
-
**Search with filters.** Pass the request body to filter before ranking — here, only facts an ACL principal may see:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
const results = await graph.search.hybrid({
|
|
56
|
-
query: "incident response runbook",
|
|
57
|
-
targets: ["entities"],
|
|
58
|
-
search: {
|
|
59
|
-
filters: {
|
|
60
|
-
op: "overlaps",
|
|
61
|
-
field: "acl",
|
|
62
|
-
values: ["user:rino@example.com", "group:engineering"],
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
top_k: 20,
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
51
|
**Bulk import.** Load an array of records (or an NDJSON string) in one call:
|
|
70
52
|
|
|
71
53
|
```ts
|
|
@@ -93,10 +75,13 @@ commit is durable and final publication was enqueued; it does not mean indexes
|
|
|
93
75
|
have already reached `committed_commit_seq`. An empty iterable is rejected
|
|
94
76
|
locally before an import POST is sent.
|
|
95
77
|
|
|
96
|
-
**Time-travel read.** Pin
|
|
78
|
+
**Time-travel read.** Pin a SPARQL read to a past instant — results reflect the graph as it was then:
|
|
97
79
|
|
|
98
80
|
```ts
|
|
99
|
-
const asOf = await
|
|
81
|
+
const asOf = await lbb.sparqlRows({
|
|
82
|
+
query: "SELECT ?s ?o WHERE { ?s <policy:retention> ?o }",
|
|
83
|
+
as_of_valid_time: "2026-01-01T00:00:00Z",
|
|
84
|
+
});
|
|
100
85
|
```
|
|
101
86
|
|
|
102
87
|
**SPARQL.** `sparqlRows` runs a SPARQL 1.1 SELECT/ASK and returns parsed rows:
|
|
@@ -113,9 +98,9 @@ Methods return parsed JSON and throw `LbbError` (with `status`, `code`, `message
|
|
|
113
98
|
|
|
114
99
|
## More
|
|
115
100
|
|
|
116
|
-
The `graph(...)` scope exposes `facts`, `
|
|
117
|
-
`
|
|
118
|
-
|
|
101
|
+
The `graph(...)` scope exposes `facts`, `entities`, `ontology`, `query`,
|
|
102
|
+
`search` (feedback surfaces), and `schema` namespaces. `query` runs SPARQL,
|
|
103
|
+
the one query language on the API; `schema`
|
|
119
104
|
reads or atomically publishes the active ontology/shapes bundle. Writes enqueue
|
|
120
105
|
published-generation maintenance automatically. Every generated shape is
|
|
121
106
|
available as `Schemas["TypeName"]`.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { DurableImportSource, ImportLine, LbbClientOptions, ListResponse, RawLbbResponse, ReadConsistencyOptions, RdfImportOptions, Schemas, SearchConsistency, SparqlResults } from "./types.js";
|
|
2
2
|
import { type CallOptions, type RequestOptions } from "./transport.js";
|
|
3
|
-
import {
|
|
3
|
+
import { EntityNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace } from "./namespaces.js";
|
|
4
4
|
export { parseSparqlResults } from "./types.js";
|
|
5
|
-
export type { AttributeFilter, AttributeFilterOp, AttributeFilterValue, EntityAttributeFilterOptions, EntityPropertiesLine, DurableImportLine, DurableImportSource, FetchLike, FlatProperties, ImportLine, LbbClientOptions, LbbRequestEvent, LbbResponseEvent, LbbRetryEvent, LbbErrorPayload, ListResponse, RawLbbResponse, ReadConsistencyOptions, RdfImportOptions, Schemas, SearchConsistency, SparqlResults, SparqlResultsJson, SparqlTerm, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView,
|
|
5
|
+
export type { AttributeFilter, AttributeFilterOp, AttributeFilterValue, EntityAttributeFilterOptions, EntityPropertiesLine, DurableImportLine, DurableImportSource, FetchLike, FlatProperties, ImportLine, LbbClientOptions, LbbRequestEvent, LbbResponseEvent, LbbRetryEvent, LbbErrorPayload, ListResponse, RawLbbResponse, ReadConsistencyOptions, RdfImportOptions, Schemas, SearchConsistency, SparqlResults, SparqlResultsJson, SparqlTerm, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, Snapshot, } from "./types.js";
|
|
6
6
|
export { LbbCapabilityError, LbbError } from "./transport.js";
|
|
7
7
|
export type { CallOptions, Query, QueryValue, RequestOptions, } from "./transport.js";
|
|
8
|
-
export
|
|
9
|
-
export { ContextNamespace, EntityNamespace, FactsNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
8
|
+
export { EntityNamespace, FactsNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
10
9
|
export interface IndexLineageObservation {
|
|
11
10
|
metadata: Schemas["GraphMetadataResponse"];
|
|
12
11
|
lineage: Schemas["IndexLineage"];
|
|
@@ -39,7 +38,6 @@ export declare class LbbClient {
|
|
|
39
38
|
private capabilities?;
|
|
40
39
|
/** A5 default read consistency applied when a read omits its own value. */
|
|
41
40
|
readonly defaultConsistency?: SearchConsistency;
|
|
42
|
-
readonly context: ContextNamespace;
|
|
43
41
|
readonly search: SearchNamespace;
|
|
44
42
|
readonly entities: EntityNamespace;
|
|
45
43
|
readonly schema: SchemaNamespace;
|
|
@@ -213,47 +211,6 @@ export declare class LbbClient {
|
|
|
213
211
|
deleteBranch(opts: {
|
|
214
212
|
confirm: string;
|
|
215
213
|
}): Promise<Schemas["GraphBranchDeleteResponse"]>;
|
|
216
|
-
embeddingConfig(): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
217
|
-
/** List the embedding models available on this deployment. */
|
|
218
|
-
embeddingModels(): Promise<Schemas["ManagedEmbeddingModelsResponse"]>;
|
|
219
|
-
/**
|
|
220
|
-
* Choose the model used automatically for writes and vector queries.
|
|
221
|
-
* Provider credentials and native dimension discovery stay server-side.
|
|
222
|
-
*/
|
|
223
|
-
setEmbeddingModel(modelId: string, opts?: {
|
|
224
|
-
autoEmbedQuery?: boolean;
|
|
225
|
-
}): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
226
|
-
/** Advanced configuration escape hatch. Prefer `setEmbeddingModel`. */
|
|
227
|
-
setEmbeddingConfig(body: Schemas["ManagedEmbeddingConfigRequest"]): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
228
|
-
submitEmbeddingBackfill(opts?: {
|
|
229
|
-
batchSize?: number;
|
|
230
|
-
limit?: number;
|
|
231
|
-
full?: boolean;
|
|
232
|
-
idempotencyKey?: string;
|
|
233
|
-
}): Promise<Schemas["ManagedEmbeddingBackfillJobStatusResponse"]>;
|
|
234
|
-
embeddingBackfillJob(jobId: string): Promise<Schemas["ManagedEmbeddingBackfillJobStatusResponse"]>;
|
|
235
|
-
cancelEmbeddingBackfill(jobId: string): Promise<Schemas["ManagedEmbeddingBackfillJobStatusResponse"]>;
|
|
236
|
-
backfillEmbeddings(opts?: {
|
|
237
|
-
batchSize?: number;
|
|
238
|
-
limit?: number;
|
|
239
|
-
full?: boolean;
|
|
240
|
-
idempotencyKey?: string;
|
|
241
|
-
timeoutMs?: number;
|
|
242
|
-
pollIntervalMs?: number;
|
|
243
|
-
}): Promise<Schemas["ManagedEmbeddingBackfillResponse"]>;
|
|
244
|
-
promoteEmbedding(opts: {
|
|
245
|
-
runId: string;
|
|
246
|
-
allowRegression?: boolean;
|
|
247
|
-
}): Promise<Schemas["ManagedEmbeddingPromoteResponse"]>;
|
|
248
|
-
/**
|
|
249
|
-
* The graph's grounding vocabulary as byte-sorted, deduped string sections —
|
|
250
|
-
* the canonical input for a decoder-side automaton (FST/trie) and the
|
|
251
|
-
* vocabulary half of an export bundle.
|
|
252
|
-
*/
|
|
253
|
-
vocabExport(opts?: {
|
|
254
|
-
sections?: string[];
|
|
255
|
-
limit?: number;
|
|
256
|
-
}): Promise<Schemas["VocabExportResponse"]>;
|
|
257
214
|
/**
|
|
258
215
|
* Captured signals by flush-seq range, oldest first — the model-training
|
|
259
216
|
* feed. The `seq` on each signal is the temporal-split coordinate (train ≤ T,
|
|
@@ -366,29 +323,11 @@ export declare class LbbClient {
|
|
|
366
323
|
runId: string;
|
|
367
324
|
allowRegression?: boolean;
|
|
368
325
|
}): Promise<unknown>;
|
|
369
|
-
/** Full semantic hybrid search from a request body (`POST /v1/graph/search`). */
|
|
370
|
-
graphSearch(body: Schemas["SemanticGraphSearchRequest"], opts?: ReadConsistencyOptions): Promise<Schemas["SemanticGraphSearchResponse"]>;
|
|
371
|
-
/** Reciprocal-rank-fusion across sub-queries. */
|
|
372
|
-
multiSearch(body: Schemas["HybridMultiSearchRequest"]): Promise<Schemas["HybridMultiSearchResponse"]>;
|
|
373
|
-
/**
|
|
374
|
-
* Grounded prefix completion from the index vocabulary + ontology. Optionally
|
|
375
|
-
* narrow relation completions by a type-signature `context` — a type
|
|
376
|
-
* pair that admits a single relation flags `signature_forced`.
|
|
377
|
-
*/
|
|
378
|
-
suggest(body: Schemas["SearchSuggestRequest"]): Promise<Schemas["SearchSuggestResponse"]>;
|
|
379
|
-
/** Snap free text to the nearest term in the pinned published vocabulary. */
|
|
380
|
-
resolveTerm(body: Schemas["ResolveTermRequest"]): Promise<Schemas["ResolveTermResponse"]>;
|
|
381
|
-
/** Decode a relation from the graph's admissible published vocabulary. */
|
|
382
|
-
decode(body: Schemas["DecodeRequest"]): Promise<Schemas["DecodeResponse"]>;
|
|
383
|
-
/** Report completion strategy fitness for the pinned published graph. */
|
|
384
|
-
groundability(opts?: {
|
|
385
|
-
sample?: number;
|
|
386
|
-
}): Promise<Schemas["GroundabilityReport"]>;
|
|
387
326
|
/**
|
|
388
|
-
* Append relevance labels for a set of
|
|
327
|
+
* Append relevance labels for a set of ranked results — how little big brain
|
|
389
328
|
* gathers customer-specific qrels. Grade results (3 ideal/good, 1 partial,
|
|
390
|
-
* 0 bad), referencing the
|
|
391
|
-
*
|
|
329
|
+
* 0 bad), referencing the ranking's `search_id` so labels tie back to it.
|
|
330
|
+
* Stored apart from customer facts and exported via
|
|
392
331
|
* {@link searchFeedbackExport} as training/eval data for embedding fine-tuning.
|
|
393
332
|
*/
|
|
394
333
|
searchFeedback(body: Schemas["SearchFeedbackRequest"], opts?: {
|
|
@@ -396,23 +335,22 @@ export declare class LbbClient {
|
|
|
396
335
|
}): Promise<Schemas["SearchFeedbackResponse"]>;
|
|
397
336
|
/** Export the stored relevance labels as qrels-style rows for training. */
|
|
398
337
|
searchFeedbackExport(): Promise<Schemas["SearchFeedbackExportResponse"]>;
|
|
399
|
-
/**
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
semanticTraverse(body: Schemas["SemanticTraverseRequest"]): Promise<Schemas["SemanticTraverseResponse"]>;
|
|
407
|
-
/** Ranked incoming/outgoing neighborhood for a graph entity. */
|
|
338
|
+
/**
|
|
339
|
+
* Ranked incoming/outgoing neighborhood for a graph entity.
|
|
340
|
+
*
|
|
341
|
+
* `edges` caps the edges returned per direction (default 1000, maximum
|
|
342
|
+
* 10000). When a cap cuts a direction the response carries a `truncation`
|
|
343
|
+
* block; an uncut response omits it entirely.
|
|
344
|
+
*/
|
|
408
345
|
entityNeighborhood(opts: {
|
|
409
346
|
id?: string;
|
|
410
347
|
type?: string;
|
|
411
348
|
name?: string;
|
|
412
349
|
relations?: string[];
|
|
413
350
|
asOf?: string;
|
|
351
|
+
edges?: number;
|
|
414
352
|
}): Promise<Schemas["EntityNeighborhoodResponse"]>;
|
|
415
|
-
/** Exact type cardinality plus a bounded deterministic sample from
|
|
353
|
+
/** Exact type cardinality plus a bounded deterministic sample from Base. */
|
|
416
354
|
entityTypeSample(opts: {
|
|
417
355
|
type: string;
|
|
418
356
|
limit?: number;
|
|
@@ -473,14 +411,6 @@ export declare class LbbClient {
|
|
|
473
411
|
* is the ASK answer (or `null` for a SELECT).
|
|
474
412
|
*/
|
|
475
413
|
sparqlRows(body: Schemas["SparqlTextRequest"], opts?: ReadConsistencyOptions): Promise<SparqlResults>;
|
|
476
|
-
/**
|
|
477
|
-
* Basic-graph-pattern query with group-graph-pattern combinators
|
|
478
|
-
* (UNION / OPTIONAL / MINUS / EXISTS / NOT EXISTS) folded over the base
|
|
479
|
-
* patterns. The complement to {@link sparql}: this route carries the
|
|
480
|
-
* combinators (but not FILTER/aggregation), so use it when a query needs an
|
|
481
|
-
* optional/union/negated leg rather than a grouped aggregate.
|
|
482
|
-
*/
|
|
483
|
-
analytics(body: Schemas["AnalyticQueryRequest"]): Promise<Schemas["AnalyticQueryResponse"]>;
|
|
484
414
|
/**
|
|
485
415
|
* The active ontology (entity types and relations) for the scoped graph.
|
|
486
416
|
* Pass `{ counts: true }` to include a per-relation current-edge count
|
package/dist/client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parseSparqlResults } from "./types.js";
|
|
2
2
|
import { bodyMarksTerminal, errorCodeFromBody, fullJitterBackoffMs, parseLbbError, parseResponseJson, retryAllowed, retryableStatus, retryDelayMs, sleep, } from "./transport.js";
|
|
3
3
|
import { LbbCapabilityError } from "./transport.js";
|
|
4
|
-
import {
|
|
4
|
+
import { EntityNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
5
5
|
export { parseSparqlResults } from "./types.js";
|
|
6
6
|
export { LbbCapabilityError, LbbError } from "./transport.js";
|
|
7
|
-
export {
|
|
7
|
+
export { EntityNamespace, FactsNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
8
8
|
function durableImportBytes(line) {
|
|
9
9
|
if (line instanceof Uint8Array)
|
|
10
10
|
return line;
|
|
@@ -105,7 +105,6 @@ export class LbbClient {
|
|
|
105
105
|
capabilities;
|
|
106
106
|
/** A5 default read consistency applied when a read omits its own value. */
|
|
107
107
|
defaultConsistency;
|
|
108
|
-
context;
|
|
109
108
|
search;
|
|
110
109
|
entities;
|
|
111
110
|
schema;
|
|
@@ -148,7 +147,6 @@ export class LbbClient {
|
|
|
148
147
|
throw new Error("no fetch implementation available; pass options.fetch");
|
|
149
148
|
}
|
|
150
149
|
this.fetchImpl = chosen;
|
|
151
|
-
this.context = new ContextNamespace(this);
|
|
152
150
|
this.search = new SearchNamespace(this);
|
|
153
151
|
this.entities = new EntityNamespace(this);
|
|
154
152
|
this.schema = new SchemaNamespace(this);
|
|
@@ -560,6 +558,7 @@ export class LbbClient {
|
|
|
560
558
|
blank_node_scope: opts.blankNodeScope,
|
|
561
559
|
resource_type: opts.resourceType,
|
|
562
560
|
edge_idempotency: opts.edgeIdempotency,
|
|
561
|
+
build: opts.build,
|
|
563
562
|
},
|
|
564
563
|
idempotencyKey: opts.idempotencyKey ?? this.idempotencyKey("import-rdf"),
|
|
565
564
|
});
|
|
@@ -667,78 +666,7 @@ export class LbbClient {
|
|
|
667
666
|
query: { confirm: opts.confirm },
|
|
668
667
|
});
|
|
669
668
|
}
|
|
670
|
-
embeddingConfig() {
|
|
671
|
-
return this.request("GET", "/v1/graph/embedding");
|
|
672
|
-
}
|
|
673
|
-
/** List the embedding models available on this deployment. */
|
|
674
|
-
embeddingModels() {
|
|
675
|
-
return this.request("GET", "/v1/graph/embedding/models");
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* Choose the model used automatically for writes and vector queries.
|
|
679
|
-
* Provider credentials and native dimension discovery stay server-side.
|
|
680
|
-
*/
|
|
681
|
-
setEmbeddingModel(modelId, opts = {}) {
|
|
682
|
-
return this.setEmbeddingConfig({
|
|
683
|
-
model_id: modelId,
|
|
684
|
-
service: "open_router",
|
|
685
|
-
auto_embed_query: opts.autoEmbedQuery ?? true,
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
/** Advanced configuration escape hatch. Prefer `setEmbeddingModel`. */
|
|
689
|
-
setEmbeddingConfig(body) {
|
|
690
|
-
return this.request("POST", "/v1/graph/embedding", { body });
|
|
691
|
-
}
|
|
692
|
-
submitEmbeddingBackfill(opts = {}) {
|
|
693
|
-
return this.request("POST", "/v1/graph/embedding/backfill-jobs", {
|
|
694
|
-
body: {
|
|
695
|
-
batch_size: opts.batchSize,
|
|
696
|
-
limit: opts.limit,
|
|
697
|
-
full: opts.full ?? false,
|
|
698
|
-
},
|
|
699
|
-
idempotencyKey: opts.idempotencyKey ?? this.idempotencyKey("embedding-backfill"),
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
embeddingBackfillJob(jobId) {
|
|
703
|
-
return this.request("GET", "/v1/graph/embedding/backfill-jobs", {
|
|
704
|
-
query: { job_id: jobId },
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
cancelEmbeddingBackfill(jobId) {
|
|
708
|
-
return this.request("DELETE", "/v1/graph/embedding/backfill-jobs", {
|
|
709
|
-
query: { job_id: jobId },
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
async backfillEmbeddings(opts = {}) {
|
|
713
|
-
let status = await this.submitEmbeddingBackfill(opts);
|
|
714
|
-
const deadline = Date.now() + (opts.timeoutMs ?? 30 * 60_000);
|
|
715
|
-
while (status.status === "pending" || status.status === "running") {
|
|
716
|
-
if (Date.now() >= deadline)
|
|
717
|
-
throw new Error(`embedding backfill ${status.job_id} did not finish before timeout`);
|
|
718
|
-
await sleep(opts.pollIntervalMs ?? 2_000);
|
|
719
|
-
status = await this.embeddingBackfillJob(status.job_id);
|
|
720
|
-
}
|
|
721
|
-
if (status.status !== "succeeded" || status.result == null)
|
|
722
|
-
throw new Error(status.terminal_error ??
|
|
723
|
-
`embedding backfill ${status.job_id} ended ${status.status}`);
|
|
724
|
-
return status.result;
|
|
725
|
-
}
|
|
726
|
-
promoteEmbedding(opts) {
|
|
727
|
-
return this.request("POST", "/v1/graph/embedding/promote", {
|
|
728
|
-
query: { run_id: opts.runId, allow_regression: opts.allowRegression },
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
669
|
// --- models as runs (training-run registry + eval machinery) ---
|
|
732
|
-
/**
|
|
733
|
-
* The graph's grounding vocabulary as byte-sorted, deduped string sections —
|
|
734
|
-
* the canonical input for a decoder-side automaton (FST/trie) and the
|
|
735
|
-
* vocabulary half of an export bundle.
|
|
736
|
-
*/
|
|
737
|
-
vocabExport(opts = {}) {
|
|
738
|
-
return this.request("GET", "/v1/search/vocab", {
|
|
739
|
-
query: { sections: opts.sections?.join(","), limit: opts.limit },
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
670
|
/**
|
|
743
671
|
* Captured signals by flush-seq range, oldest first — the model-training
|
|
744
672
|
* feed. The `seq` on each signal is the temporal-split coordinate (train ≤ T,
|
|
@@ -886,49 +814,12 @@ export class LbbClient {
|
|
|
886
814
|
query: { run_id: opts.runId, allow_regression: opts.allowRegression },
|
|
887
815
|
});
|
|
888
816
|
}
|
|
889
|
-
// ---
|
|
890
|
-
/** Full semantic hybrid search from a request body (`POST /v1/graph/search`). */
|
|
891
|
-
graphSearch(body, opts) {
|
|
892
|
-
// Consistency for hybrid graph search lives on the nested `search` options.
|
|
893
|
-
const consistency = this.resolveConsistency(opts);
|
|
894
|
-
const search = consistency !== undefined || opts?.minIndexedSeq !== undefined
|
|
895
|
-
? this.mergeReadConsistency(body.search ?? {}, opts)
|
|
896
|
-
: body.search;
|
|
897
|
-
return this.request("POST", "/v1/graph/search", {
|
|
898
|
-
body: { ...body, search },
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
/** Reciprocal-rank-fusion across sub-queries. */
|
|
902
|
-
multiSearch(body) {
|
|
903
|
-
return this.request("POST", "/v1/search/multi", { body });
|
|
904
|
-
}
|
|
817
|
+
// --- relevance feedback ---
|
|
905
818
|
/**
|
|
906
|
-
*
|
|
907
|
-
* narrow relation completions by a type-signature `context` — a type
|
|
908
|
-
* pair that admits a single relation flags `signature_forced`.
|
|
909
|
-
*/
|
|
910
|
-
suggest(body) {
|
|
911
|
-
return this.request("POST", "/v1/search/suggest", { body });
|
|
912
|
-
}
|
|
913
|
-
/** Snap free text to the nearest term in the pinned published vocabulary. */
|
|
914
|
-
resolveTerm(body) {
|
|
915
|
-
return this.request("POST", "/v1/search/resolve-term", { body });
|
|
916
|
-
}
|
|
917
|
-
/** Decode a relation from the graph's admissible published vocabulary. */
|
|
918
|
-
decode(body) {
|
|
919
|
-
return this.request("POST", "/v1/decode", { body });
|
|
920
|
-
}
|
|
921
|
-
/** Report completion strategy fitness for the pinned published graph. */
|
|
922
|
-
groundability(opts = {}) {
|
|
923
|
-
return this.request("GET", "/v1/graph/groundability", {
|
|
924
|
-
query: opts.sample == null ? undefined : { sample: opts.sample },
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* Append relevance labels for a set of search results — how little big brain
|
|
819
|
+
* Append relevance labels for a set of ranked results — how little big brain
|
|
929
820
|
* gathers customer-specific qrels. Grade results (3 ideal/good, 1 partial,
|
|
930
|
-
* 0 bad), referencing the
|
|
931
|
-
*
|
|
821
|
+
* 0 bad), referencing the ranking's `search_id` so labels tie back to it.
|
|
822
|
+
* Stored apart from customer facts and exported via
|
|
932
823
|
* {@link searchFeedbackExport} as training/eval data for embedding fine-tuning.
|
|
933
824
|
*/
|
|
934
825
|
searchFeedback(body, opts = {}) {
|
|
@@ -941,28 +832,13 @@ export class LbbClient {
|
|
|
941
832
|
searchFeedbackExport() {
|
|
942
833
|
return this.request("GET", "/v1/search/feedback/export");
|
|
943
834
|
}
|
|
944
|
-
/**
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
embeddingSearch(body, opts) {
|
|
952
|
-
return this.request("POST", "/v1/search/embedding", {
|
|
953
|
-
body: this.mergeReadConsistency(body, opts),
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
// --- traversal ---
|
|
957
|
-
/** Bounded k-hop graph traversal. */
|
|
958
|
-
traverse(body) {
|
|
959
|
-
return this.request("POST", "/v1/graph/traverse", { body });
|
|
960
|
-
}
|
|
961
|
-
/** Resolve a query to seed entities, then return bounded paths. */
|
|
962
|
-
semanticTraverse(body) {
|
|
963
|
-
return this.request("POST", "/v1/graph/semantic-traverse", { body });
|
|
964
|
-
}
|
|
965
|
-
/** Ranked incoming/outgoing neighborhood for a graph entity. */
|
|
835
|
+
/**
|
|
836
|
+
* Ranked incoming/outgoing neighborhood for a graph entity.
|
|
837
|
+
*
|
|
838
|
+
* `edges` caps the edges returned per direction (default 1000, maximum
|
|
839
|
+
* 10000). When a cap cuts a direction the response carries a `truncation`
|
|
840
|
+
* block; an uncut response omits it entirely.
|
|
841
|
+
*/
|
|
966
842
|
entityNeighborhood(opts) {
|
|
967
843
|
return this.request("GET", "/v1/graph/entity/neighborhood", {
|
|
968
844
|
query: {
|
|
@@ -971,10 +847,11 @@ export class LbbClient {
|
|
|
971
847
|
name: opts.name,
|
|
972
848
|
relations: opts.relations?.join(","),
|
|
973
849
|
as_of: opts.asOf,
|
|
850
|
+
edges: opts.edges,
|
|
974
851
|
},
|
|
975
852
|
});
|
|
976
853
|
}
|
|
977
|
-
/** Exact type cardinality plus a bounded deterministic sample from
|
|
854
|
+
/** Exact type cardinality plus a bounded deterministic sample from Base. */
|
|
978
855
|
entityTypeSample(opts) {
|
|
979
856
|
const { type, limit, ...request } = opts;
|
|
980
857
|
return this.request("GET", "/v1/graph/entities/sample", {
|
|
@@ -1076,16 +953,6 @@ export class LbbClient {
|
|
|
1076
953
|
async sparqlRows(body, opts) {
|
|
1077
954
|
return parseSparqlResults(await this.sparqlText(body, opts));
|
|
1078
955
|
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Basic-graph-pattern query with group-graph-pattern combinators
|
|
1081
|
-
* (UNION / OPTIONAL / MINUS / EXISTS / NOT EXISTS) folded over the base
|
|
1082
|
-
* patterns. The complement to {@link sparql}: this route carries the
|
|
1083
|
-
* combinators (but not FILTER/aggregation), so use it when a query needs an
|
|
1084
|
-
* optional/union/negated leg rather than a grouped aggregate.
|
|
1085
|
-
*/
|
|
1086
|
-
analytics(body) {
|
|
1087
|
-
return this.request("POST", "/v1/query/analytics", { body });
|
|
1088
|
-
}
|
|
1089
956
|
// --- ontology ---
|
|
1090
957
|
/**
|
|
1091
958
|
* The active ontology (entity types and relations) for the scoped graph.
|
|
@@ -1167,9 +1034,7 @@ export class LbbClient {
|
|
|
1167
1034
|
lineage.bm25_indexed_commit_seq != null &&
|
|
1168
1035
|
lineage.bm25_indexed_commit_seq >= targetSeq &&
|
|
1169
1036
|
lineage.ann_indexed_commit_seq != null &&
|
|
1170
|
-
lineage.ann_indexed_commit_seq >= targetSeq
|
|
1171
|
-
lineage.adjacency_indexed_commit_seq != null &&
|
|
1172
|
-
lineage.adjacency_indexed_commit_seq >= targetSeq) {
|
|
1037
|
+
lineage.ann_indexed_commit_seq >= targetSeq) {
|
|
1173
1038
|
return {
|
|
1174
1039
|
metadata: last.data,
|
|
1175
1040
|
lineage,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { LbbCapabilityError, LbbClient, LbbError, parseSparqlResults, } from "./client.js";
|
|
2
|
-
export type { DurableImportLine, DurableImportSource, LbbClientOptions, CallOptions, RequestOptions,
|
|
2
|
+
export type { DurableImportLine, DurableImportSource, LbbClientOptions, CallOptions, RequestOptions, LbbRequestEvent, LbbResponseEvent, FetchLike, ReadConsistencyOptions, SearchConsistency, Schemas, SparqlResults, SparqlResultsJson, SparqlTerm, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, Snapshot, } from "./client.js";
|
|
3
3
|
export type { components, paths, operations } from "./schema.js";
|
package/dist/namespaces.d.ts
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
import type { LbbClient } from "./client.js";
|
|
2
2
|
import type { CallOptions } from "./transport.js";
|
|
3
3
|
import { type EntityAttributeFilterOptions, type ImportLine, type ReadConsistencyOptions, type RdfImportOptions, type Schemas } from "./types.js";
|
|
4
|
-
export interface HybridSearchOptions extends CallOptions {
|
|
5
|
-
topK?: number;
|
|
6
|
-
consistency?: string;
|
|
7
|
-
/** A5 read-your-writes floor (`min_indexed_seq`): the committed sequence a
|
|
8
|
-
* write returned; under eventual, an uncovered floor yields a retryable
|
|
9
|
-
* `read_your_writes_pending` 429. */
|
|
10
|
-
minIndexedSeq?: number;
|
|
11
|
-
lexical?: boolean;
|
|
12
|
-
bm25?: boolean;
|
|
13
|
-
vector?: boolean;
|
|
14
|
-
targets?: string[];
|
|
15
|
-
profile?: string;
|
|
16
|
-
/** Opt-in impression logging for later relevance feedback. */
|
|
17
|
-
logImpression?: boolean;
|
|
18
|
-
}
|
|
19
4
|
export declare class GraphNamespace {
|
|
20
5
|
private readonly client;
|
|
21
6
|
readonly facts: FactsNamespace;
|
|
22
|
-
readonly context: ContextNamespace;
|
|
23
7
|
readonly entities: EntityNamespace;
|
|
24
8
|
readonly ontology: OntologyNamespace;
|
|
25
9
|
readonly query: QueryNamespace;
|
|
@@ -34,32 +18,6 @@ export declare class GraphNamespace {
|
|
|
34
18
|
deleteBranch(opts: {
|
|
35
19
|
confirm: string;
|
|
36
20
|
} & CallOptions): Promise<Schemas["GraphBranchDeleteResponse"]>;
|
|
37
|
-
embeddingConfig(opts?: CallOptions): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
38
|
-
/** List the embedding models available on this deployment. */
|
|
39
|
-
embeddingModels(opts?: CallOptions): Promise<Schemas["ManagedEmbeddingModelsResponse"]>;
|
|
40
|
-
/** Choose the model used automatically for writes and vector queries. */
|
|
41
|
-
setEmbeddingModel(modelId: string, options?: CallOptions & {
|
|
42
|
-
autoEmbedQuery?: boolean;
|
|
43
|
-
}): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
44
|
-
/** Advanced configuration escape hatch. Prefer `setEmbeddingModel`. */
|
|
45
|
-
setEmbeddingConfig(body: Schemas["ManagedEmbeddingConfigRequest"], opts?: CallOptions): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
46
|
-
backfillEmbeddings(options?: CallOptions & {
|
|
47
|
-
batchSize?: number;
|
|
48
|
-
limit?: number;
|
|
49
|
-
full?: boolean;
|
|
50
|
-
pollIntervalMs?: number;
|
|
51
|
-
}): Promise<Schemas["ManagedEmbeddingBackfillResponse"]>;
|
|
52
|
-
submitEmbeddingBackfill(options?: CallOptions & {
|
|
53
|
-
batchSize?: number;
|
|
54
|
-
limit?: number;
|
|
55
|
-
full?: boolean;
|
|
56
|
-
}): Promise<Schemas["ManagedEmbeddingBackfillJobStatusResponse"]>;
|
|
57
|
-
embeddingBackfillJob(jobId: string): Promise<Schemas["ManagedEmbeddingBackfillJobStatusResponse"]>;
|
|
58
|
-
cancelEmbeddingBackfill(jobId: string): Promise<Schemas["ManagedEmbeddingBackfillJobStatusResponse"]>;
|
|
59
|
-
promoteEmbedding(options: CallOptions & {
|
|
60
|
-
runId: string;
|
|
61
|
-
allowRegression?: boolean;
|
|
62
|
-
}): Promise<Schemas["ManagedEmbeddingPromoteResponse"]>;
|
|
63
21
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
64
22
|
retract(body: Schemas["GraphRetractRequest"], opts?: CallOptions): Promise<Schemas["GraphRetractResponse"]>;
|
|
65
23
|
}
|
|
@@ -82,25 +40,23 @@ export declare class FactsNamespace {
|
|
|
82
40
|
*/
|
|
83
41
|
importRdf(rdf: string, opts?: CallOptions & RdfImportOptions): Promise<Schemas["GraphRdfImportResponse"]>;
|
|
84
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Relevance-label storage. The query surfaces this namespace once fronted were
|
|
45
|
+
* removed with their routes; SPARQL is the only query path now.
|
|
46
|
+
*/
|
|
85
47
|
export declare class SearchNamespace {
|
|
86
48
|
private readonly client;
|
|
87
49
|
constructor(client: LbbClient);
|
|
88
|
-
hybrid(query: string, opts?: HybridSearchOptions): Promise<Schemas["SemanticGraphSearchResponse"]>;
|
|
89
|
-
hybrid(body: Schemas["SemanticGraphSearchRequest"], opts?: CallOptions): Promise<Schemas["SemanticGraphSearchResponse"]>;
|
|
90
|
-
multi(body: Schemas["HybridMultiSearchRequest"], opts?: CallOptions): Promise<Schemas["HybridMultiSearchResponse"]>;
|
|
91
50
|
feedback(body: Schemas["SearchFeedbackRequest"], opts?: CallOptions): Promise<Schemas["SearchFeedbackResponse"]>;
|
|
92
51
|
feedbackExport(opts?: CallOptions): Promise<Schemas["SearchFeedbackExportResponse"]>;
|
|
93
52
|
feedbackSummary(opts?: CallOptions): Promise<Schemas["SearchFeedbackSummaryResponse"]>;
|
|
94
|
-
fullText(body: Schemas["FullTextSearchRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["FullTextSearchResponse"]>;
|
|
95
|
-
vector(body: Schemas["EmbeddingSearchRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["EmbeddingSearchResponse"]>;
|
|
96
53
|
}
|
|
97
54
|
export declare class EntityNamespace {
|
|
98
55
|
private readonly client;
|
|
99
56
|
constructor(client: LbbClient);
|
|
100
57
|
/**
|
|
101
58
|
* Return the exact type cardinality and a bounded deterministic sample from
|
|
102
|
-
* the
|
|
103
|
-
* family fails closed rather than falling back to an exhaustive scan.
|
|
59
|
+
* the Base family pinned by the published generation.
|
|
104
60
|
*/
|
|
105
61
|
sample(opts: {
|
|
106
62
|
type: string;
|
|
@@ -125,17 +81,6 @@ export declare class EntityNamespace {
|
|
|
125
81
|
*/
|
|
126
82
|
filterByAttributes(opts: EntityAttributeFilterOptions): Promise<Schemas["SparqlSelectResponse"]>;
|
|
127
83
|
}
|
|
128
|
-
/** Grounding operations over one pinned published vocabulary. */
|
|
129
|
-
export declare class ContextNamespace {
|
|
130
|
-
private readonly client;
|
|
131
|
-
constructor(client: LbbClient);
|
|
132
|
-
suggest(body: Schemas["SearchSuggestRequest"], opts?: CallOptions): Promise<Schemas["SearchSuggestResponse"]>;
|
|
133
|
-
resolve(body: Schemas["ResolveTermRequest"], opts?: CallOptions): Promise<Schemas["ResolveTermResponse"]>;
|
|
134
|
-
decode(body: Schemas["DecodeRequest"], opts?: CallOptions): Promise<Schemas["DecodeResponse"]>;
|
|
135
|
-
groundability(options?: {
|
|
136
|
-
sample?: number;
|
|
137
|
-
} & CallOptions): Promise<Schemas["GroundabilityReport"]>;
|
|
138
|
-
}
|
|
139
84
|
/** Active ontology/SHACL bundle metadata and atomic publication. */
|
|
140
85
|
export declare class SchemaNamespace {
|
|
141
86
|
private readonly client;
|
|
@@ -159,12 +104,11 @@ export declare class OntologyNamespace {
|
|
|
159
104
|
evolve(body: Schemas["OntologyEvolveRequest"], opts?: CallOptions): Promise<Schemas["OntologyEvolveResponse"]>;
|
|
160
105
|
induce(body: Schemas["OntologyInduceRequest"], opts?: CallOptions): Promise<Schemas["OntologyInduceResponse"]>;
|
|
161
106
|
}
|
|
162
|
-
/** Structured
|
|
107
|
+
/** Structured and SPARQL-text query operations. */
|
|
163
108
|
export declare class QueryNamespace {
|
|
164
109
|
private readonly client;
|
|
165
110
|
constructor(client: LbbClient);
|
|
166
111
|
structured(body: Schemas["SparqlSelectRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["SparqlSelectResponse"]>;
|
|
167
112
|
sparql(body: Schemas["SparqlTextRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<import("./types.js").SparqlResults>;
|
|
168
113
|
sparqlRaw(body: Schemas["SparqlTextRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["SparqlTextResponse"]>;
|
|
169
|
-
analytics(body: Schemas["AnalyticQueryRequest"], opts?: CallOptions): Promise<Schemas["AnalyticQueryResponse"]>;
|
|
170
114
|
}
|