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