@anvia/graph 0.0.0-bootstrap.0 → 1.0.4
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/LICENSE +21 -0
- package/README.md +120 -1
- package/dist/chunk-N3CKMOPE.js +85 -0
- package/dist/chunk-N3CKMOPE.js.map +1 -0
- package/dist/explore-9jm2c1mG.d.ts +277 -0
- package/dist/explore.d.ts +5 -0
- package/dist/explore.js +7 -0
- package/dist/explore.js.map +1 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +672 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -5
- package/index.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Indra Zulfi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
1
|
# @anvia/graph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Provider-neutral schema, extraction, retrieval-context, and tool primitives for knowledge graphs.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineGraphSchema, extractGraphFacts } from "@anvia/graph";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
const schema = defineGraphSchema({
|
|
10
|
+
nodes: {
|
|
11
|
+
Product: {
|
|
12
|
+
description: "A product or service.",
|
|
13
|
+
identity: ["id"],
|
|
14
|
+
properties: z.strictObject({ id: z.string(), name: z.string() }),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
relationships: {},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const facts = await extractGraphFacts({ model, schema, chunks });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Database provisioning, persistence, and query execution belong to graph adapter packages such as
|
|
24
|
+
`@anvia/neo4j` and `@anvia/memgraph`.
|
|
25
|
+
|
|
26
|
+
## Ingestion
|
|
27
|
+
|
|
28
|
+
Managed graphs accept the same raw text document shape as vector ingestion:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { ingestGraphText } from "@anvia/graph";
|
|
32
|
+
|
|
33
|
+
const ingestion = await ingestGraphText({
|
|
34
|
+
graph,
|
|
35
|
+
document: {
|
|
36
|
+
id: "incident-42",
|
|
37
|
+
text,
|
|
38
|
+
metadata: { tenant: "acme" },
|
|
39
|
+
},
|
|
40
|
+
extractionModel,
|
|
41
|
+
embeddingModel,
|
|
42
|
+
chunking: {
|
|
43
|
+
strategy: "recursive",
|
|
44
|
+
maxSize: 1_000,
|
|
45
|
+
overlap: 100,
|
|
46
|
+
separators: ["\n\n", "\n", " "],
|
|
47
|
+
},
|
|
48
|
+
conflict: "error",
|
|
49
|
+
orphanEntities: "delete",
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Use `ingestGraphDocuments()` for a batch. Both functions extract facts, embed chunks and entities,
|
|
54
|
+
and atomically replace each source document in the managed graph. Existing graph registrations are
|
|
55
|
+
read-only and are rejected as ingestion targets by TypeScript.
|
|
56
|
+
|
|
57
|
+
The result also exposes `vectorDocuments`, grouped by source document ID, so a vector store can
|
|
58
|
+
reuse the chunk embeddings without another model call:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
await vectorStore.upsert({ documents: ingestion.vectorDocuments });
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The graph and vector writes are separate transactions. Applications that require cross-store
|
|
65
|
+
reconciliation should persist their own ingestion status and retry the incomplete write. Advanced
|
|
66
|
+
callers can use `prepareGraphDocuments()` to run chunking, extraction, and embedding without writing,
|
|
67
|
+
then pass its graph fields to `graph.replaceDocuments()` and its `vectorDocuments` to a vector store.
|
|
68
|
+
|
|
69
|
+
## Search tool
|
|
70
|
+
|
|
71
|
+
Create the same Agent tool for any graph adapter implementing `GraphContextRetriever`:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { createGraphSearchTool } from "@anvia/graph";
|
|
75
|
+
|
|
76
|
+
const searchGraph = createGraphSearchTool({
|
|
77
|
+
name: "search_graph",
|
|
78
|
+
description: "Search connected entities and supporting evidence.",
|
|
79
|
+
graph,
|
|
80
|
+
model: embeddingModel,
|
|
81
|
+
search: {
|
|
82
|
+
type: "vector",
|
|
83
|
+
seeds: ["entities"],
|
|
84
|
+
topK: 8,
|
|
85
|
+
},
|
|
86
|
+
traversal: {
|
|
87
|
+
relationships: ["AFFECTS"],
|
|
88
|
+
direction: "both",
|
|
89
|
+
maxDepth: 2,
|
|
90
|
+
maxNodes: 40,
|
|
91
|
+
maxRelationships: 80,
|
|
92
|
+
},
|
|
93
|
+
evidence: { type: "chunks", maxChunks: 12 },
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The graph registration controls which evidence modes are valid. Managed graphs can hydrate stored
|
|
98
|
+
chunks, while existing graph registrations use `{ type: "none" }`.
|
|
99
|
+
|
|
100
|
+
## Exploration
|
|
101
|
+
|
|
102
|
+
Adapters implementing `GraphExplorer` expose a portable, bounded view for visualization:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
const overview = await graph.explore({
|
|
106
|
+
mode: "overview",
|
|
107
|
+
nodeTypes: ["Product"],
|
|
108
|
+
maxNodes: 100,
|
|
109
|
+
maxRelationships: 200,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const neighborhood = await graph.explore({
|
|
113
|
+
mode: "expand",
|
|
114
|
+
nodeIds: [overview.nodes[0]!.id],
|
|
115
|
+
direction: "both",
|
|
116
|
+
maxDepth: 1,
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Explorer IDs are opaque and provider-specific. They are intended for follow-up expansion within the
|
|
121
|
+
same graph, not persistence or cross-provider migration. Adapters cap overview and expansion requests,
|
|
122
|
+
return truncation metadata, and omit reserved Anvia properties such as stored embeddings.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/explore.ts
|
|
2
|
+
var defaultMaxNodes = 100;
|
|
3
|
+
var maximumNodes = 500;
|
|
4
|
+
var defaultMaxRelationships = 200;
|
|
5
|
+
var maximumRelationships = 1e3;
|
|
6
|
+
var defaultMaxDepth = 1;
|
|
7
|
+
var maximumDepth = 4;
|
|
8
|
+
var maximumRoots = 20;
|
|
9
|
+
function resolveGraphExploreOptions(schema, options) {
|
|
10
|
+
const nodeTypes = resolveNames(options.nodeTypes, Object.keys(schema.nodes), "node type");
|
|
11
|
+
const relationships = resolveNames(
|
|
12
|
+
options.relationships,
|
|
13
|
+
Object.keys(schema.relationships),
|
|
14
|
+
"relationship type",
|
|
15
|
+
true
|
|
16
|
+
);
|
|
17
|
+
const base = {
|
|
18
|
+
nodeTypes,
|
|
19
|
+
relationships,
|
|
20
|
+
maxNodes: boundedInteger(options.maxNodes, defaultMaxNodes, maximumNodes, "maxNodes"),
|
|
21
|
+
maxRelationships: boundedInteger(
|
|
22
|
+
options.maxRelationships,
|
|
23
|
+
defaultMaxRelationships,
|
|
24
|
+
maximumRelationships,
|
|
25
|
+
"maxRelationships"
|
|
26
|
+
)
|
|
27
|
+
};
|
|
28
|
+
if (options.abortSignal !== void 0) base.abortSignal = options.abortSignal;
|
|
29
|
+
if (options.mode === "overview") {
|
|
30
|
+
return { ...base, mode: "overview" };
|
|
31
|
+
}
|
|
32
|
+
const nodeIds = uniqueNonEmptyStrings(options.nodeIds, "node id");
|
|
33
|
+
if (nodeIds.length === 0) {
|
|
34
|
+
throw new TypeError("Graph expansion requires at least one node id.");
|
|
35
|
+
}
|
|
36
|
+
if (nodeIds.length > maximumRoots) {
|
|
37
|
+
throw new RangeError(`Graph expansion accepts at most ${maximumRoots} root nodes.`);
|
|
38
|
+
}
|
|
39
|
+
const direction = options.direction ?? "both";
|
|
40
|
+
if (direction !== "outgoing" && direction !== "incoming" && direction !== "both") {
|
|
41
|
+
throw new TypeError("Graph expansion direction must be outgoing, incoming, or both.");
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...base,
|
|
45
|
+
mode: "expand",
|
|
46
|
+
nodeIds,
|
|
47
|
+
direction,
|
|
48
|
+
maxDepth: boundedInteger(options.maxDepth, defaultMaxDepth, maximumDepth, "maxDepth")
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function resolveNames(selected, available, label, allowEmpty = false) {
|
|
52
|
+
const values = selected === void 0 ? [...available] : uniqueNonEmptyStrings(selected, label);
|
|
53
|
+
if (!allowEmpty && values.length === 0) {
|
|
54
|
+
throw new TypeError(`Graph exploration requires at least one ${label}.`);
|
|
55
|
+
}
|
|
56
|
+
const known = new Set(available);
|
|
57
|
+
for (const value of values) {
|
|
58
|
+
if (!known.has(value))
|
|
59
|
+
throw new TypeError(`Graph exploration references unknown ${label} ${value}.`);
|
|
60
|
+
}
|
|
61
|
+
return values;
|
|
62
|
+
}
|
|
63
|
+
function uniqueNonEmptyStrings(values, label) {
|
|
64
|
+
const unique = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const value of values) {
|
|
66
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
67
|
+
throw new TypeError(`Graph ${label} must be a non-empty string.`);
|
|
68
|
+
}
|
|
69
|
+
if (unique.has(value)) throw new TypeError(`Duplicate graph ${label}: ${value}.`);
|
|
70
|
+
unique.add(value);
|
|
71
|
+
}
|
|
72
|
+
return [...unique];
|
|
73
|
+
}
|
|
74
|
+
function boundedInteger(value, fallback, maximum, label) {
|
|
75
|
+
const resolved = value ?? fallback;
|
|
76
|
+
if (!Number.isSafeInteger(resolved) || resolved < 1 || resolved > maximum) {
|
|
77
|
+
throw new RangeError(`Graph exploration ${label} must be between 1 and ${maximum}.`);
|
|
78
|
+
}
|
|
79
|
+
return resolved;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
resolveGraphExploreOptions
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=chunk-N3CKMOPE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/explore.ts"],"sourcesContent":["import type { GraphExploreDirection, GraphExploreOptions, GraphSchemaLike } from \"./types.js\";\n\nconst defaultMaxNodes = 100;\nconst maximumNodes = 500;\nconst defaultMaxRelationships = 200;\nconst maximumRelationships = 1_000;\nconst defaultMaxDepth = 1;\nconst maximumDepth = 4;\nconst maximumRoots = 20;\n\ntype ResolvedGraphExploreBase = Readonly<{\n nodeTypes: readonly string[];\n relationships: readonly string[];\n maxNodes: number;\n maxRelationships: number;\n abortSignal?: AbortSignal | undefined;\n}>;\n\nexport type ResolvedGraphExploreOverviewOptions = ResolvedGraphExploreBase &\n Readonly<{ mode: \"overview\" }>;\n\nexport type ResolvedGraphExploreExpandOptions = ResolvedGraphExploreBase &\n Readonly<{\n mode: \"expand\";\n nodeIds: readonly string[];\n direction: GraphExploreDirection;\n maxDepth: number;\n }>;\n\nexport type ResolvedGraphExploreOptions =\n | ResolvedGraphExploreOverviewOptions\n | ResolvedGraphExploreExpandOptions;\n\nexport function resolveGraphExploreOptions<Schema extends GraphSchemaLike>(\n schema: Schema,\n options: GraphExploreOptions<Schema>,\n): ResolvedGraphExploreOptions {\n const nodeTypes = resolveNames(options.nodeTypes, Object.keys(schema.nodes), \"node type\");\n const relationships = resolveNames(\n options.relationships,\n Object.keys(schema.relationships),\n \"relationship type\",\n true,\n );\n const base: {\n nodeTypes: string[];\n relationships: string[];\n maxNodes: number;\n maxRelationships: number;\n abortSignal?: AbortSignal | undefined;\n } = {\n nodeTypes,\n relationships,\n maxNodes: boundedInteger(options.maxNodes, defaultMaxNodes, maximumNodes, \"maxNodes\"),\n maxRelationships: boundedInteger(\n options.maxRelationships,\n defaultMaxRelationships,\n maximumRelationships,\n \"maxRelationships\",\n ),\n };\n if (options.abortSignal !== undefined) base.abortSignal = options.abortSignal;\n if (options.mode === \"overview\") {\n return { ...base, mode: \"overview\" };\n }\n const nodeIds = uniqueNonEmptyStrings(options.nodeIds, \"node id\");\n if (nodeIds.length === 0) {\n throw new TypeError(\"Graph expansion requires at least one node id.\");\n }\n if (nodeIds.length > maximumRoots) {\n throw new RangeError(`Graph expansion accepts at most ${maximumRoots} root nodes.`);\n }\n const direction = options.direction ?? \"both\";\n if (direction !== \"outgoing\" && direction !== \"incoming\" && direction !== \"both\") {\n throw new TypeError(\"Graph expansion direction must be outgoing, incoming, or both.\");\n }\n return {\n ...base,\n mode: \"expand\",\n nodeIds,\n direction,\n maxDepth: boundedInteger(options.maxDepth, defaultMaxDepth, maximumDepth, \"maxDepth\"),\n };\n}\n\nfunction resolveNames(\n selected: readonly string[] | undefined,\n available: readonly string[],\n label: string,\n allowEmpty = false,\n): string[] {\n const values = selected === undefined ? [...available] : uniqueNonEmptyStrings(selected, label);\n if (!allowEmpty && values.length === 0) {\n throw new TypeError(`Graph exploration requires at least one ${label}.`);\n }\n const known = new Set(available);\n for (const value of values) {\n if (!known.has(value))\n throw new TypeError(`Graph exploration references unknown ${label} ${value}.`);\n }\n return values;\n}\n\nfunction uniqueNonEmptyStrings(values: readonly string[], label: string): string[] {\n const unique = new Set<string>();\n for (const value of values) {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new TypeError(`Graph ${label} must be a non-empty string.`);\n }\n if (unique.has(value)) throw new TypeError(`Duplicate graph ${label}: ${value}.`);\n unique.add(value);\n }\n return [...unique];\n}\n\nfunction boundedInteger(\n value: number | undefined,\n fallback: number,\n maximum: number,\n label: string,\n): number {\n const resolved = value ?? fallback;\n if (!Number.isSafeInteger(resolved) || resolved < 1 || resolved > maximum) {\n throw new RangeError(`Graph exploration ${label} must be between 1 and ${maximum}.`);\n }\n return resolved;\n}\n"],"mappings":";AAEA,IAAM,kBAAkB;AACxB,IAAM,eAAe;AACrB,IAAM,0BAA0B;AAChC,IAAM,uBAAuB;AAC7B,IAAM,kBAAkB;AACxB,IAAM,eAAe;AACrB,IAAM,eAAe;AAyBd,SAAS,2BACd,QACA,SAC6B;AAC7B,QAAM,YAAY,aAAa,QAAQ,WAAW,OAAO,KAAK,OAAO,KAAK,GAAG,WAAW;AACxF,QAAM,gBAAgB;AAAA,IACpB,QAAQ;AAAA,IACR,OAAO,KAAK,OAAO,aAAa;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AACA,QAAM,OAMF;AAAA,IACF;AAAA,IACA;AAAA,IACA,UAAU,eAAe,QAAQ,UAAU,iBAAiB,cAAc,UAAU;AAAA,IACpF,kBAAkB;AAAA,MAChB,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,MAAI,QAAQ,gBAAgB,OAAW,MAAK,cAAc,QAAQ;AAClE,MAAI,QAAQ,SAAS,YAAY;AAC/B,WAAO,EAAE,GAAG,MAAM,MAAM,WAAW;AAAA,EACrC;AACA,QAAM,UAAU,sBAAsB,QAAQ,SAAS,SAAS;AAChE,MAAI,QAAQ,WAAW,GAAG;AACxB,UAAM,IAAI,UAAU,gDAAgD;AAAA,EACtE;AACA,MAAI,QAAQ,SAAS,cAAc;AACjC,UAAM,IAAI,WAAW,mCAAmC,YAAY,cAAc;AAAA,EACpF;AACA,QAAM,YAAY,QAAQ,aAAa;AACvC,MAAI,cAAc,cAAc,cAAc,cAAc,cAAc,QAAQ;AAChF,UAAM,IAAI,UAAU,gEAAgE;AAAA,EACtF;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,eAAe,QAAQ,UAAU,iBAAiB,cAAc,UAAU;AAAA,EACtF;AACF;AAEA,SAAS,aACP,UACA,WACA,OACA,aAAa,OACH;AACV,QAAM,SAAS,aAAa,SAAY,CAAC,GAAG,SAAS,IAAI,sBAAsB,UAAU,KAAK;AAC9F,MAAI,CAAC,cAAc,OAAO,WAAW,GAAG;AACtC,UAAM,IAAI,UAAU,2CAA2C,KAAK,GAAG;AAAA,EACzE;AACA,QAAM,QAAQ,IAAI,IAAI,SAAS;AAC/B,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,MAAM,IAAI,KAAK;AAClB,YAAM,IAAI,UAAU,wCAAwC,KAAK,IAAI,KAAK,GAAG;AAAA,EACjF;AACA,SAAO;AACT;AAEA,SAAS,sBAAsB,QAA2B,OAAyB;AACjF,QAAM,SAAS,oBAAI,IAAY;AAC/B,aAAW,SAAS,QAAQ;AAC1B,QAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG;AACnD,YAAM,IAAI,UAAU,SAAS,KAAK,8BAA8B;AAAA,IAClE;AACA,QAAI,OAAO,IAAI,KAAK,EAAG,OAAM,IAAI,UAAU,mBAAmB,KAAK,KAAK,KAAK,GAAG;AAChF,WAAO,IAAI,KAAK;AAAA,EAClB;AACA,SAAO,CAAC,GAAG,MAAM;AACnB;AAEA,SAAS,eACP,OACA,UACA,SACA,OACQ;AACR,QAAM,WAAW,SAAS;AAC1B,MAAI,CAAC,OAAO,cAAc,QAAQ,KAAK,WAAW,KAAK,WAAW,SAAS;AACzE,UAAM,IAAI,WAAW,qBAAqB,KAAK,0BAA0B,OAAO,GAAG;AAAA,EACrF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { RetrySetting, CompletionModel, Usage } from '@anvia/core';
|
|
2
|
+
import { EmbeddingModel, EmbeddedDocument } from '@anvia/core/embeddings';
|
|
3
|
+
import { Tool } from '@anvia/core/tool';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
type GraphPropertyPrimitive = string | number | boolean;
|
|
7
|
+
type GraphPropertyValue = GraphPropertyPrimitive | readonly string[] | readonly number[] | readonly boolean[];
|
|
8
|
+
type GraphProperties = Readonly<Record<string, GraphPropertyValue>>;
|
|
9
|
+
type GraphNodeIdentity = Readonly<Record<string, GraphPropertyPrimitive>>;
|
|
10
|
+
type GraphNodeDefinition = Readonly<{
|
|
11
|
+
description: string;
|
|
12
|
+
identity: readonly string[];
|
|
13
|
+
properties: z.ZodObject<z.ZodRawShape>;
|
|
14
|
+
}>;
|
|
15
|
+
type GraphRelationshipDefinition = Readonly<{
|
|
16
|
+
description: string;
|
|
17
|
+
from: string;
|
|
18
|
+
to: string;
|
|
19
|
+
identity?: readonly string[] | undefined;
|
|
20
|
+
properties: z.ZodObject<z.ZodRawShape>;
|
|
21
|
+
}>;
|
|
22
|
+
type GraphSchemaOptions = Readonly<{
|
|
23
|
+
nodes: Readonly<Record<string, GraphNodeDefinition>>;
|
|
24
|
+
relationships: Readonly<Record<string, GraphRelationshipDefinition>>;
|
|
25
|
+
}>;
|
|
26
|
+
type GraphSchema<Options extends GraphSchemaOptions = GraphSchemaOptions> = Readonly<Options & {
|
|
27
|
+
kind: "graph-schema";
|
|
28
|
+
}>;
|
|
29
|
+
type GraphSchemaLike<Options extends GraphSchemaOptions = GraphSchemaOptions> = Readonly<Options & {
|
|
30
|
+
kind: string;
|
|
31
|
+
}>;
|
|
32
|
+
type NodeDefinitions<Schema extends GraphSchemaLike> = Schema["nodes"];
|
|
33
|
+
type RelationshipDefinitions<Schema extends GraphSchemaLike> = Schema["relationships"];
|
|
34
|
+
type GraphEntity<Schema extends GraphSchemaLike = GraphSchemaLike> = {
|
|
35
|
+
[Type in keyof NodeDefinitions<Schema> & string]: Readonly<{
|
|
36
|
+
key: string;
|
|
37
|
+
type: Type;
|
|
38
|
+
identity: GraphNodeIdentity;
|
|
39
|
+
properties: z.output<NodeDefinitions<Schema>[Type]["properties"]> & GraphProperties;
|
|
40
|
+
sourceChunkIds: readonly string[];
|
|
41
|
+
}>;
|
|
42
|
+
}[keyof NodeDefinitions<Schema> & string];
|
|
43
|
+
type GraphRelationship<Schema extends GraphSchemaLike = GraphSchemaLike> = {
|
|
44
|
+
[Type in keyof RelationshipDefinitions<Schema> & string]: Readonly<{
|
|
45
|
+
key: string;
|
|
46
|
+
type: Type;
|
|
47
|
+
from: string;
|
|
48
|
+
to: string;
|
|
49
|
+
properties: z.output<RelationshipDefinitions<Schema>[Type]["properties"]> & GraphProperties;
|
|
50
|
+
sourceChunkIds: readonly string[];
|
|
51
|
+
}>;
|
|
52
|
+
}[keyof RelationshipDefinitions<Schema> & string];
|
|
53
|
+
type GraphMention = Readonly<{
|
|
54
|
+
chunkId: string;
|
|
55
|
+
entityKey: string;
|
|
56
|
+
}>;
|
|
57
|
+
type GraphFacts<Schema extends GraphSchemaLike = GraphSchemaLike> = Readonly<{
|
|
58
|
+
entities: readonly GraphEntity<Schema>[];
|
|
59
|
+
relationships: readonly GraphRelationship<Schema>[];
|
|
60
|
+
mentions: readonly GraphMention[];
|
|
61
|
+
}>;
|
|
62
|
+
type GraphChunk<Metadata extends GraphProperties = GraphProperties> = Readonly<{
|
|
63
|
+
id: string;
|
|
64
|
+
documentId: string;
|
|
65
|
+
index: number;
|
|
66
|
+
text: string;
|
|
67
|
+
metadata?: Metadata | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
type GraphDocument<Properties extends GraphProperties = GraphProperties> = Readonly<{
|
|
70
|
+
id: string;
|
|
71
|
+
properties?: Properties | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
type ExtractGraphFactsOptions<Schema extends GraphSchemaLike, Model extends CompletionModel> = Readonly<{
|
|
74
|
+
model: Model;
|
|
75
|
+
schema: Schema;
|
|
76
|
+
chunks: readonly GraphChunk[];
|
|
77
|
+
instructions?: string | undefined;
|
|
78
|
+
retries?: RetrySetting | undefined;
|
|
79
|
+
concurrency?: number | undefined;
|
|
80
|
+
abortSignal?: AbortSignal | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
type ExtractGraphFactsResult<Schema extends GraphSchemaLike> = Readonly<{
|
|
83
|
+
output: GraphFacts<Schema>;
|
|
84
|
+
usage: Usage;
|
|
85
|
+
}>;
|
|
86
|
+
type GraphVectorSearchOptions = Readonly<{
|
|
87
|
+
type: "vector";
|
|
88
|
+
seeds: readonly string[];
|
|
89
|
+
topK: number;
|
|
90
|
+
minScore?: number | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
type GraphHybridSearchOptions = Readonly<{
|
|
93
|
+
type: "hybrid";
|
|
94
|
+
seeds: readonly string[];
|
|
95
|
+
topK: number;
|
|
96
|
+
candidatesPerSeed: number;
|
|
97
|
+
rrfK: number;
|
|
98
|
+
}>;
|
|
99
|
+
type GraphSearchOptions = GraphVectorSearchOptions | GraphHybridSearchOptions;
|
|
100
|
+
type GraphEvidenceOptions = Readonly<{
|
|
101
|
+
type: "none";
|
|
102
|
+
}> | Readonly<{
|
|
103
|
+
type: "chunks";
|
|
104
|
+
maxChunks: number;
|
|
105
|
+
}>;
|
|
106
|
+
type GraphTraversalOptions<Schema extends GraphSchemaLike = GraphSchemaLike> = Readonly<{
|
|
107
|
+
relationships: readonly (keyof Schema["relationships"] & string)[];
|
|
108
|
+
direction: "outgoing" | "incoming" | "both";
|
|
109
|
+
maxDepth: number;
|
|
110
|
+
maxNodes: number;
|
|
111
|
+
maxRelationships: number;
|
|
112
|
+
}>;
|
|
113
|
+
type GraphContextSeed = Readonly<{
|
|
114
|
+
key: string;
|
|
115
|
+
type: string;
|
|
116
|
+
score: number;
|
|
117
|
+
properties: GraphProperties;
|
|
118
|
+
sourceChunkIds: readonly string[];
|
|
119
|
+
}>;
|
|
120
|
+
type GraphContextNode = Readonly<{
|
|
121
|
+
key: string;
|
|
122
|
+
type: string;
|
|
123
|
+
identity: GraphNodeIdentity;
|
|
124
|
+
properties: GraphProperties;
|
|
125
|
+
sourceChunkIds: readonly string[];
|
|
126
|
+
}>;
|
|
127
|
+
type GraphContextRelationship = Readonly<{
|
|
128
|
+
key: string;
|
|
129
|
+
type: string;
|
|
130
|
+
from: string;
|
|
131
|
+
to: string;
|
|
132
|
+
properties: GraphProperties;
|
|
133
|
+
sourceChunkIds: readonly string[];
|
|
134
|
+
}>;
|
|
135
|
+
type GraphEvidence = Readonly<{
|
|
136
|
+
chunkId: string;
|
|
137
|
+
documentId: string;
|
|
138
|
+
index: number;
|
|
139
|
+
text: string;
|
|
140
|
+
metadata: GraphProperties;
|
|
141
|
+
}>;
|
|
142
|
+
type GraphContext = Readonly<{
|
|
143
|
+
seeds: readonly GraphContextSeed[];
|
|
144
|
+
nodes: readonly GraphContextNode[];
|
|
145
|
+
relationships: readonly GraphContextRelationship[];
|
|
146
|
+
evidence: readonly GraphEvidence[];
|
|
147
|
+
}>;
|
|
148
|
+
type GraphEvidenceCapability = "none" | "chunks";
|
|
149
|
+
type GraphEvidenceFor<Capability extends GraphEvidenceCapability> = Extract<GraphEvidenceOptions, {
|
|
150
|
+
type: "none";
|
|
151
|
+
}> | (Capability extends "chunks" ? Extract<GraphEvidenceOptions, {
|
|
152
|
+
type: "chunks";
|
|
153
|
+
}> : never);
|
|
154
|
+
type GraphRetrieveOptions<Schema extends GraphSchemaLike, Evidence extends GraphEvidenceCapability = GraphEvidenceCapability> = Readonly<{
|
|
155
|
+
model: EmbeddingModel;
|
|
156
|
+
query: string;
|
|
157
|
+
search: GraphSearchOptions;
|
|
158
|
+
traversal: GraphTraversalOptions<Schema>;
|
|
159
|
+
evidence: GraphEvidenceFor<Evidence>;
|
|
160
|
+
retries?: RetrySetting | undefined;
|
|
161
|
+
abortSignal?: AbortSignal | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
interface GraphContextRetriever<Schema extends GraphSchemaLike = GraphSchemaLike, Evidence extends GraphEvidenceCapability = GraphEvidenceCapability> {
|
|
164
|
+
readonly evidenceCapability: Evidence;
|
|
165
|
+
retrieve(options: GraphRetrieveOptions<Schema, Evidence>): Promise<GraphContext>;
|
|
166
|
+
}
|
|
167
|
+
type GraphExploreDirection = "outgoing" | "incoming" | "both";
|
|
168
|
+
type GraphExploreOverviewOptions<Schema extends GraphSchemaLike> = Readonly<{
|
|
169
|
+
mode: "overview";
|
|
170
|
+
nodeTypes?: readonly (keyof Schema["nodes"] & string)[] | undefined;
|
|
171
|
+
relationships?: readonly (keyof Schema["relationships"] & string)[] | undefined;
|
|
172
|
+
maxNodes?: number | undefined;
|
|
173
|
+
maxRelationships?: number | undefined;
|
|
174
|
+
abortSignal?: AbortSignal | undefined;
|
|
175
|
+
}>;
|
|
176
|
+
type GraphExploreExpandOptions<Schema extends GraphSchemaLike> = Readonly<{
|
|
177
|
+
mode: "expand";
|
|
178
|
+
nodeIds: readonly string[];
|
|
179
|
+
nodeTypes?: readonly (keyof Schema["nodes"] & string)[] | undefined;
|
|
180
|
+
relationships?: readonly (keyof Schema["relationships"] & string)[] | undefined;
|
|
181
|
+
direction?: GraphExploreDirection | undefined;
|
|
182
|
+
maxDepth?: number | undefined;
|
|
183
|
+
maxNodes?: number | undefined;
|
|
184
|
+
maxRelationships?: number | undefined;
|
|
185
|
+
abortSignal?: AbortSignal | undefined;
|
|
186
|
+
}>;
|
|
187
|
+
type GraphExploreOptions<Schema extends GraphSchemaLike> = GraphExploreOverviewOptions<Schema> | GraphExploreExpandOptions<Schema>;
|
|
188
|
+
type GraphExploreNode = Readonly<{
|
|
189
|
+
id: string;
|
|
190
|
+
key?: string | undefined;
|
|
191
|
+
type: string;
|
|
192
|
+
identity: GraphNodeIdentity;
|
|
193
|
+
properties: GraphProperties;
|
|
194
|
+
}>;
|
|
195
|
+
type GraphExploreRelationship = Readonly<{
|
|
196
|
+
id: string;
|
|
197
|
+
key?: string | undefined;
|
|
198
|
+
type: string;
|
|
199
|
+
from: string;
|
|
200
|
+
to: string;
|
|
201
|
+
properties: GraphProperties;
|
|
202
|
+
}>;
|
|
203
|
+
type GraphExploreResult = Readonly<{
|
|
204
|
+
nodes: readonly GraphExploreNode[];
|
|
205
|
+
relationships: readonly GraphExploreRelationship[];
|
|
206
|
+
truncated: Readonly<{
|
|
207
|
+
nodes: boolean;
|
|
208
|
+
relationships: boolean;
|
|
209
|
+
}>;
|
|
210
|
+
}>;
|
|
211
|
+
interface GraphExplorer<Schema extends GraphSchemaLike = GraphSchemaLike> {
|
|
212
|
+
readonly schema: Schema;
|
|
213
|
+
explore(options: GraphExploreOptions<Schema>): Promise<GraphExploreResult>;
|
|
214
|
+
}
|
|
215
|
+
type CreateGraphSearchToolOptions<Schema extends GraphSchemaLike, Retriever extends GraphContextRetriever<Schema> = GraphContextRetriever<Schema>> = Readonly<{
|
|
216
|
+
name: string;
|
|
217
|
+
description: string;
|
|
218
|
+
graph: Retriever;
|
|
219
|
+
model: EmbeddingModel;
|
|
220
|
+
search: GraphSearchOptions;
|
|
221
|
+
traversal: GraphTraversalOptions<Schema>;
|
|
222
|
+
evidence: GraphEvidenceFor<Retriever["evidenceCapability"]>;
|
|
223
|
+
retries?: RetrySetting | undefined;
|
|
224
|
+
}>;
|
|
225
|
+
type GraphSearchTool = Tool<{
|
|
226
|
+
query: string;
|
|
227
|
+
}, GraphContext>;
|
|
228
|
+
type GraphChangeCounts = Readonly<{
|
|
229
|
+
created: number;
|
|
230
|
+
updated: number;
|
|
231
|
+
deleted: number;
|
|
232
|
+
unchanged: number;
|
|
233
|
+
}>;
|
|
234
|
+
type GraphWriteResult = Readonly<{
|
|
235
|
+
documents: GraphChangeCounts;
|
|
236
|
+
chunks: GraphChangeCounts;
|
|
237
|
+
entities: GraphChangeCounts;
|
|
238
|
+
relationships: GraphChangeCounts;
|
|
239
|
+
mentions: GraphChangeCounts;
|
|
240
|
+
}>;
|
|
241
|
+
type GraphWriteConflict = "error" | "overwrite" | "keep-existing";
|
|
242
|
+
type GraphOrphanEntityPolicy = "delete" | "keep";
|
|
243
|
+
type ReplaceGraphDocumentsOptions<Schema extends GraphSchemaLike> = Readonly<{
|
|
244
|
+
documents: readonly GraphDocument[];
|
|
245
|
+
chunks: readonly EmbeddedDocument<GraphChunk>[];
|
|
246
|
+
entities: readonly EmbeddedDocument<GraphEntity<Schema>>[];
|
|
247
|
+
relationships: readonly GraphRelationship<Schema>[];
|
|
248
|
+
mentions: readonly GraphMention[];
|
|
249
|
+
conflict: GraphWriteConflict;
|
|
250
|
+
orphanEntities: GraphOrphanEntityPolicy;
|
|
251
|
+
abortSignal?: AbortSignal | undefined;
|
|
252
|
+
}>;
|
|
253
|
+
interface GraphDocumentWriter<Schema extends GraphSchemaLike = GraphSchemaLike> {
|
|
254
|
+
readonly schema: Schema;
|
|
255
|
+
replaceDocuments(options: ReplaceGraphDocumentsOptions<Schema>): Promise<GraphWriteResult>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
type ResolvedGraphExploreBase = Readonly<{
|
|
259
|
+
nodeTypes: readonly string[];
|
|
260
|
+
relationships: readonly string[];
|
|
261
|
+
maxNodes: number;
|
|
262
|
+
maxRelationships: number;
|
|
263
|
+
abortSignal?: AbortSignal | undefined;
|
|
264
|
+
}>;
|
|
265
|
+
type ResolvedGraphExploreOverviewOptions = ResolvedGraphExploreBase & Readonly<{
|
|
266
|
+
mode: "overview";
|
|
267
|
+
}>;
|
|
268
|
+
type ResolvedGraphExploreExpandOptions = ResolvedGraphExploreBase & Readonly<{
|
|
269
|
+
mode: "expand";
|
|
270
|
+
nodeIds: readonly string[];
|
|
271
|
+
direction: GraphExploreDirection;
|
|
272
|
+
maxDepth: number;
|
|
273
|
+
}>;
|
|
274
|
+
type ResolvedGraphExploreOptions = ResolvedGraphExploreOverviewOptions | ResolvedGraphExploreExpandOptions;
|
|
275
|
+
declare function resolveGraphExploreOptions<Schema extends GraphSchemaLike>(schema: Schema, options: GraphExploreOptions<Schema>): ResolvedGraphExploreOptions;
|
|
276
|
+
|
|
277
|
+
export { type GraphExploreExpandOptions as A, type GraphExploreNode as B, type CreateGraphSearchToolOptions as C, type GraphExploreOptions as D, type ExtractGraphFactsOptions as E, type GraphExploreOverviewOptions as F, type GraphSchemaLike as G, type GraphExploreRelationship as H, type GraphExploreResult as I, type GraphExplorer as J, type GraphFacts as K, type GraphHybridSearchOptions as L, type GraphNodeDefinition as M, type GraphNodeIdentity as N, type GraphPropertyPrimitive as O, type GraphRelationshipDefinition as P, type GraphRetrieveOptions as Q, type GraphSearchOptions as R, type GraphTraversalOptions as S, type GraphVectorSearchOptions as T, type ReplaceGraphDocumentsOptions as U, type ResolvedGraphExploreExpandOptions as V, type ResolvedGraphExploreOptions as W, type ResolvedGraphExploreOverviewOptions as X, resolveGraphExploreOptions as Y, type ExtractGraphFactsResult as a, type GraphEntity as b, type GraphDocumentWriter as c, type GraphWriteConflict as d, type GraphOrphanEntityPolicy as e, type GraphDocument as f, type GraphChunk as g, type GraphRelationship as h, type GraphMention as i, type GraphWriteResult as j, type GraphSchemaOptions as k, type GraphSchema as l, type GraphProperties as m, type GraphPropertyValue as n, type GraphContextRetriever as o, type GraphSearchTool as p, type GraphChangeCounts as q, type GraphContext as r, type GraphContextNode as s, type GraphContextRelationship as t, type GraphContextSeed as u, type GraphEvidence as v, type GraphEvidenceCapability as w, type GraphEvidenceFor as x, type GraphEvidenceOptions as y, type GraphExploreDirection as z };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { V as ResolvedGraphExploreExpandOptions, W as ResolvedGraphExploreOptions, X as ResolvedGraphExploreOverviewOptions, Y as resolveGraphExploreOptions } from './explore-9jm2c1mG.js';
|
|
2
|
+
import '@anvia/core';
|
|
3
|
+
import '@anvia/core/embeddings';
|
|
4
|
+
import '@anvia/core/tool';
|
|
5
|
+
import 'zod';
|
package/dist/explore.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as _anvia_core from '@anvia/core';
|
|
2
|
+
import { CompletionModel, RetrySetting, Usage } from '@anvia/core';
|
|
3
|
+
import { G as GraphSchemaLike, E as ExtractGraphFactsOptions, a as ExtractGraphFactsResult, b as GraphEntity, c as GraphDocumentWriter, d as GraphWriteConflict, e as GraphOrphanEntityPolicy, f as GraphDocument, g as GraphChunk, h as GraphRelationship, i as GraphMention, j as GraphWriteResult, k as GraphSchemaOptions, l as GraphSchema, m as GraphProperties, n as GraphPropertyValue, o as GraphContextRetriever, C as CreateGraphSearchToolOptions, p as GraphSearchTool } from './explore-9jm2c1mG.js';
|
|
4
|
+
export { q as GraphChangeCounts, r as GraphContext, s as GraphContextNode, t as GraphContextRelationship, u as GraphContextSeed, v as GraphEvidence, w as GraphEvidenceCapability, x as GraphEvidenceFor, y as GraphEvidenceOptions, z as GraphExploreDirection, A as GraphExploreExpandOptions, B as GraphExploreNode, D as GraphExploreOptions, F as GraphExploreOverviewOptions, H as GraphExploreRelationship, I as GraphExploreResult, J as GraphExplorer, K as GraphFacts, L as GraphHybridSearchOptions, M as GraphNodeDefinition, N as GraphNodeIdentity, O as GraphPropertyPrimitive, P as GraphRelationshipDefinition, Q as GraphRetrieveOptions, R as GraphSearchOptions, S as GraphTraversalOptions, T as GraphVectorSearchOptions, U as ReplaceGraphDocumentsOptions, V as ResolvedGraphExploreExpandOptions, W as ResolvedGraphExploreOptions, X as ResolvedGraphExploreOverviewOptions, Y as resolveGraphExploreOptions } from './explore-9jm2c1mG.js';
|
|
5
|
+
import { TextDocument, TextDocumentMetadata, TextDocumentChunkingOptions } from '@anvia/core/documents';
|
|
6
|
+
import { EmbeddingModel, EmbeddedDocument } from '@anvia/core/embeddings';
|
|
7
|
+
import '@anvia/core/tool';
|
|
8
|
+
import 'zod';
|
|
9
|
+
|
|
10
|
+
declare function extractGraphFacts<Schema extends GraphSchemaLike, Model extends _anvia_core.CompletionModel>(options: ExtractGraphFactsOptions<Schema, Model>): Promise<ExtractGraphFactsResult<Schema>>;
|
|
11
|
+
declare class GraphFactConflictError extends Error {
|
|
12
|
+
readonly factKey: string;
|
|
13
|
+
readonly sourceChunkIds: readonly string[];
|
|
14
|
+
constructor(factKey: string, sourceChunkIds: readonly string[]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type GraphPreparationOptions<Schema extends GraphSchemaLike, ExtractionModel extends CompletionModel> = Readonly<{
|
|
18
|
+
graph: Readonly<{
|
|
19
|
+
schema: Schema;
|
|
20
|
+
}>;
|
|
21
|
+
documents: readonly TextDocument<TextDocumentMetadata>[];
|
|
22
|
+
extractionModel: ExtractionModel;
|
|
23
|
+
embeddingModel: EmbeddingModel;
|
|
24
|
+
chunking?: TextDocumentChunkingOptions | undefined;
|
|
25
|
+
entityText?: ((entity: GraphEntity<Schema>) => string) | undefined;
|
|
26
|
+
instructions?: string | undefined;
|
|
27
|
+
retries?: RetrySetting | undefined;
|
|
28
|
+
concurrency?: number | undefined;
|
|
29
|
+
abortSignal?: AbortSignal | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
type PrepareGraphDocumentsOptions<Schema extends GraphSchemaLike, ExtractionModel extends CompletionModel = CompletionModel> = GraphPreparationOptions<Schema, ExtractionModel>;
|
|
32
|
+
type IngestGraphDocumentsOptions<Schema extends GraphSchemaLike, ExtractionModel extends CompletionModel = CompletionModel> = Omit<GraphPreparationOptions<Schema, ExtractionModel>, "graph"> & Readonly<{
|
|
33
|
+
graph: GraphDocumentWriter<Schema>;
|
|
34
|
+
conflict: GraphWriteConflict;
|
|
35
|
+
orphanEntities: GraphOrphanEntityPolicy;
|
|
36
|
+
}>;
|
|
37
|
+
type IngestGraphTextOptions<Schema extends GraphSchemaLike, ExtractionModel extends CompletionModel = CompletionModel> = Omit<IngestGraphDocumentsOptions<Schema, ExtractionModel>, "documents"> & Readonly<{
|
|
38
|
+
document: TextDocument<TextDocumentMetadata>;
|
|
39
|
+
}>;
|
|
40
|
+
type PreparedGraphDocuments<Schema extends GraphSchemaLike> = Readonly<{
|
|
41
|
+
documents: readonly GraphDocument[];
|
|
42
|
+
chunks: readonly EmbeddedDocument<GraphChunk<TextDocumentMetadata>, TextDocumentMetadata>[];
|
|
43
|
+
vectorDocuments: readonly EmbeddedDocument<TextDocument<TextDocumentMetadata>, TextDocumentMetadata>[];
|
|
44
|
+
entities: readonly EmbeddedDocument<GraphEntity<Schema>>[];
|
|
45
|
+
relationships: readonly GraphRelationship<Schema>[];
|
|
46
|
+
mentions: readonly GraphMention[];
|
|
47
|
+
usage: Usage;
|
|
48
|
+
}>;
|
|
49
|
+
type IngestGraphDocumentsResult<Schema extends GraphSchemaLike> = PreparedGraphDocuments<Schema> & Readonly<{
|
|
50
|
+
write: GraphWriteResult;
|
|
51
|
+
}>;
|
|
52
|
+
declare function ingestGraphText<Schema extends GraphSchemaLike, ExtractionModel extends CompletionModel>(options: IngestGraphTextOptions<Schema, ExtractionModel>): Promise<IngestGraphDocumentsResult<Schema>>;
|
|
53
|
+
declare function ingestGraphDocuments<Schema extends GraphSchemaLike, ExtractionModel extends CompletionModel>(options: IngestGraphDocumentsOptions<Schema, ExtractionModel>): Promise<IngestGraphDocumentsResult<Schema>>;
|
|
54
|
+
declare function prepareGraphDocuments<Schema extends GraphSchemaLike, ExtractionModel extends CompletionModel>(options: PrepareGraphDocumentsOptions<Schema, ExtractionModel>): Promise<PreparedGraphDocuments<Schema>>;
|
|
55
|
+
|
|
56
|
+
declare const graphReservedPropertyPrefix = "__anvia_";
|
|
57
|
+
declare function defineGraphSchema<const Options extends GraphSchemaOptions>(options: Options): GraphSchema<Options>;
|
|
58
|
+
declare function validateGraphSchemaOptions(options: GraphSchemaOptions): void;
|
|
59
|
+
declare function freezeGraphSchema<const Options extends GraphSchemaOptions, const Kind extends string>(options: Options, kind: Kind): Readonly<Options & {
|
|
60
|
+
kind: Kind;
|
|
61
|
+
}>;
|
|
62
|
+
declare function parseGraphProperties(value: unknown, label: string): GraphProperties;
|
|
63
|
+
declare function parseGraphPropertyValue(value: unknown, label: string): GraphPropertyValue;
|
|
64
|
+
declare function assertGraphName(value: string, label: string): void;
|
|
65
|
+
declare function assertGraphPropertyName(value: string): void;
|
|
66
|
+
|
|
67
|
+
declare function createGraphSearchTool<Schema extends GraphSchemaLike, Retriever extends GraphContextRetriever<Schema>>(options: CreateGraphSearchToolOptions<Schema, Retriever>): GraphSearchTool;
|
|
68
|
+
|
|
69
|
+
export { CreateGraphSearchToolOptions, ExtractGraphFactsOptions, ExtractGraphFactsResult, GraphChunk, GraphContextRetriever, GraphDocument, GraphDocumentWriter, GraphEntity, GraphFactConflictError, GraphMention, GraphOrphanEntityPolicy, GraphProperties, GraphPropertyValue, GraphRelationship, GraphSchema, GraphSchemaLike, GraphSchemaOptions, GraphSearchTool, GraphWriteConflict, GraphWriteResult, type IngestGraphDocumentsOptions, type IngestGraphDocumentsResult, type IngestGraphTextOptions, type PrepareGraphDocumentsOptions, type PreparedGraphDocuments, assertGraphName, assertGraphPropertyName, createGraphSearchTool, defineGraphSchema, extractGraphFacts, freezeGraphSchema, graphReservedPropertyPrefix, ingestGraphDocuments, ingestGraphText, parseGraphProperties, parseGraphPropertyValue, prepareGraphDocuments, validateGraphSchemaOptions };
|