Fixups
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
package llm
|
||||
|
||||
import "github.com/sashabaranov/go-openai"
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
func NewClient(APIKey, URL string) *openai.Client {
|
||||
"github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
func NewClient(APIKey, URL, timeout string) *openai.Client {
|
||||
// Set up OpenAI client
|
||||
if APIKey == "" {
|
||||
//log.Fatal("OPENAI_API_KEY environment variable not set")
|
||||
@@ -10,5 +15,14 @@ func NewClient(APIKey, URL string) *openai.Client {
|
||||
}
|
||||
config := openai.DefaultConfig(APIKey)
|
||||
config.BaseURL = URL
|
||||
|
||||
dur, err := time.ParseDuration(timeout)
|
||||
if err != nil {
|
||||
dur = 150 * time.Second
|
||||
}
|
||||
|
||||
config.HTTPClient = &http.Client{
|
||||
Timeout: dur,
|
||||
}
|
||||
return openai.NewClientWithConfig(config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user