From 49a54831397d1723af4fbcd4f0c5c68dadbc54d5 Mon Sep 17 00:00:00 2001 From: Vyacheslav Moskalev Date: Thu, 1 Aug 2024 19:25:56 +0700 Subject: [PATCH] Change the order of context and prompt. --- server/routes.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/routes.go b/server/routes.go index b449136e..65ba22ea 100644 --- a/server/routes.go +++ b/server/routes.go @@ -188,21 +188,22 @@ func (s *Server) GenerateHandler(c *gin.Context) { } var b bytes.Buffer - if err := tmpl.Execute(&b, values); err != nil { + var t bytes.Buffer + if err := tmpl.Execute(&t, values); err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } if req.Context != nil { - s, err := r.Detokenize(c.Request.Context(), req.Context) + prev, err := r.Detokenize(c.Request.Context(), req.Context) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } - - b.WriteString(s) + b.WriteString(prev) } + b.WriteString(t.String()); prompt = b.String() } @@ -242,12 +243,12 @@ func (s *Server) GenerateHandler(c *gin.Context) { res.LoadDuration = checkpointLoaded.Sub(checkpointStart) 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 { ch <- gin.H{"error": err.Error()} return } - res.Context = tokens + res.Context = tokens[:] } }