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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file langchain_aws-0.1.18.tar.gz
.
File metadata
- Download URL: langchain_aws-0.1.18.tar.gz
- Upload date:
- Size: 69.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e59efc95ef6758581b7e769cd610b750c76635c437a4f43c454a14cfab67c64 |
|
MD5 | a1184ed60eb6e40692efdfac4bedf704 |
|
BLAKE2b-256 | b4b07c7c2e90170daaaaf232dc16e9271fba2c1772b29926d9dd2e40af3b8ef5 |
File details
Details for the file langchain_aws-0.1.18-py3-none-any.whl
.
File metadata
- Download URL: langchain_aws-0.1.18-py3-none-any.whl
- Upload date:
- Size: 83.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c65157c67837cd932a6a8c536b52e2308c4e917bccd187d6f42651943cdd51 |
|
MD5 | 9b4b3605817e231ab479cc6a96ac1ca6 |
|
BLAKE2b-256 | 79811134c1ba46d746a76bf7d9685e28264bf4bd3328bdc7f4d61ad30811c2ef |