Getting started with Azure OpenAI

Getting started with Azure OpenAI

I’ve been exploring ways to use AI in my day-to-day job. I personally use Azure and want to leverage as much as possible the partnership they have with OpenAI.

What you will learn in this article is how to use your own data to create a ChatGPT-like agent using Azure OpenAI API.

What I’m using in this post includes:

Azure Open AI studio: a platform where Microsoft teamed up with OpenAI to give you access to their API directly from the Azure infrastructure. It’s designed for developers and businesses that want to integrate AI into their apps or services, making them smarter and more intuitive.
Azure AI Search: a service designed to retrieve information across user-generated content, both in traditional search scenarios and in applications powered by generative AI. Whether you’re developing applications that require conventional search functionalities or generative AI capabilities, this service delivers that for you.
Azure APP service: a service that allows you to quickly build, deploy and scale web apps and APIs. Work with most programming languages and runs on Windows or Linux.

Signing up for Open AI Studio

First things first, you’ll need to create a Microsoft account and sign up for Azure Open AI Studio, best way if you don’t have one already is to navigate to https://oai.azure.com/ and create a new account

At the time of writing this post, the Azure Open AI studio was in preview mode, if this is still valid you need to request access by submitting this form in customer voice https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR7en2Ais5pxKtso_Pz4b1_xUNTZBNzRKNlVQSFhZMU9aV09EVzYxWFdORCQlQCN0PWcu

Using the Open AI studio

Once the account is created, you can access the studio by navigating to the URL https://oai.azure.com/, you’ll be presented with some options on how to get started

In the interest of this post, we’ll be using the Chat functionality in the Playground area which I define below:

Playground: this gives you the ability to test all the tools Azure Open AI Studio has, chat functionality, completions, DALL-E for generating images and assistants which are in preview mode at the time of creating this post.

Prompts: this area is where you define your prompts, you can start them from templates or create your own prompts from scratch.

Test the assistant: you can directly test your assistant in the playground by writing questions and interacting with it.

To test its capability, I will use the Microsoft Annual Report from 2023, I have a version in PDF format. For this I will use the Azure AI Search capability from Microsoft that allows us to store the document and get the agent to search information on it.

NOTE: To add your data in the steps below, you’ll first need to create an Azure AI Search service, follow the steps in this Microsoft article.

NOTE 2: It’s also important that you create the resource in a region where the Open AI service is available

Follow the steps below to add your data

Click on “Add your data”
Followed by “Add a data source”

This will take you to a wizard where you need to complete the following:

Select data source: this should be set to “Upload files”
Subscription where the Azure AI Search has been created
Select Azure Blob storage resource: a blob storage where the file can be uploaded
Select Azure AI Search resource: selectable from the list, it’s the service mentioned in the NOTE above
Enter Index name: index to be created to search the data

Add the file in the next page in the wizard and click on Upload files

The next step is to select the type of search (Keyword) and then the chunk size which is 1024 by default

Once finished, the ingestion progress will start which should take a few minutes

Querying the data

You can now ask any question to the document and it should come with an answer about the document, for instance I have asked to give a summary of Microsoft 2023 Annual report and returned the following

When answering the question, the chat result will show links to the sources which can be opened on the right hand side.

Another interesting feature is the ability to View the Code, this can be helpful to understand how the chat works and how the context is passed back and forth which enriches the conversation with the LLM.

Deploying the app

With the Azure AI Studio is quite easy to deploy the APP in azure, you simply need to click on “Deploy to” > “A new web app…”, you can either create a new app or select an existing.

Once deployed, a link will show in the notification which will redirect you to the app

It’s also possible to customise the app to your needs using environments variables in Azure, you can check the possible options in this article, this should allow you to change the logo and some of the wording in the page

And that’s all, you should have the app running now!

If you like the article, please follow me on X at @juanstoppa where a regularly post about AI.

Leave a Reply

Your email address will not be published. Required fields are marked *