mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-23 07:57:16 +00:00
fixed issue with white space and added unit tests
This commit is contained in:
parent
6d3485e798
commit
b1f649bca5
@ -121,10 +121,8 @@ 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):
|
||||
answer, sources = re.split(
|
||||
r"SOURCES?[:\s]|QUESTION:\s", answer, flags=re.IGNORECASE
|
||||
)[:2]
|
||||
sources = re.split(r"\n", sources)[0]
|
||||
answer, sources = re.split(r"SOURCES?[:\s]|QUESTION:\s", answer, flags=re.IGNORECASE)[:2]
|
||||
sources = re.split(r"\n", sources)[0].strip()
|
||||
else:
|
||||
sources = ""
|
||||
return answer, sources
|
||||
|
Loading…
Reference in New Issue
Block a user