A serverless AML (Anti-Money Laundering) assistant that combines:
- AWS Bedrock foundation models
- AWS Knowledge Bases for Retrieval-Augmented Generation (RAG)
- LangChain + LangGraph tool-based agent workflow
- AWS Lambda (container image deployed via SAM)
- Streamlit web interface
The system supports document retrieval, transaction risk assessment, sanctions checks, and compliance report generation.
- Retrieve AML policies from an AWS Knowledge Base
- Tool-based transaction risk scoring
- Simulated sanctions list screening
- Generate structured AML compliance reports
- Upload documents to S3 for Knowledge Base indexing
- REST API exposed through API Gateway
- Streamlit UI for document upload and chat
src/
agent_handler.py # Main Lambda agent with tools + workflow
lambda_function.py # Simpler RAG-only Lambda handler
requirements.txt
Dockerfile
streamlit_app.py # Streamlit frontend
template.yaml # AWS SAM deployment template
This project expects:
- An AWS Bedrock-enabled region
- An existing AWS Knowledge Base ID
- An S3 bucket used as the document source
Environment variables used by Lambda:
KB_ID=<knowledge-base-id>
S3_BUCKET=<bucket-id>
Build the container:
sam build
Deploy:
sam deploy --guided
After deployment, SAM outputs the API endpoint:
https://<api-id>.execute-api.<region>.amazonaws.com/Prod/query
Use this endpoint in the Streamlit app configuration.
Base image:
public.ecr.aws/lambda/python:3.10
Handler:
agent_handler.lambda_handler
Dependencies installed from:
requirements.txt
POST /query
{
"query": "Check a $15000 crypto transfer from IR"
}Optional mode switch:
{
"query": "...",
"mode": "agent"
}Modes:
"agent"→ tool-enabled AML agent"rag"→ simple Knowledge Base retrieval
{
"answer": "...",
"mode": "agent",
"tools_used": ["assess_transaction_risk"],
"query": "..."
}Install minimal UI dependencies:
pip install streamlit boto3 requests
Run locally:
streamlit run streamlit_app.py
The UI allows:
- Uploading AML documents to S3
- Chatting with the assistant through the deployed API
- Viewing uploaded document history
Streamlit → S3 bucket (documents/) → Knowledge Base sync → Lambda retrieval
Knowledge Base indexing may take a short time before new documents become searchable.
| Tool | Purpose |
|---|---|
search_aml_knowledge_base |
Retrieve compliance documents |
assess_transaction_risk |
Calculate AML risk score |
check_sanctions_list |
Simulated sanctions screening |
get_uploaded_documents |
List documents stored in S3 |
generate_compliance_report |
Produce structured AML report |
The agent workflow instructs the model to rely on tool outputs for transaction analysis.
- Sanctions screening logic is simplified for demonstration.
- Risk scoring logic is rule-based and not regulatory-certified.
- Knowledge Base syncing behavior depends on AWS indexing configuration.
