2
2
import pytest
3
3
4
4
from langchain .schema import Document
5
- from langchain .vectorstores .in_memory import InMemory
5
+ from langchain .vectorstores .in_memory_exact_search import InMemoryExactSearch
6
6
from tests .integration_tests .vectorstores .fake_embeddings import FakeEmbeddings
7
7
8
8
9
9
def test_in_memory_vec_store_from_texts () -> None :
10
10
"""Test end to end construction and simple similarity search."""
11
11
texts = ["foo" , "bar" , "baz" ]
12
- docsearch = InMemory .from_texts (
12
+ docsearch = InMemoryExactSearch .from_texts (
13
13
texts ,
14
14
FakeEmbeddings (),
15
15
)
16
- assert isinstance (docsearch , InMemory )
16
+ assert isinstance (docsearch , InMemoryExactSearch )
17
17
assert docsearch .doc_index .num_docs () == 3
18
18
19
19
20
20
def test_in_memory_vec_store_add_texts (tmp_path ) -> None :
21
21
"""Test end to end construction and simple similarity search."""
22
- docsearch = InMemory (
22
+ docsearch = InMemoryExactSearch (
23
23
embedding = FakeEmbeddings (),
24
24
)
25
- assert isinstance (docsearch , InMemory )
25
+ assert isinstance (docsearch , InMemoryExactSearch )
26
26
assert docsearch .doc_index .num_docs () == 0
27
27
28
28
texts = ["foo" , "bar" , "baz" ]
@@ -34,7 +34,7 @@ def test_in_memory_vec_store_add_texts(tmp_path) -> None:
34
34
def test_sim_search (metric ) -> None :
35
35
"""Test end to end construction and simple similarity search."""
36
36
texts = ["foo" , "bar" , "baz" ]
37
- in_memory_vec_store = InMemory .from_texts (
37
+ in_memory_vec_store = InMemoryExactSearch .from_texts (
38
38
texts = texts ,
39
39
embedding = FakeEmbeddings (),
40
40
metric = metric ,
@@ -48,7 +48,7 @@ def test_sim_search(metric) -> None:
48
48
def test_sim_search_with_score (metric ) -> None :
49
49
"""Test end to end construction and similarity search with score."""
50
50
texts = ["foo" , "bar" , "baz" ]
51
- in_memory_vec_store = InMemory .from_texts (
51
+ in_memory_vec_store = InMemoryExactSearch .from_texts (
52
52
texts = texts ,
53
53
embedding = FakeEmbeddings (),
54
54
metric = metric ,
@@ -67,7 +67,7 @@ def test_sim_search_with_score(metric) -> None:
67
67
def test_sim_search_by_vector (metric ) -> None :
68
68
"""Test end to end construction and similarity search by vector."""
69
69
texts = ["foo" , "bar" , "baz" ]
70
- in_memory_vec_store = InMemory .from_texts (
70
+ in_memory_vec_store = InMemoryExactSearch .from_texts (
71
71
texts = texts ,
72
72
embedding = FakeEmbeddings (),
73
73
metric = metric ,
@@ -84,7 +84,7 @@ def test_max_marginal_relevance_search(metric) -> None:
84
84
"""Test MRR search."""
85
85
texts = ["foo" , "bar" , "baz" ]
86
86
metadatas = [{"page" : i } for i in range (len (texts ))]
87
- docsearch = InMemory .from_texts (
87
+ docsearch = InMemoryExactSearch .from_texts (
88
88
texts ,
89
89
FakeEmbeddings (),
90
90
metadatas = metadatas ,
0 commit comments