Skip to content

Commit c347c6f

Browse files
committed
Refactor: Move evaluation, converter, transformer, and util classes
- Move evaluation core classes (Request, Response, Evaluator) to spring-ai-commons. - Move chat-specific evaluators (FactChecking, Relevancy) to spring-ai-client-chat#evaluation package. - Move OutputConverter implementations and related classes to spring-ai-model#converter package. - Move MetadataEnricher transformer classes to spring-ai-model#transformer package. - Move PromptAssert utility to spring-ai-rag#util package. - Update relevant pom.xml files and adjust imports in affected classes. - Document class movements in upgrade-notes.adoc for M8 release. This refactoring improves module organization and separation of concerns. Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
1 parent aa24a56 commit c347c6f

File tree

30 files changed

+55
-37
lines changed

30 files changed

+55
-37
lines changed

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/transformer/MetadataTransformerIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.junit.jupiter.api.Test;
2525
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2626

27-
import org.springframework.ai.chat.transformer.KeywordMetadataEnricher;
28-
import org.springframework.ai.chat.transformer.SummaryMetadataEnricher;
27+
import org.springframework.ai.model.transformer.KeywordMetadataEnricher;
28+
import org.springframework.ai.model.transformer.SummaryMetadataEnricher;
2929
import org.springframework.ai.document.DefaultContentFormatter;
3030
import org.springframework.ai.document.Document;
3131
import org.springframework.ai.openai.OpenAiChatModel;

spring-ai-client-chat/pom.xml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@
7373
<artifactId>spring-context</artifactId>
7474
</dependency>
7575

76-
77-
<dependency>
78-
<groupId>org.springframework</groupId>
79-
<artifactId>spring-messaging</artifactId>
80-
</dependency>
81-
8276
<dependency>
8377
<groupId>com.knuddels</groupId>
8478
<artifactId>jtokkit</artifactId>
@@ -91,22 +85,6 @@
9185
<version>${jsonschema.version}</version>
9286
</dependency>
9387

94-
<dependency>
95-
<groupId>com.github.victools</groupId>
96-
<artifactId>jsonschema-module-jackson</artifactId>
97-
<version>${jsonschema.version}</version>
98-
</dependency>
99-
100-
<dependency>
101-
<groupId>com.fasterxml.jackson.core</groupId>
102-
<artifactId>jackson-databind</artifactId>
103-
</dependency>
104-
105-
<dependency>
106-
<groupId>com.fasterxml.jackson.datatype</groupId>
107-
<artifactId>jackson-datatype-jsr310</artifactId>
108-
</dependency>
109-
11088
<dependency>
11189
<groupId>org.jetbrains.kotlin</groupId>
11290
<artifactId>kotlin-stdlib</artifactId>

spring-ai-client-chat/src/main/java/org/springframework/ai/evaluation/FactCheckingEvaluator.java renamed to spring-ai-client-chat/src/main/java/org/springframework/ai/chat/evaluation/FactCheckingEvaluator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.evaluation;
17+
package org.springframework.ai.chat.evaluation;
1818

1919
import java.util.Collections;
2020

2121
import org.springframework.ai.chat.client.ChatClient;
22+
import org.springframework.ai.evaluation.EvaluationRequest;
23+
import org.springframework.ai.evaluation.EvaluationResponse;
24+
import org.springframework.ai.evaluation.Evaluator;
2225

2326
/**
2427
* Implementation of {@link Evaluator} used to evaluate the factual accuracy of Large

spring-ai-client-chat/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java renamed to spring-ai-client-chat/src/main/java/org/springframework/ai/chat/evaluation/RelevancyEvaluator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.evaluation;
17+
package org.springframework.ai.chat.evaluation;
1818

1919
import java.util.Collections;
2020

2121
import org.springframework.ai.chat.client.ChatClient;
22+
import org.springframework.ai.evaluation.EvaluationRequest;
23+
import org.springframework.ai.evaluation.EvaluationResponse;
24+
import org.springframework.ai.evaluation.Evaluator;
2225

2326
public class RelevancyEvaluator implements Evaluator {
2427

spring-ai-docs/src/main/antora/modules/ROOT/pages/upgrade-notes.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ QuestionAnswerAdvisor newAdvisor = QuestionAnswerAdvisor.builder(vectorStore)
200200

201201
* The `PromptTemplate` API has been redesigned to support a more flexible and extensible way of templating prompts, relying on a new `TemplateRenderer` API. As part of this change, the `getInputVariables()` and `validate()` methods have been deprecated and will throw an `UnsupportedOperationException` if called. Any logic specific to a template engine should be available through the `TemplateRenderer` API.
202202

203+
=== Class Package Refactoring
204+
205+
Several classes have been moved to different modules and packages for better organization:
206+
207+
* Evaluation classes moved:
208+
** `org.springframework.ai.evaluation.FactCheckingEvaluator` moved to `org.springframework.ai.chat.evaluation` package within `spring-ai-client-chat`.
209+
** `org.springframework.ai.evaluation.RelevancyEvaluator` moved to `org.springframework.ai.chat.evaluation` package within `spring-ai-client-chat`.
210+
** `org.springframework.ai.evaluation.EvaluationRequest`, `EvaluationResponse`, and `Evaluator` moved from `spring-ai-client-chat` to `spring-ai-commons` under the `org.springframework.ai.evaluation` package.
211+
* Output converter classes moved:
212+
** Classes within `org.springframework.ai.converter` (e.g., `BeanOutputConverter`, `ListOutputConverter`, `MapOutputConverter`, `StructuredOutputConverter`, etc.) moved from `spring-ai-client-chat` to `spring-ai-model`.
213+
* Transformer classes moved:
214+
** `org.springframework.ai.chat.transformer.KeywordMetadataEnricher` moved to `org.springframework.ai.model.transformer.KeywordMetadataEnricher` in `spring-ai-model`.
215+
** `org.springframework.ai.chat.transformer.SummaryMetadataEnricher` moved to `org.springframework.ai.model.transformer.SummaryMetadataEnricher` in `spring-ai-model`.
216+
* Utility classes moved:
217+
** `org.springframework.ai.util.PromptAssert` moved from `spring-ai-client-chat` to `org.springframework.ai.rag.util.PromptAssert` in `spring-ai-rag`.
218+
219+
Please update your imports accordingly.
203220

204221
=== Observability
205222

spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/client/advisor/QuestionAnswerAdvisorIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.ai.document.DocumentReader;
2929
import org.springframework.ai.evaluation.EvaluationRequest;
3030
import org.springframework.ai.evaluation.EvaluationResponse;
31-
import org.springframework.ai.evaluation.RelevancyEvaluator;
31+
import org.springframework.ai.chat.evaluation.RelevancyEvaluator;
3232
import org.springframework.ai.integration.tests.TestApplication;
3333
import org.springframework.ai.openai.OpenAiChatModel;
3434
import org.springframework.ai.reader.markdown.MarkdownDocumentReader;

spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/client/advisor/RetrievalAugmentationAdvisorIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.springframework.ai.document.DocumentReader;
3333
import org.springframework.ai.evaluation.EvaluationRequest;
3434
import org.springframework.ai.evaluation.EvaluationResponse;
35-
import org.springframework.ai.evaluation.RelevancyEvaluator;
35+
import org.springframework.ai.chat.evaluation.RelevancyEvaluator;
3636
import org.springframework.ai.integration.tests.TestApplication;
3737
import org.springframework.ai.openai.OpenAiChatModel;
3838
import org.springframework.ai.rag.advisor.RetrievalAugmentationAdvisor;

0 commit comments

Comments
 (0)