Files
2026-02-18 19:53:25 -08:00

67 lines
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
LLM Chat node – provides an interactive chat panel inside ComfyUI.
All inference runs through the /llm_chat/send API endpoint so the
conversation stays in the widget without needing to queue each turn.
"""
import folder_paths
class LLMChatNode:
"""Interactive chat node. The JS widget handles the conversation;
this node just exposes the config widgets that the JS reads."""
@classmethod
def INPUT_TYPES(cls):
model_list = folder_paths.get_filename_list("LLMs")
return {
"required": {
"model": (model_list, {
"tooltip": "Select a .gguf model from ComfyUI/models/LLM",
}),
"system_prompt": ("STRING", {
"multiline": True,
"default": "You are a helpful assistant.",
"tooltip": "System prompt sent at the start of each conversation",
}),
"max_tokens": ("INT", {
"default": 512, "min": 1, "max": 4096, "step": 1,
}),
"temperature": ("FLOAT", {
"default": 0.7, "min": 0.0, "max": 2.0, "step": 0.05,
}),
"top_p": ("FLOAT", {
"default": 0.9, "min": 0.0, "max": 1.0, "step": 0.05,
}),
"context_length": ("INT", {
"default": 2048, "min": 512, "max": 32768, "step": 256,
}),
"gpu_layers": ("INT", {
"default": -1, "min": -1, "max": 200, "step": 1,
"tooltip": "GPU layers to offload (-1 = all)",
}),
"seed": ("INT", {
"default": 0, "min": 0, "max": 0xFFFFFFFF,
}),
},
}
RETURN_TYPES = ()
FUNCTION = "noop"
CATEGORY = "LLM"
OUTPUT_NODE = True
def noop(self, **kwargs):
"""The node never needs to execute via the queue.
All interaction happens through the JS widget + API."""
return {}
NODE_CLASS_MAPPINGS = {
"LLMChatNode": LLMChatNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"LLMChatNode": "LLM Chat",
}