From 6d3485e79858d14ee1b2a99f737ae46a5342d5c9 Mon Sep 17 00:00:00 2001 From: Nikhil Suresh Date: Fri, 25 Aug 2023 18:11:47 +0000 Subject: [PATCH] fixed regex to match sources for all cases, also includes source --- libs/langchain/langchain/chains/qa_with_sources/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain/langchain/chains/qa_with_sources/base.py b/libs/langchain/langchain/chains/qa_with_sources/base.py index d0408059a8..2c75e60e36 100644 --- a/libs/langchain/langchain/chains/qa_with_sources/base.py +++ b/libs/langchain/langchain/chains/qa_with_sources/base.py @@ -124,7 +124,7 @@ class BaseQAWithSourcesChain(Chain, ABC): answer, sources = re.split( r"SOURCES?[:\s]|QUESTION:\s", answer, flags=re.IGNORECASE )[:2] - sources = re.split(r"\n", sources)[0].strip() + sources = re.split(r"\n", sources)[0] else: sources = "" return answer, sources