fix assistant truncated answer detection
This commit is contained in:
parent
4e3e6031d4
commit
73fe617afc
1 changed files with 4 additions and 1 deletions
|
|
@ -886,8 +886,11 @@ function shouldRegenerateTruncatedAnswer(answer, finishReason) {
|
|||
answer = String(answer || '').trim();
|
||||
if (!answer) return false;
|
||||
if (finishReason === 'length') return true;
|
||||
if (/\b(the|a|an|and|or|but|with|without|for|to|of|in|on|as|by|from|because|therefore|however)$/i.test(answer)) return true;
|
||||
if (/\b(the|a|an|and|or|but|with|without|for|to|of|in|on|as|by|from|because|therefore|however|some|many|most|few|several|additional|other|further|including|such)$/i.test(answer)) return true;
|
||||
if (/[,:;\-–—(]$/.test(answer)) return true;
|
||||
var lines = answer.split(/\n+/).map(function(line) { return line.trim(); }).filter(Boolean);
|
||||
var last = lines.length ? lines[lines.length - 1] : answer;
|
||||
if (last.length > 24 && /[A-Za-z]$/.test(last) && !/[.!?\])”"']$/.test(last)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue