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.2.1.tar.gz (19.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.2.1.tar.gz.

File metadata

File hashes

Hashes for langgraph_checkpoint_aerospike-0.2.1.tar.gz
Algorithm Hash digest
SHA256 aa8c689ae54ea47de860d6e4d32be0795645b7048edca42d353351c2bcfc43ac
MD5 8497c7f257ff6eff8584cf4f9d1b135d
BLAKE2b-256 a35491963eb0ffa1df1f3d8647cb1c1a4a4ad9282cbde3728d96065e7ba75451

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_checkpoint_aerospike-0.2.1.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.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_checkpoint_aerospike-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2f342bb5c998286242771a6ede96f2ebb1895b1a821ab717090b8a1ac16ac70
MD5 c7eb5c68280940127924c52f3eeff720
BLAKE2b-256 f688b07eb7cd456e975d18dbfbc5bff8fa91f17f70c2281c56122b337cf692e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for langgraph_checkpoint_aerospike-0.2.1-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