-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_language_service.py
More file actions
70 lines (57 loc) · 2.35 KB
/
test_language_service.py
File metadata and controls
70 lines (57 loc) · 2.35 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
"""
Test script for the language learning functionality
"""
import os
import json
from src.services.language_service import LanguageService
from src.services.language_chroma_store import LanguageChromaStore
def test_language_service():
"""Test the language service functionality."""
print("Testing Language Service...")
# Initialize services
language_service = LanguageService()
chroma_store = LanguageChromaStore()
# Test 1: Check if languages directory exists
print(f"Languages directory exists: {os.path.exists('languages')}")
# Test 2: Get available languages (should be empty initially)
available_languages = language_service.get_available_languages()
print(f"Available languages: {available_languages}")
# Test 3: Test ChromaDB functionality
print("Testing ChromaDB functionality...")
# Store a test query
query_id = chroma_store.store_user_query(
language="Korean",
query="How do I conjugate verbs in Korean?",
lesson_context="Basic grammar lesson",
module=1,
submodule=1,
lesson=1
)
print(f"Stored query with ID: {query_id}")
# Store test learning history
history_id = chroma_store.store_learning_history(
language="Korean",
concept="Verb conjugation",
difficulty_level="intermediate",
user_feedback="I struggle with irregular verbs"
)
print(f"Stored learning history with ID: {history_id}")
# Store test difficulty
difficulty_id = chroma_store.store_difficulty(
language="Korean",
concept="Verb conjugation",
difficulty_description="Irregular verb patterns are confusing",
grammar_structure="irregular verbs",
semantic_concept="verb conjugation"
)
print(f"Stored difficulty with ID: {difficulty_id}")
# Test 4: Get relevant context
relevant_context = chroma_store.get_relevant_context("Korean", "verb conjugation", n_results=3)
print(f"Found {len(relevant_context)} relevant contexts")
# Test 5: Create RAG prompt
rag_prompt = chroma_store.create_rag_prompt("Korean", "How do I conjugate verbs?", 1, 1, 1)
print(f"RAG prompt length: {len(rag_prompt)} characters")
print("Language service tests completed successfully!")
if __name__ == "__main__":
test_language_service()