Kendra retriever api (#6616)

## Description
Replaces [Kendra
Retriever](https://github.com/hwchase17/langchain/blob/master/langchain/retrievers/aws_kendra_index_retriever.py)
with an updated version that uses the new [retriever
API](https://docs.aws.amazon.com/kendra/latest/dg/searching-retrieve.html)
which is better suited for retrieval augmented generation (RAG) systems.

**Note**: This change requires the latest version (1.26.159) of boto3 to
work. `pip install -U boto3` to upgrade the boto3 version.

cc @hupe1980
cc @dev2049
This commit is contained in:
Piyush Jain
2023-06-23 14:59:35 -07:00
committed by GitHub
parent 4e5d78579b
commit b1de927f1b
4 changed files with 279 additions and 105 deletions

View File

@@ -26,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"#!pip install boto3"
"%pip install boto3"
]
},
{
@@ -36,7 +36,7 @@
"outputs": [],
"source": [
"import boto3\n",
"from langchain.retrievers import AwsKendraIndexRetriever"
"from langchain.retrievers import AmazonKendraRetriever"
]
},
{
@@ -53,11 +53,8 @@
"metadata": {},
"outputs": [],
"source": [
"kclient = boto3.client(\"kendra\", region_name=\"us-east-1\")\n",
"\n",
"retriever = AwsKendraIndexRetriever(\n",
" kclient=kclient,\n",
" kendraindex=\"kendraindex\",\n",
"retriever = AmazonKendraRetriever(\n",
" index_id=\"c0806df7-e76b-4bce-9b5c-d5582f6b1a03\"\n",
")"
]
},
@@ -66,7 +63,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now you can use retrieved documents from AWS Kendra Index"
"Now you can use retrieved documents from Kendra index"
]
},
{