-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wrap command (beta/proof of concept/WIP)
- Loading branch information
Showing
14 changed files
with
179 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import annotations | ||
|
||
import dataclasses | ||
|
||
from dynamicprompts.commands import Command | ||
from dynamicprompts.enums import SamplingMethod | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class WrapCommand(Command): | ||
wrapper: Command | ||
inner: Command | ||
sampling_method: SamplingMethod | None = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Art Deco, {prompt}, sleek, geometric forms, art deco style | ||
Pop Art, {prompt}, vivid colors, flat color, 2D, strong lines, Pop Art |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
from dynamicprompts.enums import SamplingMethod | ||
from dynamicprompts.parser.parse import parse | ||
from dynamicprompts.sampling_context import SamplingContext | ||
from dynamicprompts.wildcards import WildcardManager | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"sampling_method", | ||
[ | ||
SamplingMethod.COMBINATORIAL, | ||
SamplingMethod.RANDOM, | ||
], | ||
) | ||
def test_wrap(wildcard_manager: WildcardManager, sampling_method: SamplingMethod): | ||
cmd = parse("%{__wrappers__$${fox|cow}}") | ||
scon = SamplingContext( | ||
default_sampling_method=sampling_method, | ||
wildcard_manager=wildcard_manager, | ||
) | ||
seen = set() | ||
for p in scon.sample_prompts(cmd): | ||
seen.add(str(p)) | ||
if len(seen) == 4: # no matter the sampler, we should get 4 prompts | ||
break | ||
assert seen == { | ||
"Art Deco, cow, sleek, geometric forms, art deco style", | ||
"Art Deco, fox, sleek, geometric forms, art deco style", | ||
"Pop Art, cow, vivid colors, flat color, 2D, strong lines, Pop Art", | ||
"Pop Art, fox, vivid colors, flat color, 2D, strong lines, Pop Art", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters