Merge pull request 'Ground the judge's quote with markdown emphasis and whitespace ignored' (#155) from judge-quote-markdown into main
This commit was merged in pull request #155.
This commit is contained in:
+7
-2
@@ -527,8 +527,13 @@ def complete(verdict):
|
|||||||
def grounded(verdict, transcript):
|
def grounded(verdict, transcript):
|
||||||
if not verdict["interrupt"]:
|
if not verdict["interrupt"]:
|
||||||
return True
|
return True
|
||||||
evidence = verdict["evidence"]
|
evidence = plain(verdict["evidence"])
|
||||||
return evidence.strip() != "" and evidence in transcript
|
return evidence != "" and evidence in plain(transcript)
|
||||||
|
|
||||||
|
|
||||||
|
def plain(text):
|
||||||
|
# The judge drops markdown emphasis and reflows whitespace when it quotes.
|
||||||
|
return " ".join(text.replace("*", "").replace("_", "").split())
|
||||||
|
|
||||||
|
|
||||||
# ~/.claude.json
|
# ~/.claude.json
|
||||||
|
|||||||
@@ -348,6 +348,12 @@ class Grounded(unittest.TestCase):
|
|||||||
self.assertFalse(loop.grounded({"interrupt": True, "evidence": ""}, "the transcript"))
|
self.assertFalse(loop.grounded({"interrupt": True, "evidence": ""}, "the transcript"))
|
||||||
self.assertFalse(loop.grounded({"interrupt": True, "evidence": " "}, "the transcript"))
|
self.assertFalse(loop.grounded({"interrupt": True, "evidence": " "}, "the transcript"))
|
||||||
|
|
||||||
|
def test_a_quote_may_drop_markdown_emphasis_and_reflow_whitespace(self):
|
||||||
|
transcript = "done.\n\n**Your step:**\n```\n./run.sh\n```\nRun it."
|
||||||
|
self.assertTrue(loop.grounded({"interrupt": True, "evidence": "Your step:\n```\n./run.sh\n```\nRun it."}, transcript))
|
||||||
|
self.assertTrue(loop.grounded({"interrupt": True, "evidence": "Your step: ``` ./run.sh ``` Run it."}, transcript))
|
||||||
|
self.assertFalse(loop.grounded({"interrupt": True, "evidence": "**"}, transcript))
|
||||||
|
|
||||||
|
|
||||||
class Verdict(unittest.TestCase):
|
class Verdict(unittest.TestCase):
|
||||||
def test_needs_every_field_the_schema_requires(self):
|
def test_needs_every_field_the_schema_requires(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user