Skip to content

Commit

Permalink
fix parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ljleb committed Jul 22, 2023
1 parent 9615a3c commit 15b5e42
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion lib_neutral_prompt/neutral_prompt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def parse_weight(tokens: List[str]) -> float:


def tokenize(s: str):
s = re.sub(r'\s+', ' ', s).strip()
prompt_keywords_regex = '|'.join(rf'\b{keyword}\b' for keyword in prompt_keywords)
return [s for s in re.split(rf'(\[|\]|:|{prompt_keywords_regex})', s) if s.strip()]

Expand Down
2 changes: 1 addition & 1 deletion lib_neutral_prompt/prompt_parser_hijack.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# the only difference with the original `re_weight` is the prefix `\s*` in `^(\s*.*?)` (originally `^(.*?)`)
# this makes it possible to line break AND prompts without replacing all newlines with normal spaces
prompt_parser.re_weight = re.compile(r"^(\s*.*?)(?:\s*:\s*([-+]?(?:\d+\.?|\d*\.\d+)))?\s*$")
prompt_parser.re_weight = re.compile(r"^((?:\s|.)*?)(?:\s*:\s*([-+]?(?:\d+\.?|\d*\.\d+)))?\s*$")


@prompt_parser_hijacker.hijack('get_multicond_prompt_list')
Expand Down

0 comments on commit 15b5e42

Please sign in to comment.