reordering

This commit is contained in:
Ettore Di Giacinto
2025-02-25 22:18:08 +01:00
parent d73fd545b2
commit 296734ba3b
46 changed files with 84 additions and 85 deletions

28
pkg/llm/client.go Normal file
View File

@@ -0,0 +1,28 @@
package llm
import (
"net/http"
"time"
"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")
APIKey = "sk-xxx"
}
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)
}