Skip to content

Files

Latest commit

 

History

History
 
 

Completions

Introduction

This repository contains samples demonstrating how to use GPT/ ChatGPT for Completions via Python SDK or REST API.

Installation

Install all Python modules and packages listed in the requirements.txt file using the below command.

pip install -r requirements.txt

Microsoft Azure Endpoints

In order to use the Open AI library or REST API with Microsoft Azure endpoints, you need to set CHATGPT_MODEL/COMPLETIONS_MODEL, OPENAI_API_BASE & OPENAI_API_VERSION in config.json file.

{
    "CHATGPT_MODEL":"<ChatGPT Model Name>",
    "COMPLETIONS_MODEL":"<Completions Model Name>",
    "OPENAI_API_BASE":"https://<Your Azure Resource Name>.openai.azure.com",
    "OPENAI_API_VERSION":"<OpenAI API Version>"
}

For getting started:

  • Add "OPENAI_API_KEY" as variable name and <Your API Key Value> as variable value in the environment variables.

One can get the OPENAI_API_KEY value from the Azure Portal. Go to https://portal.azure.com, find your resource and then under "Resource Management" -> "Keys and Endpoints" look for one of the "Keys" values.
  WINDOWS Users: 
     setx OPENAI_API_KEY "REPLACE_WITH_YOUR_KEY_VALUE_HERE"

  MACOS/LINUX Users: 
     export OPENAI_API_KEY="REPLACE_WITH_YOUR_KEY_VALUE_HERE"
  • For Completions scenario, one can start with using your model name ("COMPLETIONS_MODEL" in config.json file) as "text_davinci_003".
    And for ChatGPT Completions, one can start with using your model name as "gpt-35-turbo" ("CHATGPT_MODEL" in config.json file).

  • To find your "OPENAI_API_BASE" go to https://portal.azure.com, find your resource and then under "Resource Management" -> "Keys and Endpoints" look for the "Endpoint" value.

  • Current OpenAI api version is "2022-12-01". Check out versions here.

Learn more about Azure OpenAI Service REST API here.

Learn about ChatGPT Completions here.

Requirements

Python 3.8+
Jupyter Notebook 6.5.2


Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.