diff --git a/api/types.go b/api/types.go index 0c7ebf21f..178f6f68d 100644 --- a/api/types.go +++ b/api/types.go @@ -382,7 +382,7 @@ type EmbedRequest struct { // this request. KeepAlive *Duration `json:"keep_alive,omitempty"` - Truncate *bool `json:"truncate,omitempty"` + Truncate types.Null[bool] `json:"truncate,omitempty"` // Options lists model-specific options. Options map[string]any `json:"options"` diff --git a/server/routes.go b/server/routes.go index fe06f5538..84c63271f 100644 --- a/server/routes.go +++ b/server/routes.go @@ -487,12 +487,6 @@ func (s *Server) EmbedHandler(c *gin.Context) { return } - truncate := true - - if req.Truncate != nil && !*req.Truncate { - truncate = false - } - var input []string switch i := req.Input.(type) { @@ -541,6 +535,7 @@ func (s *Server) EmbedHandler(c *gin.Context) { } var count int + truncate := req.Truncate.Value(true) for i, s := range input { tokens, err := r.Tokenize(c.Request.Context(), s) if err != nil {