This commit is contained in:
2023-04-08 11:35:28 -05:00
parent f5a22be60c
commit af881d80b0
5 changed files with 122 additions and 35 deletions

View File

@@ -1,15 +1,38 @@
package controller
// Controller example
import (
"fmt"
"os"
"github.com/joho/godotenv"
openai "github.com/sashabaranov/go-openai"
)
type Controller struct {
openaiClient *openai.Client
unraidAPIKey string
unraidURI string
}
// NewController example
func NewController() *Controller {
return &Controller{}
err := godotenv.Load(".env")
openaiApiKey := os.Getenv("OPENAI_API_KEY")
openaiClient := openai.NewClient(openaiApiKey)
unraidAPIKey := os.Getenv("UNRAID_API_KEY")
UNRAID_URI := os.Getenv("UNRAID_URI")
if err != nil {
fmt.Println(err.Error())
//return err
}
return &Controller{
openaiClient: openaiClient,
unraidAPIKey: unraidAPIKey,
unraidURI: UNRAID_URI,
}
}
// Message example
type Message struct {
Message string `json:"message" example:"message"`
}