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,9 +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 |
-
Score 1 if
|
| 468 |
|
| 469 |
Transcript:
|
| 470 |
{transcript}
|
|
@@ -472,96 +472,108 @@ Transcript:
|
|
| 472 |
Timestamp Instructions:
|
| 473 |
{timestamp_instruction}
|
| 474 |
|
| 475 |
-
Required JSON structure:
|
| 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 |
-
|
| 520 |
|
| 521 |
Subject Matter Accuracy:
|
| 522 |
-
β
|
| 523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
|
| 525 |
First Principles Approach:
|
| 526 |
-
β
|
| 527 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 528 |
|
| 529 |
Examples and Business Context:
|
| 530 |
-
β
|
| 531 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
|
| 533 |
Cohesive Storytelling:
|
| 534 |
-
β
|
| 535 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 536 |
|
| 537 |
Engagement and Interaction:
|
| 538 |
-
β
|
| 539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
Professional Tone:
|
| 542 |
-
β
|
| 543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
|
| 545 |
Depth of Explanation:
|
| 546 |
-
β
|
| 547 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
|
| 549 |
Output Interpretation:
|
| 550 |
-
β
|
| 551 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
|
| 553 |
Breaking down Complexity:
|
| 554 |
-
β
|
| 555 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
|
| 557 |
Important Notes:
|
| 558 |
-
-
|
| 559 |
-
-
|
| 560 |
-
-
|
| 561 |
-
-
|
| 562 |
-
-
|
| 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,
|
|
|
|
| 436 |
time.sleep(self.retry_delay * (2 ** attempt))
|
| 437 |
|
| 438 |
def _create_analysis_prompt(self, transcript: str) -> str:
|
| 439 |
+
"""Create the analysis prompt with stricter 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 with strict standards. Each criterion must meet specific requirements for a passing score.
|
| 466 |
|
| 467 |
+
Score 1 ONLY if ALL requirements are met with clear evidence. Score 0 if ANY requirement is not fully met.
|
| 468 |
|
| 469 |
Transcript:
|
| 470 |
{transcript}
|
|
|
|
| 472 |
Timestamp Instructions:
|
| 473 |
{timestamp_instruction}
|
| 474 |
|
| 475 |
+
Required JSON structure remains the same, but with stricter scoring criteria:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
|
| 477 |
+
Concept Assessment Criteria:
|
| 478 |
|
| 479 |
Subject Matter Accuracy:
|
| 480 |
+
β Score 1 if ALL:
|
| 481 |
+
- No significant technical errors
|
| 482 |
+
- Concepts explained with precise terminology
|
| 483 |
+
- Clear distinction between facts and opinions
|
| 484 |
+
β Score 0 if ANY:
|
| 485 |
+
- Contains technical inaccuracies
|
| 486 |
+
- Uses imprecise or incorrect terminology
|
| 487 |
+
- Mixes facts with unsupported claims
|
| 488 |
|
| 489 |
First Principles Approach:
|
| 490 |
+
β Score 1 if ALL:
|
| 491 |
+
- Starts with fundamental concepts
|
| 492 |
+
- Builds complexity systematically
|
| 493 |
+
- Clear connections between basic and advanced concepts
|
| 494 |
+
β Score 0 if ANY:
|
| 495 |
+
- Jumps to advanced concepts without foundation
|
| 496 |
+
- Missing logical progression
|
| 497 |
+
- Unclear connections between concepts
|
| 498 |
|
| 499 |
Examples and Business Context:
|
| 500 |
+
β Score 1 if ALL:
|
| 501 |
+
- At least 2 relevant, detailed examples
|
| 502 |
+
- Clear business context for each example
|
| 503 |
+
- Examples directly support learning objectives
|
| 504 |
+
β Score 0 if ANY:
|
| 505 |
+
- Fewer than 2 examples
|
| 506 |
+
- Examples lack business context
|
| 507 |
+
- Examples don't clearly support learning
|
| 508 |
|
| 509 |
Cohesive Storytelling:
|
| 510 |
+
β Score 1 if ALL:
|
| 511 |
+
- Clear narrative structure
|
| 512 |
+
- Logical topic transitions
|
| 513 |
+
- Consistent theme throughout
|
| 514 |
+
β Score 0 if ANY:
|
| 515 |
+
- Disjointed narrative
|
| 516 |
+
- Abrupt topic changes
|
| 517 |
+
- Inconsistent theme
|
| 518 |
|
| 519 |
Engagement and Interaction:
|
| 520 |
+
β Score 1 if ALL:
|
| 521 |
+
- Regular audience engagement
|
| 522 |
+
- Effective use of questions
|
| 523 |
+
- Clear response to audience cues
|
| 524 |
+
β Score 0 if ANY:
|
| 525 |
+
- Minimal audience interaction
|
| 526 |
+
- One-way lecture style
|
| 527 |
+
- Misses engagement opportunities
|
| 528 |
|
| 529 |
Professional Tone:
|
| 530 |
+
β Score 1 if ALL:
|
| 531 |
+
- Consistently professional language
|
| 532 |
+
- Appropriate level of formality
|
| 533 |
+
- Clear and confident delivery
|
| 534 |
+
β Score 0 if ANY:
|
| 535 |
+
- Casual or inappropriate language
|
| 536 |
+
- Inconsistent formality
|
| 537 |
+
- Uncertain or unclear delivery
|
| 538 |
+
|
| 539 |
+
Code Assessment Criteria:
|
| 540 |
|
| 541 |
Depth of Explanation:
|
| 542 |
+
β Score 1 if ALL:
|
| 543 |
+
- Explains code purpose and structure
|
| 544 |
+
- Covers implementation details
|
| 545 |
+
- Addresses potential issues/alternatives
|
| 546 |
+
β Score 0 if ANY:
|
| 547 |
+
- Surface-level explanation
|
| 548 |
+
- Missing implementation details
|
| 549 |
+
- No discussion of alternatives
|
| 550 |
|
| 551 |
Output Interpretation:
|
| 552 |
+
β Score 1 if ALL:
|
| 553 |
+
- Clear explanation of expected outputs
|
| 554 |
+
- Error handling discussion
|
| 555 |
+
- Performance implications covered
|
| 556 |
+
β Score 0 if ANY:
|
| 557 |
+
- Unclear output expectations
|
| 558 |
+
- No error handling discussion
|
| 559 |
+
- Missing performance context
|
| 560 |
|
| 561 |
Breaking down Complexity:
|
| 562 |
+
β Score 1 if ALL:
|
| 563 |
+
- Complex concepts broken into digestible parts
|
| 564 |
+
- Clear step-by-step explanation
|
| 565 |
+
- Logical progression of difficulty
|
| 566 |
+
β Score 0 if ANY:
|
| 567 |
+
- Overwhelming complexity
|
| 568 |
+
- Missing steps in explanation
|
| 569 |
+
- Illogical difficulty progression
|
| 570 |
|
| 571 |
Important Notes:
|
| 572 |
+
- Each criterion is evaluated independently
|
| 573 |
+
- Citations must directly support scoring decision
|
| 574 |
+
- No partial credit - must meet ALL requirements for a score of 1
|
| 575 |
+
- Look for explicit evidence in transcript
|
| 576 |
+
- Different criteria can receive different scores based on evidence"""
|
|
|
|
|
|
|
| 577 |
|
| 578 |
return prompt_template.format(
|
| 579 |
transcript=transcript,
|