- * Migration example: - * - *
{@code
- * // Old way:
- * AnswerCorrectnessScorer scorer = AnswerCorrectnessScorer.create();
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * AnswerCorrectnessScorer scorer = client.scorers().builtIn().answerCorrectness().build();
- * }
- */
-@Deprecated
-public class AnswerCorrectnessScorer extends APIScorer {
- public AnswerCorrectnessScorer() {
- super(APIScorerType.ANSWER_CORRECTNESS);
- setRequiredParams(Arrays.asList("input", "actual_output", "expected_output"));
- }
-
- public static APIScorer.Builder- * Migration example: - * - *
{@code
- * // Old way:
- * AnswerRelevancyScorer scorer = AnswerRelevancyScorer.create();
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * AnswerRelevancyScorer scorer = client.scorers().builtIn().answerRelevancy().build();
- * }
- */
-@Deprecated
-public class AnswerRelevancyScorer extends APIScorer {
- public AnswerRelevancyScorer() {
- super(APIScorerType.ANSWER_RELEVANCY);
- setRequiredParams(Arrays.asList("input", "actual_output"));
- }
-
- public static APIScorer.Builder- * Migration example: - * - *
{@code
- * // Old way:
- * FaithfulnessScorer scorer = FaithfulnessScorer.create();
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * FaithfulnessScorer scorer = client.scorers().builtIn().faithfulness().build();
- * }
- */
-@Deprecated
-public class FaithfulnessScorer extends APIScorer {
- public FaithfulnessScorer() {
- super(APIScorerType.FAITHFULNESS);
- setRequiredParams(Arrays.asList("input", "actual_output", "retrieval_context"));
- }
-
- public static APIScorer.Builder- * Migration example: - * - *
{@code
- * // Old way:
- * InstructionAdherenceScorer scorer = InstructionAdherenceScorer.create();
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * InstructionAdherenceScorer scorer = client.scorers().builtIn().instructionAdherence().build();
- * }
- */
-@Deprecated
-public class InstructionAdherenceScorer extends APIScorer {
- public InstructionAdherenceScorer() {
- super(APIScorerType.INSTRUCTION_ADHERENCE);
- setRequiredParams(Arrays.asList("input", "actual_output"));
- setName("Instruction Adherence");
- }
-
- public static APIScorer.Builder- * Migration example: - * - *
{@code
- * // Old way:
- * CustomScorer scorer = CustomScorer.get("my-scorer");
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * CustomScorer scorer = client.scorers().customScorer().get("my-scorer");
- * }
- */
-@Deprecated
-public class CustomScorer extends APIScorer {
- public CustomScorer() {
- super(APIScorerType.CUSTOM);
- }
-
- /**
- * Creates a server-hosted custom scorer with the given name.
- *
- * @param name
- * scorer identifier and default class_name
- * @return configured CustomScorer
- */
- public static CustomScorer get(String name) {
- CustomScorer s = new CustomScorer();
- s.setName(name);
- s.setClassName(name);
- s.setServerHosted(true);
- return s;
- }
-
- /**
- * Creates a server-hosted custom scorer with explicit class_name for routing.
- *
- * @param name
- * scorer identifier
- * @param className
- * server-side scorer class name
- * @return configured CustomScorer
- */
- public static CustomScorer get(String name, String className) {
- CustomScorer s = get(name);
- s.setClassName(className);
- return s;
- }
-
- @Override
- /**
- * Not used for server-hosted custom scorers.
- *
- * @deprecated never returns; always throws
- * @return never returns; always throws
- */
- public ScorerConfig getScorerConfig() {
- throw new UnsupportedOperationException("CustomScorer does not use ScorerConfig");
- }
-}
diff --git a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/scorers/api_scorers/prompt_scorer/BasePromptScorer.java b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/scorers/api_scorers/prompt_scorer/BasePromptScorer.java
deleted file mode 100644
index 01f1860..0000000
--- a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/scorers/api_scorers/prompt_scorer/BasePromptScorer.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.judgmentlabs.judgeval.scorers.api_scorers.prompt_scorer;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-import com.judgmentlabs.judgeval.Env;
-import com.judgmentlabs.judgeval.data.APIScorerType;
-import com.judgmentlabs.judgeval.exceptions.JudgmentAPIError;
-import com.judgmentlabs.judgeval.internal.api.JudgmentSyncClient;
-import com.judgmentlabs.judgeval.internal.api.models.FetchPromptScorersRequest;
-import com.judgmentlabs.judgeval.internal.api.models.FetchPromptScorersResponse;
-import com.judgmentlabs.judgeval.internal.api.models.ScorerExistsRequest;
-import com.judgmentlabs.judgeval.internal.api.models.ScorerExistsResponse;
-import com.judgmentlabs.judgeval.scorers.APIScorer;
-
-public abstract class BasePromptScorer extends APIScorer {
- private static final Map- * Migration example: - * - *
{@code
- * // Old way:
- * PromptScorer scorer = PromptScorer.get("my-scorer");
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * PromptScorer scorer = client.scorers().promptScorer().get("my-scorer");
- * }
- */
-@Deprecated
-public class PromptScorer extends BasePromptScorer {
-
- public PromptScorer(String name, String prompt, double threshold, Map- * Migration example: - * - *
{@code
- * // Old way:
- * TracePromptScorer scorer = TracePromptScorer.get("my-scorer");
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * PromptScorer scorer = client.scorers().tracePromptScorer().get("my-scorer");
- * }
- */
-@Deprecated
-public class TracePromptScorer extends BasePromptScorer {
-
- public TracePromptScorer(String name, String prompt, double threshold, Map- * Migration example: - * - *
{@code
- * // Old way:
- * Tracer tracer = Tracer.createDefault("my-project");
- * tracer.initialize();
- *
- * // New way:
- * Judgeval client = Judgeval.builder().build();
- * Tracer tracer = client.tracer().create()
- * .projectName("my-project")
- * .build();
- * tracer.initialize();
- * }
- *
- * @see TracerConfiguration
- * @see SpanExporter
- * @see com.judgmentlabs.judgeval.scorers.BaseScorer
- * @see com.judgmentlabs.judgeval.data.Example
- */
-@Deprecated
public final class Tracer extends BaseTracer {
+ private SdkTracerProvider tracerProvider;
- private Tracer(TracerConfiguration configuration, ISerializer serializer, boolean shouldInitialize) {
- super(configuration, serializer, shouldInitialize);
- }
-
- /**
- * Creates a new TracerBuilder for constructing a Tracer instance.
- *
- * @return a new TracerBuilder
- */
- public static TracerBuilder builder() {
- return new TracerBuilder();
- }
-
- /**
- * Creates a Tracer with default configuration for the given project name.
- *
- * @param projectName
- * the name of the project
- * @return a new Tracer instance with default configuration
- */
- public static Tracer createDefault(String projectName) {
- return builder().configuration(TracerConfiguration.createDefault(projectName))
- .build();
- }
+ private Tracer(Builder builder) {
+ super(
+ Objects.requireNonNull(builder.projectName, "projectName required"),
+ builder.enableEvaluation,
+ Objects.requireNonNull(builder.client, "client required"),
+ builder.serializer != null ? builder.serializer : new GsonSerializer());
- /**
- * Creates a Tracer with the provided configuration.
- *
- * @param configuration
- * the tracer configuration
- * @return a new Tracer instance with the given configuration
- */
- public static Tracer createWithConfiguration(TracerConfiguration configuration) {
- return builder().configuration(configuration)
- .build();
+ if (builder.initialize) {
+ initialize();
+ }
}
/**
- * Initializes the OpenTelemetry SDK with batch span processor and registers it
- * globally.
+ * Initializes the tracer by setting up the OpenTelemetry SDK with a span
+ * exporter,
+ * configuring the tracer provider with batch span processing, and registering
+ * it globally.
*/
@Override
public void initialize() {
@@ -89,76 +45,167 @@ public void initialize() {
var resource = Resource.getDefault()
.merge(Resource.create(Attributes.builder()
- .put("service.name", configuration.projectName())
+ .put("service.name", projectName)
.put("telemetry.sdk.name", TRACER_NAME)
.put("telemetry.sdk.version", Version.getVersion())
.build()));
- SdkTracerProvider tracerProvider = SdkTracerProvider.builder()
+ this.tracerProvider = SdkTracerProvider.builder()
.setResource(resource)
.addSpanProcessor(BatchSpanProcessor.builder(spanExporter)
.build())
.build();
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder()
- .setTracerProvider(tracerProvider)
+ .setTracerProvider(this.tracerProvider)
.build();
GlobalOpenTelemetry.set(openTelemetry);
}
- public static final class TracerBuilder {
- private TracerConfiguration configuration;
- private ISerializer serializer = new GsonSerializer();
- private boolean initialize = false;
+ /**
+ * Forces the tracer to flush any pending spans within the specified timeout.
+ *
+ * @param timeoutMillis
+ * the maximum time to wait in milliseconds
+ * @return true if the flush completed successfully within the timeout
+ */
+ @Override
+ public boolean forceFlush(int timeoutMillis) {
+ if (tracerProvider == null) {
+ Logger.error("Cannot forceFlush: tracer not initialized");
+ return false;
+ }
+ return tracerProvider.forceFlush()
+ .join(timeoutMillis, java.util.concurrent.TimeUnit.MILLISECONDS)
+ .isSuccess();
+ }
+
+ /**
+ * Shuts down the tracer, flushing any remaining spans and releasing resources.
+ *
+ * @param timeoutMillis
+ * the maximum time to wait for shutdown in milliseconds
+ */
+ @Override
+ public void shutdown(int timeoutMillis) {
+ if (tracerProvider == null) {
+ Logger.error("Cannot shutdown: tracer not initialized");
+ return;
+ }
+ tracerProvider.shutdown()
+ .join(timeoutMillis, java.util.concurrent.TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * Creates a new builder for configuring a Tracer.
+ *
+ * @return a new builder instance
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder for configuring and creating Tracer instances.
+ */
+ public static final class Builder {
+ private JudgmentSyncClient client;
+ private String projectName;
+ private boolean enableEvaluation = true;
+ private ISerializer serializer;
+ private boolean initialize = true;
+
+ /**
+ * Sets the Judgment API client.
+ *
+ * @param client
+ * the API client
+ * @return this builder
+ */
+ public Builder client(JudgmentSyncClient client) {
+ this.client = client;
+ return this;
+ }
+
+ /**
+ * Sets the project name for this tracer.
+ *
+ * @param projectName
+ * the project name
+ * @return this builder
+ */
+ public Builder projectName(String projectName) {
+ this.projectName = projectName;
+ return this;
+ }
/**
- * Sets the tracer configuration.
+ * Sets whether evaluation is enabled.
*
- * @param configuration
- * the configuration to use
- * @return this builder for method chaining
+ * @param enableEvaluation
+ * true to enable evaluation
+ * @return this builder
*/
- public TracerBuilder configuration(TracerConfiguration configuration) {
- this.configuration = configuration;
+ public Builder enableEvaluation(boolean enableEvaluation) {
+ this.enableEvaluation = enableEvaluation;
return this;
}
/**
- * Sets the serializer to use for attribute serialization.
+ * Sets the custom serializer for span attributes.
*
* @param serializer
- * the serializer to use
- * @return this builder for method chaining
+ * the serializer
+ * @return this builder
*/
- public TracerBuilder serializer(ISerializer serializer) {
+ public Builder serializer(ISerializer serializer) {
this.serializer = serializer;
return this;
}
/**
- * Sets whether to automatically initialize the tracer after construction.
+ * Sets whether to automatically initialize the tracer on build.
*
* @param initialize
- * true to initialize automatically, false otherwise
- * @return this builder for method chaining
+ * true to initialize on build
+ * @return this builder
*/
- public TracerBuilder initialize(boolean initialize) {
+ public Builder initialize(boolean initialize) {
this.initialize = initialize;
return this;
}
/**
- * Builds a new Tracer instance with the configured settings.
+ * Builds and returns a new Tracer instance.
*
- * @return a new Tracer instance
- * @throws IllegalArgumentException
- * if configuration is not set
+ * @return the configured Tracer
*/
public Tracer build() {
- return Optional.ofNullable(configuration)
- .map(config -> new Tracer(config, serializer, initialize))
- .orElseThrow(() -> new IllegalArgumentException("Configuration is required"));
+ return new Tracer(this);
+ }
+ }
+
+ private static class GsonSerializer implements ISerializer {
+ private final Gson gson = new Gson();
+
+ @Override
+ public String serialize(Object obj) {
+ return Optional.ofNullable(obj)
+ .map(o -> serialize(o, o.getClass()))
+ .orElse(null);
+ }
+
+ @Override
+ public String serialize(Object obj, Type type) {
+ try {
+ return gson.toJson(obj, type);
+ } catch (Exception e) {
+ Logger.error("Failed to serialize object: " + e.getMessage());
+ return Optional.ofNullable(obj)
+ .map(Object::toString)
+ .orElse(null);
+ }
}
}
}
diff --git a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/tracer/TracerConfiguration.java b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/tracer/TracerConfiguration.java
deleted file mode 100644
index 93270a7..0000000
--- a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/tracer/TracerConfiguration.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.judgmentlabs.judgeval.tracer;
-
-import java.util.Optional;
-
-/**
- * Configuration for the Judgment Tracer that controls how tracing and
- * evaluation behave.
- * - * This class encapsulates all configuration parameters needed to initialize a - * {@link Tracer}. - *
- * Example usage: - * - *
{@code
- * TracerConfiguration config = TracerConfiguration.builder()
- * .projectName("my-project")
- * .apiKey("your-api-key")
- * .organizationId("your-org-id")
- * .enableEvaluation(true)
- * .build();
- *
- * Tracer tracer = Tracer.createWithConfiguration(config);
- * }
- *
- * @see Tracer
- * @deprecated Replaced by
- * com.judgmentlabs.judgeval.v1.tracer.TracerConfiguration
- */
-@Deprecated
-public final class TracerConfiguration {
- private final String projectName;
- private final String apiKey;
- private final String organizationId;
- private final String apiUrl;
- private final boolean enableEvaluation;
-
- private TracerConfiguration(Builder builder) {
- this.projectName = Optional.ofNullable(builder.projectName)
- .map(String::trim)
- .filter(name -> !name.isEmpty())
- .orElseThrow(() -> new IllegalArgumentException("Project name cannot be null or empty"));
- this.apiKey = Optional.ofNullable(builder.apiKey)
- .orElseThrow(() -> new IllegalArgumentException("API key cannot be null"));
- this.organizationId = Optional.ofNullable(builder.organizationId)
- .orElseThrow(() -> new IllegalArgumentException("Organization ID cannot be null"));
- this.apiUrl = Optional.ofNullable(builder.apiUrl)
- .orElseThrow(() -> new IllegalArgumentException("API URL cannot be null"));
- this.enableEvaluation = builder.enableEvaluation;
- }
-
- public String projectName() {
- return projectName;
- }
-
- public String apiKey() {
- return apiKey;
- }
-
- public String organizationId() {
- return organizationId;
- }
-
- public String apiUrl() {
- return apiUrl;
- }
-
- public boolean enableEvaluation() {
- return enableEvaluation;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Creates a default configuration with the given project name.
- * - * This method uses default values from environment variables: - *
- * Example usage: - * - *
{@code
- * TracerConfiguration config = TracerConfiguration.builder()
- * .projectName("my-project")
- * .apiKey("custom-api-key")
- * .organizationId("custom-org-id")
- * .apiUrl("https://custom-api.judgmentlabs.ai")
- * .enableEvaluation(false)
- * .build();
- * }
- */
- public static final class Builder {
- private String projectName;
- private String apiKey = com.judgmentlabs.judgeval.Env.JUDGMENT_API_KEY;
- private String organizationId = com.judgmentlabs.judgeval.Env.JUDGMENT_ORG_ID;
- private String apiUrl = com.judgmentlabs.judgeval.Env.JUDGMENT_API_URL;
- private boolean enableEvaluation = true;
-
- public Builder projectName(String projectName) {
- this.projectName = projectName;
- return this;
- }
-
- public Builder apiKey(String apiKey) {
- this.apiKey = apiKey;
- return this;
- }
-
- public Builder organizationId(String organizationId) {
- this.organizationId = organizationId;
- return this;
- }
-
- public Builder apiUrl(String apiUrl) {
- this.apiUrl = apiUrl;
- return this;
- }
-
- public Builder enableEvaluation(boolean enableEvaluation) {
- this.enableEvaluation = enableEvaluation;
- return this;
- }
-
- public TracerConfiguration build() {
- return new TracerConfiguration(this);
- }
- }
-}
diff --git a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/tracer/TracerFactory.java b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/tracer/TracerFactory.java
similarity index 92%
rename from judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/tracer/TracerFactory.java
rename to judgeval-java/src/main/java/com/judgmentlabs/judgeval/tracer/TracerFactory.java
index cffa765..4684103 100644
--- a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/tracer/TracerFactory.java
+++ b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/tracer/TracerFactory.java
@@ -1,4 +1,4 @@
-package com.judgmentlabs.judgeval.v1.tracer;
+package com.judgmentlabs.judgeval.tracer;
import com.judgmentlabs.judgeval.internal.api.JudgmentSyncClient;
diff --git a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/Judgeval.java b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/Judgeval.java
deleted file mode 100644
index d2cd402..0000000
--- a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/Judgeval.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package com.judgmentlabs.judgeval.v1;
-
-import java.util.Objects;
-
-import com.judgmentlabs.judgeval.Env;
-import com.judgmentlabs.judgeval.internal.api.JudgmentSyncClient;
-import com.judgmentlabs.judgeval.v1.evaluation.EvaluationFactory;
-import com.judgmentlabs.judgeval.v1.scorers.ScorersFactory;
-import com.judgmentlabs.judgeval.v1.tracer.TracerFactory;
-
-/**
- * Main entry point for the Judgment SDK. Provides access to tracer, scorer, and
- * evaluation factories.
- */
-public class Judgeval {
- private final String apiKey;
- private final String organizationId;
- private final String apiUrl;
- private final JudgmentSyncClient internalClient;
-
- protected Judgeval(Builder builder) {
- this.apiKey = Objects.requireNonNull(builder.apiKey, "apiKey required");
- this.organizationId = Objects.requireNonNull(builder.organizationId, "organizationId required");
- this.apiUrl = builder.apiUrl != null ? builder.apiUrl : Env.JUDGMENT_API_URL;
- this.internalClient = new JudgmentSyncClient(apiUrl, apiKey, organizationId);
- }
-
- /**
- * Returns a factory for creating tracers.
- *
- * @return the tracer factory
- */
- public TracerFactory tracer() {
- return new TracerFactory(internalClient);
- }
-
- /**
- * Returns a factory for creating scorers.
- *
- * @return the scorer factory
- */
- public ScorersFactory scorers() {
- return new ScorersFactory(internalClient);
- }
-
- /**
- * Returns a factory for creating evaluations.
- *
- * @return the evaluation factory
- */
- public EvaluationFactory evaluation() {
- return new EvaluationFactory(internalClient);
- }
-
- /**
- * Creates a new builder for configuring a Judgeval.
- *
- * @return a new builder instance
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder for configuring and creating Judgeval instances.
- */
- public static class Builder {
- private String apiKey = Env.JUDGMENT_API_KEY;
- private String organizationId = Env.JUDGMENT_ORG_ID;
- private String apiUrl = Env.JUDGMENT_API_URL;
-
- /**
- * Sets the API key for authentication.
- *
- * @param apiKey
- * the API key
- * @return this builder
- */
- public Builder apiKey(String apiKey) {
- this.apiKey = apiKey;
- return this;
- }
-
- /**
- * Sets the organization ID.
- *
- * @param organizationId
- * the organization ID
- * @return this builder
- */
- public Builder organizationId(String organizationId) {
- this.organizationId = organizationId;
- return this;
- }
-
- /**
- * Sets the API URL.
- *
- * @param apiUrl
- * the API URL
- * @return this builder
- */
- public Builder apiUrl(String apiUrl) {
- this.apiUrl = apiUrl;
- return this;
- }
-
- /**
- * Builds and returns a new Judgeval instance.
- *
- * @return the configured Judgeval
- */
- public Judgeval build() {
- return new Judgeval(this);
- }
- }
-}
diff --git a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/APIScorerType.java b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/APIScorerType.java
deleted file mode 100644
index 5af16fa..0000000
--- a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/APIScorerType.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.judgmentlabs.judgeval.v1.data;
-
-/**
- * Available types of API-based scorers.
- */
-public enum APIScorerType {
- PROMPT_SCORER("Prompt Scorer"),
- TRACE_PROMPT_SCORER("Trace Prompt Scorer"),
- FAITHFULNESS("Faithfulness"),
- ANSWER_RELEVANCY("Answer Relevancy"),
- ANSWER_CORRECTNESS("Answer Correctness"),
- CUSTOM("Custom");
-
- private final String value;
-
- APIScorerType(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-
- @Override
- public String toString() {
- return value;
- }
-}
diff --git a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/Example.java b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/Example.java
deleted file mode 100644
index 6a5e66a..0000000
--- a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/Example.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.judgmentlabs.judgeval.v1.data;
-
-import java.time.Instant;
-import java.util.UUID;
-
-/**
- * Represents an evaluation example with arbitrary properties.
- */
-public class Example extends com.judgmentlabs.judgeval.internal.api.models.Example {
-
- public Example() {
- super();
- setExampleId(UUID.randomUUID()
- .toString());
- setCreatedAt(Instant.now()
- .toString());
- setName(null);
- }
-
- /**
- * Creates a new builder for configuring an Example.
- *
- * @return a new builder instance
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder for configuring and creating Example instances.
- */
- public static final class Builder {
- private final Example example;
-
- private Builder() {
- this.example = new Example();
- }
-
- /**
- * Sets a custom property on the example.
- *
- * @param key
- * the property key
- * @param value
- * the property value
- * @return this builder
- */
- public Builder property(String key, Object value) {
- example.setAdditionalProperty(key, value);
- return this;
- }
-
- /**
- * Sets the name of the example.
- *
- * @param name
- * the example name
- * @return this builder
- */
- public Builder name(String name) {
- example.setName(name);
- return this;
- }
-
- /**
- * Builds and returns the configured Example.
- *
- * @return the configured Example
- */
- public Example build() {
- return example;
- }
- }
-}
diff --git a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/ScorerData.java b/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/ScorerData.java
deleted file mode 100644
index 3347aad..0000000
--- a/judgeval-java/src/main/java/com/judgmentlabs/judgeval/v1/data/ScorerData.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package com.judgmentlabs.judgeval.v1.data;
-
-import java.util.Map;
-
-/**
- * Represents the result of a single scorer evaluation.
- */
-public class ScorerData extends com.judgmentlabs.judgeval.internal.api.models.ScorerData {
-
- /**
- * Creates a new builder for configuring ScorerData.
- *
- * @return a new builder instance
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder for configuring and creating ScorerData instances.
- */
- public static final class Builder {
- private final ScorerData scorerData;
-
- private Builder() {
- this.scorerData = new ScorerData();
- }
-
- /**
- * Sets the scorer name.
- *
- * @param name
- * the scorer name
- * @return this builder
- */
- public Builder name(String name) {
- scorerData.setName(name);
- return this;
- }
-
- /**
- * Sets the evaluation score.
- *
- * @param score
- * the score value
- * @return this builder
- */
- public Builder score(Double score) {
- scorerData.setScore(score);
- return this;
- }
-
- /**
- * Sets whether the evaluation succeeded.
- *
- * @param success
- * true if evaluation succeeded
- * @return this builder
- */
- public Builder success(Boolean success) {
- scorerData.setSuccess(success);
- return this;
- }
-
- /**
- * Sets the reason for the evaluation result.
- *
- * @param reason
- * the evaluation reason
- * @return this builder
- */
- public Builder reason(String reason) {
- scorerData.setReason(reason);
- return this;
- }
-
- /**
- * Sets the evaluation threshold.
- *
- * @param threshold
- * the threshold value
- * @return this builder
- */
- public Builder threshold(Double threshold) {
- scorerData.setThreshold(threshold);
- return this;
- }
-
- /**
- * Sets strict mode for evaluation.
- *
- * @param strictMode
- * true for strict mode
- * @return this builder
- */
- public Builder strictMode(Boolean strictMode) {
- scorerData.setStrictMode(strictMode);
- return this;
- }
-
- /**
- * Sets the model used for evaluation.
- *
- * @param evaluationModel
- * the model name
- * @return this builder
- */
- public Builder evaluationModel(String evaluationModel) {
- scorerData.setEvaluationModel(evaluationModel);
- return this;
- }
-
- /**
- * Sets an error message if evaluation failed.
- *
- * @param error
- * the error message
- * @return this builder
- */
- public Builder error(String error) {
- scorerData.setError(error);
- return this;
- }
-
- /**
- * Sets additional metadata for the evaluation.
- *
- * @param additionalMetadata
- * the metadata map
- * @return this builder
- */
- public Builder additionalMetadata(Map
- * This exporter wraps the OTLP HTTP exporter and adds Judgment Labs specific
- * headers and project identification to all exported spans.
- */
-public class JudgmentSpanExporter implements SpanExporter {
- private final SpanExporter delegate;
-
- /**
- * Creates a new JudgmentSpanExporter with the specified configuration.
- *
- * @param endpoint
- * the OTLP endpoint URL
- * @param apiKey
- * the API key for authentication
- * @param organizationId
- * the organization ID
- * @param projectId
- * the project ID (must not be null or empty)
- * @throws IllegalArgumentException
- * if projectId is null or empty
- */
- protected JudgmentSpanExporter(String endpoint, String apiKey, String organizationId, String projectId) {
- if (projectId.isEmpty()) {
- throw new IllegalArgumentException("projectId is required for JudgmentSpanExporter");
- }
- this.delegate = OtlpHttpSpanExporter.builder()
- .setEndpoint(endpoint)
- .addHeader("Authorization", "Bearer " + apiKey)
- .addHeader("X-Organization-Id", organizationId)
- .addHeader("X-Project-Id", projectId)
- .build();
- }
-
- /**
- * Creates a new builder for constructing JudgmentSpanExporter instances.
- *
- * @return a new Builder instance
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Exports the collection of spans to the Judgment Labs backend.
- *
- * @param spans
- * the collection of spans to export
- * @return a CompletableResultCode representing the export operation status
- */
- @Override
- public CompletableResultCode export(Collection