10 Commits
Author SHA1 Message Date
limbicnation f0aaf1314a Free Ollama VRAM after node execution
Pass keep_alive="0s" on every Ollama generate call so models are
evicted from GPU VRAM immediately instead of lingering 5 minutes,
which caused CUDA OOM when downstream diffusion models loaded.

Each node now runs async VRAM cleanup in a try/finally block. The
cleanup uses unload=True so it also evicts a model loaded via the
subprocess fallback path (which carries the default keep_alive).

Add unload_model(), release_vram(), cleanup() and cleanup_async()
to OllamaClient, plus a per-node unload toggle on PromptRefiner.
2026-06-23 04:21:47 +02:00
limbicnation eab2efc461 Fix dual-stream parser false split on 'negative-space'
Require a colon separator and anchor the Negative label to a line
start so the word 'negative' in the positive prompt body (e.g. the
art term 'negative space') is no longer mistaken for a stream label.
Add regression tests.
2026-06-10 22:16:42 +02:00
limbicnation ebbb25a2a3 Add dual-stream prompt refiner node
Add PromptDualStreamRefinerNode that produces a positive and negative
prompt pair in a single pass via Ollama, intended for the shipped Q8
GGUF of qwen2-5-7b-dual-stream-prompt-lora. Reuses OllamaClient for
streaming, timeouts, progress, and llama-runner crash handling, and
parses Positive/Negative output defensively across label variants.

Includes config/Modelfile.dualstream, unit tests, node registration,
and a corrected implementation plan replacing the invalid local
transformers/PEFT approach.
2026-06-10 22:10:16 +02:00
limbicnation bf54b54ca9 fix: handle Ollama llama-runner crashes with structured error categorization
Replace the catch-all RuntimeError wrapper in OllamaClient.generate_streaming
with a StreamResult dataclass that categorises failures (ok, timeout, transient,
model_crash, server_error, unavailable). Llama-runner crashes (HTTP 500 with
"runner terminated" / "exit status" / "load failed") are detected and surfaced
as user-actionable messages in the ComfyUI prompt output instead of bubbling
up as Python stacktraces.

PromptGenerator, NegativePrompt, and PromptRefiner nodes now branch on
result.kind: model_crash / server_error / unavailable surface the message
directly (subprocess fallback would also fail), while timeout / transient
fall through to the existing subprocess fallback path.

Adds 6 unit tests covering each error class plus the success path. Updates
the existing PromptRefiner seed tests to return StreamResult from mocks.
2026-05-08 03:43:58 +02:00
limbicnation ff26170a59 style: fix ruff formatting in test_prompt_refiner.py 2026-05-01 02:42:32 +02:00
limbicnation ed5b681f06 fix: address PR #9 review issues
- fix(scripts): tomllib fallback for Python 3.10 compat
- fix(ci): remove verify-tag-exists from test.yml (publish.yml already guards)
- fix(tests): ensure local nodes/ import in test_node_registration.py
- fix(adapter): shared module-level model cache across OllamaClient instances
- fix(adapter): exact model tag match in check_health() to avoid prefix conflation
- fix(refiner): per-pass seed increment so multi-pass refinement varies
- fix(combiner): validate mode before single-prompt fast path
- feat(generator): strip DeepSeek <think> and markdown <details> blocks
- test: add prompt_refiner seed tests, cache sharing tests, exact match tests
- chore(deps): add dev extras with tomli fallback
2026-04-30 08:05:17 +02:00
limbicnationandClaude Opus 4.7 e8d781d737 feat: add registration safety guards (mapping self-check + contract tests)
Direct response to the v1.1.6 packaging gap, where the prompt-chain nodes
(combiner, refiner, negative) were authored under nodes/ but never wired
into NODE_CLASS_MAPPINGS, so they silently failed to ship.

- __init__.py now raises RuntimeError at import time if NODE_CLASS_MAPPINGS
  and NODE_DISPLAY_NAME_MAPPINGS drift apart. ComfyUI startup logs surface
  the mismatch instead of dropping the node from the menu silently.
- New tests/unit/test_node_registration.py contract suite (8 tests):
  * Expected 5 keys are registered.
  * Display names cover every class.
  * Each registered class satisfies the ComfyUI node interface
    (INPUT_TYPES classmethod, RETURN_TYPES, FUNCTION, CATEGORY,
    and the FUNCTION attribute resolves to a callable method).
  * Every nodes/*_node.py module on disk is reachable from the mapping —
    this is the regression guard that would have caught v1.1.6.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 06:14:55 +02:00
limbicnationandClaude Opus 4.7 839188382c feat: modernize typing to PEP 585, add ruff config, refactor combiner mode handling
Changes:
- Add [tool.ruff] config with target-version py310 and a curated rule set
  (E/F/W, I, UP, B, SIM, RUF) so future drift is caught in CI lint.
- PEP 585 sweep across all node modules: drop legacy typing.Dict / List /
  Tuple / Optional in favor of dict / list / tuple / `X | None`. Annotate
  class-level mutable defaults as ClassVar to satisfy RUF012.
- PromptCombinerNode: replace the magic-string mode chain with a CombineMode
  StrEnum + match statement. The dropdown choices in INPUT_TYPES are now
  derived from the same Literal alias used in the function signature, so the
  UI and the type contract can't drift apart.
- Smoke tests for PromptCombinerNode (14 tests) covering enum mapping, all
  three modes, edge cases, and the unknown-mode error path. Brings combiner
  coverage from 28% to 96%.
- Tidy preexisting issues surfaced by the new lint rules: B904 except chaining
  in style_presets, RUF013 implicit Optional, RUF059 unused unpack, SIM117
  nested-with consolidation in tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 06:14:44 +02:00
limbicnation 8f2eca40d9 fix: address code review issues (#7)
- Remove dead imports from prompt_generator_node.py and ollama_client.py
- Switch optional imports to importlib.util.find_spec pattern
- Remove orphaned _cached_models/_cache_time from PromptGeneratorNode
- Remove unused seed param from PromptRefinerNode
- Add top_p input to NegativePromptNode with proper wiring
- Fix pytest.ini to not omit adapters from coverage
- Remove unused pytest imports from test files
- Run ruff check + format (all clean now)
- All 29 tests passing
2026-04-27 17:30:19 +02:00
limbicnation 89c8341612 feat: add prompt chain nodes + test infrastructure
Phase 1 — Foundation Hardening:
- Extract ollama_client.py adapter from PromptGeneratorNode
- Add pytest suite (29 tests, 70% coverage gate)
- Unify style sources into config/styles.yaml
- Extend CI with pytest + coverage

Phase 2 — Prompt Chain Nodes:
- PromptRefinerNode: iterative LLM refinement (1-3 passes)
- NegativePromptNode: style-aware negative prompt generation
- PromptCombinerNode: blend/concat/weighted_average modes

New graph target:
  PromptGenerator -> PromptRefiner -> PromptCombiner -> CLIP
                          ^
  NegativePrompt ---------+

Closes roadmap phases 1.1-2.3
2026-04-27 07:00:58 +02:00