Skip to main content

Aerospike-based checkpoint saver for LangGraph

Project description

LangGraph Checkpoint Aerospike

Store LangGraph checkpoints in Aerospike using the provided AerospikeSaver.

Installation

pip install -U langgraph-checkpoint-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 saver at your cluster (Default):

    • AEROSPIKE_HOST=127.0.0.1
    • AEROSPIKE_PORT=3000
    • AEROSPIKE_NAMESPACE=test
  2. Build a LangGraph graph and compile it with the saver as the checkpointer. Passing the same thread_id on a later run resumes from the persisted state:

    from typing import Annotated, TypedDict
    
    import aerospike
    from langgraph.graph import START, END, StateGraph
    from langgraph.graph.message import add_messages
    from langchain_core.messages import HumanMessage
    
    from langgraph.checkpoint.aerospike import AerospikeSaver
    
    # 1. Connect to Aerospike and build the checkpointer.
    client = aerospike.client({"hosts": [("127.0.0.1", 3000)]}).connect()
    checkpointer = AerospikeSaver(client=client, namespace="test")
    
    # 2. Define a minimal LangGraph graph.
    class State(TypedDict):
        messages: Annotated[list, add_messages]
    
    def chatbot(state: State) -> State:
        last = state["messages"][-1].content
        return {"messages": [("assistant", f"You said: {last}")]}
    
    builder = StateGraph(State)
    builder.add_node("chatbot", chatbot)
    builder.add_edge(START, "chatbot")
    builder.add_edge("chatbot", END)
    
    # 3. Compile with the Aerospike checkpointer.
    graph = builder.compile(checkpointer=checkpointer)
    
    # 4. Each thread_id is a separate, persisted conversation.
    config = {"configurable": {"thread_id": "demo"}}
    graph.invoke({"messages": [HumanMessage("hello")]}, config)
    
    # 5. A later call with the same thread_id resumes from the saved state,
    #    even in a brand-new process — the history lives in Aerospike.
    result = graph.invoke({"messages": [HumanMessage("are you still there?")]}, config)
    for message in result["messages"]:
        message.pretty_print()
    

You can also inspect persisted checkpoints directly through the saver, e.g. checkpointer.get_tuple(config) for the latest checkpoint or checkpointer.list(config) to walk a thread's history.

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_checkpoint_aerospike-0.3.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file langgraph_checkpoint_aerospike-0.3.0.tar.gz.

File metadata

File hashes

Hashes for langgraph_checkpoint_aerospike-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d3308f398329793b2634fea7a4c9a16404a21ba3d0b8ba3a162e4dd3bacf871c
MD5 2b1690ddeffe12fe35266051071f0ba2
BLAKE2b-256 522c014e61d563f5badd5dcc5f13d6f0c37a859980ed3d42cd9a03a0b4b12117

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_checkpoint_aerospike-0.3.0.tar.gz:

Publisher: release-checkpoint.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_checkpoint_aerospike-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_checkpoint_aerospike-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69e45b7498e1d8ed083477b193d04640047376695e914174eb42378147ef06f8
MD5 eaef1f29eb47bec5f2d1084d60474b1b
BLAKE2b-256 127d162e110dad18385fe11842496c1b2e2835bfc8fbf8e23804b9f9313a973d

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_checkpoint_aerospike-0.3.0-py3-none-any.whl:

Publisher: release-checkpoint.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