@littlebigbrain/client 0.13.1 → 0.14.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 +103 -88
- package/dist/client.d.ts +13 -52
- package/dist/client.js +17 -68
- package/dist/namespaces.d.ts +87 -7
- package/dist/namespaces.js +177 -15
- package/dist/schema.d.ts +4014 -759
- package/dist/types.d.ts +0 -2
- package/package.json +2 -2
package/dist/namespaces.d.ts
CHANGED
|
@@ -9,11 +9,12 @@ export declare class GraphNamespace {
|
|
|
9
9
|
readonly query: QueryNamespace;
|
|
10
10
|
readonly schema: SchemaNamespace;
|
|
11
11
|
readonly search: SearchNamespace;
|
|
12
|
+
readonly evals: EvalsNamespace;
|
|
13
|
+
readonly embeddings: EmbeddingsNamespace;
|
|
12
14
|
constructor(client: LbbClient);
|
|
13
|
-
|
|
14
|
-
/** Publication lifecycle for this graph/branch, including pre-first-publish state. */
|
|
15
|
+
/** Publication lifecycle for this graph, including pre-first-publish state. */
|
|
15
16
|
publicationStatus(): Promise<Schemas["PublicationStatusResponse"]>;
|
|
16
|
-
/** Wait until this graph
|
|
17
|
+
/** Wait until this graph has an exact generation covering `targetSeq`. */
|
|
17
18
|
waitForPublished(targetSeq: number, opts?: {
|
|
18
19
|
timeoutMs?: number;
|
|
19
20
|
pollIntervalMs?: number;
|
|
@@ -22,9 +23,6 @@ export declare class GraphNamespace {
|
|
|
22
23
|
delete(opts: {
|
|
23
24
|
confirm: string;
|
|
24
25
|
} & CallOptions): Promise<Schemas["GraphDeleteResponse"]>;
|
|
25
|
-
deleteBranch(opts: {
|
|
26
|
-
confirm: string;
|
|
27
|
-
} & CallOptions): Promise<Schemas["GraphBranchDeleteResponse"]>;
|
|
28
26
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
29
27
|
retract(body: Schemas["GraphRetractRequest"], opts?: CallOptions): Promise<Schemas["GraphRetractResponse"]>;
|
|
30
28
|
}
|
|
@@ -51,7 +49,7 @@ export declare class FactsNamespace {
|
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
51
|
* Relevance-label storage. The query surfaces this namespace once fronted were
|
|
54
|
-
* removed with their routes;
|
|
52
|
+
* removed with their routes; search by meaning is `embeddings.search`.
|
|
55
53
|
*/
|
|
56
54
|
export declare class SearchNamespace {
|
|
57
55
|
private readonly client;
|
|
@@ -86,6 +84,88 @@ export declare class EntityNamespace {
|
|
|
86
84
|
*/
|
|
87
85
|
filterByAttributes(opts: EntityAttributeFilterOptions): Promise<Schemas["SparqlSelectResponse"]>;
|
|
88
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Search: embeddings declared on classes of the graph. The platform keeps the
|
|
89
|
+
* vectors in step with the published graph; a search checks every hit against
|
|
90
|
+
* one graph snapshot.
|
|
91
|
+
*/
|
|
92
|
+
export declare class EmbeddingsNamespace {
|
|
93
|
+
private readonly client;
|
|
94
|
+
constructor(client: LbbClient);
|
|
95
|
+
/** Every embedding of the graph with its status. */
|
|
96
|
+
list(opts?: CallOptions): Promise<Schemas["EmbeddingListResponse"]>;
|
|
97
|
+
/** One embedding: serving and building version, backfill, lag, recall. */
|
|
98
|
+
get(name: string, opts?: CallOptions): Promise<Schemas["EmbeddingStatus"]>;
|
|
99
|
+
/**
|
|
100
|
+
* Declare or change the embedding of a class. Without `from` the server
|
|
101
|
+
* picks the fields (the label, frequent text, the names of linked
|
|
102
|
+
* entities). A new recipe builds as a new version while the old one serves.
|
|
103
|
+
*/
|
|
104
|
+
declare(body: Schemas["EmbeddingDeclareRequest"], opts?: CallOptions): Promise<Schemas["EmbeddingStatus"]>;
|
|
105
|
+
/**
|
|
106
|
+
* What a declaration would embed: the fields, every candidate fact of the
|
|
107
|
+
* class with its coverage and examples, and sample texts. Calls no model.
|
|
108
|
+
*/
|
|
109
|
+
preview(body: Schemas["EmbeddingPreviewRequest"], opts?: CallOptions): Promise<Schemas["EmbeddingPreviewResponse"]>;
|
|
110
|
+
/**
|
|
111
|
+
* Move every embedding of the graph to another model (one model per
|
|
112
|
+
* graph). Each builds a new version; the graph switches at once when
|
|
113
|
+
* every embedding has it ready, so a search never mixes two models.
|
|
114
|
+
*/
|
|
115
|
+
setModel(body: Schemas["EmbeddingModelRequest"], opts?: CallOptions): Promise<Schemas["EmbeddingListResponse"]>;
|
|
116
|
+
/** Run one bounded step of the embed job now. */
|
|
117
|
+
refresh(name: string, opts?: CallOptions): Promise<Schemas["EmbeddingRefreshResponse"]>;
|
|
118
|
+
/** Remove an embedding. */
|
|
119
|
+
delete(name: string, opts?: CallOptions): Promise<unknown>;
|
|
120
|
+
/**
|
|
121
|
+
* Search by meaning over every searchable class of the graph (or one
|
|
122
|
+
* `embedding`). `filter` lists the conditions every hit must meet:
|
|
123
|
+
* `{ class: iri }` (or a list; subclasses too) and
|
|
124
|
+
* `{ via: "calls", to: "payment-service", direction?: "in" }` (`to` an IRI
|
|
125
|
+
* or a name). Every hit carries its class and is checked against one
|
|
126
|
+
* graph snapshot; `include: ["text"]` returns the embedded text of each
|
|
127
|
+
* hit; `explain: true` plans without running.
|
|
128
|
+
*/
|
|
129
|
+
search(body: Schemas["SearchRequest"], opts?: CallOptions): Promise<Schemas["SearchResponse"]>;
|
|
130
|
+
}
|
|
131
|
+
/** Managed evals: traces, labels (thumbs up or down), goldens, and runs. */
|
|
132
|
+
export declare class EvalsNamespace {
|
|
133
|
+
private readonly client;
|
|
134
|
+
constructor(client: LbbClient);
|
|
135
|
+
/** Settings, golden counts, unlabeled traces, the latest run, and the score by commit. */
|
|
136
|
+
summary(opts?: CallOptions): Promise<Schemas["EvalSummaryResponse"]>;
|
|
137
|
+
/** Recent traces, newest first. */
|
|
138
|
+
traces(options?: {
|
|
139
|
+
limit?: number;
|
|
140
|
+
unlabeled?: boolean;
|
|
141
|
+
} & CallOptions): Promise<Schemas["EvalTraceListResponse"]>;
|
|
142
|
+
/** One trace: the request, its query, its results (one item per hit or
|
|
143
|
+
* row), and their labels. */
|
|
144
|
+
trace(id: string, opts?: CallOptions): Promise<Schemas["EvalTrace"]>;
|
|
145
|
+
/** Thumbs up or down on results of a trace: one result as `item` +
|
|
146
|
+
* `valid`, or several in `items`. The labels become the golden's ground
|
|
147
|
+
* truth. */
|
|
148
|
+
label(traceId: string, body: Schemas["EvalLabelRequest"], opts?: CallOptions): Promise<Schemas["EvalLabelResponse"]>;
|
|
149
|
+
/** Let the managed judge label the results of one trace, or of a batch of
|
|
150
|
+
* traces with unlabeled results. */
|
|
151
|
+
judge(options?: {
|
|
152
|
+
traceId?: string;
|
|
153
|
+
limit?: number;
|
|
154
|
+
} & CallOptions): Promise<Schemas["EvalJudgeResponse"]>;
|
|
155
|
+
goldens(opts?: CallOptions): Promise<Schemas["GoldenSuite"]>;
|
|
156
|
+
/** Freeze a query: every result it returns now is relevant. */
|
|
157
|
+
createGolden(body: Schemas["GoldenCreateRequest"], opts?: CallOptions): Promise<Schemas["GoldenResponse"]>;
|
|
158
|
+
/** Accept the results a golden returns now as its reference. */
|
|
159
|
+
acceptGolden(id: string, opts?: CallOptions & Pick<ReadConsistencyOptions, "consistency">): Promise<Schemas["GoldenResponse"]>;
|
|
160
|
+
deleteGolden(id: string, opts?: CallOptions): Promise<Schemas["GoldenDeleteResponse"]>;
|
|
161
|
+
/** Replay every golden at the current commit. */
|
|
162
|
+
run(opts?: CallOptions & Pick<ReadConsistencyOptions, "consistency">): Promise<Schemas["EvalRunResponse"]>;
|
|
163
|
+
results(options?: {
|
|
164
|
+
limit?: number;
|
|
165
|
+
} & CallOptions): Promise<Schemas["EvalResultsListResponse"]>;
|
|
166
|
+
settings(opts?: CallOptions): Promise<Schemas["EvalSettings"]>;
|
|
167
|
+
setSettings(body: Schemas["EvalSettings"], opts?: CallOptions): Promise<Schemas["EvalSettings"]>;
|
|
168
|
+
}
|
|
89
169
|
/** Active ontology/SHACL bundle metadata and atomic publication. */
|
|
90
170
|
export declare class SchemaNamespace {
|
|
91
171
|
private readonly client;
|
package/dist/namespaces.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { attributeFilter, firstPatternVariable, parseSparqlResults, } from "./types.js";
|
|
2
|
-
// SPARQL is the
|
|
3
|
-
//
|
|
2
|
+
// SPARQL is the query language. Search by meaning is `embeddings.search`
|
|
3
|
+
// (`POST /v1/search`); the older search, embedding, decode, groundability,
|
|
4
|
+
// and analytics operations were removed with their routes.
|
|
4
5
|
/** A5: fold read-consistency options into a request body's `consistency` /
|
|
5
6
|
* `min_indexed_seq` fields; a per-call value wins over the client default. */
|
|
6
7
|
function withReadConsistency(client, body, opts) {
|
|
@@ -23,6 +24,8 @@ export class GraphNamespace {
|
|
|
23
24
|
query;
|
|
24
25
|
schema;
|
|
25
26
|
search;
|
|
27
|
+
evals;
|
|
28
|
+
embeddings;
|
|
26
29
|
constructor(client) {
|
|
27
30
|
this.client = client;
|
|
28
31
|
this.facts = new FactsNamespace(client);
|
|
@@ -31,15 +34,14 @@ export class GraphNamespace {
|
|
|
31
34
|
this.query = client.query;
|
|
32
35
|
this.schema = client.schema;
|
|
33
36
|
this.search = client.search;
|
|
37
|
+
this.evals = client.evals;
|
|
38
|
+
this.embeddings = client.embeddings;
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
return new GraphNamespace(this.client.withScope({ branch: name }));
|
|
37
|
-
}
|
|
38
|
-
/** Publication lifecycle for this graph/branch, including pre-first-publish state. */
|
|
40
|
+
/** Publication lifecycle for this graph, including pre-first-publish state. */
|
|
39
41
|
publicationStatus() {
|
|
40
42
|
return this.client.publicationStatus();
|
|
41
43
|
}
|
|
42
|
-
/** Wait until this graph
|
|
44
|
+
/** Wait until this graph has an exact generation covering `targetSeq`. */
|
|
43
45
|
waitForPublished(targetSeq, opts = {}) {
|
|
44
46
|
return this.client.waitForPublished(targetSeq, opts);
|
|
45
47
|
}
|
|
@@ -54,13 +56,6 @@ export class GraphNamespace {
|
|
|
54
56
|
retry: request.retry ?? true,
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
|
-
deleteBranch(opts) {
|
|
58
|
-
const { confirm, ...request } = opts;
|
|
59
|
-
return this.client.request("DELETE", "/v1/graph/branch", {
|
|
60
|
-
...request,
|
|
61
|
-
query: { confirm },
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
59
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
65
60
|
retract(body, opts = {}) {
|
|
66
61
|
return this.client.request("POST", "/v1/graph/retract", {
|
|
@@ -135,7 +130,7 @@ export class FactsNamespace {
|
|
|
135
130
|
}
|
|
136
131
|
/**
|
|
137
132
|
* Relevance-label storage. The query surfaces this namespace once fronted were
|
|
138
|
-
* removed with their routes;
|
|
133
|
+
* removed with their routes; search by meaning is `embeddings.search`.
|
|
139
134
|
*/
|
|
140
135
|
export class SearchNamespace {
|
|
141
136
|
client;
|
|
@@ -199,6 +194,173 @@ export class EntityNamespace {
|
|
|
199
194
|
});
|
|
200
195
|
}
|
|
201
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Search: embeddings declared on classes of the graph. The platform keeps the
|
|
199
|
+
* vectors in step with the published graph; a search checks every hit against
|
|
200
|
+
* one graph snapshot.
|
|
201
|
+
*/
|
|
202
|
+
export class EmbeddingsNamespace {
|
|
203
|
+
client;
|
|
204
|
+
constructor(client) {
|
|
205
|
+
this.client = client;
|
|
206
|
+
}
|
|
207
|
+
/** Every embedding of the graph with its status. */
|
|
208
|
+
list(opts = {}) {
|
|
209
|
+
return this.client.request("GET", "/v1/embeddings", opts);
|
|
210
|
+
}
|
|
211
|
+
/** One embedding: serving and building version, backfill, lag, recall. */
|
|
212
|
+
get(name, opts = {}) {
|
|
213
|
+
return this.client.request("GET", "/v1/embeddings", {
|
|
214
|
+
...opts,
|
|
215
|
+
query: { name },
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Declare or change the embedding of a class. Without `from` the server
|
|
220
|
+
* picks the fields (the label, frequent text, the names of linked
|
|
221
|
+
* entities). A new recipe builds as a new version while the old one serves.
|
|
222
|
+
*/
|
|
223
|
+
declare(body, opts = {}) {
|
|
224
|
+
return this.client.request("PUT", "/v1/embeddings", { ...opts, body });
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* What a declaration would embed: the fields, every candidate fact of the
|
|
228
|
+
* class with its coverage and examples, and sample texts. Calls no model.
|
|
229
|
+
*/
|
|
230
|
+
preview(body, opts = {}) {
|
|
231
|
+
return this.client.request("POST", "/v1/embeddings/preview", {
|
|
232
|
+
...opts,
|
|
233
|
+
body,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Move every embedding of the graph to another model (one model per
|
|
238
|
+
* graph). Each builds a new version; the graph switches at once when
|
|
239
|
+
* every embedding has it ready, so a search never mixes two models.
|
|
240
|
+
*/
|
|
241
|
+
setModel(body, opts = {}) {
|
|
242
|
+
return this.client.request("PUT", "/v1/embeddings/model", {
|
|
243
|
+
...opts,
|
|
244
|
+
body,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** Run one bounded step of the embed job now. */
|
|
248
|
+
refresh(name, opts = {}) {
|
|
249
|
+
return this.client.request("POST", "/v1/embeddings/refresh", {
|
|
250
|
+
...opts,
|
|
251
|
+
query: { name },
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/** Remove an embedding. */
|
|
255
|
+
delete(name, opts = {}) {
|
|
256
|
+
return this.client.request("DELETE", "/v1/embeddings", {
|
|
257
|
+
...opts,
|
|
258
|
+
query: { name, confirm: name },
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Search by meaning over every searchable class of the graph (or one
|
|
263
|
+
* `embedding`). `filter` lists the conditions every hit must meet:
|
|
264
|
+
* `{ class: iri }` (or a list; subclasses too) and
|
|
265
|
+
* `{ via: "calls", to: "payment-service", direction?: "in" }` (`to` an IRI
|
|
266
|
+
* or a name). Every hit carries its class and is checked against one
|
|
267
|
+
* graph snapshot; `include: ["text"]` returns the embedded text of each
|
|
268
|
+
* hit; `explain: true` plans without running.
|
|
269
|
+
*/
|
|
270
|
+
search(body, opts = {}) {
|
|
271
|
+
return this.client.request("POST", "/v1/search", {
|
|
272
|
+
...opts,
|
|
273
|
+
retry: opts.retry ?? true,
|
|
274
|
+
body,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** Managed evals: traces, labels (thumbs up or down), goldens, and runs. */
|
|
279
|
+
export class EvalsNamespace {
|
|
280
|
+
client;
|
|
281
|
+
constructor(client) {
|
|
282
|
+
this.client = client;
|
|
283
|
+
}
|
|
284
|
+
/** Settings, golden counts, unlabeled traces, the latest run, and the score by commit. */
|
|
285
|
+
summary(opts = {}) {
|
|
286
|
+
return this.client.request("GET", "/v1/evals", opts);
|
|
287
|
+
}
|
|
288
|
+
/** Recent traces, newest first. */
|
|
289
|
+
traces(options = {}) {
|
|
290
|
+
const { limit, unlabeled, ...opts } = options;
|
|
291
|
+
return this.client.request("GET", "/v1/evals/traces", {
|
|
292
|
+
...opts,
|
|
293
|
+
query: { limit, unlabeled: unlabeled ? "true" : undefined },
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/** One trace: the request, its query, its results (one item per hit or
|
|
297
|
+
* row), and their labels. */
|
|
298
|
+
trace(id, opts = {}) {
|
|
299
|
+
return this.client.request("GET", "/v1/evals/trace", {
|
|
300
|
+
...opts,
|
|
301
|
+
query: { id },
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
/** Thumbs up or down on results of a trace: one result as `item` +
|
|
305
|
+
* `valid`, or several in `items`. The labels become the golden's ground
|
|
306
|
+
* truth. */
|
|
307
|
+
label(traceId, body, opts = {}) {
|
|
308
|
+
return this.client.request("POST", "/v1/evals/label", {
|
|
309
|
+
...opts,
|
|
310
|
+
query: { trace: traceId },
|
|
311
|
+
body,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/** Let the managed judge label the results of one trace, or of a batch of
|
|
315
|
+
* traces with unlabeled results. */
|
|
316
|
+
judge(options = {}) {
|
|
317
|
+
const { traceId, limit, ...opts } = options;
|
|
318
|
+
return this.client.request("POST", "/v1/evals/judge", {
|
|
319
|
+
...opts,
|
|
320
|
+
query: { trace: traceId, limit },
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
goldens(opts = {}) {
|
|
324
|
+
return this.client.request("GET", "/v1/evals/goldens", opts);
|
|
325
|
+
}
|
|
326
|
+
/** Freeze a query: every result it returns now is relevant. */
|
|
327
|
+
createGolden(body, opts = {}) {
|
|
328
|
+
return this.client.request("POST", "/v1/evals/goldens", { ...opts, body });
|
|
329
|
+
}
|
|
330
|
+
/** Accept the results a golden returns now as its reference. */
|
|
331
|
+
acceptGolden(id, opts = {}) {
|
|
332
|
+
return this.client.request("POST", "/v1/evals/goldens/accept", {
|
|
333
|
+
...opts,
|
|
334
|
+
query: { id, consistency: opts.consistency },
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
deleteGolden(id, opts = {}) {
|
|
338
|
+
return this.client.request("DELETE", "/v1/evals/goldens", {
|
|
339
|
+
...opts,
|
|
340
|
+
query: { id },
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/** Replay every golden at the current commit. */
|
|
344
|
+
run(opts = {}) {
|
|
345
|
+
return this.client.request("POST", "/v1/evals/run", {
|
|
346
|
+
...opts,
|
|
347
|
+
query: { consistency: opts.consistency },
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
results(options = {}) {
|
|
351
|
+
const { limit, ...opts } = options;
|
|
352
|
+
return this.client.request("GET", "/v1/evals/results", {
|
|
353
|
+
...opts,
|
|
354
|
+
query: { limit },
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
settings(opts = {}) {
|
|
358
|
+
return this.client.request("GET", "/v1/evals/settings", opts);
|
|
359
|
+
}
|
|
360
|
+
setSettings(body, opts = {}) {
|
|
361
|
+
return this.client.request("PUT", "/v1/evals/settings", { ...opts, body });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
202
364
|
/** Active ontology/SHACL bundle metadata and atomic publication. */
|
|
203
365
|
export class SchemaNamespace {
|
|
204
366
|
client;
|