a

Using Amazon Q Developer CLI to build a GenAI Chat Bot

We have this new initiative that enables our clients to get AWS Bedrock API keys for free. AWS has some new LLMs, Nova, that enable you to use a version of Claude for really cheap prices. To demonstrate how easy it is to migrate from OpenAI to Bedrock, I asked the Amazon Q Developer CLI to generate a web based HTML chat bot.

First, I installed Amazon Q Developer on my Mac using the following link: https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html

The installation process forced me to use my Builder ID. If you don’t have a Builder ID setup, navigate to the AWS Builder ID profile or the sign-up page of the AWS tool or service that you want to access.

Login with your Builder ID and install the app.

Amazon Q Developer CLI Install

After successfully installing the Amazon Q Developer CLI, I navigated to the terminal prompt on my Mac. I typed

q chat

Into the > prompt, I typed

please create an html chatbot using open ai docs at @https://platform.openai.com/docs/quickstart?api-mode=chat

Amazon Q Developer CLI Q Chat Example

I encountered an issue that OpenAI was protected by CloudFlare, so I just proceeded with their Q Developers Recommendations.

Amazon Q Developer CLI OpenAI Cloudflare
Voila! Q Developer created three files

  • OpenAi-ChatBot.html
  • OpenAI-Chatbot.js
  • Readme. 

I’ve created a simple but functional OpenAI-powered chatbot for you! Here’s what I’ve set up:

  1. openai-chatbot.html: The main HTML file with the user interface
  2. openai-chatbot.js: The JavaScript file that handles the API calls to OpenAI
  3. README.md: Documentation on how to use the chatbot

## How to Use the Chatbot

  1. Open the openai-chatbot.html file in your web browser
  2. Enter your OpenAI API key in the field at the top (you can get one from https://platform.openai.com/api-keys)
  3. Start chatting with the AI!

After making code changes to support the new AWS Bedrock Nova LLM, my new html chat bot page was able to communciate with Nova.