LlamaIndex Retrievers Integration: Amazon Kendra
Overview
Amazon Kendra is an intelligent search service powered by machine learning. Kendra reimagines enterprise search for your websites and applications by allowing users to search your unstructured and structured data using natural language.
Kendra supports a wide variety of data sources including:
- Documents (PDF, Word, PowerPoint, HTML)
- FAQs
- Knowledge bases
- Databases
- Websites
- Custom data sources through connectors
Installation
pip install llama-index-retrievers-kendra
Usage
Here's a basic example of how to use the Kendra retriever:
from llama_index.retrievers.kendra import AmazonKendraRetriever
retriever = AmazonKendraRetriever(
index_id="<kendra-index-id>",
query_config={
"PageSize": 4,
"AttributeFilter": {
"EqualsTo": {
"Key": "department",
"Value": {"StringValue": "engineering"},
}
},
},
)
query = "What is our company's remote work policy?"
retrieved_results = retriever.retrieve(query)
# Print the first retrieved result
print(retrieved_results[0].get_content())
Advanced Configuration
The retriever supports Kendra's rich querying capabilities through the query_config parameter:
retriever = AmazonKendraRetriever(
index_id="<kendra-index-id>",
query_config={
"PageSize": 10, # Number of results to return
"AttributeFilter": {
# Filter results based on document attributes
"AndAllFilters": [
{
"EqualsTo": {
"Key": "department",
"Value": {"StringValue": "engineering"},
}
},
{
"GreaterThan": {
"Key": "last_updated",
"Value": {"StringValue": "2023-01-01"},
}
},
]
},
"QueryResultTypeFilter": "DOCUMENT", # Only return document results
},
)
Confidence Scores
The retriever maps Kendra's confidence levels to float scores as follows:
- VERY_HIGH: 1.0
- HIGH: 0.8
- MEDIUM: 0.6
- LOW: 0.4
- NOT_AVAILABLE: 0.0
These scores can be accessed through the score attribute of the retrieved nodes:
results = retriever.retrieve("query")
for result in results:
print(f"Text: {result.get_content()}")
print(f"Confidence Score: {result.score}")
Authentication
The retriever supports various AWS authentication methods:
retriever = AmazonKendraRetriever(
index_id="<kendra-index-id>",
profile_name="my-aws-profile", # Use AWS profile
region_name="us-west-2", # Specify AWS region
# Or use explicit credentials
aws_access_key_id="YOUR_ACCESS_KEY",
aws_secret_access_key="YOUR_SECRET_KEY",
aws_session_token="YOUR_SESSION_TOKEN", # Optional
)
Metadata
Release files for llama-index-retrievers-kendra 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llama_index_retrievers_kendra-0.4.0.tar.gz | 5.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llama_index_retrievers_kendra-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / llama_index_retrievers_kendra-0.4.0.tar.gz
| Download URL | llama_index_retrievers_kendra-0.4.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3992b9c62d88f0cf90e228f7b581cc3fbb9a7e7dce50b3433df4e51a556b0b9
|
|
BLAKE2b-256 checksum How to use checksums |
0f3a072190810769d46d1e3e20936baa1b209d7a9187ad2170fb4cee8a162246
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_retrievers_kendra-0.4.0-py3-none-any.whl
| Download URL | llama_index_retrievers_kendra-0.4.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8183b5ad6c664d08296ee74f17e00a82fad4bf85de0c808840756755d67d6768
|
|
BLAKE2b-256 checksum How to use checksums |
8694188a460b136404c4d60de6499c3569a5c24cc9fe15e6346414f3aa2ca5f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-retrievers-kendra 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.