feat: improve AI dialogue evaluation and capability boundaries
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kouyu_english/core/ai_service.dart';
|
||||
import 'package:kouyu_english/core/models.dart';
|
||||
|
||||
void main() {
|
||||
test('AI capability registry exposes stable bounded contracts', () {
|
||||
final descriptors = AiService.instance.capabilities.descriptors;
|
||||
|
||||
expect(descriptors.map((item) => item.id).toSet(), {
|
||||
'speech-transcription',
|
||||
'lexicon-explanation',
|
||||
'dialogue-coach',
|
||||
'answer-evaluation',
|
||||
'review-generation',
|
||||
});
|
||||
expect(
|
||||
descriptors.map((item) => item.id).toSet(),
|
||||
hasLength(descriptors.length),
|
||||
);
|
||||
expect(descriptors, everyElement(isA<AiCapabilityDescriptor>()));
|
||||
expect(
|
||||
descriptors,
|
||||
everyElement(
|
||||
predicate<AiCapabilityDescriptor>(
|
||||
(item) => item.promptVersion > 0 && item.outputContract.isNotEmpty,
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'lexicon capability routes through the existing validated service',
|
||||
() async {
|
||||
final result = await AiService.instance.capabilities.lexicon
|
||||
.analyzeSentence(
|
||||
provider: AiProviderType.mock,
|
||||
endpoint: '',
|
||||
model: '',
|
||||
text: "I'd like to check in, please.",
|
||||
);
|
||||
|
||||
expect(result, isNotNull);
|
||||
expect(result!.translation, isNotEmpty);
|
||||
expect(result.provider, 'mock');
|
||||
},
|
||||
);
|
||||
|
||||
test('dialogue capability preserves mock fallback behavior', () async {
|
||||
final result = await AiService.instance.capabilities.dialogue.reply(
|
||||
provider: AiProviderType.mock,
|
||||
endpoint: '',
|
||||
model: '',
|
||||
history: const [],
|
||||
aiGoal: 'Ask the learner how they are.',
|
||||
learnerTask: 'Say how they feel.',
|
||||
);
|
||||
|
||||
expect(result, isNull);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user