Nodes/SP-Nodes/SP_KoboldCppWithContext
ComfyUI Node

SP_KoboldCppWithContext

Chat-style calls to a local LLM, with real context

By bananasss00·Created 2 years ago·Updated 6 days ago· 20
SP_KoboldCppWithContext
  • override_cfg
  • banned_tokens
  • images
  • text
  • payload
api_urlhttp://localhost:5001/api/v1
system_promptAnswer in English. I give you a topic and you write a short description on that topic. The descriptions should be a few sentences long. I give you a theme, and you write a short description of the photo in a surrealistic style on that theme. Descriptions should be a few sentences long
context
prompt
llm_mode
preset
max_length0
seed0

There's a plain SP_KoboldCpp node in this pack for firing a single prompt at a local LLM. This one is the fuller version: it adds a dedicated context field alongside the prompt, which matters the moment you want the model to remember something across the call - a running story, a character sheet, a batch of prior captions - rather than answering each prompt cold. It's still the same underlying idea people have been wiring into ComfyUI for a while now: point a node at a locally running LLM server and let it generate or rewrite text without leaving the graph, most commonly for prompt generation or image captioning.

How it works

You need KoboldCpp - a real, separate llama.cpp-based inference server, not something this node ships - already running with a model loaded before this node has anything to talk to. api_url (default http://localhost:5001/api/v1, KoboldCpp's own default) is where it sends requests. The call itself is three pieces: system_prompt sets persona/instructions, context carries whatever background the model should treat as already established, and prompt is your actual ask for this call. llm_mode picks the chat template - ChatML, Alpaca, Llama3Chat, DeepSeek25, Gemma23, and 14 more, plus a KoboldCppAuto option that lets Kobold figure it out - and getting this wrong is the single most common reason a local LLM node produces rambling, template-leaking, or instruction-ignoring output, because every model family expects its prompt wrapped a specific way.

preset swaps between KoboldCpp's built-in sampler presets (simple_logical, default, simple_balanced, simple_creative, silly_tavern, coherent_creativity, godlike, liminal_drift) trading coherence for wildness. The optional images input is worth a specific warning, straight from the node's own tooltip: "Provide an image or a batch of images for vision tasks. Make sure that the selected model supports vision, otherwise it may hallucinate the response." A text-only model handed an image and asked to describe it will happily invent a description rather than error out.

Inputs and outputs that matter

  • api_url, system_prompt, context, prompt - the four you'll type into directly.
  • llm_mode - match it to your loaded model's actual training format, or use KoboldCppAuto until you know better.
  • preset - sampling character; simple_logical for obedience, godlike/liminal_drift for weirdness.
  • max_length (0-8192) and seed.
  • override_cfg (optional, from SP_KoboldCpp_OverrideCfg) and banned_tokens (optional, from SP_KoboldCpp_BannedTokens) - fine sampler control, ignore until you need it.
  • images (optional) - vision input, only useful with a vision-capable model.
  • Outputs: text (feed straight into a CLIP Text Encode or wherever you need the generated string) and payload (the raw call/response, handy for debugging).

How to install it

Through ComfyUI Manager: search "SP-Nodes," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/bananasss00/ComfyUI-SP-Nodes

Then restart ComfyUI. Separately, download KoboldCpp itself, load a GGUF model into it, and start its server - that's the piece ComfyUI Manager doesn't install for you, and this node is useless without it running.

Common issues & troubleshooting

Connection errors or hangs. Check KoboldCpp is actually running and that api_url matches its real host and port - a mismatch is by far the most common cause, especially if Kobold is running on a different machine or behind a tunnel/reverse proxy.

Output ignores context entirely, or rambles. Usually a mismatched llm_mode - the model's underlying chat template doesn't match what you told it to expect. Try KoboldCppAuto first.

Vision input produces a confident but wrong description. That's the tooltip's warning playing out - the loaded model doesn't actually support vision. Load a vision-capable GGUF in KoboldCpp before wiring in images.

CategorySP-Nodes

Inputs (11)

NameTypeDefaultDescription
api_urlSTRINGhttp://localhost:5001/api/v1
system_promptSTRINGAnswer in English. I give you a topic and you write a short description on that topic. The descriptions should be a few sentences long. I give you a theme, and you write a short description of the photo in a surrealistic style on that theme. Descriptions should be a few sentences long
contextSTRING
promptSTRING
llm_modeCOMBO19 options: KoboldCppAuto, Chat, Alpaca, ChatML, CommandR, DeepSeek25, +13
presetCOMBO8 options: simple_logical, default, simple_balanced, simple_creative, silly_tavern, coherent_creativity, +2
max_lengthINT00–8192
seedINT00–18446744073709550000
override_cfgoptOVERRIDE_CFG
banned_tokensoptBANNED_TOKENS
imagesoptIMAGEProvide an image or a batch of images for vision tasks. Make sure that the selected model supports vision, otherwise it may hallucinate the response.

Outputs (2)

NameTypeDescription
textSTRING
payloadSTRING