Gauntlet-Incept MCP
by Birdsmith
- src
- utils
/**
* LLM Utilities
*
* This file provides utilities for interacting with Large Language Models (LLMs)
* for content generation, tagging, and grading.
*/
/**
* Call an LLM with a prompt and optional parameters
*
* @param {string} prompt - The prompt to send to the LLM
* @param {Object} params - Additional parameters for the LLM call
* @returns {string} The LLM response
*/
async function callLLM(prompt, params = {}) {
try {
// TODO: Implement actual LLM API call
console.log('Calling LLM with prompt:', prompt.substring(0, 50) + '...');
// Placeholder implementation
const response = `This is a placeholder response from the LLM. In a real implementation,
this would be the result of calling an actual LLM API with the provided prompt and parameters.`;
return response;
} catch (error) {
console.error('Error calling LLM:', error);
throw new Error('Failed to call LLM: ' + error.message);
}
}
/**
* Create a prompt for tagging content
*
* @param {string} content - The content to tag
* @param {string} contentType - The type of content (question or article)
* @returns {string} The tagging prompt
*/
function createTaggingPrompt(content, contentType) {
return `
You are an expert educational content tagger. Your task is to analyze the following ${contentType}
and identify its subject, grade level, educational standard, and lesson.
${contentType.charAt(0).toUpperCase() + contentType.slice(1)}:
${content}
Please provide the following information:
- Subject (math, language, science, social studies)
- Grade level (K-8)
- Standard (CCSS for math and language, NGSS for science)
- Lesson
${contentType === 'question' ? '- Difficulty level (1-3, where 1 is easy, 2 is medium, 3 is hard)' : ''}
Format your response as a JSON object.
`;
}
/**
* Create a prompt for grading content
*
* @param {string} content - The content to grade
* @param {Object} tags - The tags for the content
* @param {string} contentType - The type of content (question or article)
* @returns {string} The grading prompt
*/
function createGradingPrompt(content, tags, contentType) {
let qualityCriteria = '';
if (contentType === 'question') {
qualityCriteria = `
1. Consistent with the preceding teaching article
2. Appropriate categorization (subject, grade, standard, lesson, difficulty)
3. All parts present (prompt, interaction type, choices, correct answer, wrong answer explanations, solution)
4. Designated correct answer is accurate
5. None of the distractors can be considered correct
6. At least 2 distractors for multiple choice must be plausible
7. The right answer can't stand out so that students can guess without knowing the concept
8. Clear explanations for each wrong answer
9. Clear solution for how to get the correct answer
10. Grade level appropriate language
11. Consistent wording that is clear, direct, and unambiguous
12. Grammatically correct
13. Properly formatted
`;
} else {
qualityCriteria = `
1. Appropriate categorization (subject, grade, standard, lesson)
2. Explicitly teaches, with worked examples, the concepts and procedures
3. Worked examples break down steps for students with lower working memory capacity
4. Factually accurate
5. Grade level appropriate language
6. Clear and unambiguous wording
7. Properly formatted
8. Consistent explanations throughout
`;
}
return `
You are an expert educational content evaluator. Your task is to grade the following ${contentType}
against quality standards for educational content.
${contentType.charAt(0).toUpperCase() + contentType.slice(1)}:
${content}
Tags:
${JSON.stringify(tags, null, 2)}
Quality Criteria:
${qualityCriteria}
Please evaluate the ${contentType} against each quality criterion and provide:
1. A pass/fail determination for each criterion
2. An overall pass/fail determination
3. Detailed feedback explaining any failures and how to improve
Format your response as a JSON object with 'pass' (boolean), 'scorecard' (object with criterion names as keys and boolean values), and 'feedback' (string) properties.
`;
}
/**
* Create a prompt for generating content
*
* @param {Object} tags - The tags for the content to generate
* @param {string} exampleContent - An example content to base the generation on
* @param {string} contentType - The type of content (question or article)
* @returns {string} The generation prompt
*/
function createGenerationPrompt(tags, exampleContent, contentType) {
let instructions = '';
if (contentType === 'question') {
instructions = `
Create a high-quality educational question with the following characteristics:
1. Multiple choice format with 4 options
2. One clearly correct answer
3. Plausible distractors that represent common misconceptions
4. Clear explanations for why each distractor is incorrect
5. A step-by-step solution showing how to arrive at the correct answer
6. Grade-appropriate language and complexity
7. Clear and unambiguous wording
`;
} else {
instructions = `
Create a high-quality educational article with the following characteristics:
1. Direct Instruction style with clear explanations
2. At least 2 worked examples that break down the steps
3. Grade-appropriate language and complexity
4. Clear and unambiguous wording
5. Proper formatting with headings and sections
6. Factually accurate content
`;
}
let prompt = `
You are an expert educational content creator. Your task is to generate a ${contentType}
for the following subject, grade level, standard, and lesson.
Tags:
${JSON.stringify(tags, null, 2)}
Instructions:
${instructions}
`;
if (exampleContent) {
prompt += `
Example ${contentType} (create a different but similar ${contentType}):
${exampleContent}
`;
}
return prompt;
}
module.exports = {
callLLM,
createTaggingPrompt,
createGradingPrompt,
createGenerationPrompt
};