mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-28 12:58:41 +02:00
use re.search instead of re.match (which searches from start of string only)
This commit is contained in:
committed by
Chris Weaver
parent
9eb48ca2c3
commit
bdaaebe955
@@ -26,9 +26,7 @@ from danswer.utils.text_processing import shared_precompare_cleanup
|
|||||||
|
|
||||||
|
|
||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
answer_pattern = re.compile(
|
answer_pattern = re.compile(r'{\s*"answer"\s*:\s*"', re.IGNORECASE)
|
||||||
r'(?:```(?:json)?)?\s*{\s*"answer"\s*:\s*"', re.DOTALL | re.IGNORECASE
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _extract_answer_quotes_freeform(
|
def _extract_answer_quotes_freeform(
|
||||||
@@ -232,7 +230,7 @@ def process_model_tokens(
|
|||||||
model_output += token
|
model_output += token
|
||||||
|
|
||||||
if not found_answer_start:
|
if not found_answer_start:
|
||||||
m = answer_pattern.match(model_output)
|
m = answer_pattern.search(model_output)
|
||||||
if m:
|
if m:
|
||||||
found_answer_start = True
|
found_answer_start = True
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user