Spaces:
Running
Running
fix: improve word selection and remove markdown formatting
Browse files- Let AI model handle word difficulty filtering with specific instructions
- Remove hardcoded technical term filtering in favor of AI selection
- Add explicit instructions to avoid proper nouns, technical terms, archaic words
- Add markdown formatting removal instructions to all AI prompts
- Specify game context in chat prompts for better responses
- Reduce maximum word length from 10 to 8 letters for easier guessing
- src/aiService.js +3 -3
- src/clozeGameEngine.js +2 -1
- src/conversationManager.js +4 -4
src/aiService.js
CHANGED
@@ -44,7 +44,7 @@ class OpenRouterService {
|
|
44 |
model: this.model,
|
45 |
messages: [{
|
46 |
role: 'system',
|
47 |
-
content: 'You provide clues for word puzzles. Follow the EXACT format requested. Be concise and direct. Never reveal the actual word. Stick to
|
48 |
}, {
|
49 |
role: 'user',
|
50 |
content: prompt
|
@@ -96,10 +96,10 @@ class OpenRouterService {
|
|
96 |
model: this.model,
|
97 |
messages: [{
|
98 |
role: 'system',
|
99 |
-
content: '
|
100 |
}, {
|
101 |
role: 'user',
|
102 |
-
content: `
|
103 |
|
104 |
Passage: "${passage}"`
|
105 |
}],
|
|
|
44 |
model: this.model,
|
45 |
messages: [{
|
46 |
role: 'system',
|
47 |
+
content: 'You provide clues for word puzzles. Follow the EXACT format requested. Be concise and direct. Never reveal the actual word. Use plain text only - no bold, italics, asterisks, or markdown formatting. Stick to word limits.'
|
48 |
}, {
|
49 |
role: 'user',
|
50 |
content: prompt
|
|
|
96 |
model: this.model,
|
97 |
messages: [{
|
98 |
role: 'system',
|
99 |
+
content: 'Select words for cloze reading exercises. Choose common, everyday words that students know. Avoid proper nouns (names, places), technical terms, archaic words, and words over 8 letters. Pick words students can guess from surrounding context.'
|
100 |
}, {
|
101 |
role: 'user',
|
102 |
+
content: `Select exactly ${count} appropriate words for a cloze exercise. Choose common words students can guess from context. Avoid: proper nouns, technical terms, rare/archaic words, words over 8 letters. Return ONLY a JSON array of words.
|
103 |
|
104 |
Passage: "${passage}"`
|
105 |
}],
|
src/clozeGameEngine.js
CHANGED
@@ -292,7 +292,7 @@ class ClozeGame {
|
|
292 |
const contentWordIndices = [];
|
293 |
words.forEach((word, index) => {
|
294 |
const cleanWord = word.toLowerCase().replace(/[^\w]/g, '');
|
295 |
-
if (cleanWord.length > 3 && !functionWords.has(cleanWord)) {
|
296 |
contentWordIndices.push({ word: cleanWord, index });
|
297 |
}
|
298 |
});
|
@@ -511,6 +511,7 @@ class ClozeGame {
|
|
511 |
return this.chatService.getSuggestedQuestions(blankId);
|
512 |
}
|
513 |
|
|
|
514 |
// Enhanced render method to include chat buttons
|
515 |
renderClozeTextWithChat() {
|
516 |
let html = this.clozeText;
|
|
|
292 |
const contentWordIndices = [];
|
293 |
words.forEach((word, index) => {
|
294 |
const cleanWord = word.toLowerCase().replace(/[^\w]/g, '');
|
295 |
+
if (cleanWord.length > 3 && cleanWord.length <= 10 && !functionWords.has(cleanWord)) {
|
296 |
contentWordIndices.push({ word: cleanWord, index });
|
297 |
}
|
298 |
});
|
|
|
511 |
return this.chatService.getSuggestedQuestions(blankId);
|
512 |
}
|
513 |
|
514 |
+
|
515 |
// Enhanced render method to include chat buttons
|
516 |
renderClozeTextWithChat() {
|
517 |
let html = this.clozeText;
|
src/conversationManager.js
CHANGED
@@ -104,13 +104,13 @@ class ChatService {
|
|
104 |
const baseContext = `From "${bookTitle}" by ${author}: "${sentence}"`;
|
105 |
|
106 |
const prompts = {
|
107 |
-
part_of_speech: `${baseContext}\n\
|
108 |
|
109 |
-
sentence_role: `${baseContext}\n\
|
110 |
|
111 |
-
word_category: `${baseContext}\n\
|
112 |
|
113 |
-
synonym: `${baseContext}\n\
|
114 |
};
|
115 |
|
116 |
return prompts[questionType] || `${baseContext}\n\nProvide a helpful hint about the missing word without revealing it.`;
|
|
|
104 |
const baseContext = `From "${bookTitle}" by ${author}: "${sentence}"`;
|
105 |
|
106 |
const prompts = {
|
107 |
+
part_of_speech: `${baseContext}\n\nFor this cloze game, identify the part of speech needed in the blank. Respond exactly: "This is a [noun/verb/adjective/adverb]" then add ONE clue about its function. Maximum 15 words. No bold text or markdown.`,
|
108 |
|
109 |
+
sentence_role: `${baseContext}\n\nFor this cloze game, analyze the blank's sentence role. Format: "Look at [word before] ____ [word after] - what fits here?" Focus on immediate context. Maximum 18 words. No markdown.`,
|
110 |
|
111 |
+
word_category: `${baseContext}\n\nFor this cloze game, categorize the missing word. Start exactly: "This is abstract" or "This is concrete" then add ONE example. Maximum 12 words. No bold or italics.`,
|
112 |
|
113 |
+
synonym: `${baseContext}\n\nFor this cloze game, give a synonym clue. Format: "Try a word similar to [related concept]" or "Another word for [meaning]". Maximum 10 words. No markdown formatting.`
|
114 |
};
|
115 |
|
116 |
return prompts[questionType] || `${baseContext}\n\nProvide a helpful hint about the missing word without revealing it.`;
|