bakks / butterfish

A shell with AI superpowers
https://butterfi.sh
MIT License
345 stars 32 forks source link

Feature Request:Azure OpenAI support #17

Open Dreamail opened 1 year ago

bakks commented 1 year ago

👋 Hi, thanks for submitting an issue -- I don't know much about Azure OpenAI so I'm curious as to how it's different than the vanilla OpenAI API. What problems would this solve for you?

Dreamail commented 1 year ago

👋 Hi, thanks for submitting an issue -- I don't know much about Azure OpenAI so I'm curious as to how it's different than the vanilla OpenAI API. What problems would this solve for you?

There is no difference in function between azure openai and official one, but it is easier to request gpt4 model in azure openai.

The API is as same as OpenAI, just different in API endpoint

(Sorry for that I am poor at English.

Dreamail commented 1 year ago
#Note: The openai-python library support for Azure OpenAI is in preview.
import os
import openai
openai.api_type = "azure"
openai.api_base = "https://xxx.openai.azure.com/"
openai.api_version = "2023-07-01-preview"
openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.ChatCompletion.create(
  engine="GPT4-32k",
  messages = [],
  temperature=0.7,
  max_tokens=800,
  top_p=0.95,
  frequency_penalty=0,
  presence_penalty=0,
  stop=None)

There is the example given by auzre openai portal. (Note that api base vary from users.

bakks commented 1 year ago

Hey @Dreamail , I've just pushed a change that enables you to set a Base URL for the model API. In other words, this allows you to point butterfish at a different server than the OpenAI api. I haven't had a chance to test this with Azure yet, but it might work, will follow up.

If you want to try this, you can install butterfish from the latest commit (I haven't yet released), and then set the Base URL. Something like:

go install github.com/bakks/butterfish/cmd/butterfish@latest
$(go env GOPATH)/bin/butterfish shell -u http://localhost:1234/v1 -A
Dreamail commented 1 year ago

Thx, I will try it if I have time later this day.