Skip to main content

Graph-Memory

A blazingly fast, agentic memory library for Chatbots. Graph-Memory combines an L1 Short-Term Buffer with a background L2 Hierarchical Topic Graph and Quantitative JSON State.

Features

  • < 200ms Retrieval Latency: Never wait for an LLM to read chat history.
  • Async Graph Construction: Builds a conceptual memory graph in the background without blocking the user.
  • Dual Semantic Search: Prevents "Catastrophic Misrouting" by searching against both Topic Labels and Expanded Topic Descriptions.
  • Bring Your Own Key (BYOK): Use your own free local embeddings (e.g., HuggingFace) and your own LLM provider (Groq, OpenAI, Gemini) to avoid vendor lock-in and high SaaS fees.

Installation

pip install graph-rag-memory

Quick Start (BYOK)

Because this library requires no paid SaaS subscription, you must inject your own LLM and Embedding functions.

import os
from pydantic import BaseModel
from typing import Optional, Any
from groq import Groq
from sentence_transformers import SentenceTransformer
from graph_memory import MemoryClient

# 1. Define your free local embedder
embedder = SentenceTransformer('all-MiniLM-L6-v2')
def embed_func(text: str) -> list[float]:
    return embedder.encode(text).tolist()

# 2. Define your LLM generator (e.g., using Groq for blazing speed)
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))

def llm_func(sys_prompt: str, user_prompt: str, schema: Optional[BaseModel] = None) -> Any:
    # If a Pydantic schema is provided, force JSON output
    # (Implementation omitted for brevity, use instructor or standard JSON mode)
    pass

# 3. Initialize the Memory Client
memory = MemoryClient(
    llm_generate=llm_func,
    embed_text=embed_func,
    use_query_expansion=True # Turn off for absolute maximum speed
)

# 4. Use it in your chatbot loop
user_id = "user_123"

# Add messages (silently batches to the Graph in the background)
memory.add_message(user_id, "user", "I bought a new Tesla Model 3 today!")

# Retrieve instant, highly accurate context for your chatbot's prompt
context = memory.retrieve_context(user_id, "What car do I drive?")

print(context['short_term_history'])
print(context['long_term_graph_context'])
print(context['global_state'])

Metadata

Release files for graph-rag-memory 0.1.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 graph-rag-memory 0.1.1
File Size Uploaded Provenance Actions
graph_rag_memory-0.1.1.tar.gz 17.1 kB Without provenance Details for graph_rag_memory-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for graph-rag-memory 0.1.1
File Interpreter ABI Platform Actions
graph_rag_memory-0.1.1-py3-none-any.whl Python 3 none any Details for graph_rag_memory-0.1.1-py3-none-any.whl

Total release size: 35.0 kB

Release files / graph_rag_memory-0.1.1.tar.gz

Download URL graph_rag_memory-0.1.1.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c388825b6fc35ad0a8370e6748ca8c8f9eeec7145c9300ecf6b4a04329daf7ec
BLAKE2b-256 checksum
How to use checksums
09b3626946475edd394f3f402a0376a750e2d94ea91f41e04943beb8ecc0b83b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / graph_rag_memory-0.1.1-py3-none-any.whl

Download URL graph_rag_memory-0.1.1-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2cd79dd745850b1aabefde870b33419568b172c8ae2471759b520470ef5587a
BLAKE2b-256 checksum
How to use checksums
e9424798d0828886b76903fc03c797521543c04418ddc1bcaab4f6ed7036c111
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for graph-rag-memory 0.1.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.

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

0.1.1 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