fix: Improve knowledge limit detection and response handling

- Increase token limit to 250 for knowledge limit responses to prevent truncation
- Streamline system prompts for more concise and effective explanations
- Improve knowledge limit detection patterns to include confusion phrases:
  - 'was das bedeutet' (what that means)
  - 'was genau passiert' (what exactly happens)
  - 'das verstehe ich nicht' (I don't understand that)
- Make knowledge limit triggers more sensitive (1 instead of 2+ occurrences)
- Provide clearer example structure for AI responses
- Ensure complete explanations with proper transitions to next fundamentals

Fixes:
- No more truncated explanations mid-sentence
- Better detection of when children reach knowledge limits
- Smoother progression through fundamentals
- More encouraging and less frustrating experience
- Complete responses that include acknowledgment + explanation + transition + next question
This commit is contained in:
root
2025-07-02 15:15:40 +02:00
parent 02d7a1d552
commit 008af06bd1

View File

@@ -936,30 +936,28 @@ Original question: "${originalTopic}"`;
} else if (hasReachedKnowledgeLimit) { } else if (hasReachedKnowledgeLimit) {
// NEW: Child has reached knowledge limit on current fundamental - provide explanation and move to next // NEW: Child has reached knowledge limit on current fundamental - provide explanation and move to next
systemPrompt = isGerman systemPrompt = isGerman
? `Du bist ein geduldiger Lernbegleiter. Ein Kind hat bei einer Grundlage seine Wissensgrenze erreicht und braucht jetzt eine klare Erklärung. ? `Du bist ein geduldiger Lernbegleiter. Ein Kind hat seine Wissensgrenze erreicht und braucht eine Erklärung plus Übergang zur nächsten Grundlage.
AUFGABE - FUNDAMENTALS FIRST mit Erklärung: AUFGABE:
1. Erkenne an, dass das Kind sein Bestes versucht hat 1. Kurze Anerkennung: "Das ist völlig in Ordnung!"
2. Gib eine KURZE, klare Erklärung der aktuellen Grundlage (2-3 Sätze) 2. KURZE Erklärung in 1-2 Sätzen
3. Leite zur nächsten Grundlage über: "Jetzt verstehen wir [erste Grundlage]! Lass uns zur nächsten Grundlage gehen: [zweite Grundlage]..." 3. Übergang: "Jetzt verstehen wir [Grundlage]! Zur nächsten Grundlage: [nächste]..."
4. Stelle EINE einfache Frage zur nächsten Grundlage 4. EINE Frage zur nächsten Grundlage
BEISPIEL STRUKTUR: BEISPIEL: "Das ist völlig in Ordnung! UV-Strahlung ist unsichtbares Sonnenlicht, das Hautzellen schädigt. Jetzt verstehen wir UV-Strahlung! Zur nächsten Grundlage: Hautzellen. Was denkst du, woraus Haut besteht?"
"Das ist völlig in Ordnung! Lass mich dir helfen: [Kurze Erklärung der aktuellen Grundlage]. Jetzt verstehen wir [erste Grundlage]! Lass uns zur nächsten Grundlage gehen: [zweite Grundlage]. [Eine Frage zur zweiten Grundlage]?"
STIL: Ermutigend, nicht frustrierend, systematisch weiterführend.` WICHTIG: Kurz und klar halten!`
: `You are a patient learning companion. A child has reached their knowledge limit on a fundamental and needs a clear explanation. : `You are a patient learning companion. A child has reached their knowledge limit and needs explanation plus transition to next fundamental.
TASK - FUNDAMENTALS FIRST with explanation: TASK:
1. Acknowledge that the child tried their best 1. Brief acknowledgment: "That's perfectly okay!"
2. Give a BRIEF, clear explanation of the current fundamental (2-3 sentences) 2. BRIEF explanation in 1-2 sentences
3. Transition to next fundamental: "Now we understand [first fundamental]! Let's move to the next fundamental: [second fundamental]..." 3. Transition: "Now we understand [fundamental]! Next fundamental: [next]..."
4. Ask ONE simple question about the next fundamental 4. ONE question about next fundamental
EXAMPLE STRUCTURE: EXAMPLE: "That's perfectly okay! UV radiation is invisible sunlight that damages skin cells. Now we understand UV radiation! Next fundamental: skin cells. What do you think skin is made of?"
"That's perfectly okay! Let me help you: [Brief explanation of current fundamental]. Now we understand [first fundamental]! Let's move to the next fundamental: [second fundamental]. [One question about second fundamental]?"
STYLE: Encouraging, not frustrating, systematically progressing.`; IMPORTANT: Keep it short and clear!`;
userPrompt = isGerman userPrompt = isGerman
? `Ein Kind hat seine Wissensgrenze bei einer Grundlage erreicht. ? `Ein Kind hat seine Wissensgrenze bei einer Grundlage erreicht.
@@ -1201,7 +1199,7 @@ Stay structured and systematic!`;
{ role: "system", content: systemPrompt }, { role: "system", content: systemPrompt },
{ role: "user", content: userPrompt } { role: "user", content: userPrompt }
], ],
max_tokens: 120, // Increased to handle German compound words and prevent truncation max_tokens: hasReachedKnowledgeLimit ? 250 : 120, // Even more tokens for complete knowledge limit explanations
temperature: 0.7 temperature: 0.7
}); });