Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any plan to support Azure OpenAI Service? #39

Open
swsoyee opened this issue Mar 23, 2023 · 9 comments
Open

Is there any plan to support Azure OpenAI Service? #39

swsoyee opened this issue Mar 23, 2023 · 9 comments

Comments

@swsoyee
Copy link

swsoyee commented Mar 23, 2023

It seems that just need to change the base_url to a function parameter that can be passed in.
https://github.com/search?q=repo%3Airudnyts%2Fopenai%20https%3A%2F%2Fapi.openai.com%2Fv1&type=code

Reference: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?tabs=powershell&pivots=rest-api

@irudnyts
Copy link
Owner

@swsoyee, what I am thinking right now is to create a new package with much higher flexibility.

@trangdata
Copy link

Hi @irudnyts any updates on the new package? 📦 🙏🏽

@irudnyts
Copy link
Owner

Hi @trangdata! Not yet 😔 Is there any particular feature you are looking forward to? Or is it just base_url for Azure?

@trangdata
Copy link

@irudnyts Really just the base_url for Azure.

@irudnyts
Copy link
Owner

@trangdata @swsoyee I'm very sorry for the long wait. Here is a new dev version, and you can do it here:

remotes::install_github("irudnyts/openai", ref = "r6")

library(openai)
client <- OpenAI(base_url = "your_azure_url")
completion <- client$chat$completions$create(
    model = "gpt-4-1106-preview",
    messages = list(list("role" = "user", "content" = "What's up?"))
)

completion$choices[[1]]$message$content

@JB0207
Copy link

JB0207 commented Apr 12, 2024

@trangdata Did you get it to work? I am always getting a 404 error using the following base_url:

"https://[...]/openai.azure.com/openai/deployments/gpt-35-turbo/chat/completions?api-version=2024-02-01"

@irudnyts
Copy link
Owner

@JB0207 Can you please specify how exactly your URL should look like? When you specify base_url in OpenAI() and then use, for example, client$chat$completions$create(), the endpoint URL will look like your_azure_url/chat/completions.

@JB0207
Copy link

JB0207 commented Apr 12, 2024

@irudnyts Thank you for your fast response! Ah, I understand... According to the documentation of Azure OpenAI Service the endpoint url should look like this: https://{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}.

@trangdata
Copy link

@trangdata Did you get it to work? I am always getting a 404 error using the following base_url:

No... I couldn't get the example code snippet to work.
Error in httr2::req_perform():
! HTTP 401 Unauthorized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants