* Options as system variables
* Additional tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import dataclasses
|
||||
from enum import Enum
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
@@ -583,6 +584,17 @@ class PromptPostProcessor: # pylint: disable=too-few-public-methods,too-many-in
|
||||
"""
|
||||
vs = self.state.variables
|
||||
vs.clear_system()
|
||||
|
||||
# Option related variables
|
||||
for opt_name in self.defopt.keys():
|
||||
opt_value = getattr(self.state.options, opt_name)
|
||||
var_name = "_opt_" + opt_name
|
||||
if isinstance(opt_value, (bool, str, int)):
|
||||
vs.set_system(var_name, opt_value)
|
||||
elif isinstance(opt_value, Enum):
|
||||
vs.set_system(var_name, str(opt_value).split(".", 1)[-1])
|
||||
|
||||
# Model related variables
|
||||
sdchecks = {x: self.env_info.get("is_" + x, False) for x in self.known_models}
|
||||
sdchecks.update({"": True})
|
||||
model_name_val = next((k for k, v in sdchecks.items() if v), "")
|
||||
|
||||
@@ -383,6 +383,18 @@ class TestWildcards(TestPromptPostProcessorBase):
|
||||
ppp="nocup",
|
||||
)
|
||||
|
||||
def test_wc_wildcardPS2_yaml(self): # yaml wildcard with object formatted choices and options and prefix and suffix
|
||||
self.process(
|
||||
InputTuple("the choices are: [__yaml/wildcardPS2__]", ""),
|
||||
OutputTuple("the choices are: [(prefix2-choice2-suffix:1.5)]", ""),
|
||||
)
|
||||
|
||||
def test_wc_wildcardAt_yaml(self): # yaml wildcard with attention in choices
|
||||
self.process(
|
||||
InputTuple("the choices are: [__yaml/wildcardAt__]", ""),
|
||||
OutputTuple("the choices are: [(choice2:1.5)]", ""),
|
||||
)
|
||||
|
||||
def test_wc_anonymouswildcard_yaml(self): # yaml anonymous wildcard
|
||||
self.process(
|
||||
InputTuple("the choices are: __yaml/anonwildcards__", ""),
|
||||
|
||||
@@ -37,6 +37,11 @@ yaml:
|
||||
- <lora:test2:1>
|
||||
- <lora:test3:1>
|
||||
|
||||
wildcardAt:
|
||||
- (choice1:0.5)
|
||||
- (choice2:1.5)
|
||||
- (choice3:1)
|
||||
|
||||
wildcardPS:
|
||||
- {
|
||||
sampler: "~",
|
||||
@@ -51,6 +56,15 @@ yaml:
|
||||
- { weight: 2, text: choice2 }
|
||||
- { weight: 1, text: choice3 }
|
||||
|
||||
wildcardPS2:
|
||||
- {
|
||||
prefix: "(prefix{1|2}-",
|
||||
suffix: "-suffix:1.5)",
|
||||
}
|
||||
- { text: choice1 }
|
||||
- { text: choice2 }
|
||||
- { text: choice3 }
|
||||
|
||||
more_nested:
|
||||
even_more_nested: # this would be __yaml/more_nested/even_more_nested__
|
||||
- one
|
||||
|
||||
Reference in New Issue
Block a user