Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -436,7 +436,7 @@ class ContentAnalyzer:
|
|
| 436 |
time.sleep(self.retry_delay * (2 ** attempt))
|
| 437 |
|
| 438 |
def _create_analysis_prompt(self, transcript: str) -> str:
|
| 439 |
-
"""Create the analysis prompt with
|
| 440 |
# First try to extract existing timestamps
|
| 441 |
timestamps = re.findall(r'\[(\d{2}:\d{2})\]', transcript)
|
| 442 |
|
|
@@ -462,7 +462,9 @@ Example: If a quote starts at word 300, timestamp would be [02:00] (300 words /
|
|
| 462 |
marked_transcript += word + " "
|
| 463 |
transcript = marked_transcript
|
| 464 |
|
| 465 |
-
prompt_template = """Analyze this teaching content
|
|
|
|
|
|
|
| 466 |
|
| 467 |
Transcript:
|
| 468 |
{transcript}
|
|
@@ -474,110 +476,92 @@ Required JSON structure:
|
|
| 474 |
{{
|
| 475 |
"Concept Assessment": {{
|
| 476 |
"Subject Matter Accuracy": {{
|
| 477 |
-
"Score": 1, # Score 1 if
|
| 478 |
"Citations": ["[MM:SS] Quote demonstrating accuracy or error"]
|
| 479 |
}},
|
| 480 |
"First Principles Approach": {{
|
| 481 |
-
"Score": 1, # Score 1 if
|
| 482 |
-
"Citations": ["[MM:SS] Quote showing
|
| 483 |
}},
|
| 484 |
"Examples and Business Context": {{
|
| 485 |
-
"Score": 1, # Score 1 if at least 2 relevant
|
| 486 |
"Citations": ["[MM:SS] Quote containing practical example"]
|
| 487 |
}},
|
| 488 |
"Cohesive Storytelling": {{
|
| 489 |
-
"Score": 1, # Score 1 if
|
| 490 |
-
"Citations": ["[MM:SS] Quote showing topic transition
|
| 491 |
}},
|
| 492 |
"Engagement and Interaction": {{
|
| 493 |
-
"Score": 1, # Score 1 if
|
| 494 |
"Citations": ["[MM:SS] Quote showing audience engagement"]
|
| 495 |
}},
|
| 496 |
"Professional Tone": {{
|
| 497 |
-
"Score": 1, # Score 1 if
|
| 498 |
"Citations": ["[MM:SS] Quote demonstrating tone"]
|
| 499 |
}}
|
| 500 |
}},
|
| 501 |
"Code Assessment": {{
|
| 502 |
"Depth of Explanation": {{
|
| 503 |
-
"Score": 1, # Score 1 if
|
| 504 |
"Citations": ["[MM:SS] Quote showing code explanation"]
|
| 505 |
}},
|
| 506 |
"Output Interpretation": {{
|
| 507 |
-
"Score": 1, # Score 1 if
|
| 508 |
"Citations": ["[MM:SS] Quote demonstrating output explanation"]
|
| 509 |
}},
|
| 510 |
"Breaking down Complexity": {{
|
| 511 |
-
"Score": 1, # Score 1 if complex concepts are
|
| 512 |
"Citations": ["[MM:SS] Quote showing concept breakdown"]
|
| 513 |
}}
|
| 514 |
}}
|
| 515 |
}}
|
| 516 |
|
| 517 |
-
Balanced
|
| 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 |
-
2. Output Interpretation:
|
| 564 |
-
- Most code outputs explained
|
| 565 |
-
- Key error cases covered
|
| 566 |
-
- Expected results discussed
|
| 567 |
-
- Basic validation covered
|
| 568 |
-
|
| 569 |
-
3. Breaking down Complexity:
|
| 570 |
-
- Complex concepts divided into components
|
| 571 |
-
- Step-by-step explanation of key concepts
|
| 572 |
-
- Logical organization
|
| 573 |
-
- Dependencies explained
|
| 574 |
-
|
| 575 |
-
Important:
|
| 576 |
-
- Score 1 if most criteria in a category are met
|
| 577 |
-
- Minor gaps or imperfections acceptable
|
| 578 |
-
- Each citation must include timestamp and relevant quote
|
| 579 |
-
- Citations should demonstrate how criteria are met
|
| 580 |
-
- Be balanced in scoring - perfection not required"""
|
| 581 |
|
| 582 |
return prompt_template.format(
|
| 583 |
transcript=transcript,
|
|
|
|
| 436 |
time.sleep(self.retry_delay * (2 ** attempt))
|
| 437 |
|
| 438 |
def _create_analysis_prompt(self, transcript: str) -> str:
|
| 439 |
+
"""Create the analysis prompt with balanced evaluation criteria"""
|
| 440 |
# First try to extract existing timestamps
|
| 441 |
timestamps = re.findall(r'\[(\d{2}:\d{2})\]', transcript)
|
| 442 |
|
|
|
|
| 462 |
marked_transcript += word + " "
|
| 463 |
transcript = marked_transcript
|
| 464 |
|
| 465 |
+
prompt_template = """Analyze this teaching content objectively. Each criterion should be evaluated independently with reasonable standards - neither too strict nor too lenient.
|
| 466 |
+
|
| 467 |
+
Score 1 if the criterion meets reasonable standards, 0 if it does not.
|
| 468 |
|
| 469 |
Transcript:
|
| 470 |
{transcript}
|
|
|
|
| 476 |
{{
|
| 477 |
"Concept Assessment": {{
|
| 478 |
"Subject Matter Accuracy": {{
|
| 479 |
+
"Score": 0 or 1, # Score 1 if content is generally accurate with only minor errors
|
| 480 |
"Citations": ["[MM:SS] Quote demonstrating accuracy or error"]
|
| 481 |
}},
|
| 482 |
"First Principles Approach": {{
|
| 483 |
+
"Score": 0 or 1, # Score 1 if key concepts are built from fundamentals
|
| 484 |
+
"Citations": ["[MM:SS] Quote showing concept explanation"]
|
| 485 |
}},
|
| 486 |
"Examples and Business Context": {{
|
| 487 |
+
"Score": 0 or 1, # Score 1 if at least 2 relevant examples are provided
|
| 488 |
"Citations": ["[MM:SS] Quote containing practical example"]
|
| 489 |
}},
|
| 490 |
"Cohesive Storytelling": {{
|
| 491 |
+
"Score": 0 or 1, # Score 1 if content flows logically most of the time
|
| 492 |
+
"Citations": ["[MM:SS] Quote showing topic transition"]
|
| 493 |
}},
|
| 494 |
"Engagement and Interaction": {{
|
| 495 |
+
"Score": 0 or 1, # Score 1 if there's meaningful audience engagement
|
| 496 |
"Citations": ["[MM:SS] Quote showing audience engagement"]
|
| 497 |
}},
|
| 498 |
"Professional Tone": {{
|
| 499 |
+
"Score": 0 or 1, # Score 1 if tone is generally professional
|
| 500 |
"Citations": ["[MM:SS] Quote demonstrating tone"]
|
| 501 |
}}
|
| 502 |
}},
|
| 503 |
"Code Assessment": {{
|
| 504 |
"Depth of Explanation": {{
|
| 505 |
+
"Score": 0 or 1, # Score 1 if code concepts are explained clearly
|
| 506 |
"Citations": ["[MM:SS] Quote showing code explanation"]
|
| 507 |
}},
|
| 508 |
"Output Interpretation": {{
|
| 509 |
+
"Score": 0 or 1, # Score 1 if important outputs are explained
|
| 510 |
"Citations": ["[MM:SS] Quote demonstrating output explanation"]
|
| 511 |
}},
|
| 512 |
"Breaking down Complexity": {{
|
| 513 |
+
"Score": 0 or 1, # Score 1 if complex concepts are made understandable
|
| 514 |
"Citations": ["[MM:SS] Quote showing concept breakdown"]
|
| 515 |
}}
|
| 516 |
}}
|
| 517 |
}}
|
| 518 |
|
| 519 |
+
Balanced Scoring Guidelines:
|
| 520 |
+
|
| 521 |
+
Subject Matter Accuracy:
|
| 522 |
+
β Pass: Content is technically sound with occasional minor errors
|
| 523 |
+
β Fail: Multiple significant errors or fundamental misunderstandings
|
| 524 |
+
|
| 525 |
+
First Principles Approach:
|
| 526 |
+
β Pass: Core concepts are explained from basic principles
|
| 527 |
+
β Fail: Advanced concepts introduced without basic foundation
|
| 528 |
+
|
| 529 |
+
Examples and Business Context:
|
| 530 |
+
β Pass: At least 2 relevant examples that illustrate concepts
|
| 531 |
+
β Fail: Examples missing or irrelevant to the topic
|
| 532 |
+
|
| 533 |
+
Cohesive Storytelling:
|
| 534 |
+
β Pass: Topics generally flow well with clear connections
|
| 535 |
+
β Fail: Frequent jumps between unrelated topics
|
| 536 |
+
|
| 537 |
+
Engagement and Interaction:
|
| 538 |
+
β Pass: Some effective engagement with audience
|
| 539 |
+
β Fail: One-way lecture with no audience consideration
|
| 540 |
+
|
| 541 |
+
Professional Tone:
|
| 542 |
+
β Pass: Generally professional with occasional casual moments
|
| 543 |
+
β Fail: Consistently unprofessional or inappropriate
|
| 544 |
+
|
| 545 |
+
Depth of Explanation:
|
| 546 |
+
β Pass: Key code concepts explained with reasonable detail
|
| 547 |
+
β Fail: Code presented without meaningful explanation
|
| 548 |
+
|
| 549 |
+
Output Interpretation:
|
| 550 |
+
β Pass: Important outputs and their significance explained
|
| 551 |
+
β Fail: Outputs shown without context or explanation
|
| 552 |
+
|
| 553 |
+
Breaking down Complexity:
|
| 554 |
+
β Pass: Complex topics broken into understandable parts
|
| 555 |
+
β Fail: Complex concepts left unexplained
|
| 556 |
+
|
| 557 |
+
Important Notes:
|
| 558 |
+
- Evaluate each criterion independently
|
| 559 |
+
- Perfect delivery is not required for a passing score
|
| 560 |
+
- Look for evidence of competent teaching rather than flawless execution
|
| 561 |
+
- Consider the overall effectiveness for the target audience
|
| 562 |
+
- One or two minor issues should not result in failure
|
| 563 |
+
- Citations must support the scoring decision
|
| 564 |
+
- Different criteria can and should receive different scores based on their individual merits"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
|
| 566 |
return prompt_template.format(
|
| 567 |
transcript=transcript,
|