mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 03:52:10 +00:00
partners: add Elasticsearch package (#17467)
### Description This PR moves the Elasticsearch classes to a partners package. Note that we will not move (and later remove) `ElasticKnnSearch`. It were previously deprecated. `ElasticVectorSearch` is going to stay in the community package since it is used quite a lot still. Also note that I left the `ElasticsearchTranslator` for self query untouched because it resides in main `langchain` package. ### Dependencies There will be another PR that updates the notebooks (potentially pulling them into the partners package) and templates and removes the classes from the community package, see https://github.com/langchain-ai/langchain/pull/17468 #### Open question How to make the transition smooth for users? Do we move the import aliases and require people to install `langchain-elasticsearch`? Or do we remove the import aliases from the `langchain` package all together? What has worked well for other partner packages? --------- Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
@@ -23,7 +23,7 @@ Elastic Cloud is a managed Elasticsearch service. Signup for a [free trial](http
|
||||
### Install Client
|
||||
|
||||
```bash
|
||||
pip install elasticsearch
|
||||
pip install langchain-elasticsearch
|
||||
```
|
||||
|
||||
## Vector Store
|
||||
@@ -31,7 +31,7 @@ pip install elasticsearch
|
||||
The vector store is a simple wrapper around Elasticsearch. It provides a simple interface to store and retrieve vectors.
|
||||
|
||||
```python
|
||||
from langchain_community.vectorstores import ElasticsearchStore
|
||||
from langchain_elasticsearch import ElasticsearchStore
|
||||
|
||||
from langchain_community.document_loaders import TextLoader
|
||||
from langchain.text_splitter import CharacterTextSplitter
|
||||
|
@@ -60,8 +60,8 @@
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"from langchain_community.vectorstores import ElasticsearchStore\n",
|
||||
"from langchain_core.documents import Document\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n",
|
||||
|
@@ -24,7 +24,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip -q install elasticsearch langchain"
|
||||
"!pip -q install langchain-elasticsearch"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -36,7 +36,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_community.embeddings.elasticsearch import ElasticsearchEmbeddings"
|
||||
"from langchain_elasticsearch import ElasticsearchEmbeddings"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@@ -21,7 +21,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install --upgrade --quiet elasticsearch langchain-openai tiktoken langchain"
|
||||
"%pip install --upgrade --quiet langchain-elasticsearch langchain-openai tiktoken langchain"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -64,7 +64,7 @@
|
||||
"\n",
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" from langchain_community.vectorstores.elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
" embedding = OpenAIEmbeddings()\n",
|
||||
@@ -79,7 +79,7 @@
|
||||
"\n",
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" from langchain_community.vectorstores import ElasticsearchStore\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
" embedding = OpenAIEmbeddings()\n",
|
||||
@@ -97,7 +97,7 @@
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" import elasticsearch\n",
|
||||
" from langchain_community.vectorstores import ElasticsearchStore\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"\n",
|
||||
" es_client= elasticsearch.Elasticsearch(\n",
|
||||
" hosts=[\"http://localhost:9200\"],\n",
|
||||
@@ -137,7 +137,7 @@
|
||||
"\n",
|
||||
"Example:\n",
|
||||
"```python\n",
|
||||
" from langchain_community.vectorstores.elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
" from langchain_openai import OpenAIEmbeddings\n",
|
||||
"\n",
|
||||
" embedding = OpenAIEmbeddings()\n",
|
||||
@@ -202,7 +202,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_community.vectorstores import ElasticsearchStore\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_openai import OpenAIEmbeddings"
|
||||
]
|
||||
},
|
||||
@@ -817,7 +817,7 @@
|
||||
"source": [
|
||||
"from typing import Dict\n",
|
||||
"\n",
|
||||
"from langchain.docstore.document import Document\n",
|
||||
"from langchain_core.documents import Document\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def custom_document_builder(hit: Dict) -> Document:\n",
|
||||
@@ -902,7 +902,7 @@
|
||||
"\n",
|
||||
"```python\n",
|
||||
"\n",
|
||||
"from langchain_community.vectorstores.elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"\n",
|
||||
"db = ElasticsearchStore(\n",
|
||||
" es_url=\"http://localhost:9200\",\n",
|
||||
@@ -936,7 +936,7 @@
|
||||
"\n",
|
||||
"```python\n",
|
||||
"\n",
|
||||
"from langchain_community.vectorstores.elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"\n",
|
||||
"db = ElasticsearchStore(\n",
|
||||
" es_url=\"http://localhost:9200\",\n",
|
||||
|
@@ -91,8 +91,8 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain.indexes import SQLRecordManager, index\n",
|
||||
"from langchain_community.vectorstores import ElasticsearchStore\n",
|
||||
"from langchain_core.documents import Document\n",
|
||||
"from langchain_elasticsearch import ElasticsearchStore\n",
|
||||
"from langchain_openai import OpenAIEmbeddings"
|
||||
]
|
||||
},
|
||||
|
Reference in New Issue
Block a user