elasticsearch[patch], community[patch]: update references, deprecate community classes (#18506)

Follow up on https://github.com/langchain-ai/langchain/pull/17467.

- Update all references to the Elasticsearch classes to use the partners
package.
- Deprecate community classes.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
Max Jakob
2024-03-07 00:09:12 +01:00
committed by GitHub
parent 6041ec3dd1
commit cca0167917
15 changed files with 72 additions and 34 deletions

View File

@@ -2,7 +2,7 @@ import os
from langchain_community.document_loaders import JSONLoader
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.vectorstores import ElasticsearchStore
from langchain_elasticsearch import ElasticsearchStore
from langchain_text_splitters import RecursiveCharacterTextSplitter
ELASTIC_CLOUD_ID = os.getenv("ELASTIC_CLOUD_ID")

View File

@@ -998,6 +998,22 @@ tenacity = ">=8.1.0,<9.0.0"
[package.extras]
extended-testing = ["jinja2 (>=3,<4)"]
[[package]]
name = "langchain-elasticsearch"
version = "0.1.0"
description = "An integration package connecting Elasticsearch and LangChain"
optional = false
python-versions = ">=3.8.1,<4.0"
files = [
{file = "langchain_elasticsearch-0.1.0-py3-none-any.whl", hash = "sha256:734b3600c2a94167a20adbde853ddd420d9e7aba09d60050de24c657096a0cba"},
{file = "langchain_elasticsearch-0.1.0.tar.gz", hash = "sha256:348343d2dcc34460180328c2775301839cfb8ccfd4931f1daf27d9753bfeb1e7"},
]
[package.dependencies]
elasticsearch = ">=8.12.0,<9.0.0"
langchain-core = ">=0.1,<0.2"
numpy = ">=1,<2"
[[package]]
name = "langchain-text-splitters"
version = "0.0.1"
@@ -1872,7 +1888,6 @@ files = [
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
@@ -3088,4 +3103,4 @@ multidict = ">=4.0"
[metadata]
lock-version = "2.0"
python-versions = ">=3.8.1,<4.0"
content-hash = "f6b9d389d68bd7bf89deec5fe34724bdb32cad352dc560c4873b1b80f16d1332"
content-hash = "35c900daced9ab0fcc8f10218eb3fda6355c13f878fa4734f53c1e58c45df3b2"

View File

@@ -8,8 +8,8 @@ readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
langchain = "^0.1"
langchain-elasticsearch = "^0.1.0"
openai = "<2"
elasticsearch = "^8.10.0"
sentence-transformers = "^2.2.2"
jq = "^1.6.0"
tiktoken = "^0.5.1"

View File

@@ -5,11 +5,11 @@ from typing import List, Tuple
from langchain.retrievers import SelfQueryRetriever
from langchain_community.chat_models import ChatOpenAI
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.vectorstores.elasticsearch import ElasticsearchStore
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import format_document
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.runnables import RunnableParallel, RunnablePassthrough
from langchain_elasticsearch.vectorstores import ElasticsearchStore
from .prompts import CONDENSE_QUESTION_PROMPT, DOCUMENT_PROMPT, LLM_CONTEXT_PROMPT