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,7 @@ 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 with
|
| 466 |
|
| 467 |
Transcript:
|
| 468 |
{transcript}
|
|
@@ -474,121 +474,110 @@ Required JSON structure:
|
|
| 474 |
{{
|
| 475 |
"Concept Assessment": {{
|
| 476 |
"Subject Matter Accuracy": {{
|
| 477 |
-
"Score": 1, # Score 1
|
| 478 |
"Citations": ["[MM:SS] Quote demonstrating accuracy or error"]
|
| 479 |
}},
|
| 480 |
"First Principles Approach": {{
|
| 481 |
-
"Score": 1, # Score 1
|
| 482 |
"Citations": ["[MM:SS] Quote showing fundamental concept explanation"]
|
| 483 |
}},
|
| 484 |
"Examples and Business Context": {{
|
| 485 |
-
"Score": 1, # Score 1
|
| 486 |
"Citations": ["[MM:SS] Quote containing practical example"]
|
| 487 |
}},
|
| 488 |
"Cohesive Storytelling": {{
|
| 489 |
-
"Score": 1, # Score 1
|
| 490 |
"Citations": ["[MM:SS] Quote showing topic transition or connection"]
|
| 491 |
}},
|
| 492 |
"Engagement and Interaction": {{
|
| 493 |
-
"Score": 1, # Score 1
|
| 494 |
"Citations": ["[MM:SS] Quote showing audience engagement"]
|
| 495 |
}},
|
| 496 |
"Professional Tone": {{
|
| 497 |
-
"Score": 1, # Score 1
|
| 498 |
"Citations": ["[MM:SS] Quote demonstrating tone"]
|
| 499 |
}}
|
| 500 |
}},
|
| 501 |
"Code Assessment": {{
|
| 502 |
"Depth of Explanation": {{
|
| 503 |
-
"Score": 1, # Score 1
|
| 504 |
-
"Citations": ["[MM:SS] Quote showing
|
| 505 |
}},
|
| 506 |
"Output Interpretation": {{
|
| 507 |
-
"Score": 1, # Score 1
|
| 508 |
"Citations": ["[MM:SS] Quote demonstrating output explanation"]
|
| 509 |
}},
|
| 510 |
"Breaking down Complexity": {{
|
| 511 |
-
"Score": 1, # Score 1
|
| 512 |
"Citations": ["[MM:SS] Quote showing concept breakdown"]
|
| 513 |
}}
|
| 514 |
}}
|
| 515 |
}}
|
| 516 |
|
| 517 |
-
|
| 518 |
|
| 519 |
Concept Assessment:
|
| 520 |
-
1. Subject Matter Accuracy
|
| 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 |
-
6. Professional Tone (Must meet ALL):
|
| 556 |
-
- Zero casual or colloquial expressions
|
| 557 |
-
- Consistent technical vocabulary
|
| 558 |
-
- Clear and confident delivery
|
| 559 |
- Appropriate level of formality
|
| 560 |
-
- No filler words or hesitations
|
| 561 |
|
| 562 |
Code Assessment:
|
| 563 |
-
1. Depth of Explanation
|
| 564 |
-
-
|
| 565 |
-
-
|
| 566 |
-
-
|
| 567 |
-
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
-
|
| 572 |
-
-
|
| 573 |
-
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
-
|
| 579 |
-
-
|
| 580 |
-
- Clear progression in complexity
|
| 581 |
-
- Logical organization of technical content
|
| 582 |
-
- Dependencies and relationships explained
|
| 583 |
|
| 584 |
Important:
|
| 585 |
-
- Score 1
|
| 586 |
-
-
|
| 587 |
-
- Each citation must include
|
| 588 |
-
- Citations
|
| 589 |
-
- Be
|
| 590 |
-
- When in doubt, score 0
|
| 591 |
-
- No partial credit - all requirements must be met for a score of 1"""
|
| 592 |
|
| 593 |
return prompt_template.format(
|
| 594 |
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 more 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 with balanced evaluation criteria. Score 1 if most key requirements are met.
|
| 466 |
|
| 467 |
Transcript:
|
| 468 |
{transcript}
|
|
|
|
| 474 |
{{
|
| 475 |
"Concept Assessment": {{
|
| 476 |
"Subject Matter Accuracy": {{
|
| 477 |
+
"Score": 1, # Score 1 if technical information is generally accurate with minor errors acceptable
|
| 478 |
"Citations": ["[MM:SS] Quote demonstrating accuracy or error"]
|
| 479 |
}},
|
| 480 |
"First Principles Approach": {{
|
| 481 |
+
"Score": 1, # Score 1 if most concepts are built from fundamentals with clear progression
|
| 482 |
"Citations": ["[MM:SS] Quote showing fundamental concept explanation"]
|
| 483 |
}},
|
| 484 |
"Examples and Business Context": {{
|
| 485 |
+
"Score": 1, # Score 1 if at least 2 relevant real-world examples are provided
|
| 486 |
"Citations": ["[MM:SS] Quote containing practical example"]
|
| 487 |
}},
|
| 488 |
"Cohesive Storytelling": {{
|
| 489 |
+
"Score": 1, # Score 1 if most transitions are smooth with clear connections between topics
|
| 490 |
"Citations": ["[MM:SS] Quote showing topic transition or connection"]
|
| 491 |
}},
|
| 492 |
"Engagement and Interaction": {{
|
| 493 |
+
"Score": 1, # Score 1 if at least 1 engagement technique is used effectively
|
| 494 |
"Citations": ["[MM:SS] Quote showing audience engagement"]
|
| 495 |
}},
|
| 496 |
"Professional Tone": {{
|
| 497 |
+
"Score": 1, # Score 1 if language is generally professional with occasional casual expressions acceptable
|
| 498 |
"Citations": ["[MM:SS] Quote demonstrating tone"]
|
| 499 |
}}
|
| 500 |
}},
|
| 501 |
"Code Assessment": {{
|
| 502 |
"Depth of Explanation": {{
|
| 503 |
+
"Score": 1, # Score 1 if most code concepts include what and why explanations
|
| 504 |
+
"Citations": ["[MM:SS] Quote showing code explanation"]
|
| 505 |
}},
|
| 506 |
"Output Interpretation": {{
|
| 507 |
+
"Score": 1, # Score 1 if most code outputs are explained with their significance
|
| 508 |
"Citations": ["[MM:SS] Quote demonstrating output explanation"]
|
| 509 |
}},
|
| 510 |
"Breaking down Complexity": {{
|
| 511 |
+
"Score": 1, # Score 1 if complex concepts are generally broken into understandable components
|
| 512 |
"Citations": ["[MM:SS] Quote showing concept breakdown"]
|
| 513 |
}}
|
| 514 |
}}
|
| 515 |
}}
|
| 516 |
|
| 517 |
+
Balanced Evaluation Criteria:
|
| 518 |
|
| 519 |
Concept Assessment:
|
| 520 |
+
1. Subject Matter Accuracy:
|
| 521 |
+
- Generally accurate technical information
|
| 522 |
+
- Minor errors acceptable if core concepts are correct
|
| 523 |
+
- Clear explanation of key technical terms
|
| 524 |
+
- Comprehensive coverage of main concepts
|
| 525 |
+
|
| 526 |
+
2. First Principles Approach:
|
| 527 |
+
- Most concepts built from fundamental principles
|
| 528 |
+
- Clear progression in concept difficulty
|
| 529 |
+
- Basic concepts explained before advanced ones
|
| 530 |
+
- Logical sequence of topics
|
| 531 |
+
|
| 532 |
+
3. Examples and Business Context:
|
| 533 |
+
- At least 2 relevant real-world examples
|
| 534 |
+
- Examples clearly related to concepts
|
| 535 |
+
- Business value explained
|
| 536 |
+
- Practical applications discussed
|
| 537 |
+
|
| 538 |
+
4. Cohesive Storytelling:
|
| 539 |
+
- Most topics connected logically
|
| 540 |
+
- Generally clear narrative flow
|
| 541 |
+
- Smooth transitions between main topics
|
| 542 |
+
- Consistent overall structure
|
| 543 |
+
|
| 544 |
+
5. Engagement and Interaction:
|
| 545 |
+
- At least 1 engagement technique used
|
| 546 |
+
- Some audience involvement
|
| 547 |
+
- Occasional checks for understanding
|
| 548 |
+
- Varied teaching approach
|
| 549 |
+
|
| 550 |
+
6. Professional Tone:
|
| 551 |
+
- Generally professional language
|
| 552 |
+
- Occasional casual expressions acceptable
|
| 553 |
+
- Clear delivery
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 554 |
- Appropriate level of formality
|
|
|
|
| 555 |
|
| 556 |
Code Assessment:
|
| 557 |
+
1. Depth of Explanation:
|
| 558 |
+
- Most code concepts explain what and why
|
| 559 |
+
- Key implementation details covered
|
| 560 |
+
- Important design decisions explained
|
| 561 |
+
- Best practices mentioned
|
| 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,
|