Store an abstain when a reasoning plan has no cited sentence
Browse files at this commitc66abbbeecf641b04a013334f418c7a53ffac02dParent: b867bdd- fix
- store an abstain when a reasoning plan has no cited sentence
2 changed files +8 -1
src/generate/prompt.pymodified+3 -1
| @@ -68,7 +68,9 @@ def drop_reasoning_plan(text: str) -> str: | |||
| 68 | continue | 68 | continue |
| 69 | if _CITED.search(line): | 69 | if _CITED.search(line): |
| 70 | kept.append(line) | 70 | kept.append(line) |
| 71 | - return "\n".join(kept) | 71 | + # An empty string is not storable. A plan with no cited sentence is an |
| 72 | + # abstain, not a blank bubble the backend rejects as bad_reply. | ||
| 73 | + return "\n".join(kept) if kept else ABSTAIN_SENTENCE | ||
| 72 | 74 | ||
| 73 | 75 | ||
| 74 | 76 | ||
tests/unit/test_query_sanitization.pymodified+5 -0
| @@ -125,6 +125,11 @@ class ReasoningPlanTests(unittest.TestCase): | |||
| 125 | text = "C# bir programlama dilidir. [1]" | 125 | text = "C# bir programlama dilidir. [1]" |
| 126 | self.assertEqual(drop_reasoning_plan(text), text) | 126 | self.assertEqual(drop_reasoning_plan(text), text) |
| 127 | 127 | ||
| 128 | + def test_a_plan_with_no_citation_is_the_abstain_sentence(self): | ||
| 129 | + raw = "We need to answer the student's question.\nSource 1: notes.\n" | ||
| 130 | + self.assertEqual(drop_reasoning_plan(raw), "Kaynaklarda bu bilgi bulunamadı.") | ||
| 131 | + | ||
| 132 | + | ||
| 128 | 133 | ||
| 129 | if __name__ == "__main__": | 134 | if __name__ == "__main__": |
| 130 | unittest.main() | 135 | unittest.main() |