A Flask-based REST API that uses AWS Bedrock to generate concise summaries of customer messages. This service is particularly useful for quickly understanding the essence of customer communications.
- RESTful API endpoint for text summarization
- Integration with AWS Bedrock's Claude model
- Simple and efficient text processing
- Error handling and input validation
- Python 3.7+
- AWS Account with Bedrock access
- AWS credentials configured
- Clone the repository:
git clone <repository-url>
cd <repository-name>
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
-
Configure AWS credentials:
- Place your AWS credentials in
bedrock-user_accessKeys.csv
- Ensure the credentials have access to AWS Bedrock
- Place your AWS credentials in
-
Configure the model settings in
config.yaml
:
model:
modelId: "anthropic.claude-v2"
contentType: "application/json"
accept: "application/json"
region: "us-east-1"
parameters:
max_tokens_to_sample: 100
temperature: 0.7
top_k: 250
top_p: 1
- Start the Flask server:
python app.py
-
The API will be available at
http://localhost:5000
-
Send a POST request to
/summarize
endpoint:
curl -X POST http://localhost:5000/summarize \
-H "Content-Type: application/json" \
-d '{"message": "Your text to summarize here"}'
Example response:
{
"summary": "Customer reports being overcharged 40 times for an invoice and expresses frustration."
}
Health check endpoint that returns the API status.
Summarizes the provided text.
Request body:
{
"message": "Text to summarize"
}
Response:
{
"summary": "Generated summary"
}
The API returns appropriate HTTP status codes:
- 200: Successful summarization
- 400: Missing or invalid input
- 500: Server error
Run the test suite:
python -m unittest test_bedrock_client.py
- Never commit AWS credentials to version control
- Keep your
config.yaml
secure - Use environment variables for sensitive configuration in production
[TBD]