mirror of
https://github.com/Sygil-Dev/sygil-webui.git
synced 2024-12-15 14:31:44 +03:00
Fixed decimal prompt weights without leading digit (#1182)
The regex was not accounting properly for prompt weights that didn't begin with a leading number such as .5 or .1 and was instead splitting those off into their own prompt which got everything all screwed up. For example, the prompt string of "Fruit:1 grapes:-.5" should parse as [('Fruit', 1.0), ('grapes', -.5)] but was being incorrectly parsed as [('Fruit', 1.0), ('grapes', 1.0), ('-.5', 1.0)] This fixes that by making the regex properly catch decimals.
This commit is contained in:
parent
4ae7a5805c
commit
b5462536f8
@ -1519,7 +1519,7 @@ prompt_parser = re.compile("""
|
||||
(?: # non-capture group
|
||||
:+ # match one or more ':' characters
|
||||
(?P<weight> # capture group for 'weight'
|
||||
-?\d+(?:\.\d+)? # match positive or negative integer or decimal number
|
||||
-?\d*\.{0,1}\d+ # match positive or negative integer or decimal number
|
||||
)? # end weight capture group, make optional
|
||||
\s* # strip spaces after weight
|
||||
| # OR
|
||||
|
Loading…
Reference in New Issue
Block a user