ldrissi commited on
Commit
3aabd8c
·
1 Parent(s): 2c37bf7

finish the idea of micro learning part 5

Browse files
Files changed (1) hide show
  1. api/agents.py +29 -1
api/agents.py CHANGED
@@ -32,4 +32,32 @@ class QuizAgent(Agent):
32
  "context": potential_answer
33
  })
34
 
35
- return questions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  "context": potential_answer
33
  })
34
 
35
+ return questions
36
+
37
+ # New PersonalizationAgent in ai/agents.py
38
+ class PersonalizationAgent(Agent):
39
+ def __init__(self, hf_service):
40
+ super().__init__("Personalizer", "Adapts content for users")
41
+ self.hf = hf_service
42
+
43
+ def process(self, content, context=None):
44
+ # Context should contain user profile/level
45
+ if not context or 'level' not in context:
46
+ return content
47
+
48
+ user_level = context['level']
49
+
50
+ if user_level == 'beginner':
51
+ # Simplify content, add more explanations
52
+ simplified = self.hf.summarize_content(
53
+ content,
54
+ max_length=len(content.split()) // 2 # Half the original length
55
+ )[0]['summary_text']
56
+ return f"{simplified}\n\nLet's break this down further: {content}"
57
+
58
+ elif user_level == 'advanced':
59
+ # Provide more detailed content
60
+ return f"{content}\n\nFor advanced learners: [Additional depth would be added here]"
61
+
62
+ # Default - intermediate
63
+ return content