From 77da7aea6cce395f27c557470aacaf2a4a79a902 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 1 Apr 2026 12:57:28 +0200 Subject: [PATCH] Restore original verbatim extraction prompt; switch to Claude Opus 4.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extraction prompt: - Restored full original prompt with strict verbatim instructions - Explanation field: must include full explanation paragraph + Critique verbatim + Content Specifications verbatim (no summarization) - Correct answer: explicit step-by-step with example showing letter→full text - Options: extract full text only, no letter prefix - All 5 rules numbered and explicit Model switch: - Default extraction model changed from Claude Haiku 4.5 → Claude Opus 4.6 - Haiku tends to compress/summarize long explanation text - Opus 4.6 follows verbatim instructions reliably and handles the structured PREP format (explanation + Critique + Content Specs) without losing content - Haiku 4.5 still available in the Extraction Model dropdown for cost-sensitive use cases Co-Authored-By: Claude Sonnet 4.6 (1M context) --- backend/app/services/ai_service.py | 47 ++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/backend/app/services/ai_service.py b/backend/app/services/ai_service.py index 7bed936..44a1d2d 100644 --- a/backend/app/services/ai_service.py +++ b/backend/app/services/ai_service.py @@ -16,34 +16,45 @@ def _proxy_model(model_id: str) -> str: EXTRACTION_PROMPT = """You are extracting questions from a PREP (Pediatric Review and Education Program) exam PDF. -These PDFs have questions with a clinical vignette, followed by five answer options A-E. -Some PDFs include "Correct Answer: X" or "Preferred Response: X" right after the options. -Some PDFs have the correct answers only at the END of the document — in that case correct_answer will be null. +These PDFs follow a strict format: +1. A numbered question with a clinical vignette (patient scenario) +2. Five answer options labeled A, B, C, D, E +3. A line "Correct Answer: X" or "Preferred Response: X" where X is the letter of the correct option +4. An explanation paragraph +5. A "Critique:" section with detailed reasoning +6. A "Content Specifications:" section listing the learning objectives -Return ONLY a JSON object: +Your task: extract every question and return ONLY a JSON object in this exact format: {{"questions": [ {{ - "item_number": "", - "question_text": "", + "item_number": "", + "question_text": "", "question_type": "mcq", "options": ["