Spaces:
Running on Zero
Running on Zero
Upload community_contributions/english_learning_tutor_ns_sly/agents/curriculum_agent.py with huggingface_hub
Browse files
community_contributions/english_learning_tutor_ns_sly/agents/curriculum_agent.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from agents.agent import Agent
|
| 2 |
+
|
| 3 |
+
class CurriculumAgent(Agent):
|
| 4 |
+
"""
|
| 5 |
+
Adaptive learning agent that upgrades or downgrades
|
| 6 |
+
user difficulty based on performance metrics.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
LEVELS = [
|
| 10 |
+
"Beginner",
|
| 11 |
+
"Intermediate",
|
| 12 |
+
"Advanced",
|
| 13 |
+
"Native"
|
| 14 |
+
]
|
| 15 |
+
|
| 16 |
+
def __init__(self):
|
| 17 |
+
|
| 18 |
+
self.upgrade_threshold = 85
|
| 19 |
+
self.downgrade_threshold = 40
|
| 20 |
+
self.name = "CurriculumAgent"
|
| 21 |
+
self.color = Agent.GREEN
|
| 22 |
+
self.log("CurriculumAgent initialized")
|
| 23 |
+
|
| 24 |
+
def evaluate(self, level, pronunciation, grammar, accent):
|
| 25 |
+
|
| 26 |
+
avg_score = (pronunciation + grammar + accent) / 3
|
| 27 |
+
|
| 28 |
+
idx = self.LEVELS.index(level)
|
| 29 |
+
|
| 30 |
+
if avg_score > self.upgrade_threshold and idx < 3:
|
| 31 |
+
return self.LEVELS[idx + 1]
|
| 32 |
+
|
| 33 |
+
if avg_score < self.downgrade_threshold and idx > 0:
|
| 34 |
+
return self.LEVELS[idx - 1]
|
| 35 |
+
|
| 36 |
+
return level
|