Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
chore: tidy up dynamic prompting leftovers
joshistoast5bd0ea248e78
diff --git a/invokeai/app/invocations/prompt.py b/invokeai/app/invocations/prompt.pyindex d998200ceb..f216e91c05 100644--- a/invokeai/app/invocations/prompt.py+++ b/invokeai/app/invocations/prompt.py@@ -16,7 +16,9 @@ from invokeai.app.util.dynamicprompts import expand_dynamic_prompttitle="Dynamic Prompt",tags=["prompt", "collection"],category="prompt",- version="1.0.1",+ # 1.1.0: wildcards now resolve against the queueing user's records, and an+ # unresolvable one fails the invocation instead of silently repeating a prompt.+ version="1.1.0",use_cache=False,)class DynamicPromptInvocation(BaseInvocation):diff --git a/invokeai/app/services/shared/invocation_context.py b/invokeai/app/services/shared/invocation_context.pyindex 1d00ed6bdc..81a19b3960 100644--- a/invokeai/app/services/shared/invocation_context.py+++ b/invokeai/app/services/shared/invocation_context.py@@ -780,7 +780,6 @@ class InvocationContext:"""Methods to interact with boards."""self.wildcards = wildcards"""Access to the queueing user's wildcards."""- """Methods to interact with boards."""self._data = data"""An internal API providing access to data about the current queue item and invocation. You probably shouldn't use this. It may change without warning."""self._services = servicesdiff --git a/invokeai/app/services/wildcard_records/wildcard_records_common.py b/invokeai/app/services/wildcard_records/wildcard_records_common.pyindex f1530986ba..c182f0dd1b 100644--- a/invokeai/app/services/wildcard_records/wildcard_records_common.py+++ b/invokeai/app/services/wildcard_records/wildcard_records_common.py@@ -23,6 +23,12 @@ WILDCARD_NAME_RE = re.compile(rf"^{_WILDCARD_NAME_SEGMENT}(?:/{_WILDCARD_NAME_SEMAX_WILDCARD_NAME_LENGTH = 128+# The values list is the only unbounded per-user write surface here, and it is stored as one JSON+# blob. These bounds are generous for the intended use (a list you would plausibly type or paste)+# and are about storage rather than expansion cost, which stays cheap either way.+MAX_WILDCARD_VALUES = 10_000+MAX_WILDCARD_VALUE_LENGTH = 2_000+def validate_wildcard_name(name: str) -> str:"""Normalizes and validates a wildcard name, or raises ValueError."""@@ -42,8 +48,18 @@ def validate_wildcard_name(name: str) -> str:def _clean_values(values: list[str]) -> list[str]:- """Drops blank entries and surrounding whitespace; a wildcard of empty strings expands to nothing."""- return [stripped for stripped in (value.strip() for value in values) if stripped]+ """Drops blank entries and surrounding whitespace, or raises ValueError if the list is oversized.++ A wildcard of empty strings expands to nothing, so blanks are dropped rather than rejected.+ """+ cleaned = [stripped for stripped in (value.strip() for value in values) if stripped]++ if len(cleaned) > MAX_WILDCARD_VALUES:+ raise ValueError(f"A wildcard may have at most {MAX_WILDCARD_VALUES} values")+ if any(len(value) > MAX_WILDCARD_VALUE_LENGTH for value in cleaned):+ raise ValueError(f"Each wildcard value must be at most {MAX_WILDCARD_VALUE_LENGTH} characters")++ return cleanedclass WildcardWithoutId(BaseModel):diff --git a/invokeai/frontend/web/openapi.json b/invokeai/frontend/web/openapi.jsonindex a3140c64be..f85f80e4c2 100644--- a/invokeai/frontend/web/openapi.json+++ b/invokeai/frontend/web/openapi.json@@ -23110,7 +23110,7 @@"tags": ["prompt", "collection"],"title": "Dynamic Prompt","type": "object",- "version": "1.0.1",+ "version": "1.1.0","output": {"$ref": "#/components/schemas/StringCollectionOutput"}diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsPanel.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsPanel.tsxindex 70d380b6c6..6732f30191 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsPanel.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/DynamicPromptsPanel.tsx@@ -84,7 +84,6 @@ export const DynamicPromptsPanel = ({[t]);const mode = config.combinatorial ? 'all' : 'random';- const modeValue = useMemo(() => [mode], [mode]);const modeLabel = modeItems.find((item) => item.value === mode)?.label ?? '';const maxPromptsLabel = config.combinatorial? t('widgets.generate.dynamicPrompts.maxPrompts')@@ -139,7 +138,7 @@ export const DynamicPromptsPanel = ({<Portal><Menu.Positioner><MenuContent minW="10rem" py="1">- <Menu.RadioItemGroup value={modeValue[0]} onValueChange={handleModeChange}>+ <Menu.RadioItemGroup value={mode} onValueChange={handleModeChange}>{modeItems.map((item) => (<Menu.RadioItem key={item.value} value={item.value}><Menu.ItemText>{item.label}</Menu.ItemText>