-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassessment_feedback_ai.py
44 lines (36 loc) · 1.61 KB
/
assessment_feedback_ai.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from transformers import pipeline
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from typing import List
class AssessmentFeedbackAI:
def __init__(self):
self.assessment_feedback_ai = pipeline('sentiment-analysis')
self.chatbot = ChatBot('AssessmentChatBot')
trainer = ChatterBotCorpusTrainer(self.chatbot)
trainer.train("chatterbot.corpus.english") # Train the chatbot based on the English corpus
def get_assessment_feedback(self, student_answers: List[str]) -> List[dict]:
try:
<<<<<<< HEAD
return self.asseitssment_feedback_ai(student_answers)
=======
return self.assessment_feedback_ai(student_answers)
>>>>>>> 8478cd0c6baded29a057b2e5cabb6540d1cb0952
except Exception as e:
print(f"An error occurred: {e}")
return []
def get_conversation(self, conversation: str) -> str:
return str(self.chatbot.get_response(conversation))
assessment_feedback_ai = AssessmentFeedbackAI()
def init() -> None:
print("Assessment Feedback AI Initialized")
def get_assessment_feedback(student_answers: List[str]) -> List[dict]:
return assessment_feedback_ai.get_assessment_feedback(student_answers)
def get_conversation(conversation: str) -> str:
return assessment_feedback_ai.get_conversation(conversation)
if __name__ == "__main__":
init()
student_answers = ["I love this class!", "This is too difficult."]
feedback = get_assessment_feedback(student_answers)
print(feedback)
conversation = get_conversation("Tell me about the test results.")
print(conversation)