MusicQA is an AI-powered system that answers questions about music using AWS services and the CDK (Cloud Development Kit) for infrastructure deployment.
This project implements a serverless architecture to process user queries about music, leveraging natural language processing and a knowledge base to provide accurate and informative responses. The system is designed to scale automatically and handle a wide range of music-related questions efficiently.
The repository is organized as follows:
app.py: The main entry point for the CDK application.cdk.json: Configuration file for the CDK project.requirements.txt: Python dependencies for the project.musicqa/: Directory containing the main application code.musicqa_stack.py: Defines the AWS resources using CDK constructs.
aws_xray_sdk/: Directory containing the AWS X-Ray SDK for Python.botocore/: Directory containing the Botocore library, which is a low-level interface to AWS services.bin/: Directory containing utility scripts.jp.py: A command-line interface for the JMESPath library.
source.bat: Windows batch script for activating the Python virtual environment.
- Ensure you have Python 3.7 or later installed.
- Install the AWS CDK CLI:
npm install -g aws-cdk - Clone this repository:
git clone https://github.com/your-repo/musicqa.git cd musicqa - Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows, use `.venv\Scripts\activate` - Install the required dependencies:
pip install -r requirements.txt
- Configure your AWS credentials:
aws configure - Synthesize the CloudFormation template:
cdk synth - Deploy the stack:
cdk deploy
After deployment, you can interact with the MusicQA system through the provided API Gateway endpoint. Send POST requests to the endpoint with your music-related questions in the request body.
Example:
curl -X POST https://your-api-gateway-url/prod/ask -d '{"question": "Who wrote Bohemian Rhapsody?"}'
- User submits a question through the API Gateway.
- The request is routed to a Lambda function.
- The Lambda function processes the question using natural language processing.
- The processed question is used to query a knowledge base (e.g., DynamoDB or Amazon Kendra).
- The retrieved information is formatted into a response.
- The response is sent back through the API Gateway to the user.
[User] -> [API Gateway] -> [Lambda] -> [NLP Processing]
-> [Knowledge Base Query]
-> [Response Formatting]
[API Gateway] <- [Lambda] <- [Final Response]
[User] <-
The project uses AWS CDK to define and deploy the following resources:
- Lambda: Processes questions and generates responses.
- API Gateway: Provides the HTTP endpoint for user interactions.
- DynamoDB: Stores the music knowledge base (optional, depending on implementation).
- Amazon Kendra: Provides intelligent search capabilities (optional, depending on implementation).
- CloudWatch: Monitors and logs system activities.
- IAM: Manages permissions for the various components.
The exact resources and their configurations are defined in the musicqa_stack.py file.