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.0

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.0
File Size Uploaded Provenance Actions
langchain_hypergraph-2.0.0.tar.gz 9.6 kB Without provenance Details for langchain_hypergraph-2.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 17.4 kB

Release files / langchain_hypergraph-2.0.0.tar.gz

Download URL langchain_hypergraph-2.0.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6a41e2c47bdda04760b49550fbd286945947ad86f6fe4a9d59f2798455186fc2
BLAKE2b-256 checksum
How to use checksums
76fcea1838a93eddbc79f6972c0c7609a69d1c9828da733d243befb0ba7c1190
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.13

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

Download URL langchain_hypergraph-2.0.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6673e599816b8e30c038eaab43929af01267df035dcda5fa88d86f092f947072
BLAKE2b-256 checksum
How to use checksums
f4c77a39dc3d6ba6b1a68f53eb59a7f295a5d1715cd8ec30bb1a64ecf2c8e1b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.13

Security for langchain-hypergraph 2.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.0 This release

2 release files No 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