Closed mitchellgordon95 closed 2 years ago
This looks solid and I'm very stoked be able to enter text prompts with colons - thanks for the thought put into this and I hope to test it soon.
I excited with this improvement, but then also reworked it a bit subsequently so that someone didn't have to choose between having a colon in the text part of the prompt or appending a weight - but in fact could flexibly have both. Here's your handy test cases with a couple of extras that show the other cases
>>> import pixray
>>> from pixray import parse_prompt
>>> parse_prompt("hello world")
('hello world', 1, -inf)
>>> parse_prompt("hello world:2")
('hello world', 2.0, -inf)
>>> parse_prompt("hello world:2:15")
('hello world', 2.0, 15.0)
>>> parse_prompt("hello world: my name is Mitchell")
('hello world: my name is Mitchell', 1, -inf)
>>> parse_prompt("hello world: my name is Mitchell:2")
('hello world: my name is Mitchell', 2.0, -inf)
>>> parse_prompt("hello world: my name is Mitchell:2:15")
('hello world: my name is Mitchell', 2.0, 15.0)
The code for that can be seen in this commit now in the pixray/future development branch. Thanks for instigating this change - I have often been frustrated with this myself but never thought to improve the parsing to fix it!
When a prompt contains a colon (i.e. "Star Wars: Return of the Sith"), it will currently crash generation. This is a small change to prompt parsing to gracefully handle this case. Before:
After: