Interactive Report Generation via AWS Bedrock

Madhuri MK
4 min readMar 16, 2024

Amazon Bedrock offers high-performing AI models (FMs) from various companies through a single API. It simplifies building generative AI applications with security and privacy in mind.

Its Knowledgebase and Agent features are very much helpful in building enterprise level interactive solutions. One such example is given here from scratch.

Problem Statemet: You are given with data of numerous organizations with unpaid principal amount from past months and year. With this data you need to build an interactive application that can answer questions and generate reports accordingly.

Pre-requisite: You need to have a csv file with desired data and the kind of reports you want to get reports. You need to have a python script that generates these kind of reports.

Here we go with the setup:

FIrst of all we need to enable the base models

S3 bucket creation

Upload the csv file for knowledge base

Obtain the S3 URI

Creating the knowledge base

After creation, sync the data

Then select model

Ask question and get the answer:

Now for generic questions, navigate to Playgroud, Text, Select Model as Claude 2.1 ask any random question, ti will give answer

Now the interesting and complex part to create agents:

With all defaults. Select the model and give specific instructions:

Create lambda function with the python script that you had earlier for reports

In order to test, you can either provide json/yml with proper data or just a dummy test event. In case of dummy test event it shows 200 OK like below

Now add this function to the agent

Now prepare the agent so that it can answer the questions that are asked. You can ask questions now and should get results or it may ask for aditional information for refining the results:

Future Scope:

Enhancing Report Functionality:

  • Advanced Calculations: Expand the report to include additional specific metrics
  • Visualization: Integrate data visualization libraries within the Lambda function to generate charts and graphs alongside the HTML report, offering a more visually compelling way to present the data.
  • Customization Options: Allow agents to configure report parameters through the Bedrock interface, such as selecting specific field types or date ranges.
  • Enhanced Analytics: Explore integrating with a Bedrock foundation model trained for time series forecasting or regression analysis.

--

--