HOWTO: ChatGPT Demonstration From Your Azure Enclave Workspace

 

 

Introduction

Researchers who have been provisioned access to an Azure Enclave ChatGPT project workspace have the ability to run the following basic ChatGPT example for demonstrative purposes.

Requirements

  • You have been provisioned access to an Azure Enclave ChatGPT Project Workspace.
  • You received your project workspace Service Endpoint URL and OpenAI Key. This information is provided to a designated member of your project to store and maintain within your project workspace.
  • You have basic knowledge of how to execute a ChatGPT conversation and tokens.

Run Demonstration

1. Login to your Azure Enclave project workspace.

2. Create a Python demonstration.py file with the following code in Visual Studio Code.

import os import openai import time ############################################################################### #  CONFIGURATION ############################################################################### openai.api_type = "azure" openai.api_base = "YourServiceEndpointURLHere" #a. openai.api_version = "2023-06-01-preview"  #b. openai.api_key = os.getenv("AZURE_OPENAI_KEY") #c. Or wherever the key is maintained # END CONFIGURATION ############################################################################### #  MAIN WORK ############################################################################### question = "What year was Abe Lincoln born?" response = openai.ChatCompletion.create(   engine='FirstDeployment',   messages=[{"role": "user", "content": question}] ) print(response) time.sleep(10) question = "What is a good mountain bike trail in Vermont?" response = openai.ChatCompletion.create(   engine='FirstDeployment',   messages=[{"role": "user", "content": question}] ) print(response) # END MAIN WORK 

a. api_base Replace YourServiceEndpointURLHere with your project workspace Service Endpoint URL.

b. api_version Use or replace with the appropriate API version. Further details can be found on the Microsoft Azure OpenAI Service REST API reference page.

c. api_key Reference your project workspace environment variable containing your OpenAI key or the location is maintained within your Enclave project workspace.

3. Run demonstration.py.

4. Responses to the two questions and token usage are displayed in the Terminal tab:

What year is Abe Lincoln born?

What is a good mountain bike trail in Vermont?

The Azure Enclave Support team can assist with environment issues when executing ChatGPT conversations. We do not provide technical support with specific tools. Researchers utilizing tools are expected to have knowledge and research solutions when using said tools.

For assistance with troubleshooting or platform support with your Azure Enclave Project Workspace environment, please open a Research Issue/Inquiry Request request. Please always include your unique Project Workspace IP Address on all communications.

Additional Resources

MS Azure OpenAI Service REST API reference

OpenAI What are tokens and how to count them?

MS OpenAI tokens and limits

Go to KB0040805 in the IS Service Desk

Related articles

Analytics Enclave

IDEA Platform