From a19cf0087397a692a22aee4cbe296797033ec509 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com> Date: Thu, 2 Oct 2025 17:17:31 +0530 Subject: [PATCH] feat(lineOutputParser): return undefined on invalid tags --- src/lib/outputParsers/lineOutputParser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/outputParsers/lineOutputParser.ts b/src/lib/outputParsers/lineOutputParser.ts index fcd69ef..5c795f2 100644 --- a/src/lib/outputParsers/lineOutputParser.ts +++ b/src/lib/outputParsers/lineOutputParser.ts @@ -4,7 +4,7 @@ interface LineOutputParserArgs { key?: string; } -class LineOutputParser extends BaseOutputParser { +class LineOutputParser extends BaseOutputParser { private key = 'questions'; constructor(args?: LineOutputParserArgs) { @@ -18,7 +18,7 @@ class LineOutputParser extends BaseOutputParser { lc_namespace = ['langchain', 'output_parsers', 'line_output_parser']; - async parse(text: string): Promise { + async parse(text: string): Promise { text = text.trim() || ''; const regex = /^(\s*(-|\*|\d+\.\s|\d+\)\s|\u2022)\s*)+/; @@ -26,7 +26,7 @@ class LineOutputParser extends BaseOutputParser { const endKeyIndex = text.indexOf(``); if (startKeyIndex === -1 || endKeyIndex === -1) { - return ''; + return undefined; } const questionsStartIndex =