A full-stack, serverless web application featuring an AI agent obsessed with weather, calculations, and synonyms. The agent uses AWS Strands to automatically orchestrate between multiple tools, demonstrating spontaneous tool selection and creative conversation flow.
.
├── backend/
│ ├── src/
│ │ ├── app.py # Lambda function implementation
│ │ └── requirements.txt # Python dependencies
│ └── template.yaml # SAM template for deployment
├── frontend/
│ └── index.html # Web interface
└── tests/
└── test_app.py # Unit tests
The backend is implemented as an AWS Lambda function using:
- Python 3.11
- AWS Strands Agents SDK (tool orchestration)
- Amazon Bedrock (Claude 3 Sonnet)
- Three integrated tools:
- Thesaurus Tool: Datamuse API for synonyms
- Calculator Tool: Built-in Strands mathematical calculations
- Weather Tool: OpenWeatherMap API with authentication
- AWS SAM for deployment
- Install AWS SAM CLI
- Configure AWS credentials
- Get an OpenWeatherMap API key from https://openweathermap.org/api
- Build and deploy:
cd backend
sam build
sam deploy --guided --parameter-overrides OpenWeatherApiKey=YOUR_API_KEY
The following environment variables must be configured:
BEDROCK_MODEL_ID
: The Bedrock model identifierOPENWEATHER_API_KEY
: API key for OpenWeatherMap service
A single-page web application built with:
- HTML5
- Tailwind CSS
- Vanilla JavaScript
- Update the
API_ENDPOINT
variable in index.html with your deployed API Gateway URL - Host the frontend files on your preferred static hosting service (e.g., S3, CloudFront)
The obsessive agent demonstrates:
- Automatic tool selection: Chooses tools based on conversational context
- Creative connections: Relates any topic to weather, math, or word choices
- Tool chaining: Combines multiple tools in single responses
- Personality-driven interactions: Enthusiastic and obsessive responses
Input: "My cat seems sad today"
Output: "You know, cats can sense barometric pressure! [uses weather tool] It's currently 29.8 inches and falling - that's a 3.2% drop [uses calculator] since yesterday which might explain your cat's mood! Speaking of moods, let me find some synonyms... [uses thesaurus] melancholy, dejected, downcast!"
Input: "I need help with my budget"
Output: "Budget calculations! [uses calculator] But speaking of budgets, did you know it's 23°F outside? [uses weather tool] That's quite frigid - or should I say glacial, icy, arctic! [uses thesaurus] Budgeting for heating costs is crucial!"
Run the unit tests:
pytest tests/
Test the Datamuse API functionality directly:
python tests/test_datamuse.py
- CORS-enabled API endpoint
- Input validation and error handling
The backend exposes a single endpoint that accepts POST requests:
POST /query
Content-Type: application/json
{
"query": "user's natural language text"
}
Response format:
{
"response": "Obsessive AI response with automatic tool usage"
}
Uses the Datamuse API for synonym lookup:
/words?ml={word}
- Find words with similar meaning/words?rel_syn={word}
- Find synonyms- Free to use, no authentication required
Leverages the built-in Strands calculator tool for mathematical operations.
Integrates with OpenWeatherMap API:
- Current weather conditions
- Temperature, humidity, pressure
- Requires API key authentication
- Demonstrates error handling and location parsing
git clone
chmod +x scripts/setup.sh && ./scripts/setup.sh
Copy real credentials to local/.aws/credentials
export AWS_SHARED_CREDENTIALS_FILE=./local/.aws/credentials
Everything stays in the project folder.