update
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
openai "github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
@@ -12,23 +10,33 @@ type Controller struct {
|
||||
openaiClient *openai.Client
|
||||
unraidAPIKey string
|
||||
unraidURI string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
RedirectURL string
|
||||
AuthURL string
|
||||
TokenURL string
|
||||
}
|
||||
|
||||
func NewController() *Controller {
|
||||
err := godotenv.Load(".env")
|
||||
|
||||
openaiApiKey := os.Getenv("OPENAI_API_KEY")
|
||||
openaiClient := openai.NewClient(openaiApiKey)
|
||||
unraidAPIKey := os.Getenv("UNRAID_API_KEY")
|
||||
unraidURI := os.Getenv("UNRAID_URI")
|
||||
ClientID := os.Getenv("ClientID")
|
||||
ClientSecret := os.Getenv("ClientSecret")
|
||||
RedirectURL := os.Getenv("RedirectURL")
|
||||
AuthURL := os.Getenv("AuthURL")
|
||||
TokenURL := os.Getenv("TokenURL")
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(".env file not found, using environment variables")
|
||||
}
|
||||
return &Controller{
|
||||
openaiClient: openaiClient,
|
||||
openaiClient: openai.NewClient(openaiApiKey),
|
||||
unraidAPIKey: unraidAPIKey,
|
||||
unraidURI: unraidURI,
|
||||
ClientID: ClientID,
|
||||
ClientSecret: ClientSecret,
|
||||
RedirectURL: RedirectURL,
|
||||
AuthURL: AuthURL,
|
||||
TokenURL: TokenURL,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user