@squidcloud/client 1.0.481 → 1.0.483
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/cjs/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/internal-common/src/public-types/ai-agent-integrations.public-types.d.ts +7 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +32 -0
- package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +4 -4
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +655 -4
- package/dist/internal-common/src/public-types/ai-matchmaking.public-types.d.ts +4 -3
- package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +6 -0
- package/dist/internal-common/src/public-types/connector.public-types.d.ts +1 -1
- package/dist/internal-common/src/public-types/extraction.public-types.d.ts +120 -1
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +1 -1
- package/dist/internal-common/src/public-types/langgraph.public-types.d.ts +40 -0
- package/dist/internal-common/src/public-types/metadata-filter.public-types.d.ts +6 -2
- package/dist/internal-common/src/public-types/web.public-types.d.ts +5 -0
- package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +34 -1
- package/dist/typescript-client/src/index.d.ts +1 -0
- package/dist/typescript-client/src/langgraph-client.d.ts +62 -0
- package/dist/typescript-client/src/public-types.d.ts +1 -0
- package/dist/typescript-client/src/squid.d.ts +6 -0
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/dist/typescript-client/src/web-client.d.ts +12 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { AgentContextRequest, AiChatModelSelection, UpsertContextStatusError } f
|
|
|
2
2
|
import { AiEmbeddingsModelSelection, AiRerankProvider } from './ai-common.public-types';
|
|
3
3
|
import { AiContextId, AiKnowledgeBaseId, AppId } from './communication.public-types';
|
|
4
4
|
import { DocumentExtractionMethod } from './extraction.public-types';
|
|
5
|
-
import { MetadataAndFilter, MetadataFieldFilter,
|
|
5
|
+
import { MetadataAndFilter, MetadataFieldFilter, MetadataOrFilter, MetadataSimpleFilter, MetadataValue, MetadataValueArray } from './metadata-filter.public-types';
|
|
6
6
|
/**
|
|
7
7
|
* The set of supported vector store backends for a knowledge base. The authoritative backend for a
|
|
8
8
|
* given KB is persisted on its record; reads/writes route through the matching vector provider.
|
|
@@ -37,6 +37,23 @@ export interface AiKnowledgeBase {
|
|
|
37
37
|
* Optional on the read type for backwards compatibility with older records.
|
|
38
38
|
*/
|
|
39
39
|
vectorDbType?: VectorDbType;
|
|
40
|
+
/**
|
|
41
|
+
* Opt-in GraphRAG configuration. Only honored for `vectorDbType:'mongoAtlas'` KBs; enables
|
|
42
|
+
* per-chunk entity/relationship extraction at ingest and `searchMode:'graph'` at query time.
|
|
43
|
+
*/
|
|
44
|
+
graphRag?: AiKnowledgeBaseGraphConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Default RAG strategy for newly ingested contexts; a per-request `options.ragType` overrides it.
|
|
47
|
+
* Omitted ⇒ the server default (`'basic'`). Changing it affects future ingests only — existing chunks
|
|
48
|
+
* are not re-processed.
|
|
49
|
+
*/
|
|
50
|
+
ragType?: AiRagType;
|
|
51
|
+
/**
|
|
52
|
+
* Lifetime LLM usage of the contextual-RAG situating-blurb calls on this KB (server-managed; ignored
|
|
53
|
+
* on upsert). Persisted on the KB itself so the record survives Core restarts and covers any vector
|
|
54
|
+
* store. Under the combined-ingest strategy this stays ≈0 — growth is a visible fallback-rate signal.
|
|
55
|
+
*/
|
|
56
|
+
contextualIngestUsage?: KnowledgeBaseGraphUsage;
|
|
40
57
|
/** The timestamp the knowledge base was last updated */
|
|
41
58
|
updatedAt: Date;
|
|
42
59
|
}
|
|
@@ -66,6 +83,13 @@ export interface AiKnowledgeBaseMetadataField {
|
|
|
66
83
|
* false once a human edits the description.
|
|
67
84
|
*/
|
|
68
85
|
descriptionGeneratedByAi?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the LLM extraction pass may fill this field when it is missing. Defaults to `true` when
|
|
88
|
+
* undefined, so knowledge bases created before this flag existed keep their behavior. Set to `false`
|
|
89
|
+
* for fields whose value the caller supplies deterministically (e.g. folder-derived path metadata): a
|
|
90
|
+
* missing value then stays absent rather than being guessed from the document.
|
|
91
|
+
*/
|
|
92
|
+
llmExtraction?: boolean;
|
|
69
93
|
}
|
|
70
94
|
/**
|
|
71
95
|
* A record of metadata key-value pairs for AI context, where values are primitive types or undefined.
|
|
@@ -113,9 +137,120 @@ export type AiContextMetadataOrFilter = MetadataOrFilter;
|
|
|
113
137
|
* - `'keyword'`: embedding-free lexical retrieval; the mechanism is backend-specific — native Lucene BM25
|
|
114
138
|
* on Mongo Atlas (ranked, term-optional: a partial-term query still matches), and a boolean substring
|
|
115
139
|
* filter on pgvector (every term must appear literally; unranked).
|
|
140
|
+
* - `'graph'`: GraphRAG retrieval — seeds entities via vector search, expands relationships via graph
|
|
141
|
+
* traversal, then maps entities back to their source chunks, RRF-fused with a standard hybrid search.
|
|
142
|
+
* Only available on `vectorDbType:'mongoAtlas'` KBs with `graphRag.enabled`; tuned via
|
|
143
|
+
* {@link AiKnowledgeBaseGraphSearchOptions}. This is the DEFAULT mode when a search omits `searchMode`
|
|
144
|
+
* on a `graphRag.enabled` KB (non-graph KBs default to `'hybrid'`).
|
|
116
145
|
* @category AI
|
|
117
146
|
*/
|
|
118
|
-
export type AiKnowledgeBaseSearchMode = 'vector' | 'hybrid' | 'keyword';
|
|
147
|
+
export type AiKnowledgeBaseSearchMode = 'vector' | 'hybrid' | 'keyword' | 'graph';
|
|
148
|
+
/**
|
|
149
|
+
* Fine-grained options for `searchMode: 'graph'` retrieval (GraphRAG). The graph channel is always
|
|
150
|
+
* RRF-fused with a standard hybrid search; themes-level "global" answering has moved to the
|
|
151
|
+
* `globalSummary` op of the `queryKnowledgeGraph` surface.
|
|
152
|
+
* @category AI
|
|
153
|
+
*/
|
|
154
|
+
export interface AiKnowledgeBaseGraphSearchOptions {
|
|
155
|
+
/** Entities seeded via vector search before graph expansion. Default 8, max 25. */
|
|
156
|
+
seedLimit?: number;
|
|
157
|
+
/** Number of hops to expand from each seed (traversal depth + 1). Default 2, max 3. */
|
|
158
|
+
maxHops?: number;
|
|
159
|
+
/** When true, attach the traversed {@link AiKnowledgeBaseGraphContext} to the response. Default false. */
|
|
160
|
+
includeGraphContext?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Per-knowledge-base GraphRAG configuration. Opt-in and mutable (unlike `embeddingModel`/`vectorDbType`);
|
|
164
|
+
* only honored for `vectorDbType:'mongoAtlas'` KBs. Enabling it on a KB that already has content requires a
|
|
165
|
+
* graph backfill (the `rebuildGraph` endpoint).
|
|
166
|
+
* @category AI
|
|
167
|
+
*/
|
|
168
|
+
export interface AiKnowledgeBaseGraphConfig {
|
|
169
|
+
/** When true, ingestion extracts an entity/relationship graph and `searchMode:'graph'` becomes available. */
|
|
170
|
+
enabled: boolean;
|
|
171
|
+
/** Chat model used for per-chunk entity/relationship extraction. Defaults to the server's graph model. */
|
|
172
|
+
extractionModel?: AiChatModelSelection;
|
|
173
|
+
/** Optional domain taxonomy hint (entity types) injected into the extraction prompt. */
|
|
174
|
+
entityTypes?: string[];
|
|
175
|
+
/** Concept-layer (facet taxonomy) configuration. Omitted ⇒ `facets: 'auto'`. */
|
|
176
|
+
concepts?: AiKnowledgeBaseGraphConceptsConfig;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Configuration of the graph's concept layer (Layered KB Graph L3 facets — deterministic trees built
|
|
180
|
+
* from metadata values at rebuild).
|
|
181
|
+
* @category AI
|
|
182
|
+
*/
|
|
183
|
+
export interface AiKnowledgeBaseGraphConceptsConfig {
|
|
184
|
+
/**
|
|
185
|
+
* Which metadata fields become value facets (flat sets of categorical values). `'auto'` (the default)
|
|
186
|
+
* profiles the KB's context metadata and selects the categorical fields; an explicit list overrides
|
|
187
|
+
* auto-selection (fields still subject to the hard cardinality cap); `[]` disables value facets.
|
|
188
|
+
*/
|
|
189
|
+
facets?: string[] | 'auto';
|
|
190
|
+
/**
|
|
191
|
+
* Explicit path facets — deterministic trees split from a hierarchical path field (e.g. a folder path)
|
|
192
|
+
* rather than LLM-grouped. Independent of {@link facets}: a path facet always builds when its field has
|
|
193
|
+
* values, coexists with auto value-facet selection (reserved outside the facet cap), and is exempt from
|
|
194
|
+
* the categorical eligibility gates (a path field is near-unique by leaf). Omitted/`[]` ⇒ no path facets.
|
|
195
|
+
*/
|
|
196
|
+
pathFacets?: AiKnowledgeBaseGraphPathFacetConfig[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The canonical folder-path metadata field: a POSIX-separated path relative to the upload root, no
|
|
200
|
+
* leading/trailing slash, case-preserved. Stamped by folder-aware ingestion (console folder upload,
|
|
201
|
+
* SDK clients). Register it under `graphRag.concepts.pathFacets` (`[{ field: 'folderPath', type: 'path' }]`)
|
|
202
|
+
* to build a navigable folder tree in the graph — the field name is never treated specially on its own.
|
|
203
|
+
* @category AI
|
|
204
|
+
*/
|
|
205
|
+
export declare const FOLDER_PATH_METADATA_FIELD_NAME = "folderPath";
|
|
206
|
+
/**
|
|
207
|
+
* A path facet: a deterministic tree built by splitting a hierarchical path field on {@link separator}.
|
|
208
|
+
* Interior nodes are the path prefixes; scoping a search to one node matches that folder and everything
|
|
209
|
+
* beneath it. Exempt from the near-unique/cardinality eligibility gates (those judge flat value sets).
|
|
210
|
+
* Declared under {@link AiKnowledgeBaseGraphConceptsConfig.pathFacets}.
|
|
211
|
+
* @category AI
|
|
212
|
+
*/
|
|
213
|
+
export interface AiKnowledgeBaseGraphPathFacetConfig {
|
|
214
|
+
/** The metadata field holding the path values (e.g. `'folderPath'`). */
|
|
215
|
+
field: string;
|
|
216
|
+
/** Marks this as a path facet. */
|
|
217
|
+
type: 'path';
|
|
218
|
+
/** Path segment separator. Defaults to `'/'`. */
|
|
219
|
+
separator?: string;
|
|
220
|
+
}
|
|
221
|
+
/** A single entity surfaced in a graph search's {@link AiKnowledgeBaseGraphContext}. @category AI */
|
|
222
|
+
export interface AiKnowledgeBaseGraphContextEntity {
|
|
223
|
+
/** Canonical display name of the entity. */
|
|
224
|
+
name: string;
|
|
225
|
+
/** Entity type (e.g. PERSON, ORGANIZATION). */
|
|
226
|
+
type: string;
|
|
227
|
+
/** Compacted description of the entity. */
|
|
228
|
+
description: string;
|
|
229
|
+
/** Traversal relevance score in [0,1]. */
|
|
230
|
+
score: number;
|
|
231
|
+
}
|
|
232
|
+
/** A single relationship surfaced in a graph search's {@link AiKnowledgeBaseGraphContext}. @category AI */
|
|
233
|
+
export interface AiKnowledgeBaseGraphContextRelationship {
|
|
234
|
+
/** Source entity display name. */
|
|
235
|
+
source: string;
|
|
236
|
+
/** Target entity display name. */
|
|
237
|
+
target: string;
|
|
238
|
+
/** Relationship label (short verb phrase). */
|
|
239
|
+
type: string;
|
|
240
|
+
/** Optional description of the relationship. */
|
|
241
|
+
description?: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The subgraph traversed to answer a `searchMode:'graph'` query. Additive/optional — returned only when
|
|
245
|
+
* `graphOptions.includeGraphContext` is set; clients that ignore it are unaffected.
|
|
246
|
+
* @category AI
|
|
247
|
+
*/
|
|
248
|
+
export interface AiKnowledgeBaseGraphContext {
|
|
249
|
+
/** Entities reached by the traversal, sorted by score descending. */
|
|
250
|
+
entities: Array<AiKnowledgeBaseGraphContextEntity>;
|
|
251
|
+
/** Outgoing relationships between reached entities. */
|
|
252
|
+
relationships: Array<AiKnowledgeBaseGraphContextRelationship>;
|
|
253
|
+
}
|
|
119
254
|
/**
|
|
120
255
|
* The options for the AI knowledgebase search method.
|
|
121
256
|
* @category AI
|
|
@@ -152,6 +287,9 @@ export interface AiKnowledgeBaseChatOptions {
|
|
|
152
287
|
*
|
|
153
288
|
* Intended to let A/B evaluations compare dense-only, hybrid and boolean-keyword candidate generation
|
|
154
289
|
* on the same backend.
|
|
290
|
+
*
|
|
291
|
+
* When omitted, the default is `'graph'` (RRF-fused GraphRAG) on a `graphRag.enabled` KB and
|
|
292
|
+
* `'hybrid'` otherwise. See {@link AiKnowledgeBaseSearchMode}.
|
|
155
293
|
*/
|
|
156
294
|
searchMode?: AiKnowledgeBaseSearchMode;
|
|
157
295
|
/**
|
|
@@ -161,6 +299,27 @@ export interface AiKnowledgeBaseChatOptions {
|
|
|
161
299
|
* default). Useful for A/B evaluating dense-vs-keyword weighting on the same backend.
|
|
162
300
|
*/
|
|
163
301
|
hybridWeights?: AiHybridSearchWeights;
|
|
302
|
+
/** Tuning for `searchMode:'graph'` (GraphRAG). Ignored for other search modes. */
|
|
303
|
+
graphOptions?: AiKnowledgeBaseGraphSearchOptions;
|
|
304
|
+
/**
|
|
305
|
+
* Scopes the search to the documents under one concept of the KB's graph (Layered KB Graph).
|
|
306
|
+
* Composes with every `searchMode` and with `contextMetadataFilter`. Requires `graphRag.enabled`.
|
|
307
|
+
*/
|
|
308
|
+
graphFilter?: AiKnowledgeBaseGraphFilter;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Graph scope for a knowledge-base search: restricts results to the documents under one concept.
|
|
312
|
+
* @category AI
|
|
313
|
+
*/
|
|
314
|
+
export interface AiKnowledgeBaseGraphFilter {
|
|
315
|
+
/**
|
|
316
|
+
* The concept to scope to: a facet nodeId (`facet_…` — exact, the only persistable concept handles)
|
|
317
|
+
* or a concept name, resolved server-side (exact → alias → similarity). Facet scopes filter by exact
|
|
318
|
+
* metadata membership; topic scopes are thematic (recall-safe but fuzzy — docs outside the theme's
|
|
319
|
+
* current membership are excluded). An unresolvable ref fails with `CONCEPT_NOT_FOUND` and the
|
|
320
|
+
* nearest matching concept names.
|
|
321
|
+
*/
|
|
322
|
+
underConcept: string;
|
|
164
323
|
}
|
|
165
324
|
/**
|
|
166
325
|
* Per-pipeline weights for native hybrid fusion. Sub-keys mirror the `$rankFusion` pipeline names.
|
|
@@ -173,10 +332,58 @@ export interface AiHybridSearchWeights {
|
|
|
173
332
|
keyword?: number;
|
|
174
333
|
}
|
|
175
334
|
/**
|
|
335
|
+
* Segment-safe subtree match on a hierarchical string field such as a folder path: matches when the
|
|
336
|
+
* field's value is exactly the operand, or begins with the operand followed by a `/` separator. Unlike
|
|
337
|
+
* a raw character prefix, `{ folderPath: { $underPath: 'reports/2023' } }` matches `reports/2023` and
|
|
338
|
+
* `reports/2023/q1/deck` but never the lexical sibling `reports/2023 drafts` — the separator supplies
|
|
339
|
+
* the segment boundary, so subtree scoping never leaks into a sibling that merely shares a prefix.
|
|
340
|
+
*
|
|
341
|
+
* The operand is normalized by stripping any leading and trailing `/` before matching, so a caller that
|
|
342
|
+
* writes `reports/2023/` addresses the same subtree as `reports/2023`. The empty operand matches every
|
|
343
|
+
* document that HAS the field. Matching is case-sensitive.
|
|
344
|
+
*
|
|
345
|
+
* ### Canonical `folderPath` contract
|
|
346
|
+
* The value this operator is designed for — a document's `folderPath` metadata — is written and matched
|
|
347
|
+
* under one canonical form so filters, subtree scoping and the knowledge-graph path facet never
|
|
348
|
+
* fragment by how a value was authored:
|
|
349
|
+
* - POSIX `/` separators; no leading or trailing slash.
|
|
350
|
+
* - The empty string denotes the upload root (a file directly under it), never `undefined`.
|
|
351
|
+
* - Case-preserved on write and matched case-sensitively (`Reports` and `reports` are distinct folders).
|
|
352
|
+
* - NFC-normalized on write, so canonically-equivalent Unicode spellings compare equal.
|
|
353
|
+
*
|
|
354
|
+
* `folderPath` is an ordinary metadata key (not reserved); this operator is the tool for scoping to it.
|
|
355
|
+
* `$underPath` is knowledge-base-only: it is deliberately absent from the shared {@link MetadataSimpleFilter}
|
|
356
|
+
* that metrics and matchmaking consume (they reject unknown operators at runtime).
|
|
357
|
+
* @category AI
|
|
358
|
+
*/
|
|
359
|
+
export interface MetadataUnderPathFilter {
|
|
360
|
+
/** The subtree root the field's value must equal or sit under (leading/trailing `/` are ignored). */
|
|
361
|
+
$underPath: string;
|
|
362
|
+
}
|
|
363
|
+
/** A knowledge-base single-field operator: the shared {@link MetadataSimpleFilter} operators plus `$underPath`. */
|
|
364
|
+
export type AiKbMetadataSimpleFilter = MetadataSimpleFilter | MetadataUnderPathFilter;
|
|
365
|
+
/** A knowledge-base field filter: field names mapped to a {@link AiKbMetadataSimpleFilter} or a direct scalar. */
|
|
366
|
+
export interface AiKbMetadataFieldFilter {
|
|
367
|
+
/** A record where keys are field names and values are either operator objects or direct scalar values. */
|
|
368
|
+
[field: string]: AiKbMetadataSimpleFilter | MetadataValue;
|
|
369
|
+
}
|
|
370
|
+
/** Knowledge-base filters combined with logical AND; each branch may itself use `$underPath`. */
|
|
371
|
+
export interface AiKbMetadataAndFilter {
|
|
372
|
+
/** An array of filters that must all be true for the condition to pass. */
|
|
373
|
+
$and: AiContextMetadataFilter[];
|
|
374
|
+
}
|
|
375
|
+
/** Knowledge-base filters combined with logical OR; each branch may itself use `$underPath`. */
|
|
376
|
+
export interface AiKbMetadataOrFilter {
|
|
377
|
+
/** An array of filters where at least one must be true for the condition to pass. */
|
|
378
|
+
$or: AiContextMetadataFilter[];
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* The knowledge-base context metadata filter: the shared MongoDB-style filter syntax extended with the
|
|
382
|
+
* KB-only `$underPath` operator (see {@link MetadataUnderPathFilter}). Other subsystems (metrics,
|
|
383
|
+
* matchmaking) use the plain `MetadataFilter`, which omits `$underPath`.
|
|
176
384
|
* @category AI
|
|
177
|
-
* @deprecated Use {@link MetadataFilter} from `metadata-filter.public-types` instead.
|
|
178
385
|
*/
|
|
179
|
-
export type AiContextMetadataFilter =
|
|
386
|
+
export type AiContextMetadataFilter = AiKbMetadataFieldFilter | AiKbMetadataAndFilter | AiKbMetadataOrFilter;
|
|
180
387
|
/**
|
|
181
388
|
* Represents an AI knowledge base's context entry with metadata and content.
|
|
182
389
|
* @category AI
|
|
@@ -386,6 +593,9 @@ export interface AiKnowledgeBaseSearchOptions {
|
|
|
386
593
|
*
|
|
387
594
|
* Intended to let A/B evaluations compare dense-only, hybrid and boolean-keyword candidate generation
|
|
388
595
|
* on the same backend.
|
|
596
|
+
*
|
|
597
|
+
* When omitted, the default is `'graph'` (RRF-fused GraphRAG) on a `graphRag.enabled` KB and
|
|
598
|
+
* `'hybrid'` otherwise. See {@link AiKnowledgeBaseSearchMode}.
|
|
389
599
|
*/
|
|
390
600
|
searchMode?: AiKnowledgeBaseSearchMode;
|
|
391
601
|
/**
|
|
@@ -395,6 +605,13 @@ export interface AiKnowledgeBaseSearchOptions {
|
|
|
395
605
|
* default). Useful for A/B evaluating dense-vs-keyword weighting on the same backend.
|
|
396
606
|
*/
|
|
397
607
|
hybridWeights?: AiHybridSearchWeights;
|
|
608
|
+
/** Tuning for `searchMode:'graph'` (GraphRAG). Ignored for other search modes. */
|
|
609
|
+
graphOptions?: AiKnowledgeBaseGraphSearchOptions;
|
|
610
|
+
/**
|
|
611
|
+
* Scopes the search to the documents under one concept of the KB's graph (Layered KB Graph).
|
|
612
|
+
* Composes with every `searchMode` and with `contextMetadataFilter`. Requires `graphRag.enabled`.
|
|
613
|
+
*/
|
|
614
|
+
graphFilter?: AiKnowledgeBaseGraphFilter;
|
|
398
615
|
}
|
|
399
616
|
/**
|
|
400
617
|
* A single chunk of data returned from an AI search operation.
|
|
@@ -417,6 +634,12 @@ export interface AiKnowledgeBaseSearchResultChunk {
|
|
|
417
634
|
export interface UpsertKnowledgeBaseContextResponse {
|
|
418
635
|
/** List of the upsert status of each item sent in the request. */
|
|
419
636
|
failure?: UpsertContextStatusError;
|
|
637
|
+
/**
|
|
638
|
+
* Set when the context was stored (and is fully searchable via vector/keyword) but NOT graph-indexed
|
|
639
|
+
* because the knowledge base is over its per-KB graph chunk cap. Only GraphRAG coverage is absent; the
|
|
640
|
+
* singular counterpart of {@link UpsertKnowledgeBaseContextsResponse.graphIndexingSkippedContextIds}.
|
|
641
|
+
*/
|
|
642
|
+
graphIndexingSkipped?: boolean;
|
|
420
643
|
}
|
|
421
644
|
/**
|
|
422
645
|
* Response structure for upserting contexts for an AiKnowledgeBase
|
|
@@ -435,6 +658,12 @@ export interface UpsertKnowledgeBaseContextsResponse {
|
|
|
435
658
|
* `undefined` at runtime — callers must handle its absence rather than trust it is always populated.
|
|
436
659
|
*/
|
|
437
660
|
contextIds?: Array<AiContextId>;
|
|
661
|
+
/**
|
|
662
|
+
* Contexts that were stored (and are fully searchable via vector/keyword) but NOT graph-indexed because
|
|
663
|
+
* the knowledge base is over its per-KB graph chunk cap. Only GraphRAG coverage is absent; surfaced so a
|
|
664
|
+
* caller can report the graph-coverage gap. Absent/empty when nothing was skipped or graph is disabled.
|
|
665
|
+
*/
|
|
666
|
+
graphIndexingSkippedContextIds?: Array<AiContextId>;
|
|
438
667
|
}
|
|
439
668
|
/**
|
|
440
669
|
* Request structure for searching an AiKnowledgeBase
|
|
@@ -610,6 +839,11 @@ export interface ListAiKnowledgeBaseContextsPageResponse {
|
|
|
610
839
|
export interface AiKnowledgeBaseSearchResponse {
|
|
611
840
|
/** Array of result chunks from the search */
|
|
612
841
|
chunks: Array<AiKnowledgeBaseSearchResultChunk>;
|
|
842
|
+
/**
|
|
843
|
+
* The subgraph traversed for a `searchMode:'graph'` query. Present only when
|
|
844
|
+
* `graphOptions.includeGraphContext` was set; absent for all other searches.
|
|
845
|
+
*/
|
|
846
|
+
graphContext?: AiKnowledgeBaseGraphContext;
|
|
613
847
|
}
|
|
614
848
|
/**
|
|
615
849
|
* Response containing the list of AI knowledge bases in an application.
|
|
@@ -640,3 +874,420 @@ export interface GeneratedMetadataFieldDescription {
|
|
|
640
874
|
/** The AI-generated description for the field. */
|
|
641
875
|
description: string;
|
|
642
876
|
}
|
|
877
|
+
/**
|
|
878
|
+
* Request structure for reading a knowledge base's GraphRAG build/readiness status.
|
|
879
|
+
* @category AI
|
|
880
|
+
*/
|
|
881
|
+
export interface GetKnowledgeBaseGraphStatusRequest {
|
|
882
|
+
/** The id of the AiKnowledgeBase. */
|
|
883
|
+
knowledgeBaseId: AiKnowledgeBaseId;
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Response structure for a knowledge base's GraphRAG build/readiness status. Drives the ai-eval
|
|
887
|
+
* readiness poll (index until `contextsIndexed === contextsTotal` and `buildJob` is not in-progress).
|
|
888
|
+
* @category AI
|
|
889
|
+
*/
|
|
890
|
+
export interface GetKnowledgeBaseGraphStatusResponse {
|
|
891
|
+
/** Whether GraphRAG is enabled on the KB. */
|
|
892
|
+
enabled: boolean;
|
|
893
|
+
/** Number of entities in the KB's graph partition. */
|
|
894
|
+
entityCount: number;
|
|
895
|
+
/** Number of outgoing relationships (mirrors excluded). */
|
|
896
|
+
relationshipCount: number;
|
|
897
|
+
/** Number of communities detected (Phase 3), 0 when none. */
|
|
898
|
+
communityCount: number;
|
|
899
|
+
/** Contexts stamped as graph-indexed. */
|
|
900
|
+
contextsIndexed: number;
|
|
901
|
+
/** Total contexts in the KB. */
|
|
902
|
+
contextsTotal: number;
|
|
903
|
+
/** Document nodes in the KB's graph (Layered KB Graph L1) — one per graph-indexed context. */
|
|
904
|
+
docNodesTotal?: number;
|
|
905
|
+
/** Document nodes carrying a non-empty LLM description (failed descriptions retry on rebuild). */
|
|
906
|
+
docsDescribed?: number;
|
|
907
|
+
/** The KB's facet trees (Layered KB Graph L3, deterministic) — empty until a rebuild builds them. */
|
|
908
|
+
facets?: Array<KnowledgeBaseGraphFacetStatus>;
|
|
909
|
+
/**
|
|
910
|
+
* The KB's topic (theme) hierarchy — present once a graph build has clustered topics. Ids churn on
|
|
911
|
+
* rebuild ({@link KnowledgeBaseGraphTopic.id}); resolve them per session, never persist them.
|
|
912
|
+
*/
|
|
913
|
+
topics?: Array<KnowledgeBaseGraphTopic>;
|
|
914
|
+
/**
|
|
915
|
+
* Leaf-level inter-topic edges (relationship counts crossing topic boundaries), present once a graph
|
|
916
|
+
* build has computed them. Roll up to coarser tiers by mapping each endpoint to its ancestor.
|
|
917
|
+
*/
|
|
918
|
+
topicEdges?: Array<KnowledgeBaseGraphTopicEdge>;
|
|
919
|
+
/**
|
|
920
|
+
* True when documents were graph-indexed after the last topic build — themes may lag content until
|
|
921
|
+
* the next `rebuildGraph`. Only meaningful once topics exist (absent before the first rebuild).
|
|
922
|
+
*/
|
|
923
|
+
structureStale?: boolean;
|
|
924
|
+
/** Documents added since the last topic build (the `structureStale` numerator). */
|
|
925
|
+
staleDocCount?: number;
|
|
926
|
+
/** Status of the most recent backfill/rebuild job, when one exists. */
|
|
927
|
+
buildJob?: KnowledgeBaseGraphBuildJob;
|
|
928
|
+
/** Lifetime LLM usage of incremental graph ingestion (per-upsert extraction), when any was recorded. */
|
|
929
|
+
ingestUsage?: KnowledgeBaseGraphUsage;
|
|
930
|
+
/** LLM usage of the most recent `rebuildGraph` run (including its re-extraction), when one ran. */
|
|
931
|
+
lastRebuildUsage?: KnowledgeBaseGraphUsage;
|
|
932
|
+
/**
|
|
933
|
+
* Lifetime LLM usage of the combined contextual-blurb + graph-extraction call (run automatically for
|
|
934
|
+
* `ragType:'contextual'` graph-enabled KBs), when any was recorded. Covers BOTH the contextual blurb
|
|
935
|
+
* and graph extraction in one call, so it is not directly comparable to the graph-only
|
|
936
|
+
* {@link ingestUsage}.
|
|
937
|
+
*/
|
|
938
|
+
combinedIngestUsage?: KnowledgeBaseGraphUsage;
|
|
939
|
+
}
|
|
940
|
+
/** The most recent graph backfill/rebuild job of a knowledge base. @category AI */
|
|
941
|
+
export interface KnowledgeBaseGraphBuildJob {
|
|
942
|
+
/** The job's lifecycle state. */
|
|
943
|
+
status: 'in_progress' | 'completed' | 'failed';
|
|
944
|
+
/** Failure message, present when `status` is `'failed'`. */
|
|
945
|
+
error?: string;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Aggregated LLM token usage (and best-effort cost) of graph work on a KB. Token counts are the
|
|
949
|
+
* provider-reported ground truth; `estCostUsd` is estimated from model list prices at call time —
|
|
950
|
+
* recompute from the tokens for exact accounting.
|
|
951
|
+
* @category AI
|
|
952
|
+
*/
|
|
953
|
+
export interface KnowledgeBaseGraphUsage {
|
|
954
|
+
/** Number of LLM calls. */
|
|
955
|
+
llmCalls: number;
|
|
956
|
+
/** Prompt (input) tokens. */
|
|
957
|
+
inputTokens: number;
|
|
958
|
+
/** Completion (output) tokens. */
|
|
959
|
+
outputTokens: number;
|
|
960
|
+
/** Reasoning tokens, where the provider reports them separately. */
|
|
961
|
+
reasoningTokens: number;
|
|
962
|
+
/** Input tokens served from the provider's prompt cache. */
|
|
963
|
+
cacheReadTokens: number;
|
|
964
|
+
/** Input tokens written into the provider's prompt cache. */
|
|
965
|
+
cacheWriteTokens: number;
|
|
966
|
+
/** Best-effort USD estimated from list prices at call time. */
|
|
967
|
+
estCostUsd: number;
|
|
968
|
+
/**
|
|
969
|
+
* Per-model split of the totals above (LLM calls only), present when any usage was recorded. The
|
|
970
|
+
* per-model figures sum to the aggregate; embedding usage is excluded from both.
|
|
971
|
+
*/
|
|
972
|
+
byModel?: Array<KnowledgeBaseGraphModelUsage>;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* One model's slice of a KB's graph LLM usage, keyed by the resolved model name. Token counts are the
|
|
976
|
+
* provider-reported ground truth; `estCostUsd` is estimated from model list prices at call time.
|
|
977
|
+
* @category AI
|
|
978
|
+
*/
|
|
979
|
+
export interface KnowledgeBaseGraphModelUsage {
|
|
980
|
+
/** The resolved model these totals are attributed to. */
|
|
981
|
+
model: string;
|
|
982
|
+
/** Number of LLM calls billed to this model. */
|
|
983
|
+
llmCalls: number;
|
|
984
|
+
/** Prompt (input) tokens. */
|
|
985
|
+
inputTokens: number;
|
|
986
|
+
/** Completion (output) tokens. */
|
|
987
|
+
outputTokens: number;
|
|
988
|
+
/** Reasoning tokens, where the provider reports them separately. */
|
|
989
|
+
reasoningTokens: number;
|
|
990
|
+
/** Input tokens served from the provider's prompt cache. */
|
|
991
|
+
cacheReadTokens: number;
|
|
992
|
+
/** Input tokens written into the provider's prompt cache. */
|
|
993
|
+
cacheWriteTokens: number;
|
|
994
|
+
/** Best-effort USD estimated from list prices at call time. */
|
|
995
|
+
estCostUsd: number;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* One facet tree in a graph status response: the metadata field it is built from and its value leaves
|
|
999
|
+
* (most-populated first, capped — compare `values.length` against `valueCount` for truncation).
|
|
1000
|
+
* @category AI
|
|
1001
|
+
*/
|
|
1002
|
+
export interface KnowledgeBaseGraphFacetStatus {
|
|
1003
|
+
/** The metadata field the facet is built from. */
|
|
1004
|
+
facetKey: string;
|
|
1005
|
+
/** Display name of the facet root. */
|
|
1006
|
+
name: string;
|
|
1007
|
+
/** Total facet-value leaves (may exceed `values.length` — the list is capped). */
|
|
1008
|
+
valueCount: number;
|
|
1009
|
+
/** Documents carrying any value of this facet. */
|
|
1010
|
+
docCount: number;
|
|
1011
|
+
/** The facet's value leaves. */
|
|
1012
|
+
values: Array<KnowledgeBaseGraphFacetValueStatus>;
|
|
1013
|
+
}
|
|
1014
|
+
/** One value leaf of a facet in a graph status response. @category AI */
|
|
1015
|
+
export interface KnowledgeBaseGraphFacetValueStatus {
|
|
1016
|
+
/** Display name of the value (the most frequent raw variant). */
|
|
1017
|
+
name: string;
|
|
1018
|
+
/** Documents assigned to this value. */
|
|
1019
|
+
docCount: number;
|
|
1020
|
+
/** Raw variants consolidated into this value ("USA" under "United States"), when any. */
|
|
1021
|
+
aliases?: string[];
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* How much of the knowledge base's graph a rebuild recomputes.
|
|
1025
|
+
*
|
|
1026
|
+
* - `'full'` — wipes the graph and re-extracts entities/relationships from every chunk with an LLM,
|
|
1027
|
+
* then rebuilds the concept layer. The expensive deep-clean: re-extraction dominates its cost.
|
|
1028
|
+
* - `'structural'` — keeps the already-extracted entity graph (LLM extraction runs only for contexts
|
|
1029
|
+
* that were never graph-indexed, e.g. after an interrupted ingest) and recomputes the derived
|
|
1030
|
+
* structure on top of it: entity resolution, lexical mentions, topics and facets. Typically a small
|
|
1031
|
+
* fraction of a full rebuild's cost — the right choice for folding freshly ingested documents into
|
|
1032
|
+
* topics/facets.
|
|
1033
|
+
* @category AI
|
|
1034
|
+
*/
|
|
1035
|
+
export type KnowledgeBaseGraphRebuildMode = 'full' | 'structural';
|
|
1036
|
+
/**
|
|
1037
|
+
* Request structure for enqueuing a GraphRAG rebuild/backfill of a knowledge base.
|
|
1038
|
+
* @category AI
|
|
1039
|
+
*/
|
|
1040
|
+
export interface RebuildKnowledgeBaseGraphRequest {
|
|
1041
|
+
/** The id of the AiKnowledgeBase. */
|
|
1042
|
+
knowledgeBaseId: AiKnowledgeBaseId;
|
|
1043
|
+
/** What to recompute (see {@link KnowledgeBaseGraphRebuildMode}). Default `'full'`. */
|
|
1044
|
+
mode?: KnowledgeBaseGraphRebuildMode;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Request structure for exploring a bounded subgraph of a knowledge base's graph (Phase 3 visualization).
|
|
1048
|
+
* Returns the highest-degree entities and the relationships among them. Seed-based exploration
|
|
1049
|
+
* (prompt/entity-name seeding + traversal depth) is a planned extension; its fields will be added
|
|
1050
|
+
* here once implemented.
|
|
1051
|
+
* @category AI
|
|
1052
|
+
*/
|
|
1053
|
+
export interface ExploreKnowledgeBaseGraphRequest {
|
|
1054
|
+
/** The id of the AiKnowledgeBase. */
|
|
1055
|
+
knowledgeBaseId: AiKnowledgeBaseId;
|
|
1056
|
+
/** Hard cap on returned nodes. Default 200, max 1000. */
|
|
1057
|
+
nodeLimit?: number;
|
|
1058
|
+
/**
|
|
1059
|
+
* Restricts the subgraph to entities under the given topic node id — any hierarchy level; an entity
|
|
1060
|
+
* matches when the topic appears anywhere in its `topicPath`. Unknown ids fail with
|
|
1061
|
+
* `TOPIC_NOT_FOUND`. Ids come from {@link KnowledgeBaseGraphTopic.id} and churn on rebuild.
|
|
1062
|
+
*/
|
|
1063
|
+
topicId?: string;
|
|
1064
|
+
}
|
|
1065
|
+
/** A node in an {@link ExploreKnowledgeBaseGraphResponse}. @category AI */
|
|
1066
|
+
export interface KnowledgeBaseGraphNode {
|
|
1067
|
+
/** Stable node id (the entity's document id). */
|
|
1068
|
+
id: string;
|
|
1069
|
+
/** Canonical display name. */
|
|
1070
|
+
name: string;
|
|
1071
|
+
/** Entity type. */
|
|
1072
|
+
type: string;
|
|
1073
|
+
/** Compacted description. */
|
|
1074
|
+
description: string;
|
|
1075
|
+
/** Relationship degree (denormalized). */
|
|
1076
|
+
degree: number;
|
|
1077
|
+
/** Community id (Phase 3), when community detection has run. */
|
|
1078
|
+
communityId?: string;
|
|
1079
|
+
/** Level-0..k topic nodeIds (bottom-up, Layered KB Graph), when a topic rebuild has run. */
|
|
1080
|
+
topicPath?: string[];
|
|
1081
|
+
/** Norm-names this entity absorbed via resolution merges (present only when non-empty). */
|
|
1082
|
+
aliases?: string[];
|
|
1083
|
+
}
|
|
1084
|
+
/** An edge in an {@link ExploreKnowledgeBaseGraphResponse}. @category AI */
|
|
1085
|
+
export interface KnowledgeBaseGraphEdge {
|
|
1086
|
+
/** Source node id. */
|
|
1087
|
+
source: string;
|
|
1088
|
+
/** Target node id. */
|
|
1089
|
+
target: string;
|
|
1090
|
+
/** Relationship label. */
|
|
1091
|
+
type: string;
|
|
1092
|
+
/** Co-mention weight. */
|
|
1093
|
+
weight: number;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Response structure for the bounded subgraph exploration (Phase 3 visualization).
|
|
1097
|
+
* @category AI
|
|
1098
|
+
*/
|
|
1099
|
+
export interface ExploreKnowledgeBaseGraphResponse {
|
|
1100
|
+
/** The subgraph nodes. */
|
|
1101
|
+
nodes: Array<KnowledgeBaseGraphNode>;
|
|
1102
|
+
/** The subgraph edges (outgoing only, both endpoints present in `nodes`). */
|
|
1103
|
+
edges: Array<KnowledgeBaseGraphEdge>;
|
|
1104
|
+
/**
|
|
1105
|
+
* The KB's topic (theme) nodes — the id→name/hierarchy table for the nodes' `topicPath` ids, so a
|
|
1106
|
+
* visualization can label and group by theme without extra round trips. Present when the concept
|
|
1107
|
+
* layer has been built (a rebuild ran).
|
|
1108
|
+
*/
|
|
1109
|
+
topics?: Array<KnowledgeBaseGraphTopic>;
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* A topic (theme) node of the graph's concept layer, as referenced by
|
|
1113
|
+
* {@link KnowledgeBaseGraphNode.topicPath}.
|
|
1114
|
+
* @category AI
|
|
1115
|
+
*/
|
|
1116
|
+
export interface KnowledgeBaseGraphTopic {
|
|
1117
|
+
/** Topic nodeId (matches `topicPath` entries). Churns on rebuild — not a persistable handle. */
|
|
1118
|
+
id: string;
|
|
1119
|
+
/** Topic display name. Re-resolves by name across rebuilds. */
|
|
1120
|
+
name: string;
|
|
1121
|
+
/** Hierarchy level: 0 = leaf tier, higher = coarser tiers. */
|
|
1122
|
+
level: number;
|
|
1123
|
+
/** Parent topic nodeId, when the topic sits under a coarser tier. */
|
|
1124
|
+
parentId?: string;
|
|
1125
|
+
/** Documents under the topic, when tracked. */
|
|
1126
|
+
docCount?: number;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* An aggregated relationship edge between two leaf topics: how many entity relationships cross
|
|
1130
|
+
* between their member entities. Undirected (one entry per pair) and pruned to each topic's
|
|
1131
|
+
* strongest neighbors, so weak long-tail links may be absent. Ids churn on rebuild, like
|
|
1132
|
+
* {@link KnowledgeBaseGraphTopic.id}.
|
|
1133
|
+
* @category AI
|
|
1134
|
+
*/
|
|
1135
|
+
export interface KnowledgeBaseGraphTopicEdge {
|
|
1136
|
+
/** One endpoint's topic nodeId. */
|
|
1137
|
+
source: string;
|
|
1138
|
+
/** The other endpoint's topic nodeId. */
|
|
1139
|
+
target: string;
|
|
1140
|
+
/** Number of entity relationships crossing between the two topics. */
|
|
1141
|
+
weight: number;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* The closed operation set of the `queryKnowledgeGraph` surface (Layered KB Graph P4). Every op is one
|
|
1145
|
+
* round trip with a complete answer — no per-level walking.
|
|
1146
|
+
* @category AI
|
|
1147
|
+
*/
|
|
1148
|
+
export type KnowledgeBaseGraphQueryOp = 'overview' | 'resolve' | 'describe' | 'subtree' | 'docsUnder' | 'conceptsOf' | 'neighborhood' | 'pathBetween' | 'globalSummary';
|
|
1149
|
+
/**
|
|
1150
|
+
* Request structure for querying a knowledge base's graph (documents, entities, topics, facets) through
|
|
1151
|
+
* the closed op set. `ref` accepts a facet nodeId (`facet_…` — exact; the only persistable concept
|
|
1152
|
+
* handles) or a name, resolved server-side (exact → alias → similarity). An unresolvable ref fails with
|
|
1153
|
+
* `CONCEPT_NOT_FOUND` plus the nearest matching names.
|
|
1154
|
+
* @category AI
|
|
1155
|
+
*/
|
|
1156
|
+
export interface QueryKnowledgeBaseGraphRequest {
|
|
1157
|
+
/** The id of the AiKnowledgeBase. */
|
|
1158
|
+
knowledgeBaseId: AiKnowledgeBaseId;
|
|
1159
|
+
/** The operation to run. */
|
|
1160
|
+
op: KnowledgeBaseGraphQueryOp;
|
|
1161
|
+
/** Node ref (name or facet nodeId). Required by resolve/describe/subtree/docsUnder/neighborhood/pathBetween. */
|
|
1162
|
+
ref?: string;
|
|
1163
|
+
/** Second node ref for `pathBetween`. */
|
|
1164
|
+
refB?: string;
|
|
1165
|
+
/** The document's contextId for `conceptsOf`. */
|
|
1166
|
+
contextId?: string;
|
|
1167
|
+
/** The free-text question for `globalSummary` (ranks the KB's topic summaries against it). */
|
|
1168
|
+
query?: string;
|
|
1169
|
+
/** `subtree`: maximum depth below the resolved node. Default (and cap) 3. */
|
|
1170
|
+
depth?: number;
|
|
1171
|
+
/** `neighborhood`: expansion hops from the resolved entity. Default 1, max 2. */
|
|
1172
|
+
hops?: number;
|
|
1173
|
+
/** `docsUnder`: when true (default), include documents under the whole subtree, not just the node itself. */
|
|
1174
|
+
recursive?: boolean;
|
|
1175
|
+
/** `docsUnder`: maximum documents returned. Default 25, max 100 (`totalDocs` always reports the full count). */
|
|
1176
|
+
limit?: number;
|
|
1177
|
+
}
|
|
1178
|
+
/** One node matched by a graph query (`resolve`, and the anchors of other ops). @category AI */
|
|
1179
|
+
export interface KnowledgeBaseGraphQueryMatch {
|
|
1180
|
+
/** What kind of node matched. */
|
|
1181
|
+
kind: 'document' | 'entity' | 'topic' | 'facetRoot' | 'facetValue';
|
|
1182
|
+
/** Display name (document title, entity/topic/facet name). */
|
|
1183
|
+
name: string;
|
|
1184
|
+
/**
|
|
1185
|
+
* Persistable handle, present only where one exists: facet nodeIds (stable across rebuilds) and
|
|
1186
|
+
* document contextIds. Topic and entity refs re-resolve by name — their internal ids are omitted.
|
|
1187
|
+
*/
|
|
1188
|
+
id?: string;
|
|
1189
|
+
/** The metadata field a facet node belongs to. */
|
|
1190
|
+
facetKey?: string;
|
|
1191
|
+
/** Node description (may be empty for facet leaves). */
|
|
1192
|
+
description?: string;
|
|
1193
|
+
/** Documents under the node, where tracked (topics and facet nodes). */
|
|
1194
|
+
docCount?: number;
|
|
1195
|
+
}
|
|
1196
|
+
/** A node in a `subtree` response: the resolved node with its children, recursively. @category AI */
|
|
1197
|
+
export interface KnowledgeBaseGraphQuerySubtreeNode {
|
|
1198
|
+
/** Display name. */
|
|
1199
|
+
name: string;
|
|
1200
|
+
/** Persistable facet nodeId (present on facet nodes; see {@link KnowledgeBaseGraphQueryMatch.id}). */
|
|
1201
|
+
id?: string;
|
|
1202
|
+
/** Documents under this node. */
|
|
1203
|
+
docCount?: number;
|
|
1204
|
+
/** Raw variants consolidated into a facet value ("United States of America" under "United States"). */
|
|
1205
|
+
aliases?: string[];
|
|
1206
|
+
/** Child nodes, depth-limited by the request. */
|
|
1207
|
+
children?: Array<KnowledgeBaseGraphQuerySubtreeNode>;
|
|
1208
|
+
}
|
|
1209
|
+
/** A document summary returned by `docsUnder`. @category AI */
|
|
1210
|
+
export interface KnowledgeBaseGraphQueryDoc {
|
|
1211
|
+
/** The document's contextId (usable with `conceptsOf` and the KB context APIs). */
|
|
1212
|
+
contextId: string;
|
|
1213
|
+
/** Document title, when one exists. */
|
|
1214
|
+
title?: string;
|
|
1215
|
+
/** The document node's LLM description ('' when generation failed). */
|
|
1216
|
+
description?: string;
|
|
1217
|
+
}
|
|
1218
|
+
/** A document's concept memberships (`conceptsOf`): facet paths + topics. @category AI */
|
|
1219
|
+
export interface KnowledgeBaseGraphQueryConcepts {
|
|
1220
|
+
/** The facet values the document carries, with their persistable leaf ids. */
|
|
1221
|
+
facets: Array<{
|
|
1222
|
+
facetKey: string;
|
|
1223
|
+
value: string;
|
|
1224
|
+
id: string;
|
|
1225
|
+
}>;
|
|
1226
|
+
/** Names of the topics (flat themes) the document belongs to. Thematic — refs re-resolve by name. */
|
|
1227
|
+
topics: Array<string>;
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* One topic (community) summary returned by the `globalSummary` op — the themes-level "global" answer
|
|
1231
|
+
* content, ranked against the query. @category AI
|
|
1232
|
+
*/
|
|
1233
|
+
export interface KnowledgeBaseGraphQueryGlobalSummary {
|
|
1234
|
+
/** Topic display name. Thematic — re-resolves by name across rebuilds. */
|
|
1235
|
+
topic: string;
|
|
1236
|
+
/** The topic's LLM-generated summary. */
|
|
1237
|
+
summary: string;
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* A `pathBetween` answer. Two-tier: an entity path when one exists (explanatory — the chain of typed
|
|
1241
|
+
* relationships), else concept/topic co-membership labeled `thematic` (the refs share concepts but no
|
|
1242
|
+
* entity chain connects them).
|
|
1243
|
+
* @category AI
|
|
1244
|
+
*/
|
|
1245
|
+
export interface KnowledgeBaseGraphQueryPath {
|
|
1246
|
+
/** Which tier answered: `'entity'` (relationship chain) or `'thematic'` (shared concepts only). */
|
|
1247
|
+
tier: 'entity' | 'thematic';
|
|
1248
|
+
/** Entity tier: the relationship chain, in order. */
|
|
1249
|
+
steps?: Array<{
|
|
1250
|
+
from: string;
|
|
1251
|
+
type: string;
|
|
1252
|
+
to: string;
|
|
1253
|
+
}>;
|
|
1254
|
+
/** Thematic tier: names of concepts both refs sit under. */
|
|
1255
|
+
sharedConcepts?: Array<string>;
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Response structure for a graph query. `op` echoes the request; exactly the fields that op produces
|
|
1259
|
+
* are set (e.g. `matches` for `resolve`, `tree` for `subtree`).
|
|
1260
|
+
* @category AI
|
|
1261
|
+
*/
|
|
1262
|
+
export interface QueryKnowledgeBaseGraphResponse {
|
|
1263
|
+
/** The operation that ran. */
|
|
1264
|
+
op: KnowledgeBaseGraphQueryOp;
|
|
1265
|
+
/** `overview`: the rendered knowledge-graph map (names + counts). */
|
|
1266
|
+
overview?: string;
|
|
1267
|
+
/** `resolve`: matching nodes across all kinds, best first. */
|
|
1268
|
+
matches?: Array<KnowledgeBaseGraphQueryMatch>;
|
|
1269
|
+
/** `describe`: the resolved node. */
|
|
1270
|
+
node?: KnowledgeBaseGraphQueryMatch;
|
|
1271
|
+
/** `describe`: ancestor names root-first (facet path / topic hierarchy), when the node has one. */
|
|
1272
|
+
path?: Array<string>;
|
|
1273
|
+
/** `describe`: immediate related nodes — children with counts, a document's concepts, an entity's edges. */
|
|
1274
|
+
related?: Array<{
|
|
1275
|
+
relation: string;
|
|
1276
|
+
name: string;
|
|
1277
|
+
docCount?: number;
|
|
1278
|
+
}>;
|
|
1279
|
+
/** `subtree`: the resolved node's subtree with doc counts. */
|
|
1280
|
+
tree?: KnowledgeBaseGraphQuerySubtreeNode;
|
|
1281
|
+
/** `docsUnder`: documents in the resolved node's closure (capped by `limit`). */
|
|
1282
|
+
documents?: Array<KnowledgeBaseGraphQueryDoc>;
|
|
1283
|
+
/** `docsUnder`: the full closure size (compare with `documents.length` for truncation). */
|
|
1284
|
+
totalDocs?: number;
|
|
1285
|
+
/** `conceptsOf`: the document's concept memberships. */
|
|
1286
|
+
concepts?: KnowledgeBaseGraphQueryConcepts;
|
|
1287
|
+
/** `neighborhood`: the entity subgraph around the resolved entity. */
|
|
1288
|
+
graph?: ExploreKnowledgeBaseGraphResponse;
|
|
1289
|
+
/** `pathBetween`: the two-tier path answer; absent when the refs are entirely unconnected. */
|
|
1290
|
+
pathBetween?: KnowledgeBaseGraphQueryPath;
|
|
1291
|
+
/** `globalSummary`: the KB's topic summaries ranked against the query, most relevant first. */
|
|
1292
|
+
summaries?: Array<KnowledgeBaseGraphQueryGlobalSummary>;
|
|
1293
|
+
}
|