|
46 | 46 | import java.util.List; |
47 | 47 | import java.util.Map; |
48 | 48 |
|
49 | | -public class ScoreAction implements AITextAnalysisAction { |
| 49 | +public class ScoreAction implements AiTextAnalysisAction { |
| 50 | + |
50 | 51 | public final AiTextAnalysisActionDefinition actionDefinition; |
51 | 52 |
|
52 | 53 | public ScoreAction(ApplicationProperties.Ai.Component component) { |
@@ -104,36 +105,38 @@ public Parameters createParameters(Parameters inputParameters) { |
104 | 105 | "You are an objective text scoring judge. You will receive a text and list of criteria that you will score the text on. Within the list of criteria you will also receive `Lowest Score` which indicates the lowest possible score you can give, `Highest Score` which indicates the highest possible score you can give and `Decimal` which tells you that you will be using decimal numbers if true or only integers if false. Your response will be a JSON array of objects for each criteria containing your score and a short explanation."; |
105 | 106 |
|
106 | 107 | StringBuilder userBuilder = new StringBuilder(); |
| 108 | + |
107 | 109 | userBuilder.append("Text: ") |
108 | 110 | .append(inputParameters.getString(TEXT)) |
109 | 111 | .append("\n"); |
110 | 112 |
|
111 | | - List<AiTextAnalysisUtil.Criteria> criteria = |
112 | | - inputParameters.getList(CRITERIA, AiTextAnalysisUtil.Criteria.class, List.of()); |
| 113 | + List<AiTextAnalysisUtil.Criteria> criteria = inputParameters.getList( |
| 114 | + CRITERIA, AiTextAnalysisUtil.Criteria.class, List.of()); |
113 | 115 |
|
114 | 116 | userBuilder.append("Criteria: {") |
115 | 117 | .append("\n"); |
116 | 118 |
|
117 | | - criteria.forEach(critrion -> userBuilder.append("{") |
| 119 | + criteria.forEach(criterion -> userBuilder.append("{") |
118 | 120 | .append("\n") |
119 | 121 | .append("Criterion: ") |
120 | | - .append(critrion.criterion()) |
| 122 | + .append(criterion.criterion()) |
121 | 123 | .append("\n") |
122 | 124 | .append("Lowest Score: ") |
123 | | - .append(critrion.lowestScore()) |
| 125 | + .append(criterion.lowestScore()) |
124 | 126 | .append("\n") |
125 | 127 | .append("Highest Score: ") |
126 | | - .append(critrion.highestScore()) |
| 128 | + .append(criterion.highestScore()) |
127 | 129 | .append("\n") |
128 | 130 | .append("Decimal: ") |
129 | | - .append(critrion.isDecimal()) |
| 131 | + .append(criterion.isDecimal()) |
130 | 132 | .append("\n") |
131 | 133 | .append("},") |
132 | 134 | .append("\n")); |
133 | 135 |
|
134 | 136 | userBuilder.append("}\n"); |
135 | 137 |
|
136 | | - modelInputParametersMap.put("messages", |
| 138 | + modelInputParametersMap.put( |
| 139 | + "messages", |
137 | 140 | List.of( |
138 | 141 | Map.of("content", systemPrompt, "role", "system"), |
139 | 142 | Map.of("content", userBuilder.toString(), "role", "user"))); |
|
0 commit comments