Package dev.braintrust.eval
Class ScorerBrainstoreImpl<INPUT,OUTPUT>
java.lang.Object
dev.braintrust.eval.ScorerBrainstoreImpl<INPUT,OUTPUT>
- All Implemented Interfaces:
Scorer<INPUT,OUTPUT>
A scorer that invokes a remote Braintrust function to compute scores.
This implementation fetches a scorer function from Braintrust and invokes it via the API for each task result. The remote function receives the input, output, expected, and metadata as arguments.
Supports distributed tracing: if an object ID is available in OTEL baggage and a valid span context exists, the scorer will pass parent span information to the remote function, enabling the remote function's spans to appear as children of the local scorer span.
-
Constructor Summary
ConstructorsConstructorDescriptionScorerBrainstoreImpl(BraintrustApiClient apiClient, String functionId, String version) Deprecated.ScorerBrainstoreImpl(BraintrustOpenApiClient apiClient, String functionId, String version) Create a new remote scorer.ScorerBrainstoreImpl(BraintrustOpenApiClient apiClient, String functionId, String version, Function<INPUT, Object> inputConverter, Function<OUTPUT, Object> outputConverter) Create a new remote scorer with custom input/output converters. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.braintrust.eval.Scorer
scoreForScorerException, scoreForTaskException
-
Constructor Details
-
ScorerBrainstoreImpl
@Deprecated public ScorerBrainstoreImpl(BraintrustApiClient apiClient, String functionId, @Nullable String version) Deprecated. -
ScorerBrainstoreImpl
public ScorerBrainstoreImpl(BraintrustOpenApiClient apiClient, String functionId, @Nullable String version) Create a new remote scorer. Input, output, and expected values are serialized with the SDK's shared mapper (BraintrustJsonMapper); useScorerBrainstoreImpl(BraintrustOpenApiClient, String, String, java.util.function.Function, java.util.function.Function)to customize serialization.- Parameters:
apiClient- the API client to use for invoking the functionfunctionId- braintrust function idversion- optional version of the function to invoke. null always invokes latest version.
-
ScorerBrainstoreImpl
public ScorerBrainstoreImpl(BraintrustOpenApiClient apiClient, String functionId, @Nullable String version, Function<INPUT, Object> inputConverter, Function<OUTPUT, Object> outputConverter) Create a new remote scorer with custom input/output converters.- Parameters:
apiClient- the API client to use for invoking the functionfunctionId- braintrust function idversion- optional version of the function to invoke. null always invokes latest version.inputConverter- converts each case'sinputvalue into a JSON-serializable form (e.g. a JacksonJsonNode,Map, or scalar) before the invoke request is sent; never invoked with nulloutputConverter- converts the taskoutputand caseexpectedvalues into a JSON-serializable form; never invoked with null
-
-
Method Details
-
getName
-
score
Description copied from interface:ScorerScores the result of a successful task execution.- Specified by:
scorein interfaceScorer<INPUT,OUTPUT> - Parameters:
taskResult- the task output and originating dataset case- Returns:
- one or more scores, each with a value between 0 and 1 inclusive
If this method thows, the error will be recorded on the span and
Scorer.scoreForScorerException(java.lang.Exception, dev.braintrust.eval.TaskResult<INPUT, OUTPUT>)will be called as a fallback
-