QWEN 文本操作
Five-step string surgery, without leaving the graph
- text
LLM output arrives in your graph as raw text, and raw text is almost never in the shape you need. Maybe the model wrapped its answer in markdown. Maybe you want a prefix on every line before that text feeds a prompt encoder. Maybe there's a boilerplate phrase to strip. QWEN_TextOperation is the pack's answer: five operation slots that run in order, each adding a prefix, suffix, or deleting content, all with zero Python on your part.
It sits in the middle of a text pipeline - after a generation node like QWEN3_Text, before a text encoder or a save. If you're building a prompt-assistant workflow, this is the formatting stage that makes the model's chatty output usable as conditioning. Left to its own devices, an LLM hands you role delimiters and "Here is your enhanced prompt:" preamble; this node is where that noise gets edited out or reformatted into something the next stage accepts.
How it works
The node runs your text through up to five paired slots, in order. Each slot has an operation_N dropdown and a content_N text field. If the operation is "无" (none) or the content is empty, that slot is skipped. Otherwise it applies one of six transforms, and the result feeds the next slot.
The operations, spelled out:
- 添加前缀 - prepend content to the whole text
- 每段添加前缀 - prepend content to every non-empty line (different beast, and the one you want for bullet-style formatting)
- 添加后缀 - append content to the end
- 删除开始内容 - delete the first occurrence of content
- 删除结束内容 - delete the last occurrence of content
- 删除指定内容 - delete every occurrence of content
So a typical chain looks like: slot 1 deletes a repeating boilerplate phrase, slot 2 strips the first occurrence of an unwanted preamble, slot 3 adds your desired prefix to every line. Five slots is enough for most real cleanup jobs, and because they run sequentially you can build genuinely multi-step transformations in one node instead of daisy-chaining a dozen single-op nodes.
The inputs and output
- text - the string to operate on. It's marked as force-input, so you connect it rather than typing.
- operation_1..5 / content_1..5 - the paired slots. All optional; every operation defaults to "无".
Output is one STRING (text), the fully processed result. That's it - no count, no side channel, just the transformed text, ready to wire onward.
Install
It's part of ComfyUI_QWEN3VL_API, so no separate download. The whole pack installs in one shot:
cd ComfyUI/custom_nodes
git clone https://github.com/flywhale-666/ComfyUI_QWEN3VL_API
cd ComfyUI_QWEN3VL_API
pip install -r requirements.txt
Restart ComfyUI, or search "ComfyUI_QWEN3VL_API" in ComfyUI Manager. Note that this node needs no API key at all - it never touches the network. It's pure string manipulation, which makes it the one node in the pack you can play with freely without spending anything.
Troubleshooting
- A slot does nothing - check the content field. Any operation with empty content is silently skipped, and that's easy to miss when you set the operation but forgot to type the string.
- "删除结束内容" didn't do what you expected - it removes the last occurrence, not "everything after X". If you wanted to truncate, that's a different tool.
- Chinese labels confusing you - the pack is authored in Chinese and the dropdowns are in Chinese. The mapping above is the full list; after one session you'll have them memorized.
- Nothing happened at all - text is required. If you don't connect the input, there's nothing to operate on.
The honest verdict: it's not glamorous, but it's the kind of utility that quietly saves you an hour of regex-ing in a text editor and pasting results back in. The five sequential slots are the feature - most LLM cleanup needs more than one transform, and this does them in one pass.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| operation_1opt | COMBO | 无 | 7 options: 无, 添加前缀, 每段添加前缀, 添加后缀, 删除开始内容, 删除结束内容, +1 |
| content_1opt | STRING | — | |
| operation_2opt | COMBO | 无 | 7 options: 无, 添加前缀, 每段添加前缀, 添加后缀, 删除开始内容, 删除结束内容, +1 |
| content_2opt | STRING | — | |
| operation_3opt | COMBO | 无 | 7 options: 无, 添加前缀, 每段添加前缀, 添加后缀, 删除开始内容, 删除结束内容, +1 |
| content_3opt | STRING | — | |
| operation_4opt | COMBO | 无 | 7 options: 无, 添加前缀, 每段添加前缀, 添加后缀, 删除开始内容, 删除结束内容, +1 |
| content_4opt | STRING | — | |
| operation_5opt | COMBO | 无 | 7 options: 无, 添加前缀, 每段添加前缀, 添加后缀, 删除开始内容, 删除结束内容, +1 |
| content_5opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |