mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-03 19:57:51 +00:00
removed unnecessary white space in regex that breaks qa with sources chain
This commit is contained in:
parent
8a4670e127
commit
64eb5a6082
@ -122,7 +122,7 @@ class BaseQAWithSourcesChain(Chain, ABC):
|
|||||||
"""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
|
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:
|
||||||
|
@ -27,6 +27,11 @@ from tests.unit_tests.llms.fake_llm import FakeLLM
|
|||||||
"This Agreement is governed by English law.\n",
|
"This Agreement is governed by English law.\n",
|
||||||
"28-pl",
|
"28-pl",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"According to the sources, the agreement is governed by English law.\nSource: 28-pl",
|
||||||
|
"According to the sources, the agreement is governed by English law.\n",
|
||||||
|
"28-pl",
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"This Agreement is governed by English law.\n"
|
"This Agreement is governed by English law.\n"
|
||||||
"SOURCES: 28-pl\n\n"
|
"SOURCES: 28-pl\n\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user