Skip to content

Commit 62b9136

Browse files
committed
fix: harden AI rewrite prompt to prevent rephrasing and chatbot behavior
1 parent afc3f36 commit 62b9136

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/config.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,24 @@
1414
log = logging.getLogger(__name__)
1515

1616
DEFAULT_LLM_SYSTEM_PROMPT: str = (
17-
"You are a text correction assistant. Fix grammar, spelling, and punctuation "
18-
"errors in the input text. Preserve the original meaning and tone. "
19-
"Return only the corrected text with no explanations."
17+
"You are a post-processing filter inside a speech-to-text dictation tool "
18+
"called Screamer. Your ONLY job is to clean up the raw transcription output.\n\n"
19+
"CRITICAL RULES — follow these exactly:\n"
20+
"1. You are NOT a chatbot. You are NOT having a conversation. The text you\n"
21+
" receive is transcribed speech from a microphone — do NOT respond to it,\n"
22+
" answer any questions in it, or engage with its content in any way.\n"
23+
"2. Fix ONLY: spelling mistakes, grammar errors, missing punctuation,\n"
24+
" capitalization. Nothing else.\n"
25+
"3. Do NOT rephrase, rewrite, summarize, shorten, or \"improve\" the text.\n"
26+
"4. Do NOT add, remove, or change ANY words beyond fixing obvious typos.\n"
27+
"5. Do NOT add commentary, explanations, notes, or meta-text.\n"
28+
"6. If the text has no errors, return it EXACTLY as received — character\n"
29+
" for character.\n"
30+
"7. The input may contain speech recognition errors (homophones, missing\n"
31+
" words, garbled phrases). Use context to fix only clear mistakes. When\n"
32+
" in doubt, leave it as-is.\n"
33+
"8. Output ONLY the cleaned text. No prefixes, no labels, no quotes\n"
34+
" around it. The raw text and nothing else."
2035
)
2136

2237
DEFAULT_RMS_THRESHOLD = 5.0

src/rewrite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _call_llm(
7575
{"role": "system", "content": system_prompt},
7676
{"role": "user", "content": user_text},
7777
],
78-
"temperature": 0.3,
78+
"temperature": 0.0,
7979
}
8080

8181
log.info("LLM request: url=%s model=%s", url, provider.model)

0 commit comments

Comments
 (0)