logo
Menu
Building on Mendix with Gen AI models from Amazon Bedrock

Building on Mendix with Gen AI models from Amazon Bedrock

In this tutorial, you'll learn how to create a Mendix application to prompt an Anthropic Claude model in Amazon Bedrock and display its responses.

Published Jun 10, 2024
Last Modified Jun 18, 2024

Summary

Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI.
Mendix is a low-code application development platform used by businesses in manufacturing, banking and other verticals to develop apps at scale
In this tutorial, you will build a Mendix application which will enable you to prompt an Anthropic Claude model in Amazon Bedrock and display its responses.

Prerequisites

  • An active AWS account
  • Mendix Studio Pro 10.6.1 or above installed on your computer
  • This workshop will run us_east_1 AWS region

Tools

  • Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies.
  • AWS Identity and Access Management (IAM) helps you securely manage access to your AWS resources by controlling who is authenticated and authorized to use them.
  • Mendix is a low-code application development platform from Siemens, an AWS partner. Mendix is used by businesses in manufacturing, banking and other verticals to develop apps at scale.

Epics

Set up your environment

Create AWS credentials for Mendix

1. On the AWS IAM console, create user named mendix-user (see instructions here)
2. On the AWS IAM console, create access keys for mendix-user (see instructions here

Create and attach policy for your AWS credentials

1. Create an IAM policy to mendix-user to utilize Amazon Bedrock. Here’s an example policy:
2. Attach the policy to mendix-user.
For this tutorial only, we use the policy above. However, for other cases, we recommend using a more restrictive following least privilege principle.

Create a Mendix application

1. Launch Mendix Studio Pro and sign in into Mendix Studio Pro
2. Under Studio Pro, choose Create New App.
3. Under Choose your starting point, choose Blank Web App, and then choose Use this starting point.
4. In App Settings enter AWSApp for App name & choose Create app.
5. Create a folder named BedrockModel in the newly created module.

Download AWS connectors in Mendix

The following versions for Mendix connectors were tested for this tutorial:
  • AWSAuthentication 3.0.2
  • Amazon Bedrock Connector 2.3.0
  • Amazon Bedrock Implementation Example 2.1.0
  • Community Commons 10.0.5
1. Choose the shopping cart icon on the top right-hand side corner of Studio Pro to open the Mendix Marketplace.
2. In the search field, enter AWS Authentication Connector and choose on the first search result.
3. Choose Download, and then choose Import on the popup that opens and afterwards confirm the information message by choosing OK.
4. Search for Amazon Bedrock Connector in the Mendix marketplace
5. Follow steps 1 through 4 for other connectors
Amazon Connectors on Mendix

Configure AWSAuthentication connector with AWS credentials

1. In the App Explorer, expand the App AWSApp section and double-click on Settings to open the App Settings in a popup.
2. We need to create a new configuration profile. Choose New to create a new configuration, which will open a popup and name it AWSCredentials.
3. Navigate to the Constants tab and choose New.
4. In the search field, type AccessKey, select the AccessKey constant of the AWSAuthentication connector, and choose Select.
5. In the popup that opens, enter your Access Key in the Value field and confirm with OK.
6. Choose New one more time and this time search for SecretAccessKey, select the SecretAccessKey constant of the AWSAuthenticationConnector, and then choose Select.
7. Enter your Secret Access Key and choose OK and OK again to save your configuration.
8. Make sure, that your configuration is set to Active. You can confirm that by checking the active column has a green check mark.
9. Choose Ok to escape the App Settings.
AWS Credentials in Mendix

Configure your application

Allow access to Claude models via Amazon Bedrock

1. In the Amazon Bedrock console, in us_east_1 region, choose Model access.
2. Choose Manage model access, then select the models Claude and Claude Instant then choose Save changes
Model acces via Amazon Bedrock

Configure Navigation on Mendix

1. In the App Explorer, under AWSApp, double click on Navigation
2. Change home page by selecting Home_Web, under Marketplace modules -> AmazonBedrockExampleImplementation -> Pages
3. In Menu, click on New Item,
  • In Caption, enter Claude
  • In Icon, press Select. In Filter, type message and select message-bubble icon
  • In On Click, select Call a microflow.
  • In Search, type NAV_ChatPrompt and select NAV_ChatPrompt_Overview
  • Click on OK
    Configuring mendix navigation page

Configure microflow

1. Open ACT_InvokeClaudeModel microflow located in Marketplace modules -> AmazonBedrockExampleImplementation -> Pages -> ChatPrompt
2. In the ACT_InvokeClaudeModel microflow, Double click on ChatPrompt_wHistory microflow call
3. Double click on region and change the expression to AWSAuthentication.ENUM_Region.us_east_1
4. Click Ok and Ok to save the new expression
Configure ACT_InvokeClaudeModel microflow

Build and Test your application

Build your application

Press on the green triangle located at the top bar to run your application locally.

View and test application

1. When application is built, click on view app. This will open tab on your browser showing the app
2. Navigate the Claude page by click on message bubble box
3. In the input field, ask a question to Claude. For instance:
Can you tell me what is the best way to travel to Morocco from South Africa?
Mendix app leveraging Claude model on Amazon Bedrock

Clean up

Delete IAM user

1. Navigate to the AWS IAM console
2. In the left menu, choose Users.
3. Choose mendix-user, and then choose Delete
4. Under To confirm deletion, enter mendix-user, and then choose Delete user.

Remove access to Claude Model

1. In the Amazon Bedrock console, in us_east_1 region choose Model access.
2. Choose Modify model access, then Unselect the models Claude and Claude Instant
3. Click and Submit
Remove Model access on Amazon Bedrock

 

Comments