The Azure OpenAI Completions Playground is an incredibly powerful tool, but unlocking its full potential requires some strategic thinking.
With the playground, you can generate text completions in a variety of formats, from simple sentences to entire articles.
One of the most exciting features of the playground is its ability to handle multiple prompts at once, allowing you to generate a large amount of content quickly and efficiently.
This is particularly useful for tasks like content generation, where you need to produce a high volume of text in a short amount of time.
Getting Started
To get started with Azure OpenAI Completions Playground, you'll first need to understand the benefits of integrating Azure OpenAI services with your data. This integration ensures the protection of your intellectual property, as your data and access to it remain securely in your control.
Azure OpenAI services work together with Azure Cognitive Search to index your data, providing responses that follow your organization's policies. You can also use Visual Studio Code to obtain instant answers to your questions without switching between multiple applications.
By integrating Azure OpenAI services with your data, you can focus on your authoring and coding environment. This allows you to stay in the flow and get the most out of your development time.
Working with GPT
To deploy a GPT model in Azure OpenAI Studio, you need to go to the deployments tab and deploy a base model. Choose your preferred GPT model, such as GPT-4o-mini, and press Confirm.
Each GPT model has different abilities and costs. To deploy the model, use the default deployment name, model version, and set the deployment type to global standard. Increase the Tokens per Minute Rate Limit to the maximum allowed value.
You can add a system message to the GPT deployment in Chat Playground to give the model instructions and context on how to respond to incoming chat messages. Copy and paste the system message into the system message field and press the Apply Changes button.
To test the GPT model, send a chat message to it in Chat Playground. Input text formatted as a support ticket email into the chat window and see what priority level is assigned by the GPT model.
Here's an example of a chat message you can send to the GPT model:
To get a chat completion from the GPT model in Azure OpenAI, you need to use an HTTP action to call the chat completions endpoint. Create an HTTP action in the flow and use the POST method. Include the following header values in the HTTP request: Content-Type: application/json and api-key: ********************************.
Add System Message to GPT Deployment
To add a system message to your GPT deployment, go to the chat tab and select the deployment you've set up. The chat playground is where you can configure and test your GPT deployment before using it in Power Automate.
The system message gives instructions and context to the GPT model on how to respond to incoming chat messages. It's where you tell the model what to do with the information it receives.
Copy and paste the text into the system message field, telling the model to categorize incoming helpdesk tickets by priority level and respond with one of three options: high-priority, medium-priority, or low-priority. Press the Apply Changes button to save the system message.
Get a Completion from GPT
To get a completion from GPT, you need to deploy a GPT model in Azure OpenAI Studio. Deploy a base model by going to the deployments tab and deploying a GPT-4o-mini model, or any other model from the list.
You can choose the deployment name, model version, and deployment type to global standard. Increasing the Tokens per Minute Rate Limit to the maximum allowed value is also a good idea.
The GPT model will look at the instructions in the system message to create a response. To test this, input text formatted as a support ticket email into the chat window and see what priority level is assigned by GPT.
Here's an example of a support ticket email: "Subject: Unable to Download Invoice From: [email protected] To: [email protected] Date: September 30, 2024 Hi, I’m unable to download my invoice from the billing section of my account. When I click the “Download” button, nothing happens. Could you please assist? Account Email: [email protected] Browser: Safari (version 16.5) Device: MacBook Air Thanks, Jane"
To get a chat completion from the GPT model, you'll need to use an HTTP action to call the chat completions endpoint in Azure OpenAI. The URI for this endpoint will look something like this: "https://matthewdevaneyazureopenai.azurewebsites.net/api/chat/completions?deploymentName=gpt-4o-mini&apiVersion=2024-02-15-preview".
Here are the header values you'll need to include in the HTTP request:
The API key can be found in the footer of the sample code menu in Chat Playground.
Power Automate
Power Automate allows you to create text using GPT & AI prompts with a cost-effective pricing plan of $0.05 per million input tokens, making it an affordable option for long-term use.
You can break down user content into individual messages, as shown in the example: [
{
“type”:“text”,
“text”:“Subject: Unable to Download Invoice”},
{
“type”:“text”,
“text”:“From: [email protected]”},
{
“type”:“text”,
“text”:“To: [email protected]”}
]
The Chat Playground will send each newline as a separate message, and it waits to respond to multiple messages as one.
Here's a quick summary of the Power Automate features:
- Break down user content into individual messages
- Send each newline as a separate message
- Use a cost-effective pricing plan of $0.05 per million input tokens
Model Deployment
To deploy a GPT model in Azure OpenAI Studio, you must first deploy a base model. This can be done by going to the deployments tab and deploying a base model.
Choose your preferred GPT model, such as GPT-4o-mini, and press Confirm. Each model has different abilities and costs, so select the one that best suits your needs.
To create a new Azure OpenAI model deployment, select the Create new deployment button in the Deployments screen. You can then select a model, such as the GPT 3.5 turbo model, and give your deployment a name.
When selecting a model, note that you may be presented with a dialog to select your subscription and model of choice directly. Select the gpt-35-turbo model and give your deployment a name, such as gpt-35-turbo-0613.
Here are the steps to create a custom model within your subscription:
- Go to "oai.azure.com" and create a new model deployment if you have done this before
- Select "gpt-35-turbo" and give your deployment a name.
- Go to playground/completions/view code,
- obtain the endpoint address (red) & API key (yellow), and store it in a safe place.
After creating a model deployment, you can experiment with the Completions playground. Select the model you deployed and an example prompt, such as Generate an email prompt, and then select Generate.
Power Automate: Create Text with AI
Power Automate allows you to create text with AI using the GPT model. You can do this by creating a flow in Power Automate, adding an action to use the OpenAI custom connector, and configuring the chat completion API.
The cost of using the GPT model in Power Automate is $0.05 per million input tokens, which is considered very affordable. You can use it forever without spending a significant amount of money.
You can also use the Chat Playground to test your flows and see how they work. The Chat Playground will break each newline into a separate message, so you need to format your input carefully.
Here's an example of how to format your input:
[
{
“type”:“text”,
“text”:“Subject: Unable to Download Invoice”
},
{
“type”:“text”,
“text”:“From: [email protected]“
},
{
“type”:“text”,
“text”:“To: [email protected]“
}
]
In Power Virtual Agent, you can use the Chat Completion API to create a chatbot that uses the GPT model. You need to create a new chatbot, add a new topic, and configure the chat completion API.
To use the Chat Completion API in Power Virtual Agent, follow these steps:
1. Create a new chatbot.
2. Create a new topic inside it with the name xbox.
3. Add the phrases as xbox and gaming.
4. Add an Ask a question node to get the user response and store it in a variable (e.g., VarUserQuestion).
5. Add a node Call an action > Create a flow.
6. Accept the user question to start with the flow.
7. Add an action to use our OpenAI custom connector.
8. Configure the chat completion API as follows:
- Return the answer from the Chat completion API.
- Configure the action with input and output.
9. Add a node with Send a message with an output of flow.
In Azure OpenAI, you can use the chat completions endpoint to get a chat completion from the GPT model. You need to create an HTTP action in the flow and use the POST method.
The URI for the Azure OpenAI chat completions endpoint looks like this:
https://matthewdevaney.azureopenai.com/deployments/gpt-4o-mini/2024-02-15-preview/channels/your_channel_id/completions
You need to replace the resource name, deployment name, and API version with your own values.
To get your own URI, open Chat Playground and select View Code. The complete web address will be found in the ENDPOINT variable.
You also need to include the following header values in the HTTP request:
- Content-Type: application/json
- api-key: your_api_key
Frequently Asked Questions
Is OpenAI playground free to use?
Yes, OpenAI Playground offers a free tier with limited usage. Paid plans are available for extended use.
Sources
- https://www.matthewdevaney.com/how-to-use-power-automate-azure-openai-gpt-models/
- https://blog.codewithdan.com/getting-started-with-azure-openai/
- https://the.cognitiveservices.ninja/azure-openai-services-as-a-copilot-in-visual-studio-code
- https://lmql.ai/docs/models/openai.html
- https://nanddeepn.github.io/posts/2023-08-06-oai-chat-completion-api-pva/
Featured Images: pexels.com