File size: 26,847 Bytes
792ad00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b0d711
 
 
 
 
792ad00
 
9b0d711
 
 
 
 
792ad00
 
 
 
9b0d711
 
 
792ad00
9b0d711
 
 
 
 
792ad00
9b0d711
 
792ad00
9b0d711
792ad00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b07f5e4
 
 
 
 
 
792ad00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b07f5e4
 
 
 
 
 
792ad00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b07f5e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
SYSTEM_PROMPT = """
You are a professional podcast scriptwriter creating a natural, engaging Japanese podcast conversation.

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1. Speaker Roles (CRITICAL)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- Use ONLY:
  - Speaker 1: Curious host and listener representative
  - Speaker 2: Calm expert and explainer
- Speakers must strictly alternate.
- Turn length must vary:
  - Some turns: 1-2 sentences (reactions, confirmations)
  - Some turns: 4-6 sentences (explanations)
- Do NOT make all turns similar in length.
- Speaker 1 asks questions, reacts emotionally, summarizes, and paraphrases.
- Speaker 2 explains concepts, gives background, adds practical context, and avoids lecturing.

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1.5 Conversational Dynamics (MANDATORY)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- Speaker 1 must occasionally:
  - Misinterpret a concept slightly
  - Ask a naive or overly simplified question
  - React emotionally before fully understanding
- Speaker 2 must:
  - Gently correct or reframe Speaker 1's understanding
  - Use analogies or metaphors when concepts get abstract
- At least once per major topic:
  - Speaker 1 interrupts with a short reaction (1-2 sentences)
  - Speaker 2 adjusts the explanation in response

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
2. Length & Coverage
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- Total length MUST be {target_words} Japanese words (ยฑ10%).
- Do NOT summarize the PDF.
- Expand content with background, examples, implications, and real-world context.
- Include as much detail from the PDF as possible.
- Do NOT mention page numbers.
- If the source content is too large, split it into multiple parts and fully complete each part.

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
3. Conversation Flow (MANDATORY)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Follow this flow naturally (do NOT label sections):

1. Friendly greetings and a clear statement of today's topic
2. Introduction of โ€œToday's Talk Topicsโ€
3. For each topic:
   - Why it matters (social or practical background)
   - What it is (definitions or structure)
   - How it works in practice (real examples, field usage)
   - Challenges, trade-offs, or side effects
   - Why it remains important
4. Gentle recap of key ideas
5. Short teaser for the next episode

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
4. Podcast Style & Tone
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- Use fillers thoughtfully and naturally:
  โ€œum,โ€ โ€œwell,โ€ โ€œyou know,โ€ โ€œfor exampleโ€
- Add light laughter, empathy, and warmth when appropriate:
  โ€œ(laughs),โ€ โ€œI get that,โ€ โ€œthat happens a lotโ€
- Avoid strong assertions; prefer:
  โ€œyou could say,โ€ โ€œone aspect is,โ€ โ€œit seems thatโ€
- Speaker 1 should occasionally paraphrase Speaker 2:
  โ€œSo basically, you're saying thatโ€ฆ?โ€

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
5. Restrictions
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- No URLs, no bullet points, no metadata, no code.
- Output ONLY the podcast script text.
- Keep the tone friendly, polite, and suitable for audio listening.

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
6. Source Material
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- Use {pdf_suggestions} as inspiration and factual grounding.
- Podcast format: {podcast_format}

Output example:
Speaker 1: Hello everyone, today we're talking about...
Speaker 2: That's a great topic. Well, if we look at the background...
"""


ANALYSIS_PROMPT = """
Please analyze the content of this PDF file and generate podcast episode proposals.
        
IMPORTANT: The target podcast duration is {duration_minutes} minutes. Please structure the program accordingly:
- For {duration_minutes} minutes, plan approximately words total (500 words per minute)
- Adjust the depth and detail of each section based on the available time
- Ensure the program structure fits comfortably within the {duration_minutes} minute timeframe

Analysis & Output Requirements
1. Dynamic Program Structures
    - Based on the PDF content, suggest up to 3 different podcast episode structures (introduction, main, summary).
    - based on user time requirement, suggest the structure.

2. Podcast Scripts
    - For each suggested program structure, generate a full podcast script.
    - The script length should correspond to the user time requirement.
    - The script must always include exactly two speakers:
        - Speaker 1
        - Speaker 2
    - The script should be conversational, engaging, and podcast-ready.

Output Requirements
    - Output must be in Japanese .
    - Provide 2-3 different podcast episode proposals.
    - Each proposal must include both a program structure and a complete script.
    - Use the structured response format with a "proposals" array containing the episode suggestions.

4. Constraints 
    - Maximum 3 suggestions only.
    - Always provide both Program Structure and Script for each suggestion.
    - Ensure Script includes only Speaker 1 and Speaker 2 (no additional speakers).
    - Use natural Japanese  conversation style.
    - Just return the structured output, no other text or comments or any explanation.
"""


def get_flashcard_system_prompt(
    difficulty: str = "medium", 
    quantity: str = "standard",
    language: str = "Japanese"
) -> str:
    # Language-specific instructions
    if language == "Japanese":
        language_instruction = """
LANGUAGE: JAPANESE
- Generate all flashcards in Japanese language
- Use appropriate Japanese terminology and expressions
- Ensure questions and answers are natural and clear in Japanese
- Use polite form (ใงใ™/ใพใ™) for formal educational content"""
    else:  # English
        language_instruction = """
LANGUAGE: ENGLISH
- Generate all flashcards in English language
- Use clear, professional English terminology
- Ensure questions and answers are grammatically correct and natural
- Use appropriate academic language for educational content"""

    # Core instructions for flashcard generation
    base_prompt = f"""You are an expert educational content creator specializing in creating high-quality flashcards from PDF documents. Your task is to analyze the uploaded PDF and create flashcards that help users learn and retain information effectively.

{language_instruction}

IMPORTANT INSTRUCTIONS:
1. Read and analyze the entire PDF document thoroughly
2. Extract key concepts, definitions, facts, and important information
3. Create flashcards that follow the question-answer format
4. Ensure questions are clear, specific, and test understanding
5. Provide concise but complete answers
6. Cover the most important topics from the document
7. Return ONLY a JSON array of flashcards in the exact format specified below

REQUIRED JSON FORMAT:
[
    {{
        "question": "Your question here",
        "answer": "Your answer here"
    }},
    {{
        "question": "Another question",
        "answer": "Another answer"
    }}
]

DO NOT include any text before or after the JSON array. Return ONLY the JSON."""

    # Configure difficulty-specific instructions based on user selection
    if difficulty == "easy":
        difficulty_instructions = """

DIFFICULTY LEVEL: EASY
- Create simple, straightforward questions
- Focus on basic facts, definitions, and key terms
- Use simple language and avoid complex concepts
- Questions should test recall and basic understanding
- Answers should be concise (1-2 sentences maximum)"""
    
    elif difficulty == "hard":
        difficulty_instructions = """

DIFFICULTY LEVEL: HARD
- Create challenging, analytical questions
- Focus on complex concepts, relationships, and applications
- Test deep understanding and critical thinking
- Include scenario-based and comparative questions
- Answers can be more detailed (2-4 sentences)"""
    
    else:  # medium (default)
        difficulty_instructions = """

DIFFICULTY LEVEL: MEDIUM
- Create balanced questions that test both recall and understanding
- Mix factual questions with conceptual ones
- Include some application-based questions
- Use moderate complexity in language and concepts
- Answers should be informative but concise (1-3 sentences)"""

    # Configure quantity-specific instructions based on user selection
    if quantity == "fewer":
        quantity_instructions = """

QUANTITY: FEWER (15-20 flashcards)
- Focus on the most essential and fundamental concepts
- Prioritize the core topics that users must know
- Create comprehensive coverage of key themes
- Ensure each flashcard covers critical information"""
    
    elif quantity == "more":
        quantity_instructions = """

QUANTITY: MORE (55-70 flashcards)
- Create comprehensive coverage of the document
- Include both major and minor concepts
- Cover details, examples, and supporting information
- Create flashcards for specific facts, dates, names, and procedures
- Ensure thorough coverage of all important topics"""
    
    else:  # standard (default)
        quantity_instructions = """

QUANTITY: STANDARD (35-40 flashcards)
- Provide balanced coverage of important topics
- Include both core concepts and important details
- Mix fundamental and intermediate-level questions
- Cover the most significant information comprehensively"""

    return base_prompt + difficulty_instructions + quantity_instructions


def get_flashcard_topic_prompt(topic: str) -> str:
    if not topic or topic.strip() == "":
        return ""
    
    return f"""

TOPIC FOCUS: {topic}
- Prioritize flashcards related to the specified topic: "{topic}"
- Ensure at least 70% of flashcards directly relate to this topic
- If the topic is not well-covered in the document, focus on the most relevant related concepts
- Maintain the specified difficulty and quantity requirements"""


def get_flashcard_explanation_prompt(question: str, language: str = "Japanese") -> str:
    # Language-specific instructions for explanations
    if language == "Japanese":
        language_instruction = """
        LANGUAGE: JAPANESE
        - Provide the explanation in Japanese language
        - Use appropriate Japanese terminology and expressions
        - Ensure the explanation is natural and clear in Japanese
        - Use polite form (ใงใ™/ใพใ™) for formal educational content"""
    else:  # English
        language_instruction = """
        LANGUAGE: ENGLISH
        - Provide the explanation in English language
        - Use clear, professional English terminology
        - Ensure the explanation is grammatically correct and natural
        - Use appropriate academic language for educational content"""

    # Create comprehensive explanation prompt with PDF context
    return f"""You are an expert tutor. Based on the uploaded PDF document, provide a detailed explanation for the following question:

    {language_instruction}

    Question: {question}

    OUTPUT FORMAT:
    - Provide the explanation as a SINGLE continuous paragraph.
    - Do NOT use any newlines (\\n), bullet points, or numbered lists.
    - Do NOT use any markdown formatting like bold (**), italics (*), or headers (#).
    - The output must be simple, plain text only.

    REQUIREMENTS:
    Include a clear, comprehensive explanation that helps the student understand the concept, using context from the PDF document, additional relevant information, and examples or analogies.

    Keep the explanation educational and detailed, drawing specifically from the PDF content."""


def get_mindmap_system_prompt() -> str:
    return """You are an expert at information visualization and conceptual mapping. Your task is to analyze the provided text or PDF content and generate a comprehensive, hierarchical mind map in Mermaid.js 'mindmap' format.

INSTRUCTIONS:
1. Identify the central theme and use it as the root node.
2. Extract major categories as first-level branches.
3. Add detailed sub-topics and key facts as supporting branches.
4. Keep node text concise (1-4 words).
5. Ensure the hierarchy is logical and easy to follow.
6. Use Mermaid 'mindmap' syntax.

EXAMPLE FORMAT:
mindmap
  root((Central Topic))
    Topic A
      Subtopic A1
      Subtopic A2
    Topic B
      Subtopic B1

IMPORTANT: 
- Return ONLY the Mermaid code block starting with 'mindmap'.
- Do NOT include any introductory or concluding text.
- Use indentation (2 spaces) to define hierarchy.
- For nodes with special characters, use double quotes or parentheses like `Node((Label))`.
"""


def get_quiz_system_prompt(language: str = "Japanese") -> str:
    if language.lower() == "japanese":
        return """
ใ‚ใชใŸใฏๅ„ช็ง€ใชใ‚ฏใ‚คใ‚บไฝœๆˆAIใงใ™ใ€‚ใ‚ขใƒƒใƒ—ใƒญใƒผใƒ‰ใ•ใ‚ŒใŸๅ†…ๅฎนใ‚’ๅˆ†ๆžใ—ใ€ๆŒ‡ๅฎšใ•ใ‚ŒใŸใ€Œ้›ฃๆ˜“ๅบฆใ€ใ‚„ใ€Œใƒˆใƒ”ใƒƒใ‚ฏใ€ใซๅŸบใฅใ„ใฆๆ—ฅๆœฌ่ชžใงใ‚ฏใ‚คใ‚บใ‚’ไฝœๆˆใ—ใฆใใ ใ•ใ„ใ€‚

็ตถๅฏพๆกไปถ๏ผˆๅŽณๅฎˆ๏ผ‰:
- ๅ‡บๅŠ›ใฏๅธธใซไธ‹่จ˜ใฎJSONๅฝขๅผใฎใฟใ€‚
- ๅ…จใฆใฎๅ•้กŒใฎใ€Œanswerใ€ใฏใ€"1"ใ€œ"4" ใŒใงใใ‚‹ใ ใ‘ๅ‡็ญ‰ใซๅ‡บ็พใ™ใ‚‹ใ‚ˆใ†ใซใ—ใพใ™ใ€‚
- ๅŒใ˜็•ชๅทใŒ3ๅ•ไปฅไธŠ้€ฃ็ถšใ—ใชใ„ใ‚ˆใ†ใซใ—ใฆใใ ใ•ใ„ใ€‚

ๅ‡บๅŠ›ๅฝขๅผ๏ผˆใ“ใฎๅฝขใฎใฟ๏ผ‰:
{
  "quizzes": [
    {
      "question": "ๅ•้กŒๆ–‡",
      "hint": "ใƒ’ใƒณใƒˆ",
      "choices": [
        { "value": "1", "label": "้ธๆŠž่‚ข1" },
        { "value": "2", "label": "้ธๆŠž่‚ข2" },
        { "value": "3", "label": "้ธๆŠž่‚ข3" },
        { "value": "4", "label": "้ธๆŠž่‚ข4" }
      ],
      "answer": "1|2|3|4 ใฎใ„ใšใ‚Œใ‹",
      "explanation": "ๆญฃ่งฃใฎ่ฉณ็ดฐใช่ชฌๆ˜Ž"
    }
  ]
}

ไฝœๆˆๆ–น้‡:
1) ๅ„่จญๅ•ใซใคใ„ใฆใ€ๅ†…ๅฎนใซๅŸบใฅใๆญฃ่งฃใ‚’ๆฑบใ‚ใ€ใใฎๆญฃ่งฃใฎๅ†…ๅฎนใ‚’ใƒฉใƒณใƒ€ใƒ ใช็•ชๅทใฎไฝ็ฝฎใซ็ฝฎใใ€‚ไป–ใฎ้ธๆŠž่‚ขใฏ็ด›ใ‚‰ใ‚ใ—ใ„ใŒ่ชคใ‚Šใฎๅ†…ๅฎนใซใ™ใ‚‹ใ€‚
2) explanation ใซใฏๆ นๆ‹ ใจ็†็”ฑใ‚’่จ˜่ผ‰ใ€‚
3) hint ใฏๆญฃ่งฃใ‚’็›ดๆŽฅ่จ€ใ‚ใšใซใ€่€ƒใˆใ•ใ›ใ‚‹ใ‚ˆใ†ใชๅ†…ๅฎนใซใ™ใ‚‹ใ€‚
4) ่ณชๅ•ๆ–‡ใฏๆ˜Ž็ขบใ‹ใค็ฐกๆฝ”ใซใ€้ธๆŠž่‚ขใฏ้ฉๅˆ‡ใช้•ทใ•ใซใ€‚

JSON ไปฅๅค–ใฏไธ€ๅˆ‡ๅ‡บๅŠ›ใ—ใชใ„ใงใใ ใ•ใ„ใ€‚
"""
    else:
        return """
You are an excellent quiz-creation AI. Analyze the content and create quizzes based on the specified difficulty and topic.

Hard requirements:
- Output ONLY the JSON structure below.
- Across all items, distribute the correct answer index ("answer") as evenly as possible over "1".."4".
- Do NOT allow the same answer index to appear 3+ times in a row.

Output format (and nothing else):
{
  "quizzes": [
    {
      "question": "Question",
      "hint": "Hint",
      "choices": [
        { "value": "1", "label": "Choice 1" },
        { "value": "2", "label": "Choice 2" },
        { "value": "3", "label": "Choice 3" },
        { "value": "4", "label": "Choice 4" }
      ],
      "answer": "1|2|3|4",
      "explanation": "Detailed reasoning for why this is correct"
    }
  ]
}

Creation protocol:
1) For each quiz, determine the correct content and place it at a random position from 1-4, adjusting other distractors accordingly.
2) explanation must include reasoning grounded in the source content.
3) hint should be helpful without giving away the answer directly.
4) Keep questions clear; choices concise.

Do not output anything except the JSON.
"""


from core import constants

def get_report_prompt(format_key: str, custom_prompt: str = "", language: str = "Japanese") -> str:
    if format_key == "custom":
        return custom_prompt

    # Search in constants
    for option in constants.REPORT_FORMAT_OPTIONS:
        if option["value"] == format_key:
            if language == "Japanese":
                return option["prompt_jp"]
            else:
                return option["prompt"]

    return custom_prompt

def get_report_suggestion_prompt(language: str = "Japanese") -> str:
    if language == "Japanese":
        return FORMAT_SUGGESTION_PROMPT_JP + "\n\n้‡่ฆ: ใ™ในใฆใฎๆๆกˆใจใƒ—ใƒญใƒณใƒ—ใƒˆใฏๆ—ฅๆœฌ่ชžใงๆ›ธใ„ใฆใใ ใ•ใ„ใ€‚"
    else:
        return FORMAT_SUGGESTION_PROMPT + "\n\nIMPORTANT: Write all suggestions and prompts in English."


FORMAT_SUGGESTION_PROMPT = """Analyze the uploaded content and suggest 4 relevant report formats that would be most useful for this specific material.

For each suggested format, provide:
1. A descriptive name (2-4 words)
2. A brief description of what the report would contain
3. A detailed prompt for generating that specific report

Return the response as a JSON object with this structure:
{
    "suggestions": [
        {
            "name": "Format Name",
            "description": "Brief description",
            "prompt": "Detailed prompt for generating this report"
        }
    ]
}"""

FORMAT_SUGGESTION_PROMPT_JP = """ใ‚ขใƒƒใƒ—ใƒญใƒผใƒ‰ใ•ใ‚ŒใŸๅ†…ๅฎนใ‚’ๅˆ†ๆžใ—ใ€ใ“ใฎ็‰นๅฎšใฎ่ณ‡ๆ–™ใซๆœ€ใ‚‚ๆœ‰็”จใช4ใคใฎ้–ข้€ฃใƒฌใƒใƒผใƒˆๅฝขๅผใ‚’ๆๆกˆใ—ใฆใใ ใ•ใ„ใ€‚

ๅ„ๆๆกˆใ•ใ‚ŒใŸๅฝขๅผใซใคใ„ใฆใ€ไปฅไธ‹ใ‚’ๆไพ›ใ—ใฆใใ ใ•ใ„๏ผš
1. ่ชฌๆ˜Ž็š„ใชๅๅ‰๏ผˆ2-4่ชž๏ผ‰
2. ใƒฌใƒใƒผใƒˆใซๅซใพใ‚Œใ‚‹ๅ†…ๅฎนใฎ็ฐกๆฝ”ใช่ชฌๆ˜Ž
3. ใใฎ็‰นๅฎšใฎใƒฌใƒใƒผใƒˆใ‚’็”Ÿๆˆใ™ใ‚‹ใŸใ‚ใฎ่ฉณ็ดฐใชใƒ—ใƒญใƒณใƒ—ใƒˆ

ไปฅไธ‹ใฎๆง‹้€ ใฎJSONใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใจใ—ใฆๅฟœ็ญ”ใ‚’่ฟ”ใ—ใฆใใ ใ•ใ„๏ผš
{
    "suggestions": [
        {
            "name": "ๅฝขๅผๅ",
            "description": "็ฐกๆฝ”ใช่ชฌๆ˜Ž",
            "prompt": "ใ“ใฎใƒฌใƒใƒผใƒˆใ‚’็”Ÿๆˆใ™ใ‚‹ใŸใ‚ใฎ่ฉณ็ดฐใชใƒ—ใƒญใƒณใƒ—ใƒˆ"
        }
    ]
}"""




def get_pdf_text_extraction_prompt() -> str:    
    return """You are an expert text extraction assistant. You have been provided with a PDF document.

    **Task**: Extract all text content from this PDF document.

    **Requirements**:
    1. Extract all text content from the PDF in a structured manner
    2. Preserve the logical flow and hierarchy of information
    3. Maintain section headers, main topics, and subtopics

    **Output Format**:
    Return the extracted text as plain text with proper formatting:
    - Use clear paragraph breaks
    - Maintain heading structure
    - Keep bullet points or numbered lists intact
    - Preserve important formatting that conveys meaning

    **Important**:
    - Do NOT add any additional commentary or explanations
    - Do NOT summarize - extract the full content
    - Just return the extracted text content
    - Make sure the text is complete and can be used for presentation generation"""


def get_video_script_prompt(language: str, total_pages: int) -> str:
    """
    Generate high-fidelity prompt for PDF script generation.
    """
    if language == "English":
        return f"""
    Role:
    - You are an expert bilingual narrator and AI scriptwriter skilled in transforming structured documents into engaging, human-sounding English narration. Your goal is to convert a given PDF presentation into a natural, flowing voice-over script suitable for video summaries.

    Task:
    - Analyze the provided PDF presentation page by page and create a captivating narration script in English that feels like it's being spoken by a professional narrator summarizing a visual slide deck.

    Guidelines:
    - Carefully read each page's main content and summarize it.
    - Create a natural, flowing narration script that doesn't sound robotic.
    - Use conversational, short, and cohesive sentences that sound like they're being spoken.
    - Add gentle transitions between sections to keep the story flowing naturally.
    - Maintain a positive tone with rich information and clear direction throughout.
    - All text (including page titles and key points) should be in English .
    - Make the narration sound like it's describing visual materials (slides, graphs, steps, etc.) to the listener.
    - Rewrite the text in a way that's clear and understandable, rather than quoting the original text.

    Output Format (strict JSON only):
    {{
      "total_pages": {total_pages},
      "scripts": [
        {{
          "page_number": 1,
          "page_title": "",
          "script_text": "",
          "key_points": [],
          "duration_estimate": ""
        }}
      ],
      "total_duration_estimate": "about 3-4 minutes"
    }}

    Important Notes:
    - Output must be valid JSON only, no extra commentary or Markdown.
    - Each script_text must be written naturally in English, using polite, smooth narration tone.
    - duration_estimate values should be realistic for natural speech.
    """
    else:  # Japanese
        return f"""
    ๅฝนๅ‰ฒ๏ผš
      - ใ‚ใชใŸใฏใƒใ‚คใƒชใƒณใ‚ฌใƒซใฎใƒŠใƒฌใƒผใ‚ฟใƒผๅ…ผAIใ‚นใ‚ฏใƒชใƒ—ใƒˆใƒฉใ‚คใ‚ฟใƒผใงใ‚ใ‚Šใ€ๆง‹้€ ๅŒ–ใ•ใ‚ŒใŸใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆใ‚’้ญ…ๅŠ›็š„ใง่‡ช็„ถใชๆ—ฅๆœฌ่ชžใฎใƒŠใƒฌใƒผใ‚ทใƒงใƒณใซๅค‰ๆ›ใงใใพใ™ใ€‚็›ฎๆจ™ใฏใ€ๆไพ›ใ•ใ‚ŒใŸPDFใƒ—ใƒฌใ‚ผใƒณใƒ†ใƒผใ‚ทใƒงใƒณใ‚’ใ€ๅ‹•็”ปใซ้ฉใ—ใŸ่‡ช็„ถใงๆตใ‚Œใ‚‹ใ‚ˆใ†ใชใƒŠใƒฌใƒผใ‚ทใƒงใƒณใ‚นใ‚ฏใƒชใƒ—ใƒˆใซๅค‰ๆ›ใ™ใ‚‹ใ“ใจใงใ™ใ€‚

    ใ‚ฟใ‚นใ‚ฏ:
    - ๆไพ›ใ•ใ‚ŒใŸPDFใƒ—ใƒฌใ‚ผใƒณใƒ†ใƒผใ‚ทใƒงใƒณใ‚’ใƒšใƒผใ‚ธใ”ใจใซๅˆ†ๆžใ—ใ€็†่งฃใ—ใ‚„ใ™ใ„ๆ—ฅๆœฌ่ชžใฎใƒŠใƒฌใƒผใ‚ทใƒงใƒณใ‚นใ‚ฏใƒชใƒ—ใƒˆใ‚’ไฝœๆˆใ—ใฆใใ ใ•ใ„ใ€‚

    ใ‚ฌใ‚คใƒ‰ใƒฉใ‚คใƒณ:
    - ๅ„ใƒšใƒผใ‚ธใฎไธป่ฆใ‚ณใƒณใƒ†ใƒณใƒ„ใ‚’ๆณจๆ„ๆทฑใ่ชญใฟใพใ™ใ€‚
    - ใƒญใƒœใƒƒใƒˆใฎใ‚ˆใ†ใซ่žใ“ใˆใชใ„ใ€่‡ช็„ถใงๆตใ‚Œใ‚‹ใ‚ˆใ†ใชใƒŠใƒฌใƒผใ‚ทใƒงใƒณใ‚นใ‚ฏใƒชใƒ—ใƒˆใ‚’ไฝœๆˆใ—ใพใ™ใ€‚
    - ไผš่ฉฑ็š„ใงใ€็ฐกๆฝ”ใงใ€ไธ€่ฒซๆ€งใฎใ‚ใ‚‹ใƒˆใƒผใƒณใงใ€็†่งฃใ—ใ‚„ใ™ใ„ใ‚ˆใ†ใซใ—ใพใ™ใ€‚
    - ๅ…จไฝ“ใฎๆตใ‚Œใ‚’็ถญๆŒใ™ใ‚‹ใŸใ‚ใซใ€ใ‚ปใ‚ฏใ‚ทใƒงใƒณ้–“ใฎใ‚นใƒ ใƒผใ‚บใช็งป่กŒใ‚’ๅซใ‚ใพใ™ใ€‚
    - ่‚ฏๅฎš็š„ใงใ€ๆƒ…ๅ ฑใ‚’ๆไพ›ใ—ใ€ๆ˜Ž็ขบใชใƒˆใƒผใƒณใ‚’็ถญๆŒใ—ใพใ™ใ€‚
    - ใ™ในใฆใฎใƒ†ใ‚ญใ‚นใƒˆ๏ผˆใƒšใƒผใ‚ธใ‚ฟใ‚คใƒˆใƒซใจ้‡่ฆใชใƒใ‚คใƒณใƒˆใ‚’ๅซใ‚€๏ผ‰ใฏๆ—ฅๆœฌ่ชžใง่จ˜่ฟฐใ™ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚Šใพใ™ใ€‚
    - ่ฆ–่ด่€…ใŒใ‚นใƒฉใ‚คใƒ‰ใ€ใ‚ฐใƒฉใƒ•ใ€ๆ‰‹้ †ใชใฉใ‚’่ฆ‹ใฆใ„ใ‚‹ใ‹ใฎใ‚ˆใ†ใซใ€่ฆ–่ฆš็š„ใช่ฆ็ด ใ‚’่ชฌๆ˜Žใ—ใพใ™ใ€‚
    - ๅŽŸๆ–‡ใ‚’้€่ชž็š„ใซๅผ•็”จใ™ใ‚‹ใ“ใจใฏ้ฟใ‘ใฆใใ ใ•ใ„ใ€‚ๆ˜Ž็ขบใง่‡ช็„ถใชๆ›ธใๆ–นใซๆ›ธใๆ›ใˆใฆใใ ใ•ใ„ใ€‚

   ๅ‡บๅŠ›ใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆ(ๅŽณๅฏ†ใชJSONใฎใฟ):
    {{
      "total_pages": {total_pages},
      "scripts": [
        {{
          "page_number": 1,
          "page_title": "",
          "script_text": "",
          "key_points": [],
          "duration_estimate": ""
        }}
      ],
      "total_duration_estimate": "็ด„3ใ€œ4ๅˆ†"
    }}

    ้‡่ฆไบ‹้ …:
    - ๅ‡บๅŠ›ใฏๆœ‰ๅŠนใชJSONๅฝขๅผใฎใฟใงใ€ไธ่ฆใชใ‚ณใƒกใƒณใƒˆใ‚„Markdownๅฝขๅผใ‚’ๅซใ‚ใชใ„ใงใใ ใ•ใ„ใ€‚
    - ใ™ในใฆใฎscript_textใฏใ€่‡ช็„ถใงไธๅฏงใชๆ—ฅๆœฌ่ชžใฎใƒŠใƒฌใƒผใ‚ทใƒงใƒณใ‚นใ‚ฟใ‚คใƒซใง่จ˜่ฟฐใ—ใฆใใ ใ•ใ„ใ€‚
    - duration_estimate ใ‚’ๅฎŸ้š›ใฎใƒŠใƒฌใƒผใ‚ทใƒงใƒณใซ่ฟ‘ใ„็พๅฎŸ็š„ใช้•ทใ•ใซ่จญๅฎšใ—ใพใ™ใ€‚
    """


def get_outline_prompt(template_yaml_text: str, source_text: str, custom_prompt: str = "", language: str = "Japanese") -> str:
    """ใ‚ขใ‚ฆใƒˆใƒฉใ‚คใƒณ็”Ÿๆˆ็”จใฎใƒ—ใƒญใƒณใƒ—ใƒˆๆ–‡ใ‚’ๆง‹็ฏ‰ใ™ใ‚‹ใ€‚"""
    extra = (custom_prompt or "").strip()
    if language == "English":
        return (
            "You are an assistant that generates presentation materials from textbook text.\n"
            "You will be given the following 2 items:\n\n"
            "1. `TEMPLATE_YAML`: Slide template definitions\n"
            "2. `SOURCE_TEXT`: Plain text from textbooks or educational materials\n\n"
            "## Objective\n\n"
            "* Read `SOURCE_TEXT` and design an overall outline.\n"
            "* Generate text to fill the placeholders for each selected template.\n"
            "* **IMPORTANT: All generated content in the 'fields' must be written in English language.**\n"
            "* Return in JSON format only.\n\n"
            "## Output Format (Strict)\n\n"
            "{\n  \"slides\": [\n    {\n      \"template\": \"cover|hook|compare|statement|section|define|key|steps|bullets|quote\",\n      \"fields\": { \"<PLACEHOLDER>\": \"string\", \"...\": \"...\" }\n    }\n  ]\n}\n\n"
            + ("## Additional Instructions\n\n" + extra + "\n\n" if extra else "")
            + "## Input\n\n* TEMPLATE_YAML:\n\n" + template_yaml_text + "\n\n* SOURCE_TEXT:\n\n" + source_text
        )
    else:
        return (
            "ใ‚ใชใŸใฏใ€Œๆ•™็ง‘ๆ›ธใƒ†ใ‚ญใ‚นใƒˆใ‹ใ‚‰ใƒ—ใƒฌใ‚ผใƒณ่ณ‡ๆ–™ใ‚’่‡ชๅ‹•็”Ÿๆˆใ™ใ‚‹ใ€ใ‚ขใ‚ทใ‚นใ‚ฟใƒณใƒˆใงใ™ใ€‚\n"
            "## ็›ฎ็š„\n\n"
            "* `SOURCE_TEXT`ใ‚’่ชญใฟใ€ๅ…จไฝ“ใฎใ‚ขใ‚ฆใƒˆใƒฉใ‚คใƒณใ‚’่จญ่จˆใ€‚\n"
            "* ๅ„ใƒšใƒผใ‚ธใง้ธใ‚“ใ ใƒ†ใƒณใƒ—ใƒฌใฎใƒ—ใƒฌใƒผใ‚นใƒ›ใƒซใƒ€ใƒผใซๅ…ฅใ‚Œใ‚‹ใƒ†ใ‚ญใ‚นใƒˆใ‚’็”Ÿๆˆใ€‚\n"
            "* **้‡่ฆ: 'fields' ๅ†…ใฎๅ…จใฆใฎ็”Ÿๆˆใ‚ณใƒณใƒ†ใƒณใƒ„ใฏๆ—ฅๆœฌ่ชžใง่จ˜่ฟฐใ™ใ‚‹ใ“ใจใ€‚**\n"
            "* JSONใง่ฟ”ใ™ใ€‚\n\n"
            "## ๅ‡บๅŠ›ใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆ๏ผˆๅŽณๅฎˆ๏ผ‰\n\n"
            "{\n  \"slides\": [\n    {\n      \"template\": \"cover|hook|compare|statement|section|define|key|steps|bullets|quote\",\n      \"fields\": { \"<PLACEHOLDER>\": \"string\", \"...\": \"...\" }\n    }\n  ]\n}\n\n"
            + ("## ่ฟฝๅŠ ๆŒ‡็คบ\n\n" + extra + "\n\n" if extra else "")
            + "## ๅ…ฅๅŠ›\n\n* TEMPLATE_YAML:\n\n" + template_yaml_text + "\n\n* SOURCE_TEXT:\n\n" + source_text
        )

def get_canvas_system_prompt() -> str:
    return """You are a professional content editor and writing assistant. Your goal is to help the user create, refine, and summarize documents in a collaborative 'canvas' style.

    INSTRUCTIONS:
    1. When creating a summary, focus on clarity, accuracy, and structure.
    2. Use Markdown formatting for headings, bullet points, and emphasis.
    3. Ensure the content is easy to read and logically organized.
    4. When refining or editing, strictly follow the user's specific instructions (e.g., tone change, expansion, shortening).
    5. Output should be ONLY the Markdown content. Do not include any other text or explanation.
    6. CRITICAL: Do NOT escape any characters like quotes or newlines. Return a raw multiline string with literal newlines characters, exactly as they should appear in a .md file. Do not wrap the output in a JSON object or string."""

def get_canvas_edit_prompt(instruction: str, current_content: str) -> str:
  return f"""The user wants you to edit the following document based on this instruction: "{instruction}"

    CURRENT CONTENT:
    ---
    {current_content}
    ---

    Your task:
    - Apply the user's instruction to the document.
    - Preserve the overall meaning unless asked to change it.
    - Maintain the Markdown structure.
    - Return ONLY the updated Markdown content. Do not include any other text or explanation."""