Skip to content

Commit 9a8143e

Browse files
committed
fix: use Java 8-compatible map/list construction in Judge
1 parent 1bd6777 commit 9a8143e

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

  • lib/sdk/server-ai/src/main/java/com/launchdarkly/sdk/server/ai

lib/sdk/server-ai/src/main/java/com/launchdarkly/sdk/server/ai/Judge.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import com.launchdarkly.sdk.server.ai.datamodel.LDAIConfigTypes.Message;
55
import com.launchdarkly.sdk.server.ai.datamodel.LDAITrackingTypes.JudgeResult;
66

7+
import java.util.Arrays;
8+
import java.util.Collections;
9+
import java.util.HashMap;
710
import java.util.List;
811
import java.util.Map;
912
import java.util.Objects;
@@ -26,12 +29,25 @@ public final class Judge {
2629
* JSON-Schema fragment sent to the runner as the {@code outputType}, requesting structured
2730
* {@code {score, reasoning}} output.
2831
*/
29-
private static final Map<String, Object> EVALUATION_SCHEMA = Map.of(
30-
"type", "object",
31-
"properties", Map.of(
32-
"score", Map.of("type", "number"),
33-
"reasoning", Map.of("type", "string")),
34-
"required", List.of("score", "reasoning"));
32+
private static final Map<String, Object> EVALUATION_SCHEMA;
33+
static {
34+
Map<String, Object> scoreSchema = new HashMap<>();
35+
scoreSchema.put("type", "number");
36+
37+
Map<String, Object> reasoningSchema = new HashMap<>();
38+
reasoningSchema.put("type", "string");
39+
40+
Map<String, Object> properties = new HashMap<>();
41+
properties.put("score", Collections.unmodifiableMap(scoreSchema));
42+
properties.put("reasoning", Collections.unmodifiableMap(reasoningSchema));
43+
44+
Map<String, Object> schema = new HashMap<>();
45+
schema.put("type", "object");
46+
schema.put("properties", Collections.unmodifiableMap(properties));
47+
schema.put("required", Arrays.asList("score", "reasoning"));
48+
49+
EVALUATION_SCHEMA = Collections.unmodifiableMap(schema);
50+
}
3551

3652
private final AIJudgeConfig config;
3753
private final Runner runner;

0 commit comments

Comments
 (0)