Spaces:
Sleeping
Sleeping
Download api/handler.go from Ashad001/api-LL3Hack: direct link, hf CLI and curl.
- Browser
- Download file 563 Bytes
-
https://huggingface.co/spaces/Ashad001/api-LL3Hack/resolve/main/api/handler.go
- Command line
-
hf download hf://spaces/Ashad001/api-LL3Hack/api/handler.go
-
curl -L -o handler.go https://huggingface.co/spaces/Ashad001/api-LL3Hack/resolve/main/api/handler.go
563 Bytes
| 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) | |
| } | |