mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2024-11-20 14:14:16 +03:00
feat(listLineOutputParser): handle invalid keys
This commit is contained in:
parent
c62e7f091e
commit
0a29237732
@ -22,6 +22,11 @@ class LineListOutputParser extends BaseOutputParser<string[]> {
|
||||
const regex = /^(\s*(-|\*|\d+\.\s|\d+\)\s|\u2022)\s*)+/;
|
||||
const startKeyIndex = text.indexOf(`<${this.key}>`);
|
||||
const endKeyIndex = text.indexOf(`</${this.key}>`);
|
||||
|
||||
if (startKeyIndex === -1 || endKeyIndex === -1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const questionsStartIndex =
|
||||
startKeyIndex === -1 ? 0 : startKeyIndex + `<${this.key}>`.length;
|
||||
const questionsEndIndex = endKeyIndex === -1 ? text.length : endKeyIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user