From 1b1fe535da3525a0f72a3d76b8d74c81b138e4fc Mon Sep 17 00:00:00 2001 From: Daniel Onyejesi Date: Tue, 24 Mar 2026 19:22:51 -0400 Subject: [PATCH] Increase PDF/doc context to 50k chars, raise maxTokens ceiling to 8k MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Supports large PDFs (~30 pages) from upload and Nextcloud. maxTokens is a ceiling, not a target — short topics still get short responses. --- src/routes/learningAI.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/learningAI.js b/src/routes/learningAI.js index 8b18b55..b6c5714 100644 --- a/src/routes/learningAI.js +++ b/src/routes/learningAI.js @@ -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();