Overview#
langchain-agensgraph is the LangChain integration for AgensGraph. It provides a full set of production components — a graph store, a pgvector-backed vector store, retrievers, a Text2Cypher QA chain, chat-message history, a LangGraph checkpointer and long-term memory store, an LLM graph transformer, and a shareable connection pool — each with synchronous and asynchronous APIs, built for LangChain 1.x. Every statement goes through the agensgraph-python 2.0 driver.
Components
Class |
What it does |
|---|---|
|
Graph store — run Cypher, introspect the schema, write graph documents. |
|
Vector store (pgvector) — semantic and hybrid search, with add/delete/get. |
|
Retriever — vector (or hybrid) search. |
|
Retriever — search plus each hit’s graph neighbourhood. |
|
Retriever — model-written Cypher run under server-side limits. |
|
Answers a question with generated Cypher run read-only. |
|
|
|
The driver’s connection pool (sync + async), shareable by multiple stores. |
|
Chat-message history stored as an ordered chain of graph vertices. |
|
LangGraph checkpointer — persists agent state so threads resume. |
|
LangGraph |
|
Extracts a graph from text via an LLM; feeds |
The data structures GraphDocument, Node, and Relationship are also exported, as is
log_queries(), which reports every statement a block of code ran and how long each took.
What you get
A graph store and vector store that share one AgensGraph database, with full async surfaces (
aquery,asimilarity_search,aadd_texts,adelete, …).Query results as the driver’s
Vertex,Edge, andPathvalues, with the label, the id, and the properties kept apart.Production vector-store ergonomics:
delete,get_by_ids,effective_search_ratioover-fetch for recall, indexed metadata filters (filter_properties), andbatch_size/embed_batch_sizetuning.Hybrid (semantic + keyword) search via reciprocal rank fusion.
Generated Cypher that is not trusted: writes refused by default, an
EXPLAINcheck before it runs, a read-only transaction, and a timeout. Because a read-only transaction is not a boundary for a role that can run a program on the server host, the Text2Cypher components refuse to run as a superuser or a member ofpg_execute_server_programunless you passallow_server_programs=True; connect them as an ordinary role with read access.Connection pooling, per-query timeouts, schema caching, and
enhanced_schemasampling for better Text2Cypher prompts.
Note
Version 0.3 moves every component onto the agensgraph-python 2.0 driver and adds
the three retrievers, AgensCypherQAChain, AgensStore, and log_queries(). It
changes behaviour that 0.2.0 code relied on: query() returns Vertex / Edge /
Path values, a str parameter is sent as text (so json.dumps(...) around it must
be removed), AgensGraph older than 2.17 is refused at connect, and Python 3.10 is no
longer supported. 0.3.1 is a documentation release; its code is 0.3.0’s.
See Installation.