read runner parameter options from map

- read runner options from map to see what was specified explicitly and overwrite zero values
This commit is contained in:
Bruce MacDonald
2023-08-01 13:36:31 -04:00
parent daa0d1de7a
commit 1c5a8770ee
5 changed files with 102 additions and 38 deletions

View File

@@ -15,7 +15,6 @@ import (
"sync"
"time"
"dario.cat/mergo"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
@@ -59,8 +58,14 @@ func GenerateHandler(c *gin.Context) {
loaded.llm = nil
}
opts := model.Options
if err := mergo.Merge(&opts, req.Options, mergo.WithOverride); err != nil {
opts := api.DefaultOptions()
if err := opts.FromMap(model.Options); err != nil {
log.Printf("could not load model options: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
if err := opts.FromMap(req.Options); err != nil {
log.Printf("could not merge model options: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}