Skip to content

Commit caed4b3

Browse files
authored
Keep the same pass check behavior for FactCheckingEvaluator and RelevancyEvaluator, and avoid NPE. (#3975)
Fixes #3975 Auto-cherry-pick to 1.0.x Signed-off-by: Mengqi Xu <[email protected]>
1 parent 196a91b commit caed4b3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public EvaluationResponse evaluate(EvaluationRequest evaluationRequest) {
134134
.call()
135135
.content();
136136

137-
boolean passing = evaluationResponse.equalsIgnoreCase("yes");
137+
boolean passing = "yes".equalsIgnoreCase(evaluationResponse);
138138
return new EvaluationResponse(passing, "", Collections.emptyMap());
139139
}
140140

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public EvaluationResponse evaluate(EvaluationRequest evaluationRequest) {
7979

8080
boolean passing = false;
8181
float score = 0;
82-
if (evaluationResponse != null && evaluationResponse.toLowerCase().contains("yes")) {
82+
if ("yes".equalsIgnoreCase(evaluationResponse)) {
8383
passing = true;
8484
score = 1;
8585
}

0 commit comments

Comments
 (0)