update
This commit is contained in:
@@ -12,14 +12,6 @@ type Controller struct {
|
||||
openaiClient *openai.Client
|
||||
unraidAPIKey string
|
||||
unraidURI string
|
||||
|
||||
config *configStruct
|
||||
}
|
||||
|
||||
type configStruct struct {
|
||||
openaiApiKey string `json : "OPENAI_API_KEY"`
|
||||
unraidAPIKey string `json : "UNRAID_API_KEY"`
|
||||
unraidURI string `json : "UNRAID_URI"`
|
||||
}
|
||||
|
||||
func NewController() *Controller {
|
||||
@@ -31,8 +23,7 @@ func NewController() *Controller {
|
||||
unraidURI := os.Getenv("UNRAID_URI")
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
//return err
|
||||
fmt.Println(".env file not found, using environment variables")
|
||||
}
|
||||
return &Controller{
|
||||
openaiClient: openaiClient,
|
||||
|
||||
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -23,7 +24,10 @@ func (c *Controller) GeneralOpenAI(ctx *gin.Context) {
|
||||
|
||||
result, err := createChatCompletion(c, message)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err)
|
||||
err := ctx.AbortWithError(http.StatusInternalServerError, err)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to send message")
|
||||
}
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, gin.H{"message": result})
|
||||
@@ -44,7 +48,10 @@ func (c *Controller) TravelAgentOpenAI(ctx *gin.Context) {
|
||||
|
||||
result, err := createChatCompletion(c, message)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err)
|
||||
err := ctx.AbortWithError(http.StatusInternalServerError, err)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to send message")
|
||||
}
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, gin.H{"message": result})
|
||||
|
||||
6
main.go
6
main.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -57,7 +58,10 @@ func main() {
|
||||
}
|
||||
}
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
r.Run(":8080")
|
||||
err := r.Run(":8080")
|
||||
if err != nil {
|
||||
fmt.Println("Failed to start server")
|
||||
}
|
||||
}
|
||||
|
||||
func authMiddleware(allowedGroups []string) gin.HandlerFunc {
|
||||
|
||||
Reference in New Issue
Block a user