cyberchitta / openai_ex

Community maintained Elixir library for OpenAI API
https://hexdocs.pm/openai_ex
Apache License 2.0
132 stars 18 forks source link

Add Azure OpenAI Support #80

Closed restlessronin closed 8 months ago

restlessronin commented 8 months ago

Describe the feature or improvement you're requesting

Discussion on how adding azure support starting at this message.

restlessronin commented 8 months ago

Update. See below

restlessronin commented 8 months ago

Update. See below

restlessronin commented 8 months ago

I have added what I believe to be the support functions needed for azure. The user only needs to call a single function for Azure.

First use the code in the currrent branch

    {:openai_ex, github: "restlessronin/openai_ex", branch: "issue-80/add-azure"}

then for non-Entra-id

openai = OpenaiEx._for_azure(azure_api_id, resource_name, deployment_id, api_version)

for Entra Id it becomes

openai = OpenaiEx.new(entra_id) |> OpenaiEx._for_azure(resource_name, deployment_id, api_version)

and then use the rest of the API as is.

This is only applicable for the "/completions", "/chat/completions" and "/embeddings" end points.

restlessronin commented 8 months ago

@raulchedrese Since this branch is based on your fixes and references, I would like to give you co-author credit on a commit. Would that be OK?

raulchedrese commented 8 months ago

👍🏽 sure. Thanks for adding this!