Skip to main content

langchain-hypergraph

LangChain chat memory and vector store backed by the Temporal Hypergraph Engine.

pip install langchain-hypergraph
docker run -d -p 50051:50051 ghcr.io/divyansh151005/temporal-hypergraph-server

For development from a clone: pip install -e integrations/python-client -e integrations/langchain.

from langchain_hypergraph import TemporalHypergraph

memory = TemporalHypergraph(api_key="your_key")  # a TemporalHypergraphMemory on session "default"
memory = TemporalHypergraph(api_key="your_key", session_id="user-42")

The server address comes from endpoint= or $HYPERGRAPH_ENDPOINT (default localhost:50051).

Chat memory

TemporalHypergraphMemory is a BaseChatMessageHistory, so it plugs into RunnableWithMessageHistory:

from langchain_core.runnables.history import RunnableWithMessageHistory

chat = RunnableWithMessageHistory(
    prompt | llm,
    lambda session_id: TemporalHypergraphMemory(session_id=session_id),
    input_messages_key="input",
    history_messages_key="history",
)
  • Each message becomes one hyperedge connecting the session:<id> node, a per-message record node, and any ids in additional_kwargs["entities"].
  • messages returns the session oldest first (history_limit= keeps the newest N).
  • relevant_context(query, k, k_hops=2) returns the most relevant facts, also reaching those linked through the messages' entities. Pass embeddings= for similarity ranking.
  • ToolMessage.tool_call_id and other message fields besides the text and entities are not stored.

Vector store

from langchain_hypergraph import TemporalHypergraphVectorStore

store = TemporalHypergraphVectorStore(embeddings)
store.add_texts(
    ["Acme acquired Beta"],
    [{"entities": ["org:acme", "org:beta"], "valid_from": 1696118400, "event_type": "ACQUISITION"}],
)
store.similarity_search("who owns Beta?", k=4, as_of=1700000000)
store.similarity_search("Beta CEO", seed_entities=["org:acme"], k_hops=3)
  • Recognized metadata: entities, valid_from, valid_to (epoch seconds), event_type, confidence. Other metadata is dropped; the engine stores only the text and the graph structure.
  • Ids are assigned by the engine and returned by add_texts.
  • Search keywords: as_of, session_id, seed_entities, k_hops, decay_lambda.
  • The embedding dimension must match the server's --embedding-dim.

Tests

cargo build --release -p grpc-server   # for the live tests; they skip otherwise
pytest integrations/langchain

Metadata

Release files for langchain-hypergraph 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-hypergraph 2.0.1
File Size Uploaded Provenance Actions
langchain_hypergraph-2.0.1.tar.gz 9.7 kB With provenance Details for langchain_hypergraph-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-hypergraph 2.0.1
File Interpreter ABI Platform Actions
langchain_hypergraph-2.0.1-py3-none-any.whl Python 3 none any Details for langchain_hypergraph-2.0.1-py3-none-any.whl

Total release size: 17.6 kB

Release files / langchain_hypergraph-2.0.1.tar.gz

Download URL langchain_hypergraph-2.0.1.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
558a323a0afe33603cc76a170b3b8834c74052578e208de36593b747e6f5d590
BLAKE2b-256 checksum
How to use checksums
90e7408e59f220911042cf259fb433900e8f3a1b49ea37ef09f37c08c53bf787
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / langchain_hypergraph-2.0.1-py3-none-any.whl

Download URL langchain_hypergraph-2.0.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42ae61da8814e89457a3280d836ed4d0bf21883a6969843ff27d4bfb7a1aa31b
BLAKE2b-256 checksum
How to use checksums
7f23379445d95f16ac80aa6a381fd05e62eec7d5f644cf3d6357524a7a2831ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for langchain-hypergraph 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_hypergraph-2.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page