Skip to content

Commit 798f5fe

Browse files
Adding ability to enable / disable online evaluation rules
1 parent 7d30193 commit 798f5fe

34 files changed

+210
-45
lines changed

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public sealed interface AutomationRule permits AutomationRuleEvaluator {
2828

2929
AutomationRuleAction getAction();
3030
float getSamplingRate();
31+
boolean isEnabled();
3132

3233
Instant getCreatedAt();
3334
String getCreatedBy();

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public abstract sealed class AutomationRuleEvaluator<T> implements AutomationRul
6161
@JsonView({View.Public.class, View.Write.class})
6262
private final float samplingRate;
6363

64+
@JsonView({View.Public.class, View.Write.class})
65+
private final boolean enabled;
66+
6467
@JsonIgnore
6568
@NotNull private final T code;
6669

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorLlmAsJudge.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ public record LlmAsJudgeCode(
3737
@JsonView({View.Public.class, View.Write.class}) @NotNull List<LlmAsJudgeOutputSchema> schema){
3838
}
3939

40-
@ConstructorProperties({"id", "projectId", "projectName", "name", "samplingRate", "code", "createdAt", "createdBy",
40+
@ConstructorProperties({"id", "projectId", "projectName", "name", "samplingRate", "enabled", "code", "createdAt",
41+
"createdBy",
4142
"lastUpdatedAt", "lastUpdatedBy"})
4243
public AutomationRuleEvaluatorLlmAsJudge(UUID id, @NotNull UUID projectId, String projectName,
4344
@NotBlank String name,
4445
float samplingRate,
46+
boolean enabled,
4547
@NotNull LlmAsJudgeCode code, Instant createdAt, String createdBy, Instant lastUpdatedAt,
4648
String lastUpdatedBy) {
47-
super(id, projectId, projectName, name, samplingRate, code, createdAt, createdBy, lastUpdatedAt, lastUpdatedBy);
49+
super(id, projectId, projectName, name, samplingRate, enabled, code, createdAt, createdBy, lastUpdatedAt,
50+
lastUpdatedBy);
4851
}
4952

5053
/**

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorTraceThreadLlmAsJudge.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ public record TraceThreadLlmAsJudgeCode(
4040

4141
}
4242

43-
@ConstructorProperties({"id", "projectId", "projectName", "name", "samplingRate", "code", "createdAt", "createdBy",
43+
@ConstructorProperties({"id", "projectId", "projectName", "name", "samplingRate", "enabled", "code", "createdAt",
44+
"createdBy",
4445
"lastUpdatedAt", "lastUpdatedBy"})
4546
public AutomationRuleEvaluatorTraceThreadLlmAsJudge(UUID id, @NotNull UUID projectId, String projectName,
4647
@NotBlank String name,
47-
float samplingRate, @NotNull TraceThreadLlmAsJudgeCode code, Instant createdAt, String createdBy,
48+
float samplingRate, boolean enabled, @NotNull TraceThreadLlmAsJudgeCode code, Instant createdAt,
49+
String createdBy,
4850
Instant lastUpdatedAt, String lastUpdatedBy) {
49-
super(id, projectId, projectName, name, samplingRate, code, createdAt, createdBy, lastUpdatedAt, lastUpdatedBy);
51+
super(id, projectId, projectName, name, samplingRate, enabled, code, createdAt, createdBy, lastUpdatedAt,
52+
lastUpdatedBy);
5053
}
5154

5255
@JsonView({View.Public.class, View.Write.class})

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorTraceThreadUserDefinedMetricPython.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ public record TraceThreadUserDefinedMetricPythonCode(
3636
public static final String CONTEXT_ARG_NAME = "context";
3737
}
3838

39-
@ConstructorProperties({"id", "projectId", "projectName", "name", "samplingRate", "code", "createdAt", "createdBy",
39+
@ConstructorProperties({"id", "projectId", "projectName", "name", "samplingRate", "enabled", "code", "createdAt",
40+
"createdBy",
4041
"lastUpdatedAt", "lastUpdatedBy"})
4142
public AutomationRuleEvaluatorTraceThreadUserDefinedMetricPython(UUID id, @NotNull UUID projectId,
4243
String projectName,
43-
@NotBlank String name, float samplingRate, @NotNull TraceThreadUserDefinedMetricPythonCode code,
44+
@NotBlank String name, float samplingRate, boolean enabled,
45+
@NotNull TraceThreadUserDefinedMetricPythonCode code,
4446
Instant createdAt, String createdBy, Instant lastUpdatedAt, String lastUpdatedBy) {
45-
super(id, projectId, projectName, name, samplingRate, code, createdAt, createdBy, lastUpdatedAt, lastUpdatedBy);
47+
super(id, projectId, projectName, name, samplingRate, enabled, code, createdAt, createdBy, lastUpdatedAt,
48+
lastUpdatedBy);
4649
}
4750

4851
@JsonView({View.Public.class, View.Write.class})

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorUpdate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public abstract sealed class AutomationRuleEvaluatorUpdate<T> implements Automat
4343

4444
private final float samplingRate;
4545

46+
private final boolean enabled;
47+
4648
@JsonIgnore
4749
@NotNull private final T code;
4850

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorUpdateLlmAsJudge.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
2323
public final class AutomationRuleEvaluatorUpdateLlmAsJudge extends AutomationRuleEvaluatorUpdate<LlmAsJudgeCode> {
2424

25-
@ConstructorProperties({"name", "samplingRate", "code", "projectId"})
25+
@ConstructorProperties({"name", "samplingRate", "enabled", "code", "projectId"})
2626
public AutomationRuleEvaluatorUpdateLlmAsJudge(
27-
@NotBlank String name, float samplingRate, @NotNull LlmAsJudgeCode code, @NotNull UUID projectId) {
28-
super(name, samplingRate, code, projectId);
27+
@NotBlank String name, float samplingRate, boolean enabled, @NotNull LlmAsJudgeCode code,
28+
@NotNull UUID projectId) {
29+
super(name, samplingRate, enabled, code, projectId);
2930
}
3031

3132
/**

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public final class AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge
2424
extends
2525
AutomationRuleEvaluatorUpdate<TraceThreadLlmAsJudgeCode> {
2626

27-
@ConstructorProperties({"name", "samplingRate", "code", "projectId"})
27+
@ConstructorProperties({"name", "samplingRate", "enabled", "code", "projectId"})
2828
public AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge(
29-
@NotBlank String name, float samplingRate, @NotNull TraceThreadLlmAsJudgeCode code,
29+
@NotBlank String name, float samplingRate, boolean enabled, @NotNull TraceThreadLlmAsJudgeCode code,
3030
@NotNull UUID projectId) {
31-
super(name, samplingRate, code, projectId);
31+
super(name, samplingRate, enabled, code, projectId);
3232
}
3333

3434
/**

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPython.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ public final class AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPyth
2424
extends
2525
AutomationRuleEvaluatorUpdate<TraceThreadUserDefinedMetricPythonCode> {
2626

27-
@ConstructorProperties({"name", "samplingRate", "code", "projectId"})
27+
@ConstructorProperties({"name", "samplingRate", "enabled", "code", "projectId"})
2828
public AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPython(
29-
@NotBlank String name, float samplingRate, @NotNull TraceThreadUserDefinedMetricPythonCode code,
29+
@NotBlank String name, float samplingRate, boolean enabled,
30+
@NotNull TraceThreadUserDefinedMetricPythonCode code,
3031
@NotNull UUID projectId) {
31-
super(name, samplingRate, code, projectId);
32+
super(name, samplingRate, enabled, code, projectId);
3233
}
3334

3435
/**

apps/opik-backend/src/main/java/com/comet/opik/api/evaluators/AutomationRuleEvaluatorUpdateUserDefinedMetricPython.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public final class AutomationRuleEvaluatorUpdateUserDefinedMetricPython
2424
extends
2525
AutomationRuleEvaluatorUpdate<UserDefinedMetricPythonCode> {
2626

27-
@ConstructorProperties({"name", "samplingRate", "code", "projectId"})
27+
@ConstructorProperties({"name", "samplingRate", "enabled", "code", "projectId"})
2828
public AutomationRuleEvaluatorUpdateUserDefinedMetricPython(
29-
@NotBlank String name, float samplingRate, @NotNull UserDefinedMetricPythonCode code,
29+
@NotBlank String name, float samplingRate, boolean enabled, @NotNull UserDefinedMetricPythonCode code,
3030
@NotNull UUID projectId) {
31-
super(name, samplingRate, code, projectId);
31+
super(name, samplingRate, enabled, code, projectId);
3232
}
3333

3434
/**

0 commit comments

Comments
 (0)