From 0ed26a3af9a2e20554da853d4f57a6453ed036b5 Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Wed, 27 Nov 2024 00:23:29 -0800 Subject: [PATCH] handle no emb situation --- libs/checkpoint/langgraph/store/memory/__init__.py | 2 +- libs/checkpoint/tests/test_store.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/checkpoint/langgraph/store/memory/__init__.py b/libs/checkpoint/langgraph/store/memory/__init__.py index b350c8a17..7af33962a 100644 --- a/libs/checkpoint/langgraph/store/memory/__init__.py +++ b/libs/checkpoint/langgraph/store/memory/__init__.py @@ -232,7 +232,7 @@ class InMemoryStore(BaseStore): if not candidates: results[i] = [] continue - if op.query: + if op.query and queryinmem_store: query_embedding = queryinmem_store[op.query] flat_items, flat_vectors = [], [] for item, vectors in candidates: diff --git a/libs/checkpoint/tests/test_store.py b/libs/checkpoint/tests/test_store.py index 8c5df5b04..d00fc21bf 100644 --- a/libs/checkpoint/tests/test_store.py +++ b/libs/checkpoint/tests/test_store.py @@ -382,7 +382,9 @@ async def test_cannot_put_empty_namespace() -> None: await store.aput(("foo", "langgraph", "foo"), "bar", doc) assert (await store.aget(("foo", "langgraph", "foo"), "bar")).value == doc # type: ignore[union-attr] - assert (await store.asearch(("foo", "langgraph", "foo")))[0].value == doc + assert (await store.asearch(("foo", "langgraph", "foo"), query="bar"))[ + 0 + ].value == doc await store.adelete(("foo", "langgraph", "foo"), "bar") assert (await store.aget(("foo", "langgraph", "foo"), "bar")) is None store.put(("foo", "langgraph", "foo"), "bar", doc)