Change the order of context and prompt.
This commit is contained in:
parent
6bc5c13758
commit
49a5483139
1 changed files with 7 additions and 6 deletions
|
@ -188,21 +188,22 @@ func (s *Server) GenerateHandler(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var b bytes.Buffer
|
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()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Context != nil {
|
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 {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
b.WriteString(prev)
|
||||||
b.WriteString(s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.WriteString(t.String());
|
||||||
prompt = b.String()
|
prompt = b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +248,7 @@ func (s *Server) GenerateHandler(c *gin.Context) {
|
||||||
ch <- gin.H{"error": err.Error()}
|
ch <- gin.H{"error": err.Error()}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res.Context = tokens
|
res.Context = tokens[:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue