|
|
|
|
|
|
|
|
|
|
|
from chatbot import ITMOChatbot
|
|
|
from knowledge_base import KnowledgeBase
|
|
|
|
|
|
def test_chatbot():
|
|
|
print("🧪 Тестирование чат-бота...")
|
|
|
|
|
|
|
|
|
try:
|
|
|
chatbot = ITMOChatbot()
|
|
|
print("✅ Чат-бот инициализирован")
|
|
|
except Exception as e:
|
|
|
print(f"❌ Ошибка инициализации: {e}")
|
|
|
return
|
|
|
|
|
|
|
|
|
kb = KnowledgeBase()
|
|
|
print(f"📊 Курсов в базе: {len(kb.courses)}")
|
|
|
|
|
|
|
|
|
for semester in [1, 2, 3, 4]:
|
|
|
courses = kb.get_courses_by_semester(semester)
|
|
|
print(f"📚 Семестр {semester}: {len(courses)} курсов")
|
|
|
if courses:
|
|
|
print(f" Пример: {courses[0]['name']}")
|
|
|
|
|
|
|
|
|
print("\n💬 Тест чата:")
|
|
|
test_messages = [
|
|
|
"Какие дисциплины по NLP в 1 семестре программы ИИ?",
|
|
|
"Расскажи о программе AI Product",
|
|
|
"Сколько кредитов за курс машинного обучения?"
|
|
|
]
|
|
|
|
|
|
history = []
|
|
|
for message in test_messages:
|
|
|
print(f"\n👤 Вопрос: {message}")
|
|
|
try:
|
|
|
response, score = chatbot.chat(message, history)
|
|
|
print(f"🤖 Ответ: {response[:100]}...")
|
|
|
print(f"📊 Релевантность: {score:.2f}")
|
|
|
history.append([message, response])
|
|
|
except Exception as e:
|
|
|
print(f"❌ Ошибка: {e}")
|
|
|
|
|
|
|
|
|
print("\n🎯 Тест рекомендаций:")
|
|
|
test_profiles = [
|
|
|
{
|
|
|
'programming_experience': 4,
|
|
|
'math_level': 3,
|
|
|
'interests': ['ml', 'dl', 'python'],
|
|
|
'semester': 1
|
|
|
},
|
|
|
{
|
|
|
'programming_experience': 2,
|
|
|
'math_level': 2,
|
|
|
'interests': ['product', 'business'],
|
|
|
'semester': 2
|
|
|
}
|
|
|
]
|
|
|
|
|
|
for i, profile in enumerate(test_profiles, 1):
|
|
|
print(f"\n👤 Профиль {i}: {profile}")
|
|
|
try:
|
|
|
recommendations = chatbot.recommend_courses(profile)
|
|
|
print(f"🎯 Рекомендации: {recommendations[:200]}...")
|
|
|
except Exception as e:
|
|
|
print(f"❌ Ошибка: {e}")
|
|
|
|
|
|
print("\n✅ Тестирование завершено!")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
test_chatbot()
|
|
|
|