fixed regex to match sources for all cases, also includes source

This commit is contained in:
Nikhil Suresh 2023-08-25 18:11:47 +00:00
parent e80834d783
commit 6d3485e798

View File

@ -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