diff --git a/vicuna-tools.d/main.go b/vicuna-tools.d/main.go index 56be30d..8cc5668 100644 --- a/vicuna-tools.d/main.go +++ b/vicuna-tools.d/main.go @@ -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 {