MCPcopy Create free account
hub / github.com/kijai/ComfyUI-WanVideoWrapper / parse_prompt_weights

Method parse_prompt_weights

nodes.py:436–454  ·  view source on GitHub ↗

Extract text and weights from prompts with (text:weight) format

(self, prompt)

Source from the content-addressed store, hash-verified

434 return (prompt_embeds_dict,)
435
436 def parse_prompt_weights(self, prompt):
437 """Extract text and weights from prompts with (text:weight) format"""
438 import re
439
440 # Parse all instances of (text:weight) in the prompt
441 pattern = r'\((.*?):([\d\.]+)\)'
442 matches = re.findall(pattern, prompt)
443
444 # Replace each match with just the text part
445 cleaned_prompt = prompt
446 weights = {}
447
448 for match in matches:
449 text, weight = match
450 orig_text = f"({text}:{weight})"
451 cleaned_prompt = cleaned_prompt.replace(orig_text, text)
452 weights[text] = float(weight)
453
454 return cleaned_prompt, weights
455
456class WanVideoTextEncodeSingle:
457 @classmethod

Callers 1

processMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected