Skip to content

Commit f7a38c3

Browse files
authored
Merge pull request #420 from drpebcak/remove-azure-builtin
2 parents 664c3fb + c38e88f commit f7a38c3

File tree

3 files changed

+11
-58
lines changed

3 files changed

+11
-58
lines changed

README.md

+1-12
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,6 @@ Download and install the archive for your platform and architecture from the [re
9191
export OPENAI_API_KEY="your-api-key"
9292
```
9393

94-
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.
95-
96-
```shell
97-
export OPENAI_API_KEY="your-api-key"
98-
export OPENAI_BASE_URL="https://<your-endpoint>.openai.azure.com/"
99-
export OPENAI_API_TYPE="AZURE"
100-
export OPENAI_AZURE_DEPLOYMENT="<your-deployment-name>"
101-
```
102-
10394
#### Windows
10495

10596
```powershell
@@ -118,9 +109,7 @@ OUTPUT:
118109
Hello, World!
119110
```
120111

121-
The model used by default is `gpt-4-turbo` and you must have access to that model in your OpenAI account.
122-
123-
If using Azure OpenAI, make sure you configure the model to be one of the supported versions with the `--default-model` argument.
112+
The model used by default is `gpt-4o` and you must have access to that model in your OpenAI account.
124113

125114
### 4. Extra Credit: Examples and Run Debugging UI
126115

docs/docs/02-getting-started.md

+1-12
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ Download and install the archive for your platform and architecture from the [re
3232
export OPENAI_API_KEY="your-api-key"
3333
```
3434

35-
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.
36-
37-
```shell
38-
export OPENAI_API_KEY="your-api-key"
39-
export OPENAI_BASE_URL="https://<your-endpoint>.openai.azure.com/"
40-
export OPENAI_API_TYPE="AZURE"
41-
export OPENAI_AZURE_DEPLOYMENT="<your-deployment-name>"
42-
```
43-
4435
#### Windows
4536

4637
```powershell
@@ -59,9 +50,7 @@ OUTPUT:
5950
Hello, World!
6051
```
6152

62-
The model used by default is `gpt-4-turbo` and you must have access to that model in your OpenAI account.
63-
64-
If using Azure OpenAI, make sure you configure the model to be one of the supported versions with the `--default-model` argument.
53+
The model used by default is `gpt-4o` and you must have access to that model in your OpenAI account.
6554

6655
### 4. Extra Credit: Examples and Run Debugging UI
6756

pkg/openai/client.go

+9-34
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ const (
2323
)
2424

2525
var (
26-
key = os.Getenv("OPENAI_API_KEY")
27-
url = os.Getenv("OPENAI_URL")
28-
azureModel = os.Getenv("OPENAI_AZURE_DEPLOYMENT")
26+
key = os.Getenv("OPENAI_API_KEY")
27+
url = os.Getenv("OPENAI_URL")
2928
)
3029

3130
type Client struct {
@@ -38,15 +37,13 @@ type Client struct {
3837
}
3938

4039
type Options struct {
41-
BaseURL string `usage:"OpenAI base URL" name:"openai-base-url" env:"OPENAI_BASE_URL"`
42-
APIKey string `usage:"OpenAI API KEY" name:"openai-api-key" env:"OPENAI_API_KEY"`
43-
APIVersion string `usage:"OpenAI API Version (for Azure)" name:"openai-api-version" env:"OPENAI_API_VERSION"`
44-
APIType openai.APIType `usage:"OpenAI API Type (valid: OPEN_AI, AZURE, AZURE_AD)" name:"openai-api-type" env:"OPENAI_API_TYPE"`
45-
OrgID string `usage:"OpenAI organization ID" name:"openai-org-id" env:"OPENAI_ORG_ID"`
46-
DefaultModel string `usage:"Default LLM model to use" default:"gpt-4o"`
47-
ConfigFile string `usage:"Path to GPTScript config file" name:"config"`
48-
SetSeed bool `usage:"-"`
49-
CacheKey string `usage:"-"`
40+
BaseURL string `usage:"OpenAI base URL" name:"openai-base-url" env:"OPENAI_BASE_URL"`
41+
APIKey string `usage:"OpenAI API KEY" name:"openai-api-key" env:"OPENAI_API_KEY"`
42+
OrgID string `usage:"OpenAI organization ID" name:"openai-org-id" env:"OPENAI_ORG_ID"`
43+
DefaultModel string `usage:"Default LLM model to use" default:"gpt-4o"`
44+
ConfigFile string `usage:"Path to GPTScript config file" name:"config"`
45+
SetSeed bool `usage:"-"`
46+
CacheKey string `usage:"-"`
5047
Cache *cache.Client
5148
}
5249

@@ -56,8 +53,6 @@ func complete(opts ...Options) (result Options, err error) {
5653
result.APIKey = types.FirstSet(opt.APIKey, result.APIKey)
5754
result.OrgID = types.FirstSet(opt.OrgID, result.OrgID)
5855
result.Cache = types.FirstSet(opt.Cache, result.Cache)
59-
result.APIVersion = types.FirstSet(opt.APIVersion, result.APIVersion)
60-
result.APIType = types.FirstSet(opt.APIType, result.APIType)
6156
result.DefaultModel = types.FirstSet(opt.DefaultModel, result.DefaultModel)
6257
result.SetSeed = types.FirstSet(opt.SetSeed, result.SetSeed)
6358
result.CacheKey = types.FirstSet(opt.CacheKey, result.CacheKey)
@@ -80,35 +75,15 @@ func complete(opts ...Options) (result Options, err error) {
8075
return result, err
8176
}
8277

83-
func GetAzureMapperFunction(defaultModel, azureModel string) func(string) string {
84-
if azureModel == "" {
85-
return func(model string) string {
86-
return model
87-
}
88-
}
89-
return func(model string) string {
90-
return map[string]string{
91-
defaultModel: azureModel,
92-
}[model]
93-
}
94-
}
95-
9678
func NewClient(opts ...Options) (*Client, error) {
9779
opt, err := complete(opts...)
9880
if err != nil {
9981
return nil, err
10082
}
10183

10284
cfg := openai.DefaultConfig(opt.APIKey)
103-
if strings.Contains(string(opt.APIType), "AZURE") {
104-
cfg = openai.DefaultAzureConfig(key, url)
105-
cfg.AzureModelMapperFunc = GetAzureMapperFunction(opt.DefaultModel, azureModel)
106-
}
107-
10885
cfg.BaseURL = types.FirstSet(opt.BaseURL, cfg.BaseURL)
10986
cfg.OrgID = types.FirstSet(opt.OrgID, cfg.OrgID)
110-
cfg.APIVersion = types.FirstSet(opt.APIVersion, cfg.APIVersion)
111-
cfg.APIType = types.FirstSet(opt.APIType, cfg.APIType)
11287

11388
cacheKeyBase := opt.CacheKey
11489
if cacheKeyBase == "" {

0 commit comments

Comments
 (0)