removed redundancy

This commit is contained in:
nicole pardal
2025-11-05 11:49:44 -08:00
parent 1f54127f9a
commit f6aaaabcc7

View File

@@ -621,34 +621,6 @@ func (s *Server) EmbedHandler(c *gin.Context) {
return return
} }
truncate := true
if req.Truncate != nil && !*req.Truncate {
truncate = false
}
// Basic server-side guard: if truncation is enabled and num_ctx <= 1, return an error
if truncate && req.Options != nil {
if v, ok := req.Options["num_ctx"]; ok {
var numCtx int
switch t := v.(type) {
case float64:
numCtx = int(t)
case int:
numCtx = t
case int64:
numCtx = int(t)
case json.Number:
if i, err := t.Int64(); err == nil {
numCtx = int(i)
}
}
if numCtx <= 1 {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "input after truncation exceeds maximum context length"})
return
}
}
}
var input []string var input []string
switch i := req.Input.(type) { switch i := req.Input.(type) {
@@ -683,13 +655,6 @@ func (s *Server) EmbedHandler(c *gin.Context) {
return return
} }
// Model KV metadata for server-side truncation decisions
kvData, _, err := getModelData(m.ModelPath, false)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
checkpointLoaded := time.Now() checkpointLoaded := time.Now()
if len(input) == 0 { if len(input) == 0 {
@@ -697,6 +662,12 @@ func (s *Server) EmbedHandler(c *gin.Context) {
return return
} }
kvData, _, err := getModelData(m.ModelPath, false)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
ctx := c.Request.Context() ctx := c.Request.Context()
embedWithRetry := func(text string) ([]float32, int, error) { embedWithRetry := func(text string) ([]float32, int, error) {