ComfyUI Node

Get LLM Response

Talk to the Local LLM You Actually Loaded

By 5agado·Created 12 months ago·Updated 18 days ago· 1
Get LLM Response
  • model
  • response_message
  • full_response
prompt
system_promptYou are a helpful assistant.
temperature0.6
max_tokens2048
top_p0.95
seed42
image_path
image_base64

The Sagado pack's LLM story is three nodes that work as a chain: Get LlamaCPP Model loads a GGUF, Get Llama VL Chat Handler optionally gives it eyes, and this one - Get LLM Response - is where you actually talk. You hand it the loaded model and a prompt, and it runs a chat completion with a system prompt and sampling controls, then hands you the reply as a string you can drop into a text encoder, a filename builder, or anything else that eats text.

How it works

It calls model.create_chat_completion() on the MODEL you wired in, with a system message plus your prompt, and passes through temperature, top_p, max_tokens, and seed straight to llama.cpp. The detail worth knowing is the output split: response_message is the cleaned-up answer, while full_response is the entire raw JSON the API returned (usage stats, finish reason, the lot). It also handles reasoning models by chopping off everything up to </think> - so if your model thinks out loud before answering, you get just the final answer on the response_message socket.

If you pass image_path or image_base64, it restructures the user content into a multimodal message (text + image) - that's the part that needs the vision chat handler wired into the loader, otherwise the text model has no idea what to do with an image.

Inputs and outputs

  • model (MODEL) - from Get LlamaCPP Model.
  • prompt (STRING), system_prompt (STRING, default "You are a helpful assistant.").
  • temperature (FLOAT, default 0.6), max_tokens (INT, default 2048), top_p (FLOAT, default 0.95), seed (INT, default 42).
  • Optional: image_path / image_base64 (STRING) for vision.
  • Outputs: response_message (STRING) - the clean answer; full_response (STRING) - the raw JSON.

Install and gotchas

Pack install is the standard dance (ComfyUI Manager → "Sagado Nodes for ComfyUI", or clone + pip install -r requirements.txt). Like its siblings, this node indirectly depends on llama-cpp-python - it doesn't import it directly, but the model it calls comes from the loader that does, so you still need pip install llama-cpp-python or the whole chain dies upstream.

The errors you'll actually see: a ModuleNotFoundError from the loader node (missing llama-cpp-python), or "Error getting LLM response" from this one when the model's context is exhausted or max_tokens is negative (negative means "no limit," which can run away on a chatty model). If response_message comes back empty but full_response has content, your model is a thinking model and the </think> strip ate everything - check full_response for the real output. And remember this is fully local: same VRAM math as the rest of the llama.cpp chain, so keep the model sized for your card.

CategorySagado-Nodes

Inputs (9)

NameTypeDefaultDescription
modelMODEL
promptSTRING
system_promptSTRINGYou are a helpful assistant.
temperatureFLOAT0.60–1
max_tokensINT2048-1–32000
top_pFLOAT0.950–1
seedINT42
image_pathoptSTRING
image_base64optSTRING

Outputs (2)

NameTypeDescription
response_messageSTRING
full_responseSTRING