Skip to content

Commit

Permalink
fix: fix azure support
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Nov 8, 2023
1 parent 191bd4c commit 78a54f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
17 changes: 9 additions & 8 deletions chatgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ type ChatGPT struct {
}

func NewChatGPT(conf GlobalConfig) *ChatGPT {
config := openai.DefaultConfig(conf.APIKey)
config.OrgID = conf.OrgID
if conf.Endpoint != "" {
config.BaseURL = conf.Endpoint
}
if conf.APIType != openai.APITypeOpenAI {
config.APIType = conf.APIType
var config openai.ClientConfig
if conf.APIType == openai.APITypeOpenAI {
config = openai.DefaultConfig(conf.APIKey)
if conf.Endpoint != "" {
config.BaseURL = conf.Endpoint
}
} else {
config = openai.DefaultAzureConfig(conf.APIKey, conf.Endpoint)
config.APIVersion = conf.APIVersion
config.Engine = conf.Engine
}
config.OrgID = conf.OrgID
client := openai.NewClientWithConfig(config)
return &ChatGPT{globalConf: conf, client: client}
}
Expand Down
1 change: 0 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type GlobalConfig struct {
Endpoint string `json:"endpoint"`
APIType openai.APIType `json:"api_type,omitempty"`
APIVersion string `json:"api_version,omitempty"` // required when APIType is APITypeAzure or APITypeAzureAD
Engine string `json:"engine,omitempty"` // required when APIType is APITypeAzure or APITypeAzureAD
OrgID string `json:"org_id,omitempty"`
Prompts map[string]string `json:"prompts"`
Conversation ConversationConfig `json:"conversation"` // Default conversation config
Expand Down

0 comments on commit 78a54f0

Please sign in to comment.