feat: Refactor grading logic to utilize ModelProfile and ClientService in Grader2 and related tests
This commit is contained in:
@@ -3,27 +3,30 @@ package de.extio.lmlib.grader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.extio.lmlib.client.Client;
|
||||
import de.extio.lmlib.client.ClientService;
|
||||
import de.extio.lmlib.client.Conversation;
|
||||
import de.extio.lmlib.profile.ModelCategory;
|
||||
import de.extio.lmlib.profile.ModelProfile;
|
||||
import de.extio.lmlib.profile.ModelProfileService;
|
||||
|
||||
public class Grader2 {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Grader2.class);
|
||||
|
||||
public static boolean assessScoreBinary(final String question, final String text, final ClientService clientService) {
|
||||
final var client = clientService.getClient(ModelCategory.MEDIUM);
|
||||
return assessScoreBinary(question, text, client);
|
||||
public static boolean assessScoreBinary(final String question, final String text, final ModelCategory modelCategory, final ModelProfileService modelProfileService, final ClientService clientService) {
|
||||
final var modelProfile = modelProfileService.getModelProfile(modelCategory);
|
||||
return assessScoreBinary(question, text, modelProfile, clientService);
|
||||
}
|
||||
|
||||
public static boolean assessScoreBinary(final String question, final String text, final Client client) {
|
||||
public static boolean assessScoreBinary(final String question, final String text, final ModelProfile modelProfile, final ClientService clientService) {
|
||||
LOGGER.info(question);
|
||||
|
||||
final var client = clientService.getClient(modelProfile);
|
||||
|
||||
var score = 0;
|
||||
while (Math.abs(score) < 3) {
|
||||
final var completion = client.conversation(
|
||||
ModelCategory.MEDIUM,
|
||||
modelProfile,
|
||||
Conversation.create(
|
||||
"""
|
||||
You are an expert grader. Your role is to assess the truthfulness of a given text in response to a user question.
|
||||
|
||||
Reference in New Issue
Block a user