break recurse generation if current output contains a delimiter using first OR last when combined with prev if not contains

master
bel 2023-06-17 14:01:13 -06:00
parent 68a87dc3db
commit 287b72639d
1 changed files with 6 additions and 4 deletions

View File

@ -383,8 +383,8 @@ func chatBotGenerateAndFillInputF(ctx context.Context, cacheF, inputF, reversePr
commands[1:]...,
)
command.Dir = Config.ChatBot.WD
command.Stderr = io.Discard
command.Stderr = log.Writer()
command.Stderr = io.Discard
stdout, err := command.StdoutPipe()
if err != nil {
@ -412,11 +412,13 @@ func chatBotGenerateAndFillInputF(ctx context.Context, cacheF, inputF, reversePr
return nil, err
}
justNew := oldAndNew[len(priorContent):]
idx := bytes.LastIndex(
if idx := bytes.Index(justNew, []byte(reversePrompt)); idx > 0 {
justNew = justNew[:idx]
} else if idx := bytes.LastIndex(
append(priorContent, justNew...),
[]byte(reversePrompt),
)
if idx+len(reversePrompt) > len(priorContent) {
); idx+len(reversePrompt) > len(priorContent) {
justNew = justNew[:idx+len(reversePrompt)-len(priorContent)]
}
if err := _appendFile(inputF, string(justNew)); err != nil {