From 57c3a1734489f807fe4719fae3dc8ab7b71ab466 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Mon, 3 Jun 2024 12:39:03 -0700 Subject: [PATCH] chore: remove broken builtin support for azure gpt models in favor of external providers Signed-off-by: Taylor Price --- README.md | 13 +--------- docs/docs/02-getting-started.md | 13 +--------- pkg/openai/client.go | 43 +++++++-------------------------- 3 files changed, 11 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 8adfcef5..5de388d4 100644 --- a/README.md +++ b/README.md @@ -91,15 +91,6 @@ Download and install the archive for your platform and architecture from the [re export OPENAI_API_KEY="your-api-key" ``` -Alternatively Azure OpenAI can be utilized. If the [Azure deployment name is different than the model being used](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints#keyword-argument-for-model), be sure to include the `OPENAI_AZURE_DEPLOYMENT` argument. - -```shell -export OPENAI_API_KEY="your-api-key" -export OPENAI_BASE_URL="https://.openai.azure.com/" -export OPENAI_API_TYPE="AZURE" -export OPENAI_AZURE_DEPLOYMENT="" -``` - #### Windows ```powershell @@ -118,9 +109,7 @@ OUTPUT: Hello, World! ``` -The model used by default is `gpt-4-turbo` and you must have access to that model in your OpenAI account. - -If using Azure OpenAI, make sure you configure the model to be one of the supported versions with the `--default-model` argument. +The model used by default is `gpt-4o` and you must have access to that model in your OpenAI account. ### 4. Extra Credit: Examples and Run Debugging UI diff --git a/docs/docs/02-getting-started.md b/docs/docs/02-getting-started.md index 24752653..51a02769 100644 --- a/docs/docs/02-getting-started.md +++ b/docs/docs/02-getting-started.md @@ -32,15 +32,6 @@ Download and install the archive for your platform and architecture from the [re export OPENAI_API_KEY="your-api-key" ``` -Alternatively Azure OpenAI can be utilized. If the [Azure deployment name is different than the model being used](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints#keyword-argument-for-model), be sure to include the `OPENAI_AZURE_DEPLOYMENT` argument. - -```shell -export OPENAI_API_KEY="your-api-key" -export OPENAI_BASE_URL="https://.openai.azure.com/" -export OPENAI_API_TYPE="AZURE" -export OPENAI_AZURE_DEPLOYMENT="" -``` - #### Windows ```powershell @@ -59,9 +50,7 @@ OUTPUT: Hello, World! ``` -The model used by default is `gpt-4-turbo` and you must have access to that model in your OpenAI account. - -If using Azure OpenAI, make sure you configure the model to be one of the supported versions with the `--default-model` argument. +The model used by default is `gpt-4o` and you must have access to that model in your OpenAI account. ### 4. Extra Credit: Examples and Run Debugging UI diff --git a/pkg/openai/client.go b/pkg/openai/client.go index d5d56a22..7eba75dc 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -23,9 +23,8 @@ const ( ) var ( - key = os.Getenv("OPENAI_API_KEY") - url = os.Getenv("OPENAI_URL") - azureModel = os.Getenv("OPENAI_AZURE_DEPLOYMENT") + key = os.Getenv("OPENAI_API_KEY") + url = os.Getenv("OPENAI_URL") ) type Client struct { @@ -38,15 +37,13 @@ type Client struct { } type Options struct { - BaseURL string `usage:"OpenAI base URL" name:"openai-base-url" env:"OPENAI_BASE_URL"` - APIKey string `usage:"OpenAI API KEY" name:"openai-api-key" env:"OPENAI_API_KEY"` - APIVersion string `usage:"OpenAI API Version (for Azure)" name:"openai-api-version" env:"OPENAI_API_VERSION"` - APIType openai.APIType `usage:"OpenAI API Type (valid: OPEN_AI, AZURE, AZURE_AD)" name:"openai-api-type" env:"OPENAI_API_TYPE"` - OrgID string `usage:"OpenAI organization ID" name:"openai-org-id" env:"OPENAI_ORG_ID"` - DefaultModel string `usage:"Default LLM model to use" default:"gpt-4o"` - ConfigFile string `usage:"Path to GPTScript config file" name:"config"` - SetSeed bool `usage:"-"` - CacheKey string `usage:"-"` + BaseURL string `usage:"OpenAI base URL" name:"openai-base-url" env:"OPENAI_BASE_URL"` + APIKey string `usage:"OpenAI API KEY" name:"openai-api-key" env:"OPENAI_API_KEY"` + OrgID string `usage:"OpenAI organization ID" name:"openai-org-id" env:"OPENAI_ORG_ID"` + DefaultModel string `usage:"Default LLM model to use" default:"gpt-4o"` + ConfigFile string `usage:"Path to GPTScript config file" name:"config"` + SetSeed bool `usage:"-"` + CacheKey string `usage:"-"` Cache *cache.Client } @@ -56,8 +53,6 @@ func complete(opts ...Options) (result Options, err error) { result.APIKey = types.FirstSet(opt.APIKey, result.APIKey) result.OrgID = types.FirstSet(opt.OrgID, result.OrgID) result.Cache = types.FirstSet(opt.Cache, result.Cache) - result.APIVersion = types.FirstSet(opt.APIVersion, result.APIVersion) - result.APIType = types.FirstSet(opt.APIType, result.APIType) result.DefaultModel = types.FirstSet(opt.DefaultModel, result.DefaultModel) result.SetSeed = types.FirstSet(opt.SetSeed, result.SetSeed) result.CacheKey = types.FirstSet(opt.CacheKey, result.CacheKey) @@ -80,19 +75,6 @@ func complete(opts ...Options) (result Options, err error) { return result, err } -func GetAzureMapperFunction(defaultModel, azureModel string) func(string) string { - if azureModel == "" { - return func(model string) string { - return model - } - } - return func(model string) string { - return map[string]string{ - defaultModel: azureModel, - }[model] - } -} - func NewClient(opts ...Options) (*Client, error) { opt, err := complete(opts...) if err != nil { @@ -100,15 +82,8 @@ func NewClient(opts ...Options) (*Client, error) { } cfg := openai.DefaultConfig(opt.APIKey) - if strings.Contains(string(opt.APIType), "AZURE") { - cfg = openai.DefaultAzureConfig(key, url) - cfg.AzureModelMapperFunc = GetAzureMapperFunction(opt.DefaultModel, azureModel) - } - cfg.BaseURL = types.FirstSet(opt.BaseURL, cfg.BaseURL) cfg.OrgID = types.FirstSet(opt.OrgID, cfg.OrgID) - cfg.APIVersion = types.FirstSet(opt.APIVersion, cfg.APIVersion) - cfg.APIType = types.FirstSet(opt.APIType, cfg.APIType) cacheKeyBase := opt.CacheKey if cacheKeyBase == "" {