spring-ai-test/README.md
The Spring AI Test module provides utilities and base classes for testing AI applications built with Spring AI.
The BasicEvaluationTest class provides a framework for evaluating the quality and relevance of AI-generated answers to questions.
Extend the BasicEvaluationTest class in your test classes:
@SpringBootTest
public class MyAiEvaluationTest extends BasicEvaluationTest {
@Test
public void testQuestionAnswerAccuracy() {
String question = "What is the capital of France?";
String answer = "The capital of France is Paris.";
// Evaluate if the answer is accurate and related to the question
evaluateQuestionAndAnswer(question, answer, true);
}
}
The test requires:
ChatModel bean (typically OpenAI)classpath:/prompts/spring/test/evaluation/factBased = true for questions requiring factual accuracyfactBased = false for more subjective questionsThe evaluation process: