67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
"""
|
||
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",
|
||
}
|