feat(adapters): ✨ add Azure OpenAI #386
Merged
+244
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As discussed in #383 I added a new adapter using the OpenAI adapter handlers comparable to xAI and Copilot.
The adapter uses these env vars:
The first two are also used in the official OpenAI Python library, so they should be pretty standard. The api_version shouldn't change too often, maybe only for newly released models.
I'm not sure about the deployment. Azure OpenAI does not select the model based on a parameter as OpenAI-compatible APIs usually do. Instead each model can be deployed multiple times under custom names. As far as I know usually these deployment names are set the same as the actual OpenAI model name, but I guess not everyone would do that. Because the rest of codecompanion.nvim assumes the model parameter to be set I decided to keep it in there and use it as the configuration for the deployment name.
Note that this is also very similar to the official OpenAI Python library:
Please check if I used the schema value replacement for the env var correctly. I was a bit confused because the docs always mentioned
schema.model.default
when talking about this functionality. I'm also not really sure what to put into the choices for the parameter - the default ones of OpenAI really don't make sense here because of the deployment stuff. I guess I should change it to type string with no default? Open to suggestions.Example usage:
Related Issue(s)
#383
Screenshots
Checklist