# langchain-aws
This package contains the LangChain integrations with AWS.
## Installation
```bash
pip install -U langchain-aws
```
All integrations in this package assume that you have the credentials setup to connect with AWS services.
## Chat Models
`ChatBedrock` class exposes chat models from Bedrock.
```python
from langchain_aws import ChatBedrock
llm = ChatBedrock()
llm.invoke("Sing a ballad of LangChain.")
```
## Embeddings
`BedrockEmbeddings` class exposes embeddings from Bedrock.
```python
from langchain_aws import BedrockEmbeddings
embeddings = BedrockEmbeddings()
embeddings.embed_query("What is the meaning of life?")
```
## LLMs
`BedrockLLM` class exposes LLMs from Bedrock.
```python
from langchain_aws import BedrockLLM
llm = BedrockLLM()
llm.invoke("The meaning of life is")
```
## Retrievers
`AmazonKendraRetriever` class provides a retriever to connect with Amazon Kendra.
```python
from langchain_aws import AmazonKendraRetriever
retriever = AmazonKendraRetriever(
index_id="561be2b6d-9804c7e7-f6a0fbb8-5ccd350"
)
retriever.get_relevant_documents(query="What is the meaning of life?")
```
`AmazonKnowledgeBasesRetriever` class provides a retriever to connect with Amazon Knowledge Bases.
```python
from langchain_aws import AmazonKnowledgeBasesRetriever
retriever = AmazonKnowledgeBasesRetriever(
knowledge_base_id="IAPJ4QPUEU",
retrieval_config={"vectorSearchConfiguration": {"numberOfResults": 4}},
)
retriever.get_relevant_documents(query="What is the meaning of life?")
```
## VectorStores
`InMemoryVectorStore` class provides a vectorstore to connect with Amazon MemoryDB.
```python
from langchain_aws.vectorstores.inmemorydb import InMemoryVectorStore
vds = InMemoryVectorStore.from_documents(
chunks,
embeddings,
redis_url="rediss://cluster_endpoint:6379/ssl=True ssl_cert_reqs=none",
vector_schema=vector_schema,
index_name=INDEX_NAME,
)
```
## MemoryDB as Retriever
Here we go over different options for using the vector store as a retriever.
There are three different search methods we can use to do retrieval. By default, it will use semantic similarity.
```python
retriever=vds.as_retriever()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/langchain-ai/langchain-aws",
"name": "langchain-aws",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/70/12/f95b1c773ffa3b81b34dddba6e77771136789b2efb7acb1d8054ab412d1d/langchain_aws-0.2.16.tar.gz",
"platform": null,
"description": "# langchain-aws\n\nThis package contains the LangChain integrations with AWS.\n\n## Installation\n\n```bash\npip install -U langchain-aws\n```\nAll integrations in this package assume that you have the credentials setup to connect with AWS services.\n\n## Chat Models\n\n`ChatBedrock` class exposes chat models from Bedrock.\n\n```python\nfrom langchain_aws import ChatBedrock\n\nllm = ChatBedrock()\nllm.invoke(\"Sing a ballad of LangChain.\")\n```\n\n## Embeddings\n\n`BedrockEmbeddings` class exposes embeddings from Bedrock.\n\n```python\nfrom langchain_aws import BedrockEmbeddings\n\nembeddings = BedrockEmbeddings()\nembeddings.embed_query(\"What is the meaning of life?\")\n```\n\n## LLMs\n`BedrockLLM` class exposes LLMs from Bedrock.\n\n```python\nfrom langchain_aws import BedrockLLM\n\nllm = BedrockLLM()\nllm.invoke(\"The meaning of life is\")\n```\n\n## Retrievers\n`AmazonKendraRetriever` class provides a retriever to connect with Amazon Kendra.\n\n```python\nfrom langchain_aws import AmazonKendraRetriever\n\nretriever = AmazonKendraRetriever(\n index_id=\"561be2b6d-9804c7e7-f6a0fbb8-5ccd350\"\n)\n\nretriever.get_relevant_documents(query=\"What is the meaning of life?\")\n```\n\n`AmazonKnowledgeBasesRetriever` class provides a retriever to connect with Amazon Knowledge Bases.\n\n```python\nfrom langchain_aws import AmazonKnowledgeBasesRetriever\n\nretriever = AmazonKnowledgeBasesRetriever(\n knowledge_base_id=\"IAPJ4QPUEU\",\n retrieval_config={\"vectorSearchConfiguration\": {\"numberOfResults\": 4}},\n)\n\nretriever.get_relevant_documents(query=\"What is the meaning of life?\")\n```\n## VectorStores \n`InMemoryVectorStore` class provides a vectorstore to connect with Amazon MemoryDB.\n\n```python\nfrom langchain_aws.vectorstores.inmemorydb import InMemoryVectorStore\n\nvds = InMemoryVectorStore.from_documents(\n chunks,\n embeddings,\n redis_url=\"rediss://cluster_endpoint:6379/ssl=True ssl_cert_reqs=none\",\n vector_schema=vector_schema,\n index_name=INDEX_NAME,\n )\n```\n\n## MemoryDB as Retriever\n\nHere we go over different options for using the vector store as a retriever.\n\nThere are three different search methods we can use to do retrieval. By default, it will use semantic similarity.\n\n```python\nretriever=vds.as_retriever()\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An integration package connecting AWS and LangChain",
"version": "0.2.16",
"project_urls": {
"Homepage": "https://github.com/langchain-ai/langchain-aws",
"Repository": "https://github.com/langchain-ai/langchain-aws",
"Source Code": "https://github.com/langchain-ai/langchain-aws/tree/main/libs/aws"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "dad0fb70532ec035ec625fe647b582bee8bb39158210480c0b0750e7199bbb3e",
"md5": "8e8a50c972eee2ef19422d36b56f7220",
"sha256": "7db813eb88628a78a535194f61715c0bcc8722882793716e58beba4aa1cd8ebc"
},
"downloads": -1,
"filename": "langchain_aws-0.2.16-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8e8a50c972eee2ef19422d36b56f7220",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 113760,
"upload_time": "2025-03-19T00:33:14",
"upload_time_iso_8601": "2025-03-19T00:33:14.339777Z",
"url": "https://files.pythonhosted.org/packages/da/d0/fb70532ec035ec625fe647b582bee8bb39158210480c0b0750e7199bbb3e/langchain_aws-0.2.16-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7012f95b1c773ffa3b81b34dddba6e77771136789b2efb7acb1d8054ab412d1d",
"md5": "1a6220def51ff8843335343c6c99b2af",
"sha256": "2c2971b3a5ef49c0fe275740e4389ccf2665ee4d070cfbaee157b2b46895c6f5"
},
"downloads": -1,
"filename": "langchain_aws-0.2.16.tar.gz",
"has_sig": false,
"md5_digest": "1a6220def51ff8843335343c6c99b2af",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 92761,
"upload_time": "2025-03-19T00:33:17",
"upload_time_iso_8601": "2025-03-19T00:33:17.020722Z",
"url": "https://files.pythonhosted.org/packages/70/12/f95b1c773ffa3b81b34dddba6e77771136789b2efb7acb1d8054ab412d1d/langchain_aws-0.2.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-03-19 00:33:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "langchain-ai",
"github_project": "langchain-aws",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "langchain-aws"
}