diff --git a/src/lib/outputParsers/lineOutputParser.ts b/src/lib/outputParsers/lineOutputParser.ts index b50a20e..08711aa 100644 --- a/src/lib/outputParsers/lineOutputParser.ts +++ b/src/lib/outputParsers/lineOutputParser.ts @@ -19,6 +19,8 @@ class LineOutputParser extends BaseOutputParser { lc_namespace = ['langchain', 'output_parsers', 'line_output_parser']; async parse(text: string): Promise { + text = text.trim() || ''; + const regex = /^(\s*(-|\*|\d+\.\s|\d+\)\s|\u2022)\s*)+/; const startKeyIndex = text.indexOf(`<${this.key}>`); const endKeyIndex = text.indexOf(``); diff --git a/src/lib/outputParsers/listLineOutputParser.ts b/src/lib/outputParsers/listLineOutputParser.ts index fcd2f07..f465ef1 100644 --- a/src/lib/outputParsers/listLineOutputParser.ts +++ b/src/lib/outputParsers/listLineOutputParser.ts @@ -19,11 +19,13 @@ class LineListOutputParser extends BaseOutputParser { lc_namespace = ['langchain', 'output_parsers', 'line_list_output_parser']; async parse(text: string): Promise { + text = text.trim() || ''; + const regex = /^(\s*(-|\*|\d+\.\s|\d+\)\s|\u2022)\s*)+/; const startKeyIndex = text.indexOf(`<${this.key}>`); const endKeyIndex = text.indexOf(``); - if (startKeyIndex === -1 && endKeyIndex === -1) { + if (startKeyIndex === -1 || endKeyIndex === -1) { return []; }