-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Support multiple deployment_ids for azure #300
base: main
Are you sure you want to change the base?
Conversation
Thanks for this. Looks like a breaking change for Azure users? |
Not really, they can just use the same base uri as always and then omit the |
Sorry to ping you @alexrudall Not sure what you want to do with the Rubycop warning |
@henrikbjorn - this should now be solved in v5 of ruby-openai as you can create multiple Client objects each with different configuration (so you can set different URI as needed). Let me know if this doesn't solve your problem, and thank you for your contribution! |
That dosen't solve the problem. It makes it complex and unneeded. Since I would have to have a Embedding Client, GPT-4 Client etc. That does nok make sense to me |
Since especially that usecase is even still supported with this code. Just set the base uri to the deployment directly and omit the deployment_id from the api calls |
Hmm OK let me take another look |
The |
This is what I'm doing to support multiple models in Azure which is working fine. module OpenAi
class Client
def self.client(deployment_id)
OpenAI::Client.new(
uri_base: "https://***.openai.azure.com/openai/deployments/#{deployment_id}"
)
end
def self.default
client("gpt-35-turbo")
end
def self.gpt35_16k
client("gpt-35-16k")
end
def self.gpt4
client("gpt-4-8k")
end
def self.embedding
client("text-embedding-ada-002")
end
end
end
OpenAi::Client.gpt35_16k.chat(parameters: ...) |
Either works, but I think it is a good idea to follow the same API as the python SDK, so the SDKs works the same |
One minor annoyance with the current setup is that, even if creating multiple OpenAI clients, we have to duplicate and construct the uri each time. In that sense, the configuration for Azure isn't actually "URI base," but "full URI." Ideally, we'd configure the true "base" of the URI once (e.g. from an env var), and then set the deployment per client initialization. As a compromise, could we instead split out an optional deployment_id constructor arg that gets appended to the uri_base? |
Which is what this PR does |
This enables support for calling multiple azure deployments when using the library. This follows the same convention as the official python openai package.
So
client.embeddings(deployment_id: 'my-gpt-deployment', ...rest_of_args)
Since a embedding model would be one deployment and the actual chat model would be another this is required to use both.
All Submissions: