Files
darth-veitcher-comfydv/src/comfydv/__init__.py
T
James VeitchandClaude Sonnet 5 5af502d07e feat(llamacpp): add LlamaCppProvider + LlamaCppClient node (spec 008)
Second LLMProvider (ADR-007), backed by llama-server's router mode. Only
one new ComfyUI node — LlamaCppClient, emitting the same LLM_CLIENT socket
Ollama Client does. ChatCompletion, LLMModelSelector, LLMLoadModel,
LLMUnloadModel work unmodified once wired to it — the actual proof the
provider abstraction generalizes, not just Ollama-shaped in practice.

API shape verified live against ggml-org/llama.cpp's tools/server/README.md
(research.md) rather than assumed: model identifier field is "id" (not
"name"), status is a nested {"value": "..."} object. list_models() needs
no normalization — llama.cpp's status vocabulary is exactly ModelStatus's
full set, unlike Ollama's narrower one.

38 new tests (test_llamacpp_provider.py, test_llamacpp.py), including a
dedicated US4 test proving no generic node branches on provider type —
the same call sequence succeeds against an Ollama-shaped or llama.cpp-
shaped fake provider.

README/docs updated for the new node this time, not left stale.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0132ojafeazQ3ephcBejEWFj
2026-07-11 15:27:29 +01:00

85 lines
3.1 KiB
Python

import logging
from .circuit_breaker import CircuitBreaker
from .format_string import FormatString
from .llamacpp import LlamaCppClient
from .ollama import (
ChatCompletion,
LLMLoadModel,
LLMModelSelector,
LLMUnloadModel,
OllamaClient,
OllamaDebugHistory,
OllamaHeaderBasicAuth,
OllamaHeaderBearerToken,
OllamaHeaderCustom,
OllamaHistoryLength,
OllamaOptionExtraBody,
OllamaOptionMaxTokens,
OllamaOptionRepeatPenalty,
OllamaOptionSeed,
OllamaOptionTemperature,
OllamaOptionTopK,
OllamaOptionTopP,
)
from .random_choice import RandomChoice
logging.getLogger(__name__).addHandler(logging.NullHandler())
# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS = {
"RandomChoice": RandomChoice,
"CircuitBreaker": CircuitBreaker,
"FormatString": FormatString,
# LLM nodes (generic, ADR-007) — see comfydv.ollama.MIGRATION_MAP for
# the pre-cutover Ollama-specific names these replace
"OllamaClient": OllamaClient,
"LlamaCppClient": LlamaCppClient,
"LLMModelSelector": LLMModelSelector,
"LLMLoadModel": LLMLoadModel,
"LLMUnloadModel": LLMUnloadModel,
"ChatCompletion": ChatCompletion,
"OllamaOptionTemperature": OllamaOptionTemperature,
"OllamaOptionSeed": OllamaOptionSeed,
"OllamaOptionMaxTokens": OllamaOptionMaxTokens,
"OllamaOptionTopP": OllamaOptionTopP,
"OllamaOptionTopK": OllamaOptionTopK,
"OllamaOptionRepeatPenalty": OllamaOptionRepeatPenalty,
"OllamaOptionExtraBody": OllamaOptionExtraBody,
"OllamaDebugHistory": OllamaDebugHistory,
"OllamaHistoryLength": OllamaHistoryLength,
"OllamaHeaderBasicAuth": OllamaHeaderBasicAuth,
"OllamaHeaderBearerToken": OllamaHeaderBearerToken,
"OllamaHeaderCustom": OllamaHeaderCustom,
}
# A dictionary that contains the friendly/humanly readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = {
"RandomChoice": "Random Choice",
"CircuitBreaker": "Circuit Breaker",
"FormatString": "Format String (Python f-strings)",
# LLM nodes (generic, ADR-007)
"OllamaClient": "Ollama Client",
"LlamaCppClient": "LlamaCpp Client",
"LLMModelSelector": "LLM Model Selector",
"LLMLoadModel": "LLM Load Model",
"LLMUnloadModel": "LLM Unload Model",
"ChatCompletion": "Chat Completion",
"OllamaOptionTemperature": "Ollama Option — Temperature",
"OllamaOptionSeed": "Ollama Option — Seed",
"OllamaOptionMaxTokens": "Ollama Option — Max Tokens",
"OllamaOptionTopP": "Ollama Option — Top P",
"OllamaOptionTopK": "Ollama Option — Top K",
"OllamaOptionRepeatPenalty": "Ollama Option — Repeat Penalty",
"OllamaOptionExtraBody": "Ollama Option — Extra Body",
"OllamaDebugHistory": "Ollama Debug History",
"OllamaHistoryLength": "Ollama History Length",
"OllamaHeaderBasicAuth": "Ollama Header — Basic Auth",
"OllamaHeaderBearerToken": "Ollama Header — Bearer Token",
"OllamaHeaderCustom": "Ollama Header — Custom",
}
WEB_DIRECTORY = "../js"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]