Closed a116062 closed 1 month ago
Thanks, for the code example and writing the issue. This looks fairly similar to the vanilla openai API request. My original idea was to add the azure logic into the chatgpt()
or my planned openai()
function that implements OpenAI Api calls and to just look whether a deployment and an "AZURE-OPENAI-KEY" was set to see if it should direct to azure instead of OpenAI. But there seems to be some more potential to add azure-specific functionality like data_sources
in an own function and models seem to be specified differently in the azure API. Perhaps the best choice would be to implement a azure_openai()
function instead. I will try to do this, but will need to sign up for azure myself to add this feature. I guess I will need a few weeks to implement this.
I had a few minutes and implemented a first version of azure_openai()
earlier than I had thought and could test it a bit, before the relatively strong rate limiting of the Azure OpenAI free tier cut me off for a day. rate limiting, authentication and error messages are different enough for azure that having azure_openai()
as a seperate function from openai()
seems reasonable . Here is the documentation on the pkgdown site. Till my ratelmiting kicked in I tested, basic text messages to the API, streaming back tokens and normal json mode (all worked for me). The current environment variable azure_openai()
searches for the API key is called "AZURE_OPENAI_API_KEY". Also the .endpoint
-arguement of the function searches for an env-variable called "AZURE_ENDPOINT_URL" by default, but can be set freely in the function. If you want you can test whether the function works for you, and whether multimodal allready work or if Azure deals with images differently than the standard openai API. I'll write unit tests sometimes in the next weeks and will also try to read into azure-specific functionality.
It's working both for text and images! Thank you so much for your work. Noting that...
.deployment
not .model
Thanks a lot for testing it! I now changed the reuqest building to properly use httr2 and both myendpoint.openai.azure.com/ and myendpoint.openai.azure.com should now work. The example is also updated to have .deployment instead of .model. I'll add azure_openai()
to the get started vignette then.
Many organizations rely on Azure to use OpenAI's models in order to keep the data private. It would be great if this package supported azure. Below is an example of a function I wrote to hit Azure's end-point.