-
Notifications
You must be signed in to change notification settings - Fork 110
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
Azure OpenAI details are not recognized #150
Comments
Yes, I have the same problems as you. I am googling all over and cannot find anything related to "task". I hope the team can give us a clear instruction with examples of what to fill in for these environment variables. |
Inspecting the source code shows that the base request for the azure openai method is defined as the following. request_base_azure_openai <-
function(task = Sys.getenv("AZURE_OPENAI_TASK"),
base_url = Sys.getenv("AZURE_OPENAI_ENDPOINT"),
deployment_name = Sys.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
token = Sys.getenv("AZURE_OPENAI_KEY"),
api_version = Sys.getenv("AZURE_OPENAI_API_VERSION")
) {
httr2::request(base_url) %>%
httr2::req_url_path_append("openai/deployments") %>%
httr2::req_url_path_append(deployment_name) %>%
httr2::req_url_path_append(task) %>%
httr2::req_url_path_append(api_version) %>%
httr2::req_headers("api-key" = token,
"Content-Type" = "application/json") %>%
httr2::req_method("POST")
} So this is how the request is translated. The request_base_azure_openai(
base_url = "https://www.example.com",
deployment_name = "gpt-35-turbo-instruct",
task = "completions",
api_version = "2023-05-15",
token = "MY_API_KEY"
)
#> <httr2_request>
#> POST
#> https://www.example.com/openai/deployments/gpt-35-turbo-instruct/completions/2023-05-15
#> Headers:
#> • api-key: 'MY_API_KEY'
#> • Content-Type: 'application/json'
#> Body: empty By looking at the REST documentation, it looks to me like you can just set it as "completions".
The same documentation tells us that there is still a small bug that will prevent it from working. This should be how the base request is defined, with the api version as a url query parameter: request_base_azure_openai <-
function(task = Sys.getenv("AZURE_OPENAI_TASK"),
base_url = Sys.getenv("AZURE_OPENAI_ENDPOINT"),
deployment_name = Sys.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
token = Sys.getenv("AZURE_OPENAI_KEY"),
api_version = Sys.getenv("AZURE_OPENAI_API_VERSION")
) {
httr2::request(base_url) %>%
httr2::req_url_path_append("openai/deployments") %>%
httr2::req_url_path_append(deployment_name) %>%
httr2::req_url_path_append(task) %>%
httr2::req_url_query("api-version" = api_version) %>%
httr2::req_headers("api-key" = token,
"Content-Type" = "application/json") %>%
httr2::req_method("POST")
}
request_base_azure_openai(
base_url = "https://www.example.com",
deployment_name = "gpt-35-turbo-instruct",
task = "completions",
api_version = "2023-05-15",
token = "MY_API_KEY"
)
#> <httr2_request>
#> POST
#> https://www.example.com/openai/deployments/gpt-35-turbo-instruct/completions?api-version=2023-05-15
#> Headers:
#> • api-key: 'MY_API_KEY'
#> • Content-Type: 'application/json'
#> Body: empty I'll make a PR about this Created on 2023-11-02 with reprex v2.0.2 |
Hello, I was trying out the 0.3.0 version on my local (Windows) laptop using R 4.3.1 in RStudio.
Since I have an Azure OpenAI Services deployment running gpt-35-turbo, I wanted to set the env variables according to descriptions in the README.
I changed my (project scope and user scope) .Renviron file accordingly and it contains the following lines now (entries masked):
However, it does not recognize the variables, it still asks me for the OPENAI_API_KEY environment variable which I did not provide because I don't have one and I do want to use my Azure endpoint.
One other thing that is missing in the README --> What is the "TASK" supposed to be? I only found something called AZURE_OPENAI_TYPE in the context of the Microsoft Quickstart guide and "openai Python library" -- which I, by the way, have successfully set up with my AZURE_OPENAI_xxx environment variables elsewhere already --.
That one is referring to the API_TYPE which in the case of Azure OpenAI Services should take the value "azure" as above.
So is TYPE = TASK? Or is it something else?
The text was updated successfully, but these errors were encountered: