Skip to content

Commit 3f3664c

Browse files
authored
Update client version, update tests for new retriever format and update auth flow (#80)
* update client version and poetry lock file * resolve authentication issues in integration tests * update query body tests for new retriever format * lint and cleanup * lint: fix comment length * linting * linting: add type annotation for client_kwargs * delete poetry.lock * update elasticsearch client version range * consolidate lock file dependacies in pyproject.toml * add lock file to git ignore * remove lock check command from _lint.yml * add version flexibility for langchain pkgs * remove langchain community and text splitters test dependancies * use langchain core to import pkgs FakeMessagesListChatModel * add DistanceStrategy import to __init__ * add DistanceStrategy to test_imports * update spynhix docs to not use langchain_community * update elasticsearch client in release script * Release 0.4.0
1 parent 5bfedea commit 3f3664c

File tree

18 files changed

+330
-2457
lines changed

18 files changed

+330
-2457
lines changed

.github/workflows/_lint.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ jobs:
4848
run: |
4949
poetry check
5050
51-
- name: Check lock file
52-
shell: bash
53-
working-directory: ${{ inputs.working-directory }}
54-
run: |
55-
poetry lock --check
5651
5752
- name: Install dependencies
5853
# Also installs dev/lint/test/typing dependencies, to ensure we have

.github/workflows/_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
runs-on: ubuntu-latest
9191
services:
9292
elasticsearch:
93-
image: elasticsearch:8.13.0
93+
image: elasticsearch:8.16.0
9494
env:
9595
discovery.type: single-node
9696
xpack.license.self_generated.type: trial

libs/elasticsearch/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
__pycache__
2+
poetry.lock

libs/elasticsearch/langchain_elasticsearch/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
SparseVectorStrategy,
1313
)
1414

15+
from langchain_elasticsearch._utilities import DistanceStrategy
1516
from langchain_elasticsearch.cache import (
1617
AsyncElasticsearchCache,
1718
AsyncElasticsearchEmbeddingsCache,
@@ -62,6 +63,7 @@
6263
"DenseVectorScriptScoreStrategy",
6364
"DenseVectorStrategy",
6465
"DistanceMetric",
66+
"DistanceStrategy",
6567
"RetrievalStrategy",
6668
"SparseVectorStrategy",
6769
# deprecated retrieval strategies

libs/elasticsearch/langchain_elasticsearch/_async/vectorstores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class AsyncElasticsearchStore(VectorStore):
283283
284284
from langchain_elasticsearch.vectorstores import ElasticsearchStore
285285
from langchain_openai import OpenAIEmbeddings
286-
from langchain_community.vectorstores.utils import DistanceStrategy
286+
from langchain_elasticsearch import DistanceStrategy
287287
288288
store = ElasticsearchStore(
289289
"langchain-demo",

libs/elasticsearch/langchain_elasticsearch/_sync/vectorstores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class ElasticsearchStore(VectorStore):
283283
284284
from langchain_elasticsearch.vectorstores import ElasticsearchStore
285285
from langchain_openai import OpenAIEmbeddings
286-
from langchain_community.vectorstores.utils import DistanceStrategy
286+
from langchain_elasticsearch import DistanceStrategy
287287
288288
store = ElasticsearchStore(
289289
"langchain-demo",

libs/elasticsearch/poetry.lock

Lines changed: 0 additions & 2279 deletions
This file was deleted.

libs/elasticsearch/pyproject.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "langchain-elasticsearch"
3-
version = "0.3.2"
3+
version = "0.4.0"
44
description = "An integration package connecting Elasticsearch and LangChain"
55
authors = []
66
readme = "README.md"
@@ -12,8 +12,8 @@ license = "MIT"
1212

1313
[tool.poetry.dependencies]
1414
python = ">=3.9,<4.0"
15-
langchain-core = "^0.3.0"
16-
elasticsearch = {version = "^8.15.1", extras = ["vectorstore_mmr"]}
15+
langchain-core = ">=0.3.0"
16+
elasticsearch = {version = ">=8.16.0,<9.0.0", extras = ["vectorstore_mmr"]}
1717

1818
[tool.poetry.group.test]
1919
optional = true
@@ -25,10 +25,7 @@ pytest-mock = "^3.10.0"
2525
syrupy = "^4.0.2"
2626
pytest-watcher = "^0.3.4"
2727
pytest-asyncio = "^0.21.1"
28-
langchain = {git = "https://github.com/langchain-ai/langchain.git", subdirectory = "libs/langchain" }
29-
langchain-community = {git = "https://github.com/langchain-ai/langchain.git", subdirectory = "libs/community" }
30-
langchain-text-splitters = {git = "https://github.com/langchain-ai/langchain.git", subdirectory = "libs/text-splitters" }
31-
langchain-core = {git = "https://github.com/langchain-ai/langchain.git", subdirectory = "libs/core" }
28+
langchain = ">=0.3.10,<1.0.0"
3229

3330
[tool.poetry.group.codespell]
3431
optional = true
@@ -44,13 +41,11 @@ ruff = "^0.1.5"
4441

4542
[tool.poetry.group.typing.dependencies]
4643
mypy = "^0.991"
47-
langchain-core = {git = "https://github.com/langchain-ai/langchain.git", subdirectory = "libs/core" }
4844

4945
[tool.poetry.group.dev]
5046
optional = true
5147

5248
[tool.poetry.group.dev.dependencies]
53-
langchain-core = {git = "https://github.com/langchain-ai/langchain.git", subdirectory = "libs/core" }
5449

5550
[tool.poetry.group.test_integration]
5651
optional = true

libs/elasticsearch/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from elasticsearch import AsyncElasticsearch, Elasticsearch
77
from elasticsearch._async.client import IndicesClient as AsyncIndicesClient
88
from elasticsearch._sync.client import IndicesClient
9-
from langchain_community.chat_models.fake import FakeMessagesListChatModel
109
from langchain_core.language_models import BaseChatModel
10+
from langchain_core.language_models.fake_chat_models import FakeMessagesListChatModel
1111
from langchain_core.messages import AIMessage
1212

1313
from langchain_elasticsearch import (

libs/elasticsearch/tests/integration_tests/_async/_test_utilities.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ def read_env() -> Dict:
1717

1818
if cloud_id:
1919
return {"es_cloud_id": cloud_id, "es_api_key": api_key}
20-
return {"es_url": url}
20+
21+
result = {"es_url": url}
22+
if api_key:
23+
result["es_api_key"] = api_key
24+
return result
2125

2226

2327
class AsyncRequestSavingTransport(AsyncTransport):
@@ -46,7 +50,12 @@ def create_es_client(
4650
**es_kwargs,
4751
)
4852

49-
return AsyncElasticsearch(hosts=[es_params["es_url"]], **es_kwargs)
53+
client_kwargs: Dict[str, Any] = {"hosts": [es_params["es_url"]]}
54+
if "es_api_key" in es_params:
55+
client_kwargs["api_key"] = es_params["es_api_key"]
56+
client_kwargs.update(es_kwargs)
57+
58+
return AsyncElasticsearch(**client_kwargs)
5059

5160

5261
def requests_saving_es_client() -> AsyncElasticsearch:

0 commit comments

Comments
 (0)