milwright commited on
Commit
18f0d59
·
1 Parent(s): 6e0c330

fix: implement constrained prompts matching tool-calling behavior

Browse files

- Add exact format requirements to each question type
- Enforce word limits (15-25 words per response)
- Specify response patterns like 'This is a [noun/verb]' format
- Reduce max_tokens from 100 to 50 for concise responses
- Match the quality and constraint of original tool-calling approach

Files changed (2) hide show
  1. src/aiService.js +2 -2
  2. src/conversationManager.js +7 -4
src/aiService.js CHANGED
@@ -44,12 +44,12 @@ class OpenRouterService {
44
  model: this.model,
45
  messages: [{
46
  role: 'system',
47
- content: 'You provide clues for word puzzles. Give useful information about grammar, meaning, or context. Keep responses short and focused. Never reveal the actual word.'
48
  }, {
49
  role: 'user',
50
  content: prompt
51
  }],
52
- max_tokens: 100,
53
  temperature: 0.6
54
  })
55
  });
 
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 the word limits specified.'
48
  }, {
49
  role: 'user',
50
  content: prompt
51
  }],
52
+ max_tokens: 50,
53
  temperature: 0.6
54
  })
55
  });
src/conversationManager.js CHANGED
@@ -104,10 +104,13 @@ class ChatService {
104
  const baseContext = `From "${bookTitle}" by ${author}: "${sentence}"`;
105
 
106
  const prompts = {
107
- part_of_speech: `${baseContext}\n\nWhat part of speech is the missing word? Look at the sentence structure.`,
108
- sentence_role: `${baseContext}\n\nWhat grammatical role does the missing word play? How does it function in the sentence?`,
109
- word_category: `${baseContext}\n\nIs the missing word concrete or abstract? What type of concept does it represent?`,
110
- synonym: `${baseContext}\n\nWhat's a related word or concept that would fit in this blank?`
 
 
 
111
  };
112
 
113
  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\nRespond with exactly this format: "This is a [noun/verb/adjective/adverb]" then add one simple, concrete clue about what type (e.g., "a thing", "an action", "describes something"). Keep it under 20 words total.`,
108
+
109
+ sentence_role: `${baseContext}\n\nPoint to specific words around the blank. Example format: "Look at 'the [words before] ____ [words after]' - what could [function]?" Focus only on the immediate context. Keep under 25 words.`,
110
+
111
+ word_category: `${baseContext}\n\nStart with exactly: "This is abstract" or "This is concrete." Then give one relatable example or size clue: "Think about something very [big/small]" or "Like [feelings/objects]". Keep under 20 words total.`,
112
+
113
+ synonym: `${baseContext}\n\nUse this format: "Try a word similar to [related word]" or "Think of another word for [meaning]". Give direct synonyms or word families only. Keep under 15 words.`
114
  };
115
 
116
  return prompts[questionType] || `${baseContext}\n\nProvide a helpful hint about the missing word without revealing it.`;