mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-23 16:08:10 +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]:
|
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?[:\s]", answer, re.IGNORECASE):
|
||||||
answer, sources = re.split(
|
answer, sources = re.split(r"SOURCES?[:\s]|QUESTION:\s", answer, flags=re.IGNORECASE)[:2]
|
||||||
r"SOURCES?[:\s]|QUESTION:\s", answer, flags=re.IGNORECASE
|
sources = re.split(r"\n", sources)[0].strip()
|
||||||
)[:2]
|
|
||||||
sources = re.split(r"\n", sources)[0]
|
|
||||||
else:
|
else:
|
||||||
sources = ""
|
sources = ""
|
||||||
return answer, sources
|
return answer, sources
|
||||||
|
Loading…
Reference in New Issue
Block a user