@anvia/neo4j 1.0.3 → 1.0.5

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.
Files changed (2) hide show
  1. package/README.md +18 -29
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -16,9 +16,8 @@ pnpm add @anvia/graph @anvia/neo4j @anvia/core
16
16
 
17
17
  ```ts
18
18
  import { Agent } from "@anvia/core/agent";
19
- import { embedDocuments } from "@anvia/core/embeddings";
20
- import { createGraphSearchTool } from "@anvia/graph";
21
- import { Neo4jClient, defineNeo4jGraphSchema, extractGraphFacts } from "@anvia/neo4j";
19
+ import { createGraphSearchTool, ingestGraphText } from "@anvia/graph";
20
+ import { Neo4jClient, defineNeo4jGraphSchema } from "@anvia/neo4j";
22
21
  import { z } from "zod";
23
22
 
24
23
  const schema = defineNeo4jGraphSchema({
@@ -71,32 +70,21 @@ const graph = client.managedKnowledgeGraph({
71
70
 
72
71
  await graph.ensure({ indexTimeoutMs: 60_000 });
73
72
 
74
- const facts = await extractGraphFacts({ model: extractionModel, schema, chunks });
75
- const [embeddedChunks, embeddedEntities] = await Promise.all([
76
- embedDocuments({
77
- model: embeddingModel,
78
- documents: chunks,
79
- id: (chunk) => chunk.id,
80
- content: (chunk) => chunk.text,
81
- }),
82
- embedDocuments({
83
- model: embeddingModel,
84
- documents: [...facts.output.entities],
85
- id: (entity) => entity.key,
86
- content: (entity) => formatEntity(entity),
87
- }),
88
- ]);
89
-
90
- const write = await graph.replaceDocuments({
91
- documents,
92
- chunks: embeddedChunks.documents,
93
- entities: embeddedEntities.documents,
94
- relationships: facts.output.relationships,
95
- mentions: facts.output.mentions,
73
+ const ingestion = await ingestGraphText({
74
+ graph,
75
+ document: { id: "incident-42", text },
76
+ extractionModel,
77
+ embeddingModel,
78
+ chunking: {
79
+ strategy: "recursive",
80
+ maxSize: 1_000,
81
+ overlap: 100,
82
+ separators: ["\n\n", "\n", " "],
83
+ },
96
84
  conflict: "error",
97
85
  orphanEntities: "delete",
98
86
  });
99
- console.log(write);
87
+ console.log(ingestion.write);
100
88
 
101
89
  const searchGraph = createGraphSearchTool({
102
90
  name: "search_support_graph",
@@ -123,9 +111,10 @@ const searchGraph = createGraphSearchTool({
123
111
  const agent = new Agent({ id: "support", model: chatModel, tools: [searchGraph] });
124
112
  ```
125
113
 
126
- The application owns file discovery, reading, chunking, entity embedding text, model loading,
127
- retry policy, and Agent lifecycle. `extractGraphFacts()` performs model extraction but no writes.
128
- `replaceDocuments()` performs one deterministic transaction but no model calls.
114
+ The application owns file discovery, reading, model loading, retry policy, and Agent lifecycle.
115
+ `ingestGraphText()` and `ingestGraphDocuments()` provide the convenient end-to-end path. Advanced
116
+ callers can compose `prepareGraphDocuments()`, `extractGraphFacts()`, `embedDocuments()`, and
117
+ `replaceDocuments()` directly when they need custom orchestration.
129
118
 
130
119
  Graph property schemas must use `z.strictObject()` and must not coerce, default, transform,
131
120
  preprocess, catch, trim, or otherwise overwrite values. This keeps extraction, comparison, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvia/neo4j",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Schema-first Neo4j GraphRAG integration for Anvia.",
5
5
  "author": "anvia",
6
6
  "maintainer": "Indra Zulfi",
@@ -28,17 +28,17 @@
28
28
  "dependencies": {
29
29
  "neo4j-driver": "^6.2.0",
30
30
  "zod": "^4.4.3",
31
- "@anvia/graph": "1.0.3"
31
+ "@anvia/graph": "1.0.5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^24.9.1",
35
35
  "tsup": "^8.5.0",
36
36
  "typescript": "^5.9.3",
37
37
  "vitest": "^4.0.8",
38
- "@anvia/core": "1.0.2"
38
+ "@anvia/core": "1.0.4"
39
39
  },
40
40
  "peerDependencies": {
41
- "@anvia/core": "1.0.2"
41
+ "@anvia/core": "1.0.4"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup src/index.ts --format esm --dts --sourcemap --clean",