minor updates to regex

This commit is contained in:
Nikhil Suresh 2023-08-29 23:13:31 +00:00
parent dd10cf945c
commit b31475c622

View File

@ -120,9 +120,9 @@ class BaseQAWithSourcesChain(Chain, ABC):
def _split_sources(self, answer: str) -> Tuple[str, str]: def _split_sources(self, answer: str) -> Tuple[str, str]:
"""Split sources from answer.""" """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( answer, sources = re.split(
r"SOURCES?[:]\s|QUESTION:\s", answer, flags=re.IGNORECASE r"SOURCES?:|QUESTION:\s", answer, flags=re.IGNORECASE
)[:2] )[:2]
sources = re.split(r"\n", sources)[0].strip() sources = re.split(r"\n", sources)[0].strip()
else: else: