remove unnecessary llm refusal guard
This commit is contained in:
1 parent
912417792f
commit
aa25693091
3 files changed
+5
-24
No files matched your search
@@ -1164,8 +1164,8 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
runner, and the rewrite is never fed back into assessment, tracing, or the
|
runner, and the rewrite is never fed back into assessment, tracing, or the
|
||||||
decision log (the runner and REPL keep the raw deterministic summary). The
|
decision log (the runner and REPL keep the raw deterministic summary). The
|
||||||
prompt forbids adding/inferring/dropping facts, and `Humanizer.humanize`
|
prompt forbids adding/inferring/dropping facts, and `Humanizer.humanize`
|
||||||
always falls back to the original text on any error, timeout, empty/refusal
|
always falls back to the original text on any error, timeout, empty reply, or
|
||||||
reply, or runaway length, so a cleanup failure never swallows a real result.
|
runaway length, so a cleanup failure never swallows a real result.
|
||||||
It reuses the scheduler's `llm` client (endpoint/model/sampler configured
|
It reuses the scheduler's `llm` client (endpoint/model/sampler configured
|
||||||
once) with a short per-call `timeout` (a new optional `chat()` argument) so a
|
once) with a short per-call `timeout` (a new optional `chat()` argument) so a
|
||||||
slow cleanup cannot hold the gateway poll loop for the authoring budget. Off
|
slow cleanup cannot hold the gateway poll loop for the authoring budget. Off
|
||||||
@@ -1205,7 +1205,7 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
real `Scheduler` (lazy engine, unreachable LLM).
|
real `Scheduler` (lazy engine, unreachable LLM).
|
||||||
`tests/test_humanize.py` covers the optional result cleanup with an injected
|
`tests/test_humanize.py` covers the optional result cleanup with an injected
|
||||||
fake `llm` client (rewrite, quote/whitespace normalization, fallback on
|
fake `llm` client (rewrite, quote/whitespace normalization, fallback on
|
||||||
error/empty/refusal/runaway, disabled passthrough, and the global +
|
error/empty/runaway, disabled passthrough, and the global +
|
||||||
per-platform gateway enable/disable wiring).
|
per-platform gateway enable/disable wiring).
|
||||||
`tests/test_lxmf_transport.py` covers the neutral LXMF transport's
|
`tests/test_lxmf_transport.py` covers the neutral LXMF transport's
|
||||||
missing-dep contract, default paths, and `normalize_message` (no real `lxmf`
|
missing-dep contract, default paths, and `normalize_message` (no real `lxmf`
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ It is generation, never a decision: the success/failure verdict and the routing
|
|||||||
are already settled by SemIf and the runner, and the rewrite is never fed back
|
are already settled by SemIf and the runner, and the rewrite is never fed back
|
||||||
into assessment, tracing, or the decision log. The prompt forbids adding,
|
into assessment, tracing, or the decision log. The prompt forbids adding,
|
||||||
inferring, or dropping facts, and `humanize` falls back to the original text on
|
inferring, or dropping facts, and `humanize` falls back to the original text on
|
||||||
any error, timeout, empty reply, refusal, or runaway length — a cleanup failure
|
any error, timeout, empty reply, or runaway length — a cleanup failure
|
||||||
must never swallow or corrupt a real result.
|
must never swallow or corrupt a real result.
|
||||||
|
|
||||||
It reuses the scheduler's configured ``llm`` client (its endpoint/model/sampler)
|
It reuses the scheduler's configured ``llm`` client (its endpoint/model/sampler)
|
||||||
@@ -35,18 +35,6 @@ SYSTEM_PROMPT = (
|
|||||||
"- If the result is already a plain sentence, return it unchanged."
|
"- If the result is already a plain sentence, return it unchanged."
|
||||||
)
|
)
|
||||||
|
|
||||||
#: Leading phrases that mark a meta/refusal reply rather than a rewrite.
|
|
||||||
_REFUSAL_PREFIXES = (
|
|
||||||
"i cannot",
|
|
||||||
"i can't",
|
|
||||||
"i'm sorry",
|
|
||||||
"i am sorry",
|
|
||||||
"i'm unable",
|
|
||||||
"i am unable",
|
|
||||||
"as an ai",
|
|
||||||
"sorry,",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _clean_reply(raw: str) -> str:
|
def _clean_reply(raw: str) -> str:
|
||||||
"""Normalize a model reply into one bare sentence, or "" if unusable."""
|
"""Normalize a model reply into one bare sentence, or "" if unusable."""
|
||||||
@@ -82,7 +70,7 @@ class Humanizer:
|
|||||||
"""Return a grounded rewrite of `text`, or `text` unchanged.
|
"""Return a grounded rewrite of `text`, or `text` unchanged.
|
||||||
|
|
||||||
Never raises: any failure (unreachable client, timeout, empty or
|
Never raises: any failure (unreachable client, timeout, empty or
|
||||||
unusable reply, refusal, runaway length) returns the original text.
|
unusable reply, runaway length) returns the original text.
|
||||||
"""
|
"""
|
||||||
source = (text or "").strip()
|
source = (text or "").strip()
|
||||||
if not self.enabled or not source:
|
if not self.enabled or not source:
|
||||||
@@ -100,8 +88,6 @@ class Humanizer:
|
|||||||
cleaned = _clean_reply(raw)
|
cleaned = _clean_reply(raw)
|
||||||
if not cleaned:
|
if not cleaned:
|
||||||
return text
|
return text
|
||||||
if cleaned.lower().startswith(_REFUSAL_PREFIXES):
|
|
||||||
return text
|
|
||||||
if len(cleaned) > self.max_chars:
|
if len(cleaned) > self.max_chars:
|
||||||
return text
|
return text
|
||||||
return cleaned
|
return cleaned
|
||||||
@@ -61,11 +61,6 @@ def test_humanize_falls_back_on_empty_reply():
|
|||||||
assert Humanizer(client).humanize("raw result") == "raw result"
|
assert Humanizer(client).humanize("raw result") == "raw result"
|
||||||
|
|
||||||
|
|
||||||
def test_humanize_falls_back_on_refusal():
|
|
||||||
client = FakeClient(reply="I cannot rewrite that.")
|
|
||||||
assert Humanizer(client).humanize("raw result") == "raw result"
|
|
||||||
|
|
||||||
|
|
||||||
def test_humanize_falls_back_on_runaway_length():
|
def test_humanize_falls_back_on_runaway_length():
|
||||||
client = FakeClient(reply="x" * 1000)
|
client = FakeClient(reply="x" * 1000)
|
||||||
assert Humanizer(client, max_chars=100).humanize("raw") == "raw"
|
assert Humanizer(client, max_chars=100).humanize("raw") == "raw"
|
||||||
|
|||||||
Reference in new issue
Block a user