Skip to content

Commit

Permalink
Add support for OPENAI_URL environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
aandrew-me committed Oct 11, 2024
1 parent 28bd255 commit 1e751fb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion providers/openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ func NewRequest(input string, params structs.Params) (*http.Response, error) {
apiKey = params.ApiKey
}

url := params.Url
if os.Getenv("OPENAI_URL") != "" {
url = os.Getenv("OPENAI_URL")
}

temperature := "0.5"
if params.Temperature != "" {
temperature = params.Temperature
Expand Down Expand Up @@ -60,7 +65,7 @@ func NewRequest(input string, params structs.Params) (*http.Response, error) {
}
`, params.PrevMessages, string(safeInput), model, temperature, top_p))

req, err := http.NewRequest("POST", params.Url, data)
req, err := http.NewRequest("POST", url, data)
if err != nil {
fmt.Println("\nSome error has occurred.")
fmt.Println("Error:", err)
Expand Down

0 comments on commit 1e751fb

Please sign in to comment.