langchain-aws


Namelangchain-aws JSON
Version 0.2.29 PyPI version JSON
download
home_pagehttps://github.com/langchain-ai/langchain-aws
SummaryAn integration package connecting AWS and LangChain
upload_time2025-07-22 03:08:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

## Authentication

In order to use Amazon Bedrock models, you need to configure AWS credentials. One of the options is to set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. More information can be found [here](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html). 
Alternatively, set the `AWS_BEARER_TOKEN_BEDROCK` environment variable locally for API Key authentication. For additional API key details, refer to [docs](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html).

## 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": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/5e/3a/eb72246f42b6c1d6a7ca49f4d50f1a7b7c808692165592cee1cab28ce07e/langchain_aws-0.2.29.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## Authentication\n\nIn order to use Amazon Bedrock models, you need to configure AWS credentials. One of the options is to set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. More information can be found [here](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html). \nAlternatively, set the `AWS_BEARER_TOKEN_BEDROCK` environment variable locally for API Key authentication. For additional API key details, refer to [docs](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html).\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.29",
    "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": "e44fd8422af0058e75f4f5d87b57b77da401c1b045c30d06894415055415af28",
                "md5": "93ecd6022f43b4d457a5f61b1ca92670",
                "sha256": "dd04c0d859ea44d506a85f179cb3f638529687881dcf14b12e63899c67478320"
            },
            "downloads": -1,
            "filename": "langchain_aws-0.2.29-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93ecd6022f43b4d457a5f61b1ca92670",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 133051,
            "upload_time": "2025-07-22T03:08:01",
            "upload_time_iso_8601": "2025-07-22T03:08:01.902947Z",
            "url": "https://files.pythonhosted.org/packages/e4/4f/d8422af0058e75f4f5d87b57b77da401c1b045c30d06894415055415af28/langchain_aws-0.2.29-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5e3aeb72246f42b6c1d6a7ca49f4d50f1a7b7c808692165592cee1cab28ce07e",
                "md5": "0bf40f985804e3db4ca7989cf549a2ed",
                "sha256": "a7b24b9b3d96af0ff5c7e55988c178c17e090aa954325b77d725f334eb2c4479"
            },
            "downloads": -1,
            "filename": "langchain_aws-0.2.29.tar.gz",
            "has_sig": false,
            "md5_digest": "0bf40f985804e3db4ca7989cf549a2ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 109161,
            "upload_time": "2025-07-22T03:08:03",
            "upload_time_iso_8601": "2025-07-22T03:08:03.219054Z",
            "url": "https://files.pythonhosted.org/packages/5e/3a/eb72246f42b6c1d6a7ca49f4d50f1a7b7c808692165592cee1cab28ce07e/langchain_aws-0.2.29.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-22 03:08:03",
    "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"
}
        
Elapsed time: 1.00234s