Increase PDF/doc context to 50k chars, raise maxTokens ceiling to 8k

Supports large PDFs (~30 pages) from upload and Nextcloud.
maxTokens is a ceiling, not a target — short topics still get short responses.
This commit is contained in:
Daniel Onyejesi 2026-03-24 19:22:51 -04:00
parent feb47b5e79
commit 1b1fe535da

View file

@ -55,7 +55,7 @@ function buildGeneratePrompt(opts) {
var { topic, docText, contentType, questionCount, refinement, wordCount, slideCount } = opts;
var source = docText
? 'Based on the following document/resource text, generate educational content.\n\nDOCUMENT:\n"""\n' + docText.substring(0, 12000) + '\n"""\n'
? 'Based on the following document/resource text, generate educational content.\n\nDOCUMENT:\n"""\n' + docText.substring(0, 50000) + '\n"""\n'
: 'Generate educational content on the following topic for a medical professional audience (pediatrics / primary care).\n\nTOPIC: ' + topic + '\n';
var refineInstr = refinement ? '\n\nAdditional instructions for tone/style/focus: ' + refinement : '';
@ -206,7 +206,7 @@ router.post('/ai-generate', upload.single('file'), async function(req, res) {
{ role: 'system', content: 'You are a medical education content generator. Return ONLY the requested JSON or Marp markdown — no preamble, no commentary, no code fences, no thinking. Start your response with { or --- as appropriate.' },
{ role: 'user', content: prompt }
],
{ model: model, temperature: 0.4, maxTokens: 6000 }
{ model: model, temperature: 0.4, maxTokens: 8000 }
);
var raw = result.content.trim();