Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d33e8146b |
@@ -187,6 +187,10 @@ class LMStudioImageToText(io.ComfyNode):
|
||||
)
|
||||
|
||||
text = strip_think_content(text)
|
||||
if not text:
|
||||
raise ValueError(
|
||||
"All content was inside <think> blocks; no visible text was produced."
|
||||
)
|
||||
|
||||
status = f"Model '{connection.model}' via {via_endpoint} (seed={resolved_seed})."
|
||||
if fallback_reason:
|
||||
|
||||
@@ -158,3 +158,38 @@ def test_execute_chat_fallback_reports_dropped_frames(
|
||||
assert "via chat.completions" in output.ui.text
|
||||
assert "responses unavailable" in output.ui.text
|
||||
assert "additional frame(s) were dropped" in output.ui.text
|
||||
|
||||
|
||||
def test_execute_raises_when_all_text_is_think_blocks(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""
|
||||
Regression: when the model returns only <think> content (no visible text),
|
||||
strip_think_content reduces the response to "". The node must raise
|
||||
ValueError rather than silently returning an empty string.
|
||||
"""
|
||||
image_node = _image_module()
|
||||
|
||||
fake_client = SimpleNamespace(
|
||||
responses=SimpleNamespace(
|
||||
create=lambda **_: SimpleNamespace(output_text="<think>internal only</think>")
|
||||
),
|
||||
chat=SimpleNamespace(
|
||||
completions=SimpleNamespace(
|
||||
create=lambda **_: (_ for _ in ()).throw(
|
||||
AssertionError("chat fallback should not run")
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(image_node, "resolve_request_seed", lambda _: 1)
|
||||
monkeypatch.setattr(image_node, "create_openai_client", lambda **_: fake_client)
|
||||
|
||||
with pytest.raises(ValueError, match="All content was inside <think> blocks"):
|
||||
image_node.LMStudioImageToText.execute(
|
||||
connection=_connection_payload(),
|
||||
image=_single_image(),
|
||||
system_prompt="sys",
|
||||
user_prompt="describe",
|
||||
seed=1,
|
||||
)
|
||||
|
||||
@@ -168,3 +168,38 @@ def test_execute_raises_if_both_endpoints_return_no_text(
|
||||
user_prompt="hello",
|
||||
seed=1,
|
||||
)
|
||||
|
||||
|
||||
def test_execute_raises_when_all_text_is_think_blocks(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""
|
||||
Regression: when the model returns only <think> content (no visible text),
|
||||
strip_think_content reduces the response to "". The node must raise
|
||||
ValueError rather than silently returning an empty string.
|
||||
"""
|
||||
text_gen_node = _text_module()
|
||||
|
||||
fake_client = SimpleNamespace(
|
||||
responses=SimpleNamespace(
|
||||
create=lambda **_: SimpleNamespace(output_text="<think>internal only</think>")
|
||||
),
|
||||
chat=SimpleNamespace(
|
||||
completions=SimpleNamespace(
|
||||
create=lambda **_: (_ for _ in ()).throw(
|
||||
AssertionError("chat fallback should not run")
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
monkeypatch.setattr(text_gen_node, "resolve_request_seed", lambda _: 1)
|
||||
monkeypatch.setattr(text_gen_node, "create_openai_client", lambda **_: fake_client)
|
||||
|
||||
with pytest.raises(ValueError, match="All content was inside <think> blocks"):
|
||||
text_gen_node.LMStudioTextGen.execute(
|
||||
connection=_connection_payload(),
|
||||
system_prompt="sys",
|
||||
user_prompt="hello",
|
||||
seed=1,
|
||||
)
|
||||
|
||||
@@ -149,6 +149,10 @@ class LMStudioTextGen(io.ComfyNode):
|
||||
raise ValueError("chat.completions fallback returned no text output")
|
||||
|
||||
text = strip_think_content(text)
|
||||
if not text:
|
||||
raise ValueError(
|
||||
"All content was inside <think> blocks; no visible text was produced."
|
||||
)
|
||||
|
||||
status = f"Model '{connection.model}' via {via_endpoint} (seed={resolved_seed})."
|
||||
if fallback_reason:
|
||||
|
||||
Reference in New Issue
Block a user