Skip to content

Latest commit

 

History

History
130 lines (99 loc) · 4.78 KB

README.md

File metadata and controls

130 lines (99 loc) · 4.78 KB

For this workshop you MUST have the following:

Requirements

  • VsCode
  • Python 3.10 (Install Python 3.10.0 from here)
  • A virtual environment tool (venv)
  • An Azure account
  • An active Azure OpenAI account with 2 deployed models see below

Preparation

OpenAI subscription and deployments. Skip to the next section if you already have an Azure OpenAI account with the following deployments.

  • Create an Azure OpenAI account
  • Create 'gpt-35-turbo', gpt-35-turbo-instruct, 'text-embedding-ada-002' deployments

Clone workshop repository from github

  • create a folder in your local machine called azure-openai

  • cd into the folder

  • run the following command:

    git clone https://github.com/vladfeigin/openaiworkshop.git 
    

    Note that you must git / github desktop installed on your machine. If you don't have it installed you can download it from here

  • cd into the openaiworkshop folder, here you will find all the sources for the workshop

VsCode

Python

Install Virtual Environment in VsCode (Simplest Way)

- Install the Python extension for VsCode
- Install the Jupyter notebooks extension for VsCode
- In Command Palette (Ctrl+Shift+P), select Python: Create Virtual Environment
- Select: Venv Create a .venv virtual environment..
- Select the interpreter/kernel: Python 3.10 

Python3 Virtualenv Setup. Skip to the next section if you already installed Virtualenv via VsCode

  • Installation To install virtualenv via pip run: $ pip3 install virtualenv

  • Creation of virtualenv:

    • Windows $ python -m virtualenv venv (in the openAI workshop directory)
    • Mac $ virtualenv -p python3

    Activate the virtualenv: $ source /bin/activate

    Deactivate the virtualenv: $ deactivate

Install all libraries in your virtual environment

  • Open New Terminal in VsCode and run:

    • $ pip install -r requirements.txt

    Make sure you are in the openaiworkshop folder the project root folder

    Windows users: If you encouner this error when opening a new terminal: venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. Then do following actions as described in this link

    • If you have proxy issues, when running pip install, then run the following command to bypasas the proxy:
      set http_proxy = http://<proxy>:8080
      set https_proxy = https://<proxy>:8080
      
      or in the code:
      
      os.environ['HTTP_PROXY'] = proxy
      os.environ['HTTPS_PROXY'] = proxy
      
      

Optional. Create a sample Azure SQL DB with Adventureworks sample data.

  • Insert your subscription ID in the file createAll.ps1 and save it.

    $SubscriptionId = "<your subscription here>"
    
  • Insert a name for your sql server in the file deployAll.bicep and save it

    param serverName string = '<sql server name>'
    
  • This powershell script will create:

    • A resourcegroup called openai-workshop
    • An Azure SQL server called with an AdventureWorks DB
  • Go to the azure portal and login with a user that has administrator permissions

  • Open the cloud shell in the azure portal as follows: Cloud shell

  • Upload the files in the scripts folder: "createAll.ps1" and "deployAll.bicep" ONE BY ONE by using the upload file button in the cloud shell Upload

  • Run ./createAll.ps1 Upload NOTE: This takes time so be patient You should get an Azure SQL server with a DB called aworks Upload

IMPORTANT!

Setup environment variables

  • Rename the '.env.template' file to '.env' and modify all the endpoints and api keys for all openai deployments as follows:
OPENAI_DEPLOYMENT_ENDPOINT ="<your openai endpoint>" 
OPENAI_API_KEY = "<your openai api key>"

OPENAI_DEPLOYMENT_NAME="gpt-35-turbo"
OPENAI_MODEL_NAME="gpt-35-turbo"

OPENAI_ADA_EMBEDDING_DEPLOYMENT_NAME="text-embedding-ada-002"
OPENAI_ADA_EMBEDDING_MODEL_NAME="text-embedding-ada-002"

#Model for Completion API
OPENAI_GPT_35_TURBO_INSTRUCT_MODEL_NAME="gpt-35-turbo-instruct"
OPENAI_GPT_35_TURBO_INSTRUCT_DEPLOYMENT_NAME="gpt-35-turbo-instruct"

OPENAI_API_TYPE="azure"
OPENAI_DEPLOYMENT_VERSION='2023-05-15'

SQL_SERVER="<your sql server>.database.windows.net"
SQL_USER="SqlAdmin"
SQL_PWD="ChangeYourAdminPassword1"
SQL_DBNAME="aworks"