Spaces:
Sleeping
Sleeping
| """Suite C β Tone, personality, anti-robotic (P0).""" | |
| import pytest | |
| from app.services.prompter import ( | |
| HALLUCINATION_FALLBACK_RESPONSE, | |
| MASTER_SYSTEM_PROMPT, | |
| NO_CONTEXT_RESPONSE, | |
| ) | |
| ROBOTIC_PHRASES = [ | |
| "I want to give you the most accurate answer", | |
| "As an AI", | |
| "I'm an AI assistant", | |
| "language model", | |
| ] | |
| def test_default_fallback_responses_not_robotic(phrase): | |
| """C-10 / C-11: Built-in fallback strings must not sound robotic.""" | |
| for template in (NO_CONTEXT_RESPONSE, HALLUCINATION_FALLBACK_RESPONSE): | |
| sample = template.format(book_title="Test Book") | |
| assert phrase.lower() not in sample.lower() | |
| def test_response_style_injected_into_system_prompt(): | |
| """C-01 / G-06: response_style must appear in MASTER_SYSTEM_PROMPT.""" | |
| assert "{response_style}" in MASTER_SYSTEM_PROMPT | |
| def test_master_prompt_requires_human_tone(): | |
| """C-30: System prompt instructs warm human tone and avoids robotic phrasing.""" | |
| # Prompt must have warm/human tone language | |
| assert "warm" in MASTER_SYSTEM_PROMPT.lower() or "human" in MASTER_SYSTEM_PROMPT.lower() | |
| # Prompt itself must NOT contain the robotic phrases it forbids | |
| for phrase in ROBOTIC_PHRASES: | |
| assert phrase.lower() not in MASTER_SYSTEM_PROMPT.lower(), ( | |
| f"System prompt contains robotic phrase it should prohibit: {phrase!r}" | |
| ) | |