Skip to main content

Aerospike-based store base for LangGraph

Project description

LangGraph Store Aerospike

Store LangGraph state and data in Aerospike using the provided AerospikeStore.

Installation

pip install -U langgraph-store-aerospike

Usage

  1. Bring up Aerospike locally using prebuilt Aerospike Docker Image:
docker run -d --name aerospike -p 3000-3002:3000-3002 container.aerospike.com/aerospike/aerospike-server
  1. Point the store at your cluster (Default):

    • AEROSPIKE_HOST=127.0.0.1
    • AEROSPIKE_PORT=3000
    • AEROSPIKE_NAMESPACE=langgraph (default namespace for the store)
    • AEROSPIKE_SET=store (default set name)
  2. Compile a LangGraph graph with the store. Nodes reach it through get_store(), so the same long-term memory is shared across every run and every thread (unlike a checkpointer, which is scoped to a single thread):

from typing import TypedDict

import aerospike
from langgraph.config import get_store
from langgraph.graph import START, END, StateGraph

from langgraph.store.aerospike import AerospikeStore

# 1. Connect to Aerospike and build the store.
client = aerospike.client({"hosts": [("127.0.0.1", 3000)]}).connect()
store = AerospikeStore(client=client, namespace="test", set="langgraph_store")

# 2. Define a graph whose node reads and writes long-term memory.
class State(TypedDict):
    user_id: str
    food: str

def remember_preference(state: State) -> State:
    store = get_store()
    namespace = ("users", state["user_id"])

    # Persist something we learned about this user.
    store.put(namespace, key="profile", value={"favorite_food": state["food"]})

    # Read it back (would also be visible in any future run / thread).
    profile = store.get(namespace, key="profile")
    print(profile.value)  # {"favorite_food": "pizza"}
    return state

builder = StateGraph(State)
builder.add_node("remember_preference", remember_preference)
builder.add_edge(START, "remember_preference")
builder.add_edge("remember_preference", END)

# 3. Compile with the Aerospike store and run.
graph = builder.compile(store=store)
graph.invoke({"user_id": "user_123", "food": "pizza"})

The store is also a standalone BaseStore, so you can use it directly outside a graph for the same cross-thread memory:

# Search within a namespace prefix, filtering on stored fields.
results = store.search(("users",), filter={"favorite_food": "pizza"}, limit=10)

# Delete an item.
store.delete(("users", "user_123"), key="profile")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langgraph_store_aerospike-0.2.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langgraph_store_aerospike-0.2.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_store_aerospike-0.2.1.tar.gz.

File metadata

File hashes

Hashes for langgraph_store_aerospike-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ed08b3a0f76433ac9ad855fe95ee0cff72976333a9ca5f8b3d6aeca8fa051d16
MD5 b9414116016467db5b64f7b8312313ea
BLAKE2b-256 ce5038e8159fe38bed1509fb868530c6c241b6fd22ef5c09cc59439168df6763

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_store_aerospike-0.2.1.tar.gz:

Publisher: release-store.yml on aerospike/langgraph-aerospike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langgraph_store_aerospike-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_store_aerospike-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac571da67428559d746fc29337d36824502a505c44df9694bd5ee2aad605af7f
MD5 b1ab35c5dac097a027fbaf843c429ce0
BLAKE2b-256 d6c207a141fdb997455177a116f80bd7451c0c7619bb5ca71cc9a9d26e5509bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_store_aerospike-0.2.1-py3-none-any.whl:

Publisher: release-store.yml on aerospike/langgraph-aerospike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page