@anvia/graph ​
@anvia/graph is the provider-neutral knowledge-graph layer for Anvia. It owns typed graph schemas, fact extraction, raw-text ingestion, retrieval contracts, graph search tools, and bounded exploration. Database connections, provisioning, persistence, and query execution stay in an adapter such as @anvia/neo4j or @anvia/memgraph.
Install ​
sh
pnpm add @anvia/graph @anvia/core zodInstall one graph adapter alongside it:
sh
pnpm add @anvia/neo4j
# or
pnpm add @anvia/memgraphPortable workflow ​
text
raw text → deterministic chunks → typed fact extraction
→ chunk/entity embeddings → managed graph write
query → vector or hybrid seeds → bounded traversal → optional source evidenceThe same schema, ingestion helpers, retrieval options, result types, and Agent tool factory work with either first-party adapter. Provider-specific configuration is limited to the client and graph registration.
Main entry points ​
| API | Purpose |
|---|---|
defineGraphSchema() | Define typed nodes, relationships, identities, and strict property schemas. |
extractGraphFacts() | Extract schema-valid entities, relationships, and source mentions. |
ingestGraphText() | Chunk, extract, embed, and replace one raw-text source document. |
ingestGraphDocuments() | Apply the same workflow to a batch of documents. |
prepareGraphDocuments() | Prepare graph and reusable vector records without writing them. |
createGraphSearchTool() | Expose any compatible graph retriever as an Agent tool. |
GraphExplorer | Read bounded overviews and neighborhoods for visualization. |