Skip to content

Commit 5d2324a

Browse files
refactor: rename InMemory to InMemoryExactSearch
Signed-off-by: anna-charlotte <[email protected]>
1 parent 30456bc commit 5d2324a

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

langchain/vectorstores/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from langchain.vectorstores.elastic_vector_search import ElasticVectorSearch
99
from langchain.vectorstores.faiss import FAISS
1010
from langchain.vectorstores.hnsw_lib import HnswLib
11-
from langchain.vectorstores.in_memory import InMemory
11+
from langchain.vectorstores.in_memory_exact_search import InMemoryExactSearch
1212
from langchain.vectorstores.milvus import Milvus
1313
from langchain.vectorstores.myscale import MyScale, MyScaleSettings
1414
from langchain.vectorstores.opensearch_vector_search import OpenSearchVectorSearch
@@ -37,5 +37,5 @@
3737
"SupabaseVectorStore",
3838
"AnalyticDB",
3939
"HnswLib",
40-
"InMemory",
40+
"InMemoryExactSearch",
4141
]

langchain/vectorstores/in_memory.py renamed to langchain/vectorstores/in_memory_exact_search.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
)
1212

1313

14-
class InMemory(VecStoreFromDocIndex):
15-
"""Wrapper around in-memory storage.
14+
class InMemoryExactSearch(VecStoreFromDocIndex):
15+
"""Wrapper around in-memory storage for exact search.
1616
1717
To use it, you should have the ``docarray`` package with version >=0.31.0 installed.
1818
You can install it with `pip install "langchain[in_memory_store]"`.
@@ -23,7 +23,7 @@ def __init__(
2323
embedding: Embeddings,
2424
metric: str = "cosine_sim",
2525
) -> None:
26-
"""Initialize in-memory store.
26+
"""Initialize InMemoryExactSearch store.
2727
2828
Args:
2929
embedding (Embeddings): Embedding function.
@@ -45,8 +45,8 @@ def from_texts(
4545
embedding: Embeddings,
4646
metadatas: Optional[List[dict]] = None,
4747
metric: str = "cosine_sim",
48-
) -> InMemory:
49-
"""Create an in-memory store and insert data.
48+
) -> InMemoryExactSearch:
49+
"""Create an InMemoryExactSearch store and insert data.
5050
5151
Args:
5252
texts (List[str]): Text data.
@@ -58,7 +58,7 @@ def from_texts(
5858
Defaults to "cosine_sim".
5959
6060
Returns:
61-
InMemory Vector Store
61+
InMemoryExactSearch Vector Store
6262
"""
6363
store = cls(
6464
embedding=embedding,

tests/integration_tests/vectorstores/test_in_memory.py renamed to tests/integration_tests/vectorstores/test_in_memory_exact_search.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22
import pytest
33

44
from langchain.schema import Document
5-
from langchain.vectorstores.in_memory import InMemory
5+
from langchain.vectorstores.in_memory_exact_search import InMemoryExactSearch
66
from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings
77

88

99
def test_in_memory_vec_store_from_texts() -> None:
1010
"""Test end to end construction and simple similarity search."""
1111
texts = ["foo", "bar", "baz"]
12-
docsearch = InMemory.from_texts(
12+
docsearch = InMemoryExactSearch.from_texts(
1313
texts,
1414
FakeEmbeddings(),
1515
)
16-
assert isinstance(docsearch, InMemory)
16+
assert isinstance(docsearch, InMemoryExactSearch)
1717
assert docsearch.doc_index.num_docs() == 3
1818

1919

2020
def test_in_memory_vec_store_add_texts(tmp_path) -> None:
2121
"""Test end to end construction and simple similarity search."""
22-
docsearch = InMemory(
22+
docsearch = InMemoryExactSearch(
2323
embedding=FakeEmbeddings(),
2424
)
25-
assert isinstance(docsearch, InMemory)
25+
assert isinstance(docsearch, InMemoryExactSearch)
2626
assert docsearch.doc_index.num_docs() == 0
2727

2828
texts = ["foo", "bar", "baz"]
@@ -34,7 +34,7 @@ def test_in_memory_vec_store_add_texts(tmp_path) -> None:
3434
def test_sim_search(metric) -> None:
3535
"""Test end to end construction and simple similarity search."""
3636
texts = ["foo", "bar", "baz"]
37-
in_memory_vec_store = InMemory.from_texts(
37+
in_memory_vec_store = InMemoryExactSearch.from_texts(
3838
texts=texts,
3939
embedding=FakeEmbeddings(),
4040
metric=metric,
@@ -48,7 +48,7 @@ def test_sim_search(metric) -> None:
4848
def test_sim_search_with_score(metric) -> None:
4949
"""Test end to end construction and similarity search with score."""
5050
texts = ["foo", "bar", "baz"]
51-
in_memory_vec_store = InMemory.from_texts(
51+
in_memory_vec_store = InMemoryExactSearch.from_texts(
5252
texts=texts,
5353
embedding=FakeEmbeddings(),
5454
metric=metric,
@@ -67,7 +67,7 @@ def test_sim_search_with_score(metric) -> None:
6767
def test_sim_search_by_vector(metric) -> None:
6868
"""Test end to end construction and similarity search by vector."""
6969
texts = ["foo", "bar", "baz"]
70-
in_memory_vec_store = InMemory.from_texts(
70+
in_memory_vec_store = InMemoryExactSearch.from_texts(
7171
texts=texts,
7272
embedding=FakeEmbeddings(),
7373
metric=metric,
@@ -84,7 +84,7 @@ def test_max_marginal_relevance_search(metric) -> None:
8484
"""Test MRR search."""
8585
texts = ["foo", "bar", "baz"]
8686
metadatas = [{"page": i} for i in range(len(texts))]
87-
docsearch = InMemory.from_texts(
87+
docsearch = InMemoryExactSearch.from_texts(
8888
texts,
8989
FakeEmbeddings(),
9090
metadatas=metadatas,

0 commit comments

Comments
 (0)