Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.springframework.ai.evaluation;

import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.model.Content;

import java.util.List;
Expand All @@ -20,12 +19,12 @@ public class EvaluationRequest {

private final List<Content> dataList;

private final ChatResponse chatResponse;
private final String responseContent;

public EvaluationRequest(String userText, List<Content> dataList, ChatResponse chatResponse) {
public EvaluationRequest(String userText, List<Content> dataList, String responseContent) {
this.userText = userText;
this.dataList = dataList;
this.chatResponse = chatResponse;
this.responseContent = responseContent;
}

public String getUserText() {
Expand All @@ -36,14 +35,14 @@ public List<Content> getDataList() {
return dataList;
}

public ChatResponse getChatResponse() {
return chatResponse;
public String getResponseContent() {
return responseContent;
}

@Override
public String toString() {
return "EvaluationRequest{" + "userText='" + userText + '\'' + ", dataList=" + dataList + ", chatResponse="
+ chatResponse + '}';
+ responseContent + '}';
}

@Override
Expand All @@ -53,12 +52,12 @@ public boolean equals(Object o) {
if (!(o instanceof EvaluationRequest that))
return false;
return Objects.equals(userText, that.userText) && Objects.equals(dataList, that.dataList)
&& Objects.equals(chatResponse, that.chatResponse);
&& Objects.equals(responseContent, that.responseContent);
}

@Override
public int hashCode() {
return Objects.hash(userText, dataList, chatResponse);
return Objects.hash(userText, dataList, responseContent);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public RelevancyEvaluator(ChatClient.Builder chatClientBuilder) {
@Override
public EvaluationResponse evaluate(EvaluationRequest evaluationRequest) {

var response = doGetResponse(evaluationRequest);
var response = evaluationRequest.getResponseContent();
var context = doGetSupportingData(evaluationRequest);

String evaluationResponse = this.chatClientBuilder.build()
Expand All @@ -52,10 +52,6 @@ public EvaluationResponse evaluate(EvaluationRequest evaluationRequest) {
return new EvaluationResponse(passing, score, "", Collections.emptyMap());
}

protected String doGetResponse(EvaluationRequest evaluationRequest) {
return evaluationRequest.getChatResponse().getResult().getOutput().getContent();
}

protected String doGetSupportingData(EvaluationRequest evaluationRequest) {
List<Content> data = evaluationRequest.getDataList();
String supportingData = data.stream()
Expand Down