Questions: 300 characters, refused when they look like prompt injection
Three layers for the text users write into a prompt (questions about an analysis, tarot questions): - analysis_prompt::guard cleans it (controls, zero-width characters, spaces, empty lines) and refuses links, tags, code fences, chat role labels, more than 6 lines and phrases that try to change the model's instructions (Hungarian and English, accent-insensitive). The check runs before any unit is spent; refusals are logged without the text. - The prompt puts the question (and earlier ones) between <kerdes> tags, with anything that could close the tag neutralized. - The system prompts say the tagged text is data, not instructions, and not to quote or summarize the rules (the tarot prompts now say it too). The question limit drops from 600 to 300 characters (as for tarot), with a counter always shown under the box. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -12,7 +12,8 @@ import { RegenerateButton } from "./RegenerateButton";
|
||||
import { RetryNotice } from "./RetryNotice";
|
||||
import { Paragraphs } from "./Rich";
|
||||
|
||||
const MAX_CHARS = 600;
|
||||
/** The longest question (the backend checks it too: QUESTION_MAX_CHARS). */
|
||||
const MAX_CHARS = 300;
|
||||
|
||||
export const QUESTION_TEXTS = {
|
||||
natal: {
|
||||
@@ -221,7 +222,9 @@ export function AnalysisQuestions({
|
||||
</button>
|
||||
<span className="hint">
|
||||
{waiting ? "Várd meg az előző válaszát." : `Még ${left} kérdésed van.`}{" "}
|
||||
{text.length > MAX_CHARS - 100 && `${text.length}/${MAX_CHARS}`}
|
||||
<span className="num" aria-live="polite">
|
||||
· {text.length}/{MAX_CHARS}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
{error && (
|
||||
|
||||
@@ -207,7 +207,10 @@ export function TarotTable({
|
||||
onChange={(e) => setQuestion(e.target.value)}
|
||||
/>
|
||||
<span className="hint">
|
||||
Nyitott kérdés működik a legjobban („mire figyeljek”, „mit tanulhatok”), nem igen–nem kérdés.
|
||||
Nyitott kérdés működik a legjobban („mire figyeljek”, „mit tanulhatok”), nem igen–nem kérdés.{" "}
|
||||
<span className="num">
|
||||
{question.length}/{TAROT_QUESTION_MAX}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
|
||||
Reference in New Issue
Block a user