diff --git a/evoprompt/evolution/evolution.py b/evoprompt/evolution/evolution.py index e57e6817dd3b93b934d78e5ea6ece439a1c15475..5204ef1498b494a892e0f51446af1149ae5fd62f 100644 --- a/evoprompt/evolution/evolution.py +++ b/evoprompt/evolution/evolution.py @@ -111,7 +111,7 @@ class EvolutionAlgorithm(PromptOptimization, metaclass=ABCMeta): # TODO another option would be to select the first match that is not equal to " and " (which is part of the instruction and usually repeated in the response) matches = re.findall( # regex that matches any characters between last pair of `start_token` and `end_token`, and optionally allow missing `end_token` - rf"{start_token}(?!.*{start_token})(?:(.*){end_token}{"|(.*)" if allow_missing_end_token else ""})", + rf"{start_token}(?!.*{start_token})(?:(.*){end_token}{'|(.*)' if allow_missing_end_token else ''})", response, flags=(re.IGNORECASE | re.DOTALL), )