Closed rubberbaron closed 1 year ago
can you double-check your prompt? I had the same issue, and then noticed that there was an extra divider | after the last altnernating word. As soon as I removed it, the error stopped.
The point is that the | at the end is there intentionally, it's trying to choose the empty string intentionally. It is a bug that you can't do that.
As a trivial example of why you might want this, consider [fe|]male
. Yes, obviously you can write [female|male]
, but it gets at the reason for wanting it.
I looked into the code, but since the grammar uses a CFG with an LALR parser it looks pretty complicated to support; you'd have to add an empty production and then adjust rules to include that as an option, and I'm not familiar enough with Lark to make those sorts of changes myself. (It would be trivial to handle in some alternative parsing engines, but it doesn't make sense to switch parsers just for this.)
Is there an existing issue for this?
What happened?
Using an empty option in an alternation, like "[red|] apple", throws an exception. Easy workaround is to put a space in the empty option, like "[red| ] apple", and then it doesn't error out.
Steps to reproduce the problem
What should have happened?
does not throw an exception
Commit where the problem happens
d5ce044b
What platforms do you use to access the UI ?
Windows
What browsers do you use to access the UI ?
Mozilla Firefox
Command Line Arguments
List of extensions
wildcards, controlnet
Console logs
Additional information
No response