Skip to content

Commit

Permalink
Update LangChain imports to use langchain-elasticsearch
Browse files Browse the repository at this point in the history
the new partner integration package:
https://pypi.org/project/langchain-elasticsearch/
  • Loading branch information
maxjakob committed Mar 4, 2024
1 parent 41c0a05 commit ea50c1c
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions notebooks/document-chunking/with-langchain-splitters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python3 -m pip install -qU langchain elasticsearch eland jq"
"!python3 -m pip install -qU langchain langchain-elasticsearch elasticsearch eland jq"
]
},
{
Expand Down Expand Up @@ -548,7 +548,7 @@
}
],
"source": [
"from langchain.vectorstores.elasticsearch import (\n",
"from langchain_elasticsearch import (\n",
" ElasticsearchStore,\n",
" ApproxRetrievalStrategy,\n",
")\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/generative-ai/chatbot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}
],
"source": [
"%pip install -qU langchain openai elasticsearch tiktoken"
"%pip install -qU langchain openai langchain-elasticsearch tiktoken"
]
},
{
Expand Down Expand Up @@ -195,7 +195,7 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain.embeddings import OpenAIEmbeddings\n",
"\n",
"embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/generative-ai/question-answering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
],
"source": [
"!python3 -m pip install -qU langchain openai==0.28.1 elasticsearch tiktoken jq"
"!python3 -m pip install -qU langchain langchain-elasticsearch openai==0.28.1 tiktoken jq"
]
},
{
Expand Down Expand Up @@ -77,7 +77,7 @@
},
"outputs": [],
"source": [
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain.embeddings.openai import OpenAIEmbeddings\n",
"from getpass import getpass\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"outputs": [],
"source": [
"# install packages\n",
"!python3 -m pip install -qU langchain elasticsearch boto3\n",
"!python3 -m pip install -qU langchain langchain-elasticsearch boto3\n",
"\n",
"# import modules\n",
"from getpass import getpass\n",
"from urllib.request import urlopen\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain.embeddings.bedrock import BedrockEmbeddings\n",
"from langchain.llms import Bedrock\n",
"from langchain.chains import RetrievalQA\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"metadata": {},
"outputs": [],
"source": [
"pip install -q -U google-generativeai elasticsearch langchain langchain_google_genai"
"pip install -q -U google-generativeai langchain-elasticsearch langchain langchain_google_genai"
]
},
{
Expand All @@ -60,8 +60,7 @@
"from getpass import getpass\n",
"from urllib.request import urlopen\n",
"\n",
"from elasticsearch import Elasticsearch, helpers\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain.text_splitter import CharacterTextSplitter\n",
"from langchain_google_genai import GoogleGenerativeAIEmbeddings\n",
"from langchain_google_genai import ChatGoogleGenerativeAI\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/langchain/langchain-using-own-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"metadata": {},
"outputs": [],
"source": [
"!python3 -m pip install -qU langchain elasticsearch tiktoken sentence-transformers eland transformers\n",
"!python3 -m pip install -qU langchain langchain-elasticsearch tiktoken sentence-transformers eland transformers\n",
"\n",
"from getpass import getpass\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from urllib.request import urlopen\n",
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
"import json"
Expand Down
4 changes: 2 additions & 2 deletions notebooks/langchain/langchain-vector-store-using-elser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
"outputs": [],
"source": [
"# install packages\n",
"!python3 -m pip install -qU langchain openai elasticsearch tiktoken\n",
"!python3 -m pip install -qU langchain langchain-elasticsearch openai tiktoken\n",
"\n",
"# import modules\n",
"from getpass import getpass\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from urllib.request import urlopen\n",
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
"import json"
Expand Down
4 changes: 2 additions & 2 deletions notebooks/langchain/langchain-vector-store.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"outputs": [],
"source": [
"# install packages\n",
"!python3 -m pip install -qU langchain openai elasticsearch tiktoken\n",
"!python3 -m pip install -qU langchain langchain-elasticsearch openai tiktoken\n",
"\n",
"# import modules\n",
"from getpass import getpass\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain.embeddings.openai import OpenAIEmbeddings\n",
"from urllib.request import urlopen\n",
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
}
],
"source": [
"!python3 -m pip install -qU jq lark elasticsearch langchain_openai tiktoken\n",
"!python3 -m pip install -qU jq lark langchain langchain-elasticsearch langchain_openai tiktoken\n",
"\n",
"from langchain_openai.embeddings import OpenAIEmbeddings\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain_openai.llms import OpenAI\n",
"from langchain.retrievers.multi_query import MultiQueryRetriever\n",
"from getpass import getpass"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
}
],
"source": [
"!python3 -m pip install -qU lark elasticsearch langchain_openai tiktoken\n",
"!python3 -m pip install -qU lark langchain langchain-elasticsearh langchain_openai tiktoken\n",
"\n",
"from langchain.schema import Document\n",
"from langchain_openai.embeddings import OpenAIEmbeddings\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain_openai.chat_models import ChatOpenAI\n",
"from langchain.retrievers.multi_query import MultiQueryRetriever\n",
"from getpass import getpass"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
}
],
"source": [
"!python3 -m pip install -qU lark elasticsearch langchain openai\n",
"!python3 -m pip install -qU lark elasticsearch langchain langchain-elasticsearch openai\n",
"\n",
"from langchain.schema import Document\n",
"from langchain.embeddings.openai import OpenAIEmbeddings\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain.llms import OpenAI\n",
"from langchain.retrievers.self_query.base import SelfQueryRetriever\n",
"from langchain.chains.query_constructor.base import AttributeInfo\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
],
"source": [
"!python3 -m pip install -qU lark elasticsearch langchain openai"
"!python3 -m pip install -qU lark elasticsearch langchain langchain-elasticsearch openai"
]
},
{
Expand Down Expand Up @@ -209,12 +209,11 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain.vectorstores.elasticsearch import ApproxRetrievalStrategy\n",
"from typing import List, Union\n",
"from langchain.retrievers.self_query.base import SelfQueryRetriever\n",
"from langchain.chains.query_constructor.base import AttributeInfo\n",
"from langchain.llms import OpenAI\n",
"from langchain.vectorstores.elasticsearch import ElasticsearchStore\n",
"from langchain_elasticsearch import ApproxRetrievalStrategy, ElasticsearchStore\n",
"\n",
"# Add details about metadata fields\n",
"metadata_field_info = [\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
}
],
"source": [
"!python3 -m pip install -qU lark elasticsearch langchain openai\n",
"!python3 -m pip install -qU lark langchain langchain-elasticsearch openai\n",
"\n",
"from langchain.schema import Document\n",
"from langchain.embeddings.openai import OpenAIEmbeddings\n",
"from langchain.vectorstores import ElasticsearchStore\n",
"from langchain_elasticsearch import ElasticsearchStore\n",
"from langchain.llms import OpenAI\n",
"from langchain.retrievers.self_query.base import SelfQueryRetriever\n",
"from langchain.chains.query_constructor.base import AttributeInfo\n",
Expand Down

0 comments on commit ea50c1c

Please sign in to comment.