-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat(openai): add azure support #96
feat(openai): add azure support #96
Conversation
Not inclined to merge this because we have custom URLs - would Azure work with that? https://github.com/kharvd/gpt-cli?tab=readme-ov-file#customize-openai-api-url |
Annoyingly I don't think the The other complication is that that azure replaces
Happy for you to opt-out of supporting Azure Open AI if you think it'll keep things cleaner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to support Azure, but would like to suggest that we use model name prefixes instead of a config flag
gptcli/assistant.py
Outdated
elif gptcli.providers.openai.use_azure: | ||
return OpenAICompletionProvider() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having Azure be essentially the default, I think we can add a prefix to Azure model names, similar to oai-compat:
- maybe oai-azure:
?
gptcli/config.py
Outdated
@@ -21,6 +21,10 @@ class GptCliConfig: | |||
api_key: Optional[str] = os.environ.get("OPENAI_API_KEY") | |||
openai_api_key: Optional[str] = os.environ.get("OPENAI_API_KEY") | |||
openai_base_url: Optional[str] = os.environ.get("OPENAI_BASE_URL") | |||
# When using azure open ai, set your assistant's model to your deployment | |||
# name | |||
openai_use_azure: bool = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have oai-azure:
prefix, we probably don't need this
gptcli/providers/openai.py
Outdated
@@ -15,10 +15,16 @@ | |||
UsageEvent, | |||
) | |||
|
|||
use_azure: bool = False | |||
|
|||
class OpenAICompletionProvider(CompletionProvider): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably would want class AzureOpenAICompletionProvider(OpenAICompletionProvider):
that overrides the client
edb060b
to
b8425ee
Compare
Agree the |
gptcli/providers/azure_openai.py
Outdated
def __init__(self): | ||
self.client = AzureOpenAI( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's call super().__init__(self)
here - in case we ever decide to do some initialization in the parent class' __init__
other than setting the client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Adds support for using Azure OpenAI endpoints