Skip to main content

An integration package connecting AWS and LangChain

Project description

langchain-aws

This package contains the LangChain integrations with AWS.

Installation

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.

from langchain_aws import ChatBedrock

llm = ChatBedrock()
llm.invoke("Sing a ballad of LangChain.")

Embeddings

BedrockEmbeddings class exposes embeddings from Bedrock.

from langchain_aws import BedrockEmbeddings

embeddings = BedrockEmbeddings()
embeddings.embed_query("What is the meaning of life?")

LLMs

BedrockLLM class exposes LLMs from Bedrock.

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.

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.

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.

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.

retriever=vds.as_retriever()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_aws-0.1.16.tar.gz (63.5 kB view details)

Uploaded Source

Built Distribution

langchain_aws-0.1.16-py3-none-any.whl (76.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_aws-0.1.16.tar.gz.

File metadata

  • Download URL: langchain_aws-0.1.16.tar.gz
  • Upload date:
  • Size: 63.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for langchain_aws-0.1.16.tar.gz
Algorithm Hash digest
SHA256 cb479a565d0450c9bfba9d2336973191beb97574a519ddd376713addd5b9226c
MD5 d8bb78ff203eecd0b94cac77af46d7e2
BLAKE2b-256 6bcf0caff72c699d2842940a10a70b61a5fe4b74f23732c7639c8104d75f1199

See more details on using hashes here.

File details

Details for the file langchain_aws-0.1.16-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_aws-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 b4722a13954a6e330c4b1e7b85a9884bfe789ecc24e11f0e83aa5c294d95093e
MD5 a3a419632ea66c8525e8d4b1e3d2edfc
BLAKE2b-256 9fa37fccb14d890a7cef8a9753141d93c5f1551a8a3a3a237649df598c5f2774

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page