break recurse generation if current output contains a delimiter using first OR last when combined with prev if not contains
This commit is contained in:
@@ -383,8 +383,8 @@ func chatBotGenerateAndFillInputF(ctx context.Context, cacheF, inputF, reversePr
|
|||||||
commands[1:]...,
|
commands[1:]...,
|
||||||
)
|
)
|
||||||
command.Dir = Config.ChatBot.WD
|
command.Dir = Config.ChatBot.WD
|
||||||
command.Stderr = io.Discard
|
|
||||||
command.Stderr = log.Writer()
|
command.Stderr = log.Writer()
|
||||||
|
command.Stderr = io.Discard
|
||||||
|
|
||||||
stdout, err := command.StdoutPipe()
|
stdout, err := command.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -412,11 +412,13 @@ func chatBotGenerateAndFillInputF(ctx context.Context, cacheF, inputF, reversePr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
justNew := oldAndNew[len(priorContent):]
|
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...),
|
append(priorContent, justNew...),
|
||||||
[]byte(reversePrompt),
|
[]byte(reversePrompt),
|
||||||
)
|
); idx+len(reversePrompt) > len(priorContent) {
|
||||||
if idx+len(reversePrompt) > len(priorContent) {
|
|
||||||
justNew = justNew[:idx+len(reversePrompt)-len(priorContent)]
|
justNew = justNew[:idx+len(reversePrompt)-len(priorContent)]
|
||||||
}
|
}
|
||||||
if err := _appendFile(inputF, string(justNew)); err != nil {
|
if err := _appendFile(inputF, string(justNew)); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user