Separate settings per generation step; explain Practice and Exam on shares
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 29s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 29s
- Settings -> AI: Planning, Writing, Python check and Second review each get their own model, reasoning effort, temperature and output limit, shown under Content generation. Unset choices follow Content generation, then the default model. - Shared quizzes say what Practice and Exam mean under the mode toggle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2454ab6e95
commit
10be5c39da
9 changed files with 128 additions and 36 deletions
|
|
@ -778,7 +778,7 @@ export function startGeneration(
|
|||
if (!folder || (req.classId && folder.class_id !== req.classId)) throw badRequest('That exam is not part of this class.');
|
||||
}
|
||||
// Fail fast (before creating a draft) when no model is configured.
|
||||
const resolved = resolveModel(app, 'generate', req.modelId);
|
||||
const resolved = resolveModel(app, 'write', req.modelId);
|
||||
const draftId = createDraft(app.db, {
|
||||
kind: req.kind,
|
||||
classId: req.classId ?? null,
|
||||
|
|
@ -856,7 +856,7 @@ async function runWithRestart(app: AppContext, draftId: string, req: GenerateReq
|
|||
|
||||
async function runGeneration(app: AppContext, draftId: string, req: GenerateRequest, signal: AbortSignal): Promise<void> {
|
||||
const { db } = app;
|
||||
const resolved = resolveModel(app, 'generate', req.modelId);
|
||||
const resolved = resolveModel(app, 'write', req.modelId);
|
||||
const window = resolved.model.contextWindow ?? 32_000;
|
||||
const budgetTokens = Math.max(2_500, Math.min(Math.floor(window * 0.4), 28_000));
|
||||
setProgress(db, draftId, 0.03, 'Reading your material');
|
||||
|
|
@ -944,7 +944,7 @@ async function runGeneration(app: AppContext, draftId: string, req: GenerateRequ
|
|||
const user = [math ? '' : sourceBlock(sources, index), ask.filter(Boolean).join('\n')].filter(Boolean).join('\n\n======\n\n');
|
||||
|
||||
const result = await generateStructured(app, {
|
||||
task: 'generate',
|
||||
task: 'write',
|
||||
purpose: isQuiz ? 'quiz generation' : 'flashcard generation',
|
||||
modelId: req.modelId,
|
||||
system,
|
||||
|
|
@ -992,7 +992,7 @@ async function runGeneration(app: AppContext, draftId: string, req: GenerateRequ
|
|||
if (!isQuiz || n <= 0) return [];
|
||||
try {
|
||||
const result = await generateStructured(app, {
|
||||
task: 'generate',
|
||||
task: 'plan',
|
||||
purpose: 'planning questions',
|
||||
modelId: req.modelId,
|
||||
system: `${baseSystem(db, req, hasSources)}\n\nYou plan NCLEX-style quizzes. List distinct angles, one per question: each names the client situation and the single decision or fact it tests, in one line (for example "Continuous IV heparin, aPTT 3x control with gum bleeding: first action"). No two angles may test the same decision, fact or teaching point, even in a different scenario. Spread them over the client-needs areas the material supports (pharmacology, safety, prioritisation, delegation, teaching, lab values, complications, psychosocial). When the material is short, vary the situations and the area tested rather than repeating its points.`,
|
||||
|
|
@ -1016,7 +1016,7 @@ async function runGeneration(app: AppContext, draftId: string, req: GenerateRequ
|
|||
toolName: 'plan_questions',
|
||||
toolDescription: 'Submit the planned angles.',
|
||||
schema: { type: 'object', properties: { angles: { type: 'array', items: { type: 'string' } } }, required: ['angles'] },
|
||||
maxOutputTokens: outputBudget(resolved, 8_000),
|
||||
maxOutputTokens: outputBudget(resolveModel(app, 'plan', req.modelId), 8_000),
|
||||
signal,
|
||||
});
|
||||
const list = (result.data as { angles?: unknown }).angles;
|
||||
|
|
@ -1271,7 +1271,7 @@ export async function nameSet(
|
|||
|
||||
async function generateNote(app: AppContext, draftId: string, req: GenerateRequest, signal: AbortSignal, budgetTokens: number, window: number): Promise<void> {
|
||||
const { db } = app;
|
||||
const resolved = resolveModel(app, 'generate', req.modelId);
|
||||
const resolved = resolveModel(app, 'write', req.modelId);
|
||||
const style = req.noteStyle ?? 'study_guide';
|
||||
// A guide reads the material in as few passes as possible; allow a bigger slice per pass than item generation.
|
||||
const perPass = Math.max(budgetTokens, Math.min(Math.floor(window * 0.55), 90_000));
|
||||
|
|
@ -1304,7 +1304,7 @@ async function generateNote(app: AppContext, draftId: string, req: GenerateReque
|
|||
if (passes.length <= 1) {
|
||||
setProgress(db, draftId, 0.2, 'Writing');
|
||||
const body = [passes[0]?.length ? `SOURCE EXCERPTS:\n\n${formatExcerpts(passes[0])}` : '', sources.inline, ask].filter(Boolean).join('\n\n======\n\n');
|
||||
const res = await runChatWithMcp(app, { task: 'generate', purpose: 'study guide', modelId: req.modelId, system, messages: [{ role: 'user', content: [{ type: 'text', text: body }] }], maxOutputTokens: outputBudget(resolved, 16_000), signal }, 'generate');
|
||||
const res = await runChatWithMcp(app, { task: 'write', purpose: 'study guide', modelId: req.modelId, system, messages: [{ role: 'user', content: [{ type: 'text', text: body }] }], maxOutputTokens: outputBudget(resolved, 16_000), signal }, 'generate');
|
||||
content = res.text;
|
||||
} else {
|
||||
// Long material: condense each part, then write the final piece from the condensed notes.
|
||||
|
|
@ -1313,7 +1313,7 @@ async function generateNote(app: AppContext, draftId: string, req: GenerateReque
|
|||
if (signal.aborted) throw new AIError('aborted', 'Generation was cancelled.');
|
||||
setProgress(db, draftId, 0.05 + (0.7 * i) / passes.length, `Reading part ${i + 1} of ${passes.length}`);
|
||||
const res = await runChat(app, {
|
||||
task: 'generate',
|
||||
task: 'write',
|
||||
purpose: 'study guide',
|
||||
modelId: req.modelId,
|
||||
system: `${baseSystem(db, req, true)}\n\nCondense this part of the material into detailed notes: every key concept, value, medication, cause, sign, intervention and warning, as Markdown bullet points under short headings. Keep the bracketed excerpt ids (e.g. [c42]) next to the points they support. Do not add outside information.`,
|
||||
|
|
@ -1327,7 +1327,7 @@ async function generateNote(app: AppContext, draftId: string, req: GenerateReque
|
|||
const res = await runChatWithMcp(
|
||||
app,
|
||||
{
|
||||
task: 'generate',
|
||||
task: 'write',
|
||||
purpose: 'study guide',
|
||||
modelId: req.modelId,
|
||||
system,
|
||||
|
|
@ -1387,7 +1387,7 @@ export function startImprove(app: AppContext, input: z.input<typeof improveReque
|
|||
if (req.questionIds?.length) questions = questions.filter((q) => req.questionIds!.includes(q.id));
|
||||
if (questions.length === 0) throw badRequest('No questions to improve');
|
||||
questions = questions.slice(0, 60);
|
||||
const resolved = resolveModel(app, 'generate', req.modelId);
|
||||
const resolved = resolveModel(app, 'write', req.modelId);
|
||||
const draftId = createDraft(app.db, {
|
||||
kind: 'quiz',
|
||||
classId: quiz.class_id,
|
||||
|
|
@ -1420,7 +1420,7 @@ Return the questions in the same order, one output question per input question.$
|
|||
)
|
||||
.join('\n\n');
|
||||
const result = await generateStructured(app, {
|
||||
task: 'generate',
|
||||
task: 'write',
|
||||
purpose: 'improve questions',
|
||||
modelId: req.modelId,
|
||||
system,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue