This solution provides a Generative AI Application reference that is able to access structured data stored in a PostgreSQL database based on a question-answering assistant that generates SQL queries to obtain the necessary data to provide an answer in natural language.
Also, you can change the data source to connect to your preferred database engine by adapting the Agent's instructions and the Lambda function logic.
IMPORTANT: This sample application is meant for demo purposes and is not production ready. Please make sure to validate the code with your organizations security best practices.
IMPORTANT: Clean up resources after you test the demo to avoid unnecessary costs. Follow the clean-up steps provided.
RECOMMENDATION: Enhance AI safety and compliance by implementing Amazon Bedrock Guardrails for your AI applications.
It is recommended to use the Oregon (us-west-2) or N. Virginia (us-east-1) regions to deploy the application.
To deploy the application, please follow these two steps:
- Getting Started with SAM Video Games Sales Assistant and Amazon Bedrock Agents
- Getting Started with Amplify Video Games Sales Assistant
The following images are part of a conversation analysis that includes the natural language answer, the rationale used by the LLM to generate the SQL query, the records resulting from the SQL query used to answer the question, and chart generation.
Agent answers
Answer details including the rationale to generate the SQL
The record results from the SQL used to answer the question
The chart generated using the agent's answer and the record results from the SQL Query (charts created using Apexcharts)