Add mutex, build only lite images

This commit is contained in:
mudler 2023-03-27 01:01:10 +02:00
parent 1f45ff8cd6
commit e860e62036
2 changed files with 6 additions and 2 deletions

View File

@ -43,5 +43,5 @@ lite-image:
SAVE IMAGE --push $IMAGE-lite
image-all:
BUILD --platform=linux/amd64 --platform=linux/arm64 +image
BUILD --platform=linux/amd64 --platform=linux/arm64 +lite-image
#BUILD --platform=linux/amd64 --platform=linux/arm64 +image
BUILD --platform=linux/amd64 --platform=linux/arm64 +lite-image

4
api.go
View File

@ -4,6 +4,7 @@ import (
"embed"
"net/http"
"strconv"
"sync"
llama "github.com/go-skynet/llama/go"
"github.com/gofiber/fiber/v2"
@ -28,9 +29,12 @@ func api(l *llama.LLama, listenAddr string, threads int) error {
"tokens": 100
}'
*/
var mutex = &sync.Mutex{}
// Endpoint to generate the prediction
app.Post("/predict", func(c *fiber.Ctx) error {
mutex.Lock()
defer mutex.Unlock()
// Get input data from the request body
input := new(struct {
Text string `json:"text"`