milwright commited on
Commit
bd503ab
·
1 Parent(s): 9c565fb

improve: implement better prompt engineering with word concealment and simplified hints

Browse files
Files changed (1) hide show
  1. src/conversationManager.js +8 -13
src/conversationManager.js CHANGED
@@ -94,24 +94,23 @@ class ChatService {
94
  console.warn('AI response failed:', error);
95
  }
96
 
97
- // Fallback - return enhanced fallback response without revealing word
98
- const fallback = this.getSimpleFallback(context, questionType);
99
- return fallback.response;
100
  }
101
 
102
- // Build focused prompt for specific question types with level awareness
103
  buildFocusedPrompt(context, questionType, userInput) {
104
  const { sentence, bookTitle, author } = context;
105
  const baseContext = `From "${bookTitle}" by ${author}: "${sentence}"`;
106
 
107
  const prompts = {
108
- 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.`,
109
 
110
- 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.`,
111
 
112
- 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.`,
113
 
114
- 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.`
115
  };
116
 
117
  return prompts[questionType] || `${baseContext}\n\nProvide a helpful hint about the missing word without revealing it.`;
@@ -126,11 +125,7 @@ class ChatService {
126
  synonym: "What other word could fit in this same spot with similar meaning?"
127
  };
128
 
129
- return {
130
- success: true,
131
- response: fallbacks[questionType] || "Consider the context and what word would make sense here.",
132
- questionType: questionType
133
- };
134
  }
135
 
136
 
 
94
  console.warn('AI response failed:', error);
95
  }
96
 
97
+ // Fallback - return simple fallback response
98
+ return this.getSimpleFallback(context, questionType);
 
99
  }
100
 
101
+ // Build focused prompt for specific question types
102
  buildFocusedPrompt(context, questionType, userInput) {
103
  const { sentence, bookTitle, author } = context;
104
  const baseContext = `From "${bookTitle}" by ${author}: "${sentence}"`;
105
 
106
  const prompts = {
107
+ part_of_speech: `${baseContext}\n\nWhat type of word fits in the blank? Say "This is a [noun/verb/adjective/adverb]" then give a grammatical hint about its function. Maximum 20 words. Never reveal the word.`,
108
 
109
+ sentence_role: `${baseContext}\n\nWhat meaning role does the blank serve? Does it express action, emotion, description, or relationship? Maximum 20 words.`,
110
 
111
+ word_category: `${baseContext}\n\nWhat category does this word belong to? Say "This word describes [general category]" without giving specific examples. Maximum 20 words.`,
112
 
113
+ synonym: `${baseContext}\n\nGive a conceptual hint. Format: "Think of something that [general description of concept]." Be indirect and conceptual. Maximum 20 words.`
114
  };
115
 
116
  return prompts[questionType] || `${baseContext}\n\nProvide a helpful hint about the missing word without revealing it.`;
 
125
  synonym: "What other word could fit in this same spot with similar meaning?"
126
  };
127
 
128
+ return fallbacks[questionType] || "Consider the context and what word would make sense here.";
 
 
 
 
129
  }
130
 
131