Skip to content

Commit 18ce768

Browse files
Ensure all public classes are picked up by documentation (#61)
1 parent ca5c263 commit 18ce768

File tree

6 files changed

+152
-39
lines changed

6 files changed

+152
-39
lines changed

libs/elasticsearch/langchain_elasticsearch/cache.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
from langchain_elasticsearch._async.cache import (
1313
AsyncElasticsearchEmbeddingsCache as _AsyncElasticsearchEmbeddingsCache,
1414
)
15-
from langchain_elasticsearch._sync.cache import ( # noqa: F401
16-
ElasticsearchCache,
17-
ElasticsearchEmbeddingsCache,
15+
from langchain_elasticsearch._sync.cache import (
16+
ElasticsearchCache as _ElasticsearchCache,
17+
)
18+
from langchain_elasticsearch._sync.cache import (
19+
ElasticsearchEmbeddingsCache as _ElasticsearchEmbeddingsCache,
1820
)
1921
from langchain_elasticsearch.client import ( # noqa: F401
2022
create_async_elasticsearch_client,
@@ -49,3 +51,12 @@ def mdelete(self, keys: Sequence[str]) -> None:
4951

5052
def yield_keys(self, *, prefix: Optional[str] = None) -> Iterator[str]:
5153
raise NotImplementedError("This class is asynchronous, use ayield_keys()")
54+
55+
56+
# these are only defined here so that they are picked up by Langchain's docs generator
57+
class ElasticsearchCache(_ElasticsearchCache):
58+
pass
59+
60+
61+
class ElasticsearchEmbeddingsCache(_ElasticsearchEmbeddingsCache):
62+
pass
Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
from typing import List
22

3+
from langchain_core.embeddings import Embeddings # noqa: F401
4+
35
from langchain_elasticsearch._async.embeddings import (
46
AsyncElasticsearchEmbeddings as _AsyncElasticsearchEmbeddings,
57
)
6-
from langchain_elasticsearch._async.embeddings import ( # noqa: F401
7-
AsyncEmbeddingService,
8-
AsyncEmbeddingServiceAdapter,
9-
Embeddings,
8+
from langchain_elasticsearch._async.embeddings import (
9+
AsyncEmbeddingService as _AsyncEmbeddingService,
10+
)
11+
from langchain_elasticsearch._async.embeddings import (
12+
AsyncEmbeddingServiceAdapter as _AsyncEmbeddingServiceAdapter,
13+
)
14+
from langchain_elasticsearch._sync.embeddings import (
15+
ElasticsearchEmbeddings as _ElasticsearchEmbeddings,
16+
)
17+
from langchain_elasticsearch._sync.embeddings import (
18+
EmbeddingService as _EmbeddingService,
1019
)
11-
from langchain_elasticsearch._sync.embeddings import ( # noqa: F401
12-
ElasticsearchEmbeddings,
13-
EmbeddingService,
14-
EmbeddingServiceAdapter,
20+
from langchain_elasticsearch._sync.embeddings import (
21+
EmbeddingServiceAdapter as _EmbeddingServiceAdapter,
1522
)
1623

1724

@@ -23,3 +30,24 @@ def embed_documents(self, texts: List[str]) -> List[List[float]]:
2330

2431
def embed_query(self, text: str) -> List[float]:
2532
raise NotImplementedError("This class is asynchronous, use aembed_query()")
33+
34+
35+
# these are only defined here so that they are picked up by Langchain's docs generator
36+
class ElasticsearchEmbeddings(_ElasticsearchEmbeddings):
37+
pass
38+
39+
40+
class EmbeddingService(_EmbeddingService):
41+
pass
42+
43+
44+
class EmbeddingServiceAdapter(_EmbeddingServiceAdapter):
45+
pass
46+
47+
48+
class AsyncEmbeddingService(_AsyncEmbeddingService):
49+
pass
50+
51+
52+
class AsyncEmbeddingServiceAdapter(_AsyncEmbeddingServiceAdapter):
53+
pass

libs/elasticsearch/langchain_elasticsearch/retrievers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
AsyncElasticsearchRetriever as _AsyncElasticsearchRetriever,
88
)
99
from langchain_elasticsearch._sync.retrievers import (
10-
ElasticsearchRetriever, # noqa: F401
10+
ElasticsearchRetriever as _ElasticsearchRetriever,
1111
)
1212

1313

@@ -20,3 +20,8 @@ def _get_relevant_documents(
2020
raise NotImplementedError(
2121
"This class is asynchronous, use _aget_relevant_documents()"
2222
)
23+
24+
25+
# this is only defined here so that it is picked up by Langchain's docs generator
26+
class ElasticsearchRetriever(_ElasticsearchRetriever):
27+
pass

libs/elasticsearch/langchain_elasticsearch/vectorstores.py

Lines changed: 81 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
from typing import Any, Optional
22

3-
from langchain_elasticsearch._async.vectorstores import ( # noqa: F401
4-
AsyncBM25Strategy,
5-
AsyncDenseVectorScriptScoreStrategy,
6-
AsyncDenseVectorStrategy,
7-
AsyncRetrievalStrategy,
8-
AsyncSparseVectorStrategy,
9-
DistanceMetric,
10-
Document,
11-
Embeddings,
3+
from langchain_elasticsearch._async.vectorstores import (
4+
AsyncBM25Strategy as _AsyncBM25Strategy,
5+
)
6+
from langchain_elasticsearch._async.vectorstores import (
7+
AsyncDenseVectorScriptScoreStrategy as _AsyncDenseVectorScriptScoreStrategy,
8+
)
9+
from langchain_elasticsearch._async.vectorstores import (
10+
AsyncDenseVectorStrategy as _AsyncDenseVectorStrategy,
1211
)
1312
from langchain_elasticsearch._async.vectorstores import (
1413
AsyncElasticsearchStore as _AsyncElasticsearchStore,
1514
)
16-
from langchain_elasticsearch._sync.vectorstores import ( # noqa: F401
17-
BM25Strategy,
18-
DenseVectorScriptScoreStrategy,
19-
DenseVectorStrategy,
20-
ElasticsearchStore,
21-
RetrievalStrategy,
22-
SparseVectorStrategy,
15+
from langchain_elasticsearch._async.vectorstores import (
16+
AsyncRetrievalStrategy as _AsyncRetrievalStrategy,
17+
)
18+
from langchain_elasticsearch._async.vectorstores import (
19+
AsyncSparseVectorStrategy as _AsyncSparseVectorStrategy,
20+
)
21+
from langchain_elasticsearch._async.vectorstores import (
22+
DistanceMetric, # noqa: F401
23+
Document,
24+
Embeddings,
25+
)
26+
from langchain_elasticsearch._sync.vectorstores import (
27+
BM25Strategy as _BM25Strategy,
28+
)
29+
from langchain_elasticsearch._sync.vectorstores import (
30+
DenseVectorScriptScoreStrategy as _DenseVectorScriptScoreStrategy,
31+
)
32+
from langchain_elasticsearch._sync.vectorstores import (
33+
DenseVectorStrategy as _DenseVectorStrategy,
34+
)
35+
from langchain_elasticsearch._sync.vectorstores import (
36+
ElasticsearchStore as _ElasticsearchStore,
37+
)
38+
from langchain_elasticsearch._sync.vectorstores import (
39+
RetrievalStrategy as _RetrievalStrategy,
40+
)
41+
from langchain_elasticsearch._sync.vectorstores import (
42+
SparseVectorStrategy as _SparseVectorStrategy,
2343
)
2444

2545
# deprecated strategy classes
@@ -54,3 +74,48 @@ def similarity_search(
5474
raise NotImplementedError(
5575
"This class is asynchronous, use asimilarity_search()"
5676
)
77+
78+
79+
# these are only defined here so that they are picked up by Langchain's docs generator
80+
class ElasticsearchStore(_ElasticsearchStore):
81+
pass
82+
83+
84+
class BM25Strategy(_BM25Strategy):
85+
pass
86+
87+
88+
class DenseVectorScriptScoreStrategy(_DenseVectorScriptScoreStrategy):
89+
pass
90+
91+
92+
class DenseVectorStrategy(_DenseVectorStrategy):
93+
pass
94+
95+
96+
class RetrievalStrategy(_RetrievalStrategy):
97+
pass
98+
99+
100+
class SparseVectorStrategy(_SparseVectorStrategy):
101+
pass
102+
103+
104+
class AsyncBM25Strategy(_AsyncBM25Strategy):
105+
pass
106+
107+
108+
class AsyncDenseVectorScriptScoreStrategy(_AsyncDenseVectorScriptScoreStrategy):
109+
pass
110+
111+
112+
class AsyncDenseVectorStrategy(_AsyncDenseVectorStrategy):
113+
pass
114+
115+
116+
class AsyncRetrievalStrategy(_AsyncRetrievalStrategy):
117+
pass
118+
119+
120+
class AsyncSparseVectorStrategy(_AsyncSparseVectorStrategy):
121+
pass

libs/elasticsearch/tests/unit_tests/_async/test_vectorstores.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88
from elasticsearch import AsyncElasticsearch
99
from langchain_core.documents import Document
1010

11-
from langchain_elasticsearch._async.vectorstores import _convert_retrieval_strategy
12-
from langchain_elasticsearch._utilities import _hits_to_docs_scores
13-
from langchain_elasticsearch.embeddings import AsyncEmbeddingServiceAdapter, Embeddings
14-
from langchain_elasticsearch.vectorstores import (
11+
from langchain_elasticsearch._async.vectorstores import (
1512
ApproxRetrievalStrategy,
1613
AsyncBM25Strategy,
1714
AsyncDenseVectorScriptScoreStrategy,
1815
AsyncDenseVectorStrategy,
19-
AsyncElasticsearchStore,
2016
AsyncSparseVectorStrategy,
17+
_convert_retrieval_strategy,
18+
)
19+
from langchain_elasticsearch._utilities import _hits_to_docs_scores
20+
from langchain_elasticsearch.embeddings import AsyncEmbeddingServiceAdapter, Embeddings
21+
from langchain_elasticsearch.vectorstores import (
22+
AsyncElasticsearchStore,
2123
BM25RetrievalStrategy,
2224
DistanceMetric,
2325
DistanceStrategy,

libs/elasticsearch/tests/unit_tests/_sync/test_vectorstores.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@
88
from elasticsearch import Elasticsearch
99
from langchain_core.documents import Document
1010

11-
from langchain_elasticsearch._sync.vectorstores import _convert_retrieval_strategy
12-
from langchain_elasticsearch._utilities import _hits_to_docs_scores
13-
from langchain_elasticsearch.embeddings import Embeddings, EmbeddingServiceAdapter
14-
from langchain_elasticsearch.vectorstores import (
11+
from langchain_elasticsearch._sync.vectorstores import (
1512
ApproxRetrievalStrategy,
16-
BM25RetrievalStrategy,
1713
BM25Strategy,
1814
DenseVectorScriptScoreStrategy,
1915
DenseVectorStrategy,
16+
SparseVectorStrategy,
17+
_convert_retrieval_strategy,
18+
)
19+
from langchain_elasticsearch._utilities import _hits_to_docs_scores
20+
from langchain_elasticsearch.embeddings import Embeddings, EmbeddingServiceAdapter
21+
from langchain_elasticsearch.vectorstores import (
22+
BM25RetrievalStrategy,
2023
DistanceMetric,
2124
DistanceStrategy,
2225
ElasticsearchStore,
2326
ExactRetrievalStrategy,
2427
SparseRetrievalStrategy,
25-
SparseVectorStrategy,
2628
)
2729

2830
from ...fake_embeddings import ConsistentFakeEmbeddings

0 commit comments

Comments
 (0)