Skip to content

Commit

Permalink
Merge pull request #10 from sohaha/main
Browse files Browse the repository at this point in the history
feat: Add support for custom OpenAI API baseURL
  • Loading branch information
soulteary authored May 29, 2023
2 parents 574f3f4 + d9200f0 commit bed3b8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions connectors/openai-api/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ func GetClient() *openai.Client {
transport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
config.HTTPClient = &http.Client{Transport: transport}
}

if define.OPENAI_API_BASEURL != "" {
config.BaseURL = define.OPENAI_API_BASEURL
}

return openai.NewClientWithConfig(config)
}

Expand Down
1 change: 1 addition & 0 deletions internal/define/define.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
ENABLE_OPENAI_API = GetBool("ENABLE_OPENAI_API", false) // Enable OpenAI 3.5 API
ENABLE_OPENAI_API_ONLY = GetBool("ENABLE_OPENAI_API_ONLY", false) // Only Enable the 3.5 model
OPENAI_API_KEY = strings.TrimSpace(os.Getenv("OPENAI_API_KEY")) // OpenAI API Key
OPENAI_API_BASEURL = strings.TrimSpace(os.Getenv("OPENAI_API_BASEURL")) // Custom OpenAI API BASEURL
ENABLE_OPENAI_API_PROXY = GetBool("OPENAI_API_PROXY_ENABLE", false) // Enable OpenAI API Proxy
OPENAI_API_PROXY_ADDR = GetHostName("OPENAI_API_PROXY_ADDR", DEFAULT_OPENAI_API_PROXY_ADDR) // OpenAI API Proxy Address
)
Expand Down

0 comments on commit bed3b8a

Please sign in to comment.