How to Use GPT-4 and ChatGPT on Azure OpenAI Service

ChatGPT and GPT-4 are huge language models from OpenAI that may be used to generate text, translate languages, write various types of creative material, and provide useful answers to your questions. They are both available on Azure OpenAI Service, making them simple to integrate into your applications. In this article, I’ll show you How to Use ChatGPT on Azure OpenAI Service step by step procedures.

Prerequisites

  • An Azure subscription can be created for free.
  • Azure OpenAI has been granted access in the desired Azure subscription.
  • Currently, access to this service is only available through application. You can apply for Azure OpenAI access by filling out the form at https://aka.ms/oai/access. If you have a problem, please open an issue on this repo.
  • An Azure OpenAI Service resource running the gpt-35-turbo or gpt-41 models. See the resource deployment guide for additional information on model deployment.

What is Azure OpenAI Service?

Azure OpenAI Service provides a REST API through which you may use OpenAI’s advanced language models, including as GPT-3, Codex, Embeddings, GPT-4, and ChatGPT. These models can be applied to a wide range of tasks, including content generation, summarization, semantic search, and natural language to code translation. The service can be accessed via REST APIs, the Python SDK, or the web-based interface in Azure OpenAI Studio.

How to Access Azure OpenAI Studio?

Follow these steps to access Azure OpenAI Studio and use Chat playground.

  1. Navigate to the Azure OpenAI Studio website at https://oai.azure.com/
  2. Sign in with the credentials you use to access your OpenAI resource. To log in securely, provide the essential authentication details.
  3. If prompted, pick the proper directory linked with your Azure account during the sign-in step.
  4. Then, select the Azure subscription that has access to your Azure OpenAI resource.
  5. You will be taken to the Azure OpenAI Studio homepage page after successfully signing in and selecting the proper directory and subscription.
  6. Look for the “Chat playground” option on the landing page. This option lets you experiment with and interact with language models.
  7. To access the Chat playground, click the “Chat playground” button.
See also  SAM and HQ-SAM: A New Generation of Image Segmentation Models
Chatgpt On Azure
How to Use GPT-4 and ChatGPT on Azure OpenAI Service 1

Azure OpenAI Studio Chat playground

The Azure OpenAI Studio Chat playground is a no-code interface for experimenting with OpenAI capabilities. You may quickly iterate and experiment with different features from this page.

Chatgpt On Azure
How to Use GPT-4 and ChatGPT on Azure OpenAI Service 2

Overview of Azure OpenAI Studio Chat playground

By default, the Azure OpenAI Studio Chat playground has three panels: assistant setup, chat session, and settings.

You can use Show panels to add, remove, or rearrange these panels. If you close a panel and need to get it back, use Show panels to restore the lost panel.

Assistant Setup Feature

  • Locate the “Assistant setup” dropdown menu in the Chat playground interface. It enables you to choose from a library of pre-loaded System message samples to deliver instructions and context to the model.
  • Select one of the pre-loaded System message samples from the “Assistant setup” dropdown menu. These examples can assist you in defining the assistant’s personality, specifying what it should and should not answer, and instructing it on how to style responses.
  • You can also use the “Add few-shot examples” function to provide conversational examples for the model to learn from in-context. These examples assist the model in understanding the required behavior and improving its responses based on the examples presented.
  • When interacting with the Chat playground, pick “View code” to see code samples in Python, curl, and JSON. These code samples are produced automatically based on your current chat session and preferences. You can refer to these code samples when creating your own applications to accomplish the same functionality outside of the playground environment.
  • Using the Assistant setting choices, you may define the assistant’s behavior and personality, improve its replies, and fine-tune its output to meet your individual needs. The Chat playground allows you to experiment, test, and get insights for integrating OpenAI language models into your own apps.
See also  How to Customize Action Button on iPhone 15 Pro

Chat session

Sending Text: Type your preferred text into the input text box and press the “Send” button. This passes the text to the completions API, and the model responds based on the input. The model’s reaction is then displayed in the text field, allowing for a conversational back-and-forth.

Clearing Chat History: Click the “Clear chat” button to wipe the current conversation history and begin over. This action deletes all previous chat messages from the text box, leaving a blank slate for fresh conversations.

Additional Settings

Settings

How to use Azure ChatGPT playground?

Step by step instructions to use GPT-4 and ChatGPT on Azure OpenAI Service.

Step1: Select Xbox customer care agent from the assistant setup drop-down list.

Step2: When asked if you wish to update the system message, choose Continue.

Step3: In the chat session pane, type “I’m interested in buying a new Xbox” and press Send.

Step4: You’ll get something like this:

Chatgpt On Azure
How to Use GPT-4 and ChatGPT on Azure OpenAI Service 3

Step5: Add a follow-up question, such as “which models support 4K?”

Chatgpt On Azure
How to Use GPT-4 and ChatGPT on Azure OpenAI Service 4

Step6: Now that you have a basic conversation, pick View code from Assistant setup to see a replay of the code behind the entire conversation thus far:

#Note: The openai-python library support for Azure OpenAI is in preview. import os import openai openai.api_type = “azure” openai.api_base = “https://docs-test-001.openai.azure.com/” openai.api_version = “2023-05-15” openai.api_key = os.getenv(“OPENAI_API_KEY”) response = openai.ChatCompletion.create( engine=”gpt-35-turbo”, # replace this value with the deployment name you chose when you deployed the associated model. messages =[ { “role”: “system”, “content”: “You are an Xbox customer support agent whose primary goal is to help users with issues they are experiencing with their Xbox devices. You are friendly and concise. You only provide factual answers to queries, and do not provide answers that are not related to Xbox.” }, { “role”: “user”, “content”: “How much is a PS5?” }, { “role”: “assistant”, “content”: “I apologize, but I do not have information about the prices of other gaming devices such as the PS5. My primary focus is to assist with issues regarding Xbox devices. Is there a specific issue you are having with your Xbox device that I may be able to help with?” } ], temperature=0, max_tokens=350, top_p=0.95, frequency_penalty=0, presence_penalty=0, stop=None)

See also  18+ Best Free NSFW AI Generators of 2023

Prompt Structure

Special tokens used in ChatGPT on Azure

  • |im_start|>: This token denotes the start of the input message.
  • <|im_end|>: This token indicates the end of the input message.
  • |as_start|>: This token denotes the start of the assistant’s response.
  • <|as_end|>: This token indicates the end of the assistant’s response.

The tokens |im_start|> and |im_end|> indicate the start and end of the system message, respectively. The tokens |as_start|> and |as_end|> indicate the start and end of the assistant’s response, respectively.

ChatGPT can comprehend that the system message is a welcome message, and that the user wants to learn more about ChatGPT by using these tokens. This enables ChatGPT to provide a more natural-sounding response that is tailored to the user’s individual needs.

You may also display these tokens in the chat session window by using the Show raw syntax toggle button. This can be useful for troubleshooting or understanding how ChatGPT handles prompts.

Also read: For a more comprehensive overview DataStax refer to our guide DataStax Enhances Astra DB on Google Cloud with Vector Search Capability

Conclusion

Finally, ChatGPT on Azure OpenAI Service are excellent tools for natural language processing and conversational AI. Developers can simply integrate these models into their applications because to their user-friendly interfaces and extensive documentation. As language understanding and generating capabilities improve, these services become valuable tools for creating intelligent and engaging conversational interactions. Please feel free to share your thoughts and feedback in the comment section below.