|
6 | 6 | import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
|
7 | 7 | import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
|
8 | 8 | import org.springframework.ai.chat.model.ChatModel;
|
| 9 | +import org.springframework.ai.document.Document; |
9 | 10 | import org.springframework.ai.evaluation.EvaluationRequest;
|
10 | 11 | import org.springframework.ai.evaluation.EvaluationResponse;
|
11 | 12 | import org.springframework.ai.evaluation.FactCheckingEvaluator;
|
12 |
| -import org.springframework.ai.model.Content; |
13 | 13 | import org.springframework.ai.ollama.OllamaChatModel;
|
14 | 14 | import org.springframework.ai.ollama.api.OllamaApi;
|
15 | 15 | import org.springframework.ai.ollama.api.OllamaOptions;
|
@@ -48,12 +48,8 @@ class TestcontainersHelpControllerTest {
|
48 | 48 | @BeforeEach
|
49 | 49 | void setUp() {
|
50 | 50 | ChatModel chatModel = OllamaChatModel.builder()
|
51 |
| - .withOllamaApi(this.ollamaApi) |
52 |
| - .withDefaultOptions(OllamaOptions.builder() |
53 |
| - .withModel(BESPOKE_MINICHECK) |
54 |
| - .withNumPredict(2) |
55 |
| - .withTemperature(0.0d) |
56 |
| - .build()) |
| 51 | + .ollamaApi(this.ollamaApi) |
| 52 | + .defaultOptions(OllamaOptions.builder().model(BESPOKE_MINICHECK).numPredict(2).temperature(0.0d).build()) |
57 | 53 | .build();
|
58 | 54 | this.factCheckChatClientBuilder = ChatClient.builder(chatModel).defaultAdvisors(new SimpleLoggerAdvisor());
|
59 | 55 | }
|
@@ -84,12 +80,13 @@ private String retrieveAnswer(String question) {
|
84 | 80 | }
|
85 | 81 |
|
86 | 82 | private void assertFactCheck(String question, String answer) {
|
87 |
| - FactCheckingEvaluator factCheckingEvaluator = new FactCheckingEvaluator(this.factCheckChatClientBuilder); |
| 83 | + FactCheckingEvaluator factCheckingEvaluator = FactCheckingEvaluator |
| 84 | + .forBespokeMinicheck(this.factCheckChatClientBuilder); |
88 | 85 | EvaluationResponse evaluate = factCheckingEvaluator.evaluate(new EvaluationRequest(docs(question), answer));
|
89 | 86 | assertThat(evaluate.isPass()).isTrue();
|
90 | 87 | }
|
91 | 88 |
|
92 |
| - private List<Content> docs(String question) { |
| 89 | + private List<Document> docs(String question) { |
93 | 90 | var response = TestcontainersHelpController
|
94 | 91 | .callResponseSpec(this.chatClientBuilder.build(), this.vectorStore, question)
|
95 | 92 | .chatResponse();
|
|
0 commit comments