Commit 8a9f946c authored by Vyacheslav Moskalev's avatar Vyacheslav Moskalev
Browse files

Refactor and format code.

parent 3b521054
...@@ -188,21 +188,21 @@ func (s *Server) GenerateHandler(c *gin.Context) { ...@@ -188,21 +188,21 @@ func (s *Server) GenerateHandler(c *gin.Context) {
} }
var b bytes.Buffer var b bytes.Buffer
if err := tmpl.Execute(&b, values); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
if req.Context != nil { if req.Context != nil {
s, err := r.Detokenize(c.Request.Context(), req.Context) s, err := r.Detokenize(c.Request.Context(), req.Context)
if err != nil { if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return return
} }
prompt = s + b.String() b.WriteString(s)
} else {
prompt = b.String();
} }
if err := tmpl.Execute(&b, values); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
prompt = b.String()
} }
slog.Debug("generate request", "prompt", prompt, "images", images) slog.Debug("generate request", "prompt", prompt, "images", images)
...@@ -241,12 +241,12 @@ func (s *Server) GenerateHandler(c *gin.Context) { ...@@ -241,12 +241,12 @@ func (s *Server) GenerateHandler(c *gin.Context) {
res.LoadDuration = checkpointLoaded.Sub(checkpointStart) res.LoadDuration = checkpointLoaded.Sub(checkpointStart)
if !req.Raw { if !req.Raw {
tokens, err := r.Tokenize(c.Request.Context(), prompt + sb.String()) tokens, err := r.Tokenize(c.Request.Context(), prompt+sb.String())
if err != nil { if err != nil {
ch <- gin.H{"error": err.Error()} ch <- gin.H{"error": err.Error()}
return return
} }
res.Context = tokens[:] res.Context = tokens
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment