From b31475c6223fb02f6e512ad77dee01249ab4a699 Mon Sep 17 00:00:00 2001 From: Nikhil Suresh Date: Tue, 29 Aug 2023 23:13:31 +0000 Subject: [PATCH] minor updates to regex --- libs/langchain/langchain/chains/qa_with_sources/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/chains/qa_with_sources/base.py b/libs/langchain/langchain/chains/qa_with_sources/base.py index 79b083de0b..3e3023ce2b 100644 --- a/libs/langchain/langchain/chains/qa_with_sources/base.py +++ b/libs/langchain/langchain/chains/qa_with_sources/base.py @@ -120,9 +120,9 @@ class BaseQAWithSourcesChain(Chain, ABC): def _split_sources(self, answer: str) -> Tuple[str, str]: """Split sources from answer.""" - if re.search(r"SOURCES?[:]\s", answer, re.IGNORECASE): + if re.search(r"SOURCES?:", answer, re.IGNORECASE): answer, sources = re.split( - r"SOURCES?[:]\s|QUESTION:\s", answer, flags=re.IGNORECASE + r"SOURCES?:|QUESTION:\s", answer, flags=re.IGNORECASE )[:2] sources = re.split(r"\n", sources)[0].strip() else: