Skip to content

Commit f566a4b

Browse files
committed
Refactor ModerationResult builder methods
- Deprecate the existing builder methods to remove the prefix `with` - Update references
1 parent 99a44fb commit f566a4b

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiModerationModel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ private ModerationResponse convertResponse(
147147
.build();
148148
}
149149
ModerationResult moderationResult = ModerationResult.builder()
150-
.withCategories(categories)
151-
.withCategoryScores(categoryScores)
152-
.withFlagged(result.flagged())
150+
.categories(categories)
151+
.categoryScores(categoryScores)
152+
.flagged(result.flagged())
153153
.build();
154154
moderationResults.add(moderationResult);
155155
}

spring-ai-core/src/main/java/org/springframework/ai/moderation/ModerationResult.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,43 @@ public static class Builder {
100100

101101
private CategoryScores categoryScores;
102102

103+
public Builder flagged(boolean flagged) {
104+
this.flagged = flagged;
105+
return this;
106+
}
107+
108+
public Builder categories(Categories categories) {
109+
this.categories = categories;
110+
return this;
111+
}
112+
113+
public Builder categoryScores(CategoryScores categoryScores) {
114+
this.categoryScores = categoryScores;
115+
return this;
116+
}
117+
118+
/**
119+
* @deprecated use {@link #flagged(boolean)} instead.
120+
*/
121+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
103122
public Builder withFlagged(boolean flagged) {
104123
this.flagged = flagged;
105124
return this;
106125
}
107126

127+
/**
128+
* @deprecated use {@link #categories(Categories)} instead.
129+
*/
130+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
108131
public Builder withCategories(Categories categories) {
109132
this.categories = categories;
110133
return this;
111134
}
112135

136+
/**
137+
* @deprecated use {@link #categoryScores(CategoryScores)} instead.
138+
*/
139+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
113140
public Builder withCategoryScores(CategoryScores categoryScores) {
114141
this.categoryScores = categoryScores;
115142
return this;

0 commit comments

Comments
 (0)