
Developing a Serverless Generative AI Knowledge Base App on AWS
As part of my diploma project, I have developed a Generative AI application on Amazon Web Services (AWS). It's designed to create a knowledge base from user documents and answer natural language queries. Users can maintain their document library and submit queries through a Command Line Interface (CLI), which is written in GoLang.
Architecture
I used several managed AWS services to construct a cost-effective and scalable architecture. AWS API Gateway facilitated communication between the CLI and backend services via API endpoints. These endpoints ran on AWS Lambda, ensuring a cost-effective and responsive system. I utilized pre-trained AI models from AWS Bedrock, specifically Amazon Titan and Anthropic Claude-3, for accurate and efficient document analysis and user query responses. I used OpenSearch Serverless to store vector embeddings and analysis of user-uploaded documents, which enhanced user experience by removing the hassle of infrastructure and data management.
Infrastructure Deployment
To automate the infrastructure deployment process, I embraced Infrastructure as Code (IaC) principles and leveraged the capabilities of Pulumi. Through IaC, I transformed manual and error-prone infrastructure management into an automated and scalable approach. I wrote code in familiar programming languages, such as GoLang, to define and deploy cloud resources. IaC enhanced the consistency and reliability of the infrastructure setup and streamlined my development workflow for greater agility and control.
AI Agents
One of the most exciting aspects of the project was the integration of AI agents. I started by defining the logic and functions of various agents. Using OpenSearch Serverless, I created collections and then a knowledge base from the documents provided by the user, while AWS Bedrock provided the necessary AI functionalities.
However, I encountered a significant challenge in creating a vector index programmatically. Unlike the straightforward process through the OpenSearch dashboard, there was no native functionality within any of AWS SDKs to accomplish this. My only recourse was to call the OpenSearch API directly.
To securely sign my HTTP requests to OpenSearch, I used AWS Signer, which ensured safe communication with the AWS infrastructure and successful creation of the index.
Interacting with the system using the CLI
The Command Line Interface (CLI), named acpml, is a critical part of the project. I began by setting up the CLI environment and dependencies. Then, I developed the main functions of the CLI. I integrated document management and agent interactions into the CLI, thus enabling users to interact with the application.
Example of a question to an agent
Next steps
In the future, the application could be improved in many ways, such as:
- Developing a web interface to enhance accessibility and streamline user interaction across multiple devices.
- Integrating with existing document management platforms or databases to simplify workflows and increase efficiency.
For further insights or consulting services on cloud adoption, AI integration, and DevOps automation, please reach out!
Get in touch
Feel free to get in touch to discuss your project ideas.
