oliversen / chatgpt-docstrings

VSCode extension to automatically generate docstrings using ChatGPT
https://marketplace.visualstudio.com/items?itemName=oliversen.chatgpt-docstrings
MIT License
3 stars 2 forks source link

Support Azure OpenAI services #2

Closed adumont closed 5 months ago

adumont commented 10 months ago

It would be great to support Azure OpenAI services, as an alternative. With Azure OpenAI the API call is slightly different and requires more arguments besides the API_KEY, as shown in this example:

#Note: The openai-python library support for Azure OpenAI is in preview.
import os
import openai

openai.api_type = "azure"
openai.api_base = "https://my_custom_endpoint_name.openai.azure.com/"
openai.api_version = "2023-07-01-preview"
openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.ChatCompletion.create(
  engine="gpt-35-turbo-v0301",
  messages = [{"role":"system","content":"You are an AI assistant that helps people find information."}],
  temperature=0.7,
  max_tokens=800,
  top_p=0.95,
  frequency_penalty=0,
  presence_penalty=0,
  stop=None)

Here are the 5 inputs needed from the user to be able to make a succesful call (values are provided in the Azure configuration):

oliversen commented 5 months ago

Great suggestion. It will definitely be considered. Thank you!

UPD: Unfortunately, support for Azure OpenAI services will not be added, because it currently has limited access.