Spaces:
Sleeping
Sleeping
File size: 563 Bytes
94c8517 59a46e8 94c8517 59a46e8 94c8517 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | package api
import (
"log"
"net/http"
"os"
"github.com/gin-gonic/gin"
)
func ChatHandler(c *gin.Context) {
var inputData ChatInput
if err := c.ShouldBindJSON(&inputData); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
apiKey := os.Getenv("GROQ_API_KEY")
log.Println("API Key: ", apiKey)
response, err := InvokeChain(apiKey, inputData.UserQuery)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
// response := "Hello, World!"
c.JSON(http.StatusOK, response)
}
|