use re.search instead of re.match (which searches from start of string only)

This commit is contained in:
Richard Kuo (Danswer)
2024-08-07 20:50:37 -07:00
committed by Chris Weaver
parent 9eb48ca2c3
commit bdaaebe955

View File

@@ -26,9 +26,7 @@ from danswer.utils.text_processing import shared_precompare_cleanup
logger = setup_logger()
answer_pattern = re.compile(
r'(?:```(?:json)?)?\s*{\s*"answer"\s*:\s*"', re.DOTALL | re.IGNORECASE
)
answer_pattern = re.compile(r'{\s*"answer"\s*:\s*"', re.IGNORECASE)
def _extract_answer_quotes_freeform(
@@ -232,7 +230,7 @@ def process_model_tokens(
model_output += token
if not found_answer_start:
m = answer_pattern.match(model_output)
m = answer_pattern.search(model_output)
if m:
found_answer_start = True