feat: reduce initial question batch size for a topic to 5
When a topic's quiz bank is empty (or below the requested count), we previously seeded it with a fresh batch of 10 questions. That meant the first weekly quiz for any new topic triggered a 10-question LLM call — heavy for what's ultimately a 1-question sample for review topics, and overkill for the typical 5-question primary topic. - forceGenerateTopicQuestions default count: 10 → 5 - getOrGenerateTopicQuestions seed amount: 10 → 5 - TestManager "Generate" defaults + empty-state button copy: 10 → 5 - QUIZ_SYSTEM difficulty hint: rewritten for a 5-question batch (2 easy / 2 medium / 1 hard) with explicit "scale proportionally for larger batches" so admins can still generate 10+ via TestManager when they want more depth. Tests 61/61 pass, lint clean (0 errors), build clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ const TestManager = () => {
|
|||||||
loadData();
|
loadData();
|
||||||
}, [selectedTopic]);
|
}, [selectedTopic]);
|
||||||
|
|
||||||
const handleGenerate = async (topic, count = 10) => {
|
const handleGenerate = async (topic, count = 5) => {
|
||||||
setLoadingTopicId(topic.id);
|
setLoadingTopicId(topic.id);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
@@ -97,8 +97,8 @@ const TestManager = () => {
|
|||||||
{questions.length === 0 ? (
|
{questions.length === 0 ? (
|
||||||
<Card className="text-center py-12 text-fg-muted border-dashed border-2">
|
<Card className="text-center py-12 text-fg-muted border-dashed border-2">
|
||||||
<p>No questions generated for this topic yet.</p>
|
<p>No questions generated for this topic yet.</p>
|
||||||
<Button className="mt-4" onClick={() => handleGenerate(selectedTopic, 10)} disabled={loadingTopicId === selectedTopic.id}>
|
<Button className="mt-4" onClick={() => handleGenerate(selectedTopic, 5)} disabled={loadingTopicId === selectedTopic.id}>
|
||||||
Generate 10 Questions
|
Generate 5 Questions
|
||||||
</Button>
|
</Button>
|
||||||
</Card>
|
</Card>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const QUIZ_SYSTEM = `You are a quiz generator for Respellion, an internal IT com
|
|||||||
You generate multiple-choice questions to test employee knowledge on specific topics.
|
You generate multiple-choice questions to test employee knowledge on specific topics.
|
||||||
Always write in clear, professional English.
|
Always write in clear, professional English.
|
||||||
|
|
||||||
Emit questions through the emit_quiz_questions tool. Each question has exactly four options; correctIndex is 0-based; mix difficulty roughly 4 easy / 4 medium / 2 hard.`;
|
Emit questions through the emit_quiz_questions tool. Each question has exactly four options; correctIndex is 0-based. For a typical 5-question batch, mix difficulty roughly 2 easy / 2 medium / 1 hard; scale the ratio proportionally for larger batches.`;
|
||||||
|
|
||||||
const cachedSystem = (text) => [{ type: 'text', text, cache_control: { type: 'ephemeral' } }];
|
const cachedSystem = (text) => [{ type: 'text', text, cache_control: { type: 'ephemeral' } }];
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ export async function getCachedQuiz(userId, weekNumber) {
|
|||||||
return db.getCachedQuiz(userId, weekNumber);
|
return db.getCachedQuiz(userId, weekNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function forceGenerateTopicQuestions(topic, count = 10) {
|
export async function forceGenerateTopicQuestions(topic, count = 5) {
|
||||||
let bank = await db.getQuizBank(topic.id);
|
let bank = await db.getQuizBank(topic.id);
|
||||||
|
|
||||||
const prompt = `Generate exactly ${count} multiple-choice quiz questions for this knowledge topic and emit them via the emit_quiz_questions tool:
|
const prompt = `Generate exactly ${count} multiple-choice quiz questions for this knowledge topic and emit them via the emit_quiz_questions tool:
|
||||||
@@ -105,7 +105,9 @@ async function getOrGenerateTopicQuestions(topic, count) {
|
|||||||
let bank = await db.getQuizBank(topic.id);
|
let bank = await db.getQuizBank(topic.id);
|
||||||
|
|
||||||
if (bank.length < count) {
|
if (bank.length < count) {
|
||||||
await forceGenerateTopicQuestions(topic, 10);
|
// Seed an empty/low bank with a small initial batch; admins can grow it
|
||||||
|
// explicitly via TestManager when they want more depth per topic.
|
||||||
|
await forceGenerateTopicQuestions(topic, 5);
|
||||||
bank = await db.getQuizBank(topic.id);
|
bank = await db.getQuizBank(topic.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user