Skip to content

Commit d60e6c7

Browse files
committed
move overloaded task method to taskFunction
makes passing lambdas to the eval builder unambiguous
1 parent e2fd2f2 commit d60e6c7

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

examples/src/main/java/dev/braintrust/examples/ExperimentExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception {
4141
EvalCase.of("asparagus", "vegetable"),
4242
EvalCase.of("apple", "fruit"),
4343
EvalCase.of("banana", "fruit"))
44-
.task(getFoodType)
44+
.taskFunction(getFoodType)
4545
.scorers(
4646
Scorer.of(
4747
"fruit_scorer",

src/main/java/dev/braintrust/eval/Eval.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ public Builder<INPUT, OUTPUT> task(Task<INPUT, OUTPUT> task) {
250250
return this;
251251
}
252252

253-
public Builder<INPUT, OUTPUT> task(Function<INPUT, OUTPUT> taskFn) {
254-
return task((Task<INPUT, OUTPUT>) evalCase -> taskFn.apply(evalCase.input()));
253+
public Builder<INPUT, OUTPUT> taskFunction(Function<INPUT, OUTPUT> taskFn) {
254+
return task(evalCase -> taskFn.apply(evalCase.input()));
255255
}
256256

257257
@SafeVarargs

src/test/java/dev/braintrust/eval/EvalTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import dev.braintrust.api.BraintrustApiClient;
77
import dev.braintrust.trace.BraintrustTracing;
88
import io.opentelemetry.api.common.AttributeKey;
9-
import java.util.function.Function;
109
import org.junit.jupiter.api.BeforeEach;
1110
import org.junit.jupiter.api.Test;
1211

@@ -30,7 +29,7 @@ public void evalOtelTraceWithProperAttributes() {
3029
.cases(
3130
EvalCase.of("strawberry", "fruit"),
3231
EvalCase.of("asparagus", "vegetable"))
33-
.task((Function<String, String>) food -> "fruit")
32+
.task(food -> "fruit")
3433
.scorers(
3534
Scorer.of(
3635
"fruit_scorer",

0 commit comments

Comments
 (0)