Description
unable to retrieve from store more than 10 entries, even with passing limit argument
plz see code example
`
from langgraph.checkpoint.redis import RedisSaver
from langchain_core.runnables import RunnableConfig
from langgraph.checkpoint.redis import RedisSaver
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.store.redis import RedisStore
from langgraph.store.base import BaseStore
import uuid
Function that uses store to access and save user memories
def call_model(state: MessagesState, config: RunnableConfig, *, store: BaseStore):
user_id = config["configurable"]["user_id"]
namespace = ("memories", user_id)
# Store relevant memories for this user
for count in range(15) :
store.put(namespace, str(uuid.uuid4()), {"data": count})
# Retrieve relevant memories for this user
memories = store.search(namespace,limit=1000)
for memory in memories :
print(f'memory: {memory}')
# Store new memories if the user asks to remember something
return {"messages": "dummy"}
Build the graph
builder = StateGraph(MessagesState)
builder.add_node("call_model", call_model)
builder.add_edge(START, "call_model")
Initialize Redis persistence and store
REDIS_URI = "redis://localhost:6379"
with RedisSaver.from_conn_string(REDIS_URI) as checkpointer:
checkpointer.setup()
with RedisStore.from_conn_string(REDIS_URI) as store:
store.setup()
# Compile graph with both checkpointer and store
graph = builder.compile(checkpointer=checkpointer, store=store)
First conversation - tell the agent to remember something
config = {"configurable": {"thread_id": "thread_1", "user_id": "user_x"}}
response = graph.invoke(
{"messages": [{"role": "user", "content": "dummy_call"}]},
config
)`