Skip to main content

llama-index retrievers kendra integration

Project description

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
)

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

llama_index_retrievers_kendra-0.3.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_retrievers_kendra-0.3.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_retrievers_kendra-0.3.0.tar.gz.

File metadata

  • Download URL: llama_index_retrievers_kendra-0.3.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}

File hashes

Hashes for llama_index_retrievers_kendra-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7b8b6fec921109118afa7f0021b91f19674b55170ae59f01230ac759ce5d79d9
MD5 4083d352c984cbad7d7ef5b81cc5784f
BLAKE2b-256 66ce55bef3626c75ce25d11c5a9ac6bc188dd7dc9ccdcc1bc3987cde5e748df3

See more details on using hashes here.

File details

Details for the file llama_index_retrievers_kendra-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_retrievers_kendra-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}

File hashes

Hashes for llama_index_retrievers_kendra-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5caf56c9cba1116e4f3521d249fe145ddebe8bfbec69f63b8b766f390c04472e
MD5 8ae377e04c3455f90329254ca208fc6b
BLAKE2b-256 5e2f9ff454dcacbeda8f50eb2c8e3833485738947bda0a41ed6a87d500b087ed

See more details on using hashes here.

Supported by

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