This commit is contained in:
2023-05-26 20:06:00 -05:00
parent eab2cb9963
commit 5ec35ec521
13 changed files with 188 additions and 58 deletions

View File

@@ -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,
}
}