EmAySee Submit To Oobabooga API With Key With THinkParse
Chat API call that splits the model's reasoning out of its answer
- clean_text
- thinking_content
Modern reasoning models - the R1-style and QwQ-style families - don't just answer you; they think out loud first, typically inside <think>...</think> tags, then give the actual answer. If you're feeding that output into a CLIP Text Encode, the thinking trace is garbage. It's meta-commentary about solving the problem, not the answer. That's exactly what this node is built around: it makes a chat-style call to your local text-generation-webui, and it hands you the thinking and the answer as two separate string outputs, with the tags stripped out of the answer.
The "Thinker" node is the lightweight member of this family. It does the chat/completions call (system prompt + user message), parses <think> blocks, and returns clean_text plus thinking_content. It deliberately skips the sampler kitchen sink - just max_tokens, temperature, top_p, and seed are exposed. If you want the full parameter panel (DRY repetition control, min_p, guidance scale, reasoning effort), that's the _WithThinkParse sibling; this one is the "just make the call and split it" version.
How it works
It POSTs to /v1/chat/completions with mode: "instruct", stream: false, and the standard OpenAI-style message array. On the way back it grabs choices[0].message.content, then:
- finds
<think>...</think>with a regex and pulls the contents intothinking_content; - removes the tags entirely from the reply, producing
clean_textfor your prompt.
If the model emits no thinking tags, thinking_content comes back empty and clean_text is just the reply - so it degrades gracefully with non-reasoning models.
The inputs that matter
text- your user message, force-input, usually wired from upstream.api_url- change this. Defaulthttp://10.0.0.71:5000/v1/chat/completionsis the author's LAN address.api_key- default"supersecretkey", which is the author's placeholder, not a real secret. Put your actual key here.system_prompt(optional) - default "You are a helpful assistant."; for prompt-expansion work you'll want something like "Expand this into a detailed image prompt."max_tokens(default 500),temperature(0.7),top_p(0.9),seed(default 0) - the only sampling knobs.
Outputs: clean_text → your prompt encoder; thinking_content → a text preview/display node if you're curious what the model was mulling.
Installing it
Pack standard: ComfyUI_EmAySee_CustomNodes via Manager, or git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes into custom_nodes/, restart. No extra dependencies; requests ships with ComfyUI.
Where people get burned
The default api_key of supersecretkey is a tell - it's the author's test box, not a configuration anyone else should run. If your server expects a real key, the call 401s and you get an error string back in clean_text. Also worth knowing: this node needs a text-generation-webui server running the chat/completions endpoint with a reasoning-capable model loaded for the thinking output to be meaningful. And if you see the model's entire reply (thinking included) dumped into clean_text, your server version may be returning reasoning in a field this node doesn't parse - the tag-splitting only works on models that actually emit <think> tags inline.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| api_url | STRING | http://10.0.0.71:5000/v1/chat/completions | — |
| api_key | STRING | supersecretkey | — |
| max_tokens | INT | 5001–8192 | — |
| temperature | FLOAT | 0.700.1–2 | — |
| top_p | FLOAT | 0.900–1 | — |
| seed | INT | 00–18446744073709550000 | — |
| system_promptopt | STRING | You are a helpful assistant. | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| clean_text | STRING | — |
| thinking_content | STRING | — |