Leadership Takeaways Patrick Henry QuestFusion CEO

I was fortunate enough to be interviewed by internationally renowned executive coach, Rachael Orchard, from My Pocket Coach, on her program Leadership Takeaways Patrick Henry QuestFusion CEO. Rachael…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Create a custom AI chatbot powered by the OpenAI ChatGPT model

In this article, I am going to show how Azure OpenAI models’ API can be embedded in a web app that simulates a chatbot.

I am using a Python app, built using the Streamlit framework, to allow users to have interactive conversations with an AI assistant named Khalid.

Here’s a breakdown of the code:

Overall, this app allows users to have conversational interactions with the AI assistant Khalid, powered by the OpenAI ChatGPT model.

This app has dependencies. I will put them in a requirements.txt file:

I use Docker to encapsulate the entire application stack, including dependencies, services, and configurations.

We can start writing our Dockerfile:

I won’t give the API secrets directly into the Dockerfile. I will make use of the docker compose YAML file.

Let’s build the docker image.

I need to create a Resource Group in Azure that keeps all the resources bound together. Create a Resource Group with Azure CLI:

I also need to create an Azure OpenAI resource and deploy a model :

Before I can generate text or inference, I need to deploy a model. To deploy a model, I have to follow these steps:

Get the API ENDPOINT and API KEY:

Then I need to create a Container Registry with Azure CLI:

To push the docker image to the Container Registry (ACR), I need to tag the Docker image first and push it to the right registry after login :

Now I will write the Docker compose file, that I will use to deploy and orchestrate the app (For now I will use only one container) :

Create an App Service Plan with Azure CLI:

Create a Web App with Azure CLI:

Configure the Web App to get the image from the ACR:

(I used Admin Credentials but you could use Managed Identity as well)

Here is a summary of the resources I created in Azure:

From the page of the newly created web service in the Azure Portal, I can get the URL to access the application. Let’s see if it works:

Using the Azure OpenAI models’ API and Streamlit framework, we can create a custom ChatGPT. In this article, I am demonstrating the power of the OpenAI models’ API in adding intelligence and user-oriented features to any application. With just a few lines of code, I created a seamless conversational experience, showcasing the potential of AI-powered interactions in various applications.

Add a comment

Related posts:

Introduction

I have been surprised how many people are not aware of Microsoft’s open source shift over last 8 years. A lots of people are not aware of current state of .NET, .NET Core and ASP.NET Core. And I do…

Ads on RT and other Russian channels are no longer allowed on YouTube

According to Reuters, YouTube is preventing state-owned Russian media outlets from advertising and generating money on the platform. YouTube told Reuters that it is “pausing a number of channels’…

25 Ways To Lose Weight Effectively

The first step in losing weight is to set realistic goals. Weight loss is a journey that requires patience and dedication, and it is essential to set goals that are achievable in the long run. Losing…