Spaces:
Sleeping
Sleeping
Rename generate_with_claude.py to prompts.py
Browse files
generate_with_claude.py → prompts.py
RENAMED
@@ -1,20 +1,87 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
]
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
1. Segments should be STRICTLY max=15
|
19 |
2. For each segment/topic you identify:
|
20 |
- Provide a SPECIFIC and UNIQUE topic name (3-5 words) that clearly differentiates it from other segments
|
@@ -61,28 +128,3 @@ Course information:
|
|
61 |
- Ensure the quiz questions challenge the reader and are not easily guessable.
|
62 |
- FOCUS ON CONCEPTUAL UNDERSTANDING, not trivial facts or statistics.
|
63 |
"""
|
64 |
-
|
65 |
-
try:
|
66 |
-
response = client.messages.create(
|
67 |
-
model="claude-3-5-sonnet-20241022",
|
68 |
-
max_tokens=8192,
|
69 |
-
temperature=0.7,
|
70 |
-
system=system_prompt,
|
71 |
-
messages=[
|
72 |
-
{
|
73 |
-
"role": "user",
|
74 |
-
"content": prompt
|
75 |
-
}
|
76 |
-
],
|
77 |
-
tools=tools,
|
78 |
-
tool_choice={"type": "tool", "name": "build_segment_analysis"}
|
79 |
-
)
|
80 |
-
|
81 |
-
# Extract the tool call content
|
82 |
-
if response.content and len(response.content) > 0 and hasattr(response.content[0], 'input'):
|
83 |
-
function_call = response.content[0].input
|
84 |
-
return function_call
|
85 |
-
else:
|
86 |
-
raise Exception("No valid tool call found in the response")
|
87 |
-
except Exception as e:
|
88 |
-
raise Exception(f"Error calling Anthropic API: {str(e)}")
|
|
|
1 |
+
SYSTEM_PROMPT = """You are an expert educational content analyzer. Your task is to analyze text content,
|
2 |
+
identify distinct segments, and create high-quality educational quiz questions for each segment."""
|
3 |
+
|
4 |
+
ANALYSIS_PROMPT_TEMPLATE_GEMINI = """Analyze the following text and identify distinct segments within it and do text segmentation:
|
5 |
+
1. Segments should be STRICTLY max=15
|
6 |
+
2. For each segment/topic you identify:
|
7 |
+
- Provide a SPECIFIC and UNIQUE topic name (3-5 words) that clearly differentiates it from other segments
|
8 |
+
- List 3-5 key concepts discussed in that segment (be precise and avoid repetition between segments)
|
9 |
+
- Write a brief summary of that segment (3-5 sentences)
|
10 |
+
- Create 5 high-quality, meaningful quiz questions based DIRECTLY on the content in that segment only
|
11 |
+
- Questions and answers should be only from the content of the segment
|
12 |
+
|
13 |
+
For each quiz question:
|
14 |
+
- Create cognitively demanding questions that test COMPREHENSION and ANALYSIS, not just recall
|
15 |
+
- Focus on CORE PRINCIPLES, key insights, and conceptual understanding
|
16 |
+
- Questions should require readers to think critically about the material
|
17 |
+
- AVOID superficial questions about statistics, numbers, or trivial details
|
18 |
+
- AVOID questions about the document structure or presentation
|
19 |
+
- Create one correct answer that comes DIRECTLY from the text
|
20 |
+
- Create two plausible but incorrect answers that require discernment
|
21 |
+
- Ensure all answer options have similar length (± 2 words)
|
22 |
+
- Ensure the correct answer is clearly indicated with a ✓ symbol
|
23 |
+
IMPORTANT QUIZ QUESTION CRITERIA:
|
24 |
+
- Questions should assess understanding of fundamental concepts and principles
|
25 |
+
- Questions should require application of knowledge, not just memorization
|
26 |
+
- Questions should focus on important ideas that have educational value
|
27 |
+
- Questions should be meaningful in an educational context
|
28 |
+
- Questions should challenge the reader to think about implications and connections
|
29 |
+
- No need questions on the introduction, conclusion or the demonstration from the context,
|
30 |
+
|
31 |
+
ADDITIONAL REQUIREMENT:
|
32 |
+
- **First, detect the language of the original text.**
|
33 |
+
- **Generate ALL output (topic names, key concepts, summaries, and quizzes) in the same language as the original text.**
|
34 |
+
- If the text is in another language, generate responses in that original language.
|
35 |
+
|
36 |
+
COURSE INFORMATION:
|
37 |
+
- Course Name: {course_name}
|
38 |
+
- Section Name: {section_name}
|
39 |
+
- Lesson Name: {lesson_name}
|
40 |
+
- Use this information to contextualize the quiz and make it relevant to the educational content.
|
41 |
+
- Include this information in the JSON response structure.
|
42 |
+
|
43 |
+
Text:
|
44 |
+
{text}
|
45 |
+
|
46 |
+
RESPONSE FORMAT:
|
47 |
+
Return your answer as a valid JSON object with the following structure:
|
48 |
+
{{
|
49 |
+
"course_info": {{
|
50 |
+
"course_name": "{course_name}",
|
51 |
+
"section_name": "{section_name}",
|
52 |
+
"lesson_name": "{lesson_name}"
|
53 |
+
}},
|
54 |
+
"segments": [
|
55 |
+
{{
|
56 |
+
"topic_name": "Unique and Specific Topic Name",
|
57 |
+
"key_concepts": ["concept1", "concept2", "concept3"],
|
58 |
+
"summary": "Brief summary of this segment.",
|
59 |
+
"quiz_questions": [
|
60 |
+
{{
|
61 |
+
"question": "Question text?",
|
62 |
+
"options": [
|
63 |
+
{{
|
64 |
+
"text": "Option A",
|
65 |
+
"correct": false
|
66 |
+
}},
|
67 |
+
{{
|
68 |
+
"text": "Option B",
|
69 |
+
"correct": true
|
70 |
+
}},
|
71 |
+
{{
|
72 |
+
"text": "Option C",
|
73 |
+
"correct": false
|
74 |
+
}}
|
75 |
+
]
|
76 |
+
}}
|
77 |
+
]
|
78 |
+
}}
|
79 |
]
|
80 |
+
}}
|
81 |
+
"""
|
82 |
+
|
83 |
+
|
84 |
+
ANALYSIS_PROMPT_TEMPLATE_CLAUDE = """Analyze the following text and identify distinct segments within it and do text segmentation:
|
85 |
1. Segments should be STRICTLY max=15
|
86 |
2. For each segment/topic you identify:
|
87 |
- Provide a SPECIFIC and UNIQUE topic name (3-5 words) that clearly differentiates it from other segments
|
|
|
128 |
- Ensure the quiz questions challenge the reader and are not easily guessable.
|
129 |
- FOCUS ON CONCEPTUAL UNDERSTANDING, not trivial facts or statistics.
|
130 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|