langgraph-checkpoint-cloudflare-d1
Installation
pip install -U langmem-cloudflare-vectorize langgraph langchain-cloudflare
Usage
This package provides both synchronous and asynchronous interfaces for semantic vector search capabilities. Use this package when you want to use a custom store with langmem.
from langmem_cloudflare_vectorize import CloudflareVectorizeLangmemStore
from langchain_cloudflare.chat_models import ChatCloudflareWorkersAI
from langmem import create_manage_memory_tool, create_search_memory_tool
from langgraph.prebuilt import create_react_agent
from langchain_core.tools import tool
# Cloudflare credentials
account_id = "your-cloudflare-account-id"
vectorize_api_token = "your-vectorize-api-token"
workers_ai_token = "your-workers-ai-api-token"
# Create the langmem vectorize store
agent_store = CloudflareVectorizeLangmemStore.with_cloudflare_embeddings(
account_id=account_id,
index_name="cool-vectorize-index-name",
vectorize_api_token=vectorize_api_token,
workers_ai_token=workers_ai_token,
embedding_model="@cf/baai/bge-base-en-v1.5",
dimensions=768
)
# Create the llm
cloudflare_llm = ChatCloudflareWorkersAI(
cloudflare_account_id=account_id,
cloudflare_api_token=workers_ai_token,
model="@cf/meta/llama-3.3-70b-instruct-fp8-fast"
)
# Create memory tools
manage_memory = create_manage_memory_tool(
namespace=("memories",)
)
search_memory = create_search_memory_tool(
namespace=("memories",)
)
@tool
def get_weather(location: str):
"""Get the current weather for a location."""
if location.lower() in ["sf", "san francisco"]:
return "It's 60 degrees and foggy in San Francisco."
elif location.lower() in ["ny", "new york"]:
return "It's 45 degrees and sunny in New York."
else:
return f"It's 75 degrees and partly cloudy in {location}."
# Create the agent
agent = create_react_agent(
cloudflare_llm,
tools=[
manage_memory,
search_memory,
],
store=agent_store, # This is how LangMem gets access to your store
)
config = {"configurable": {"thread_id": "test_session_1"}}
response1 = agent.invoke(
{"messages": [{"role": "user",
"content": "Please remember this important information about me: My name is Sarah, I'm allergic to peanuts, and I love Italian food, especially pasta carbonara. Please use your manage_memory tool to store this."}]},
config
)
print(
"User: Please remember this important information about me: My name is Sarah, I'm allergic to peanuts, and I love Italian food, especially pasta carbonara. Please use your manage_memory tool to store this.")
print(f"Agent: {response1['messages'][-1].content}")
# Test 2: Try to recall the stored information
print("\nCONVERSATION 2: THE MEMORY TEST")
print("-" * 40)
print("Testing if the agent remembers the stored information...")
response2 = agent.invoke(
{"messages": [{"role": "user",
"content": "What do you remember about my dietary restrictions and food preferences? Please search your memory using search_memory tool."}]},
config
)
print(
"User: What do you remember about my dietary restrictions and food preferences? Please search your memory using search_memory tool.")
print(f"Agent: {response2['messages'][-1].content}")
# Test 3: Different topic, then back to memory
print("\n📅 CONVERSATION 3: Different topic")
print("-" * 40)
response3 = agent.invoke(
{"messages": [{"role": "user",
"content": "What's the weather like in San Francisco?"}]},
config
)
print("User: What's the weather like in San Francisco?")
print(f"Agent: {response3['messages'][-1].content}")
response4 = agent.invoke(
{"messages": [{"role": "user",
"content": "What is my name and what am I allergic to?"}]},
config
)
print(
"User: What is my name and what am I allergic to?")
print(f"Agent: {response4['messages'][-1].content}")
Release Notes
v0.1.2` (2025-09-25)
- Added support for environmental variables
Metadata
Release files for langmem-cloudflare-vectorize 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langmem_cloudflare_vectorize-0.1.0.tar.gz | 8.6 kB | Without provenance | Details for langmem_cloudflare_vectorize-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langmem_cloudflare_vectorize-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langmem_cloudflare_vectorize-0.1.0-py3-none-any.whl |
Total release size: 16.5 kB
Release files / langmem_cloudflare_vectorize-0.1.0.tar.gz
| Download URL | langmem_cloudflare_vectorize-0.1.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
757b8f82b4972b4a9f8dbf3c85567237711d406003eab62877621400ab8698f4
|
|
BLAKE2b-256 checksum How to use checksums |
e065c51d011874e9812df2b2f2285f3bf13be21c1ead57e007184f847ab6232b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.6 Darwin/24.6.0
|
Release files / langmem_cloudflare_vectorize-0.1.0-py3-none-any.whl
| Download URL | langmem_cloudflare_vectorize-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8719e894d5a0e494805f3e3137d7c99a75f47b8a2669421c1db88374f916777
|
|
BLAKE2b-256 checksum How to use checksums |
12ca6e78fec8a9816d1cf9e59dd22921f0355cbe324721a5a72ffd3e8a81998b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.6 Darwin/24.6.0
|
Security for langmem-cloudflare-vectorize 0.1.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.