correção de bugs, creação propria para turmas, e preparação para criar quizzes
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import '../lib/core/services/content_service.dart';
|
||||
import '../lib/core/services/vector_service.dart';
|
||||
import '../lib/core/services/rag_service.dart';
|
||||
import '../lib/core/services/rag_ai_service.dart';
|
||||
import '../lib/core/services/rag_service.dart' show TutorMode;
|
||||
import '../lib/core/models/content_chunk.dart';
|
||||
|
||||
void main() {
|
||||
@@ -64,81 +63,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('RAGService - Mode Instructions', () {
|
||||
print('🔍 Testing RAG service mode instructions...');
|
||||
|
||||
// Test different modes
|
||||
final explanationMode = RAGService._getModeInstructions(
|
||||
TutorMode.explanation,
|
||||
);
|
||||
final tutorMode = RAGService._getModeInstructions(TutorMode.tutor);
|
||||
final explorationMode = RAGService._getModeInstructions(
|
||||
TutorMode.exploration,
|
||||
);
|
||||
|
||||
expect(explanationMode, contains('explicações detalhadas'));
|
||||
expect(tutorMode, contains('método socrático'));
|
||||
expect(explorationMode, contains('exploração'));
|
||||
|
||||
print('✅ Mode instructions generated correctly');
|
||||
print(' Explanation: "${explanationMode.substring(0, 50)}..."');
|
||||
print(' Tutor: "${tutorMode.substring(0, 50)}..."');
|
||||
print(' Exploration: "${explorationMode.substring(0, 50)}..."');
|
||||
});
|
||||
|
||||
test('RAGService - Context Building', () {
|
||||
print('🔍 Testing context window building...');
|
||||
|
||||
// Create mock content chunks
|
||||
final chunks = [
|
||||
ContentChunk(
|
||||
id: 'test1',
|
||||
contentId: 'content1',
|
||||
text:
|
||||
'A fotossíntese é o processo biológico que converte luz solar em energia química.',
|
||||
subject: 'Biologia',
|
||||
concept: 'Fotossíntese',
|
||||
unit: 'Processos Biológicos',
|
||||
difficulty: 0.6,
|
||||
grade: 10,
|
||||
embedding: List.filled(384, 0.1),
|
||||
sourceDocument: 'Biologia Manual.pdf',
|
||||
metadata: {},
|
||||
createdAt: DateTime.now(),
|
||||
),
|
||||
ContentChunk(
|
||||
id: 'test2',
|
||||
contentId: 'content1',
|
||||
text:
|
||||
'Durante a fotossíntese, as plantas absorvem CO2 e liberam oxigénio.',
|
||||
subject: 'Biologia',
|
||||
concept: 'Fotossíntese',
|
||||
unit: 'Processos Biológicos',
|
||||
difficulty: 0.7,
|
||||
grade: 10,
|
||||
embedding: List.filled(384, 0.2),
|
||||
sourceDocument: 'Biologia Manual.pdf',
|
||||
metadata: {},
|
||||
createdAt: DateTime.now(),
|
||||
),
|
||||
];
|
||||
|
||||
final context = RAGService._buildContextWindow(
|
||||
chunks,
|
||||
'O que é fotossíntese?',
|
||||
TutorMode.explanation,
|
||||
);
|
||||
|
||||
expect(context, contains('CONTEÚDO EDUCACIONAL RELEVANTE'));
|
||||
expect(context, contains('Fotossíntese'));
|
||||
expect(context, contains('Biologia'));
|
||||
expect(context, contains('INSTRUÇÕES DE TUTORIA'));
|
||||
|
||||
print('✅ Context window built successfully');
|
||||
print(' Context length: ${context.length} characters');
|
||||
print(' Contains ${chunks.length} source chunks');
|
||||
});
|
||||
|
||||
test('RAGAIService - Service Availability', () async {
|
||||
print('🔍 Testing Ollama service availability...');
|
||||
|
||||
@@ -200,19 +124,11 @@ void main() {
|
||||
),
|
||||
];
|
||||
|
||||
// Step 3: Build context
|
||||
final context = RAGService._buildContextWindow(
|
||||
mockChunks,
|
||||
userQuery,
|
||||
mode,
|
||||
);
|
||||
print(' ✅ Context built (${context.length} chars)');
|
||||
|
||||
// Step 4: Test AI service if available
|
||||
// Step 3: Test AI service if available
|
||||
try {
|
||||
final ragResponse = await RAGAIService.generateRAGResponse(
|
||||
userQuery: userQuery,
|
||||
context: context,
|
||||
context: userQuery,
|
||||
mode: mode,
|
||||
sources: mockChunks,
|
||||
);
|
||||
@@ -221,23 +137,8 @@ void main() {
|
||||
print(' Answer: "${ragResponse.answer.substring(0, 100)}..."');
|
||||
print(' Confidence: ${ragResponse.confidence.toStringAsFixed(2)}');
|
||||
print(' Sources: ${ragResponse.sources.length}');
|
||||
print(
|
||||
' Related concepts: ${ragResponse.relatedConcepts.join(', ')}',
|
||||
);
|
||||
} catch (e) {
|
||||
print(' ⚠️ AI service not available, using mock response');
|
||||
|
||||
// Create mock response
|
||||
final mockResponse = RAGService._createRAGResponse(
|
||||
query: userQuery,
|
||||
context: context,
|
||||
mode: mode,
|
||||
sources: mockChunks,
|
||||
);
|
||||
|
||||
print(' ✅ Mock RAG response created');
|
||||
print(' Answer: "${mockResponse.answer.substring(0, 100)}..."');
|
||||
print(' Confidence: ${mockResponse.confidence.toStringAsFixed(2)}');
|
||||
print(' ⚠️ AI service not available: $e');
|
||||
}
|
||||
|
||||
print('✅ RAG pipeline simulation completed successfully');
|
||||
|
||||
Reference in New Issue
Block a user