diff --git a/.stats.yml b/.stats.yml index 1253c71..ac9200d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 104 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-ac2727014d937f1e6de19bcb6b11f2ce15209632d4ccf56e4e98ef291747f990.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-9d216c8243fe39ba2ffe3bffaab0dba53f1c04b7216d22f9072f6611233de0c7.yml diff --git a/SECURITY.md b/SECURITY.md index 9e161b9..5702c21 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -20,7 +20,7 @@ or products provided by Braintrust please follow the respective company's securi ### Braintrust Terms and Policies -Please contact info@braintrustdata.com for any questions or concerns regarding security of our services. +Please contact info-test@braintrustdata.com for any questions or concerns regarding security of our services. --- diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index 183102e..d99a8cc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -434,22 +434,22 @@ private constructor( @JsonSerialize(using = Position.Serializer::class) class Position private constructor( - private val type: Type? = null, + private val task: Task? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) + fun task(): Optional = Optional.ofNullable(task) fun scorer(): Optional = Optional.ofNullable(scorer) - fun isType(): Boolean = type != null + fun isTask(): Boolean = task != null fun isScorer(): Boolean = scorer != null - fun asType(): Type = type.getOrThrow("type") + fun asTask(): Task = task.getOrThrow("task") fun asScorer(): Scorer = scorer.getOrThrow("scorer") @@ -457,7 +457,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - type != null -> visitor.visitType(type) + task != null -> visitor.visitTask(task) scorer != null -> visitor.visitScorer(scorer) else -> visitor.unknown(_json) } @@ -465,10 +465,10 @@ private constructor( fun validate(): Position = apply { if (!validated) { - if (type == null && scorer == null) { + if (task == null && scorer == null) { throw BraintrustInvalidDataException("Unknown Position: $_json") } - type?.validate() + task?.validate() scorer?.validate() validated = true } @@ -480,17 +480,17 @@ private constructor( } return other is Position && - this.type == other.type && + this.task == other.task && this.scorer == other.scorer } override fun hashCode(): Int { - return Objects.hash(type, scorer) + return Objects.hash(task, scorer) } override fun toString(): String { return when { - type != null -> "Position{type=$type}" + task != null -> "Position{task=$task}" scorer != null -> "Position{scorer=$scorer}" _json != null -> "Position{_unknown=$_json}" else -> throw IllegalStateException("Invalid Position") @@ -499,14 +499,14 @@ private constructor( companion object { - @JvmStatic fun ofType(type: Type) = Position(type = type) + @JvmStatic fun ofTask(task: Task) = Position(task = task) @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) } interface Visitor { - fun visitType(type: Type): T + fun visitTask(task: Task): T fun visitScorer(scorer: Scorer): T @@ -519,9 +519,9 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Position { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Position(type = it, _json = json) + return Position(task = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -540,324 +540,13 @@ private constructor( provider: SerializerProvider ) { when { - value.type != null -> generator.writeObject(value.type) + value.task != null -> generator.writeObject(value.task) value.scorer != null -> generator.writeObject(value.scorer) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Position") } } } - - @JsonDeserialize(builder = Type.Builder::class) - @NoAutoDetect - class Type - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Type = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TASK, - } - - enum class Value { - TASK, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = Scorer.Builder::class) - @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun index(): Long = index.getRequired("index") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("index") @ExcludeMissing fun _index() = index - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scorer = apply { - if (!validated) { - type() - index() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - this.type = scorer.type - this.index = scorer.index - additionalProperties(scorer.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun index(index: Long) = index(JsonField.of(index)) - - @JsonProperty("index") - @ExcludeMissing - fun index(index: JsonField) = apply { this.index = index } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SCORER = Type(JsonField.of("scorer")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - SCORER, - } - - enum class Value { - SCORER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } } class Type diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt new file mode 100644 index 0000000..78763be --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +@JsonDeserialize(builder = FunctionToolChoice.Builder::class) +@NoAutoDetect +class FunctionToolChoice +private constructor( + private val name: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun name(): String = name.getRequired("name") + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FunctionToolChoice = apply { + if (!validated) { + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionToolChoice && + this.name == other.name && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode + } + + override fun toString() = + "FunctionToolChoice{name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionToolChoice: FunctionToolChoice) = apply { + this.name = functionToolChoice.name + additionalProperties(functionToolChoice.additionalProperties) + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FunctionToolChoice = + FunctionToolChoice(name, additionalProperties.toUnmodifiable()) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt index 227bd20..41a70ed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing @@ -15,7 +14,6 @@ import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -39,7 +37,7 @@ private constructor( private val created: JsonField, private val name: JsonField, private val description: JsonField, - private val scoreType: JsonField, + private val scoreType: JsonField, private val categories: JsonField, private val config: JsonField, private val position: JsonField, @@ -69,7 +67,7 @@ private constructor( Optional.ofNullable(description.getNullable("description")) /** The type of the configured score */ - fun scoreType(): ScoreType = scoreType.getRequired("score_type") + fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) @@ -183,7 +181,7 @@ private constructor( private var created: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var scoreType: JsonField = JsonMissing.of() + private var scoreType: JsonField = JsonMissing.of() private var categories: JsonField = JsonMissing.of() private var config: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() @@ -249,12 +247,12 @@ private constructor( fun description(description: JsonField) = apply { this.description = description } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } fun categories(categories: Categories) = categories(JsonField.of(categories)) @@ -306,81 +304,6 @@ private constructor( ) } - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) - - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) - - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) - - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) - - @JvmField val ONLINE = ScoreType(JsonField.of("online")) - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) class Categories diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt index 083259e..fa6fc58 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt @@ -4,9 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow @@ -15,7 +13,6 @@ import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -31,7 +28,7 @@ class ProjectScoreCreateParams constructor( private val name: String, private val projectId: String, - private val scoreType: ScoreType, + private val scoreType: ProjectScoreType, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -44,7 +41,7 @@ constructor( fun projectId(): String = projectId - fun scoreType(): ScoreType = scoreType + fun scoreType(): ProjectScoreType = scoreType fun categories(): Optional = Optional.ofNullable(categories) @@ -76,7 +73,7 @@ constructor( internal constructor( private val name: String?, private val projectId: String?, - private val scoreType: ScoreType?, + private val scoreType: ProjectScoreType?, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -92,7 +89,7 @@ constructor( @JsonProperty("project_id") fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType @JsonProperty("categories") fun categories(): Categories? = categories @@ -150,7 +147,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ScoreType? = null + private var scoreType: ProjectScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -176,7 +173,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } @JsonProperty("categories") fun categories(categories: Categories) = apply { this.categories = categories } @@ -267,7 +264,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ScoreType? = null + private var scoreType: ProjectScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -295,7 +292,7 @@ constructor( fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = apply { this.categories = categories } @@ -393,81 +390,6 @@ constructor( ) } - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) - - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) - - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) - - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) - - @JvmField val ONLINE = ScoreType(JsonField.of("online")) - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) class Categories diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt index 1d64ae0..a2d3f5f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt @@ -4,15 +4,12 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -201,7 +198,7 @@ constructor( fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** The type of the configured score */ - fun scoreType(projectScoreType: ScoreType.ProjectScoreType) = apply { + fun scoreType(projectScoreType: ProjectScoreType) = apply { this.scoreType = ScoreType.ofProjectScoreType(projectScoreType) } @@ -509,155 +506,5 @@ constructor( } } } - - class ProjectScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SLIDER = ProjectScoreType(JsonField.of("slider")) - - @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) - - @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) - - @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) - - @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) - - @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class ProjectScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SLIDER = ProjectScoreType(JsonField.of("slider")) - - @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) - - @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) - - @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) - - @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) - - @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt index 7d1adec..ad05f84 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt @@ -4,9 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow @@ -15,7 +13,6 @@ import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -31,7 +28,7 @@ class ProjectScoreReplaceParams constructor( private val name: String, private val projectId: String, - private val scoreType: ScoreType, + private val scoreType: ProjectScoreType, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -44,7 +41,7 @@ constructor( fun projectId(): String = projectId - fun scoreType(): ScoreType = scoreType + fun scoreType(): ProjectScoreType = scoreType fun categories(): Optional = Optional.ofNullable(categories) @@ -76,7 +73,7 @@ constructor( internal constructor( private val name: String?, private val projectId: String?, - private val scoreType: ScoreType?, + private val scoreType: ProjectScoreType?, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -92,7 +89,7 @@ constructor( @JsonProperty("project_id") fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType @JsonProperty("categories") fun categories(): Categories? = categories @@ -150,7 +147,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ScoreType? = null + private var scoreType: ProjectScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -176,7 +173,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } @JsonProperty("categories") fun categories(categories: Categories) = apply { this.categories = categories } @@ -267,7 +264,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ScoreType? = null + private var scoreType: ProjectScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -295,7 +292,7 @@ constructor( fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = apply { this.categories = categories } @@ -393,81 +390,6 @@ constructor( ) } - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) - - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) - - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) - - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) - - @JvmField val ONLINE = ScoreType(JsonField.of("online")) - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) class Categories diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt new file mode 100644 index 0000000..fb9ec5b --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +class ProjectScoreType +@JsonCreator +private constructor( + private val value: JsonField, +) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectScoreType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SLIDER = ProjectScoreType(JsonField.of("slider")) + + @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) + + @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) + + @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) + + @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) + + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + ONLINE, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + ONLINE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt index 6df0ae4..4548ffb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt @@ -4,9 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow @@ -15,7 +13,6 @@ import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -34,7 +31,7 @@ constructor( private val config: ProjectScoreConfig?, private val description: String?, private val name: String?, - private val scoreType: ScoreType?, + private val scoreType: ProjectScoreType?, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -50,7 +47,7 @@ constructor( fun name(): Optional = Optional.ofNullable(name) - fun scoreType(): Optional = Optional.ofNullable(scoreType) + fun scoreType(): Optional = Optional.ofNullable(scoreType) @JvmSynthetic internal fun getBody(): ProjectScoreUpdateBody { @@ -84,7 +81,7 @@ constructor( private val config: ProjectScoreConfig?, private val description: String?, private val name: String?, - private val scoreType: ScoreType?, + private val scoreType: ProjectScoreType?, private val additionalProperties: Map, ) { @@ -101,7 +98,7 @@ constructor( @JsonProperty("name") fun name(): String? = name /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType @JsonAnyGetter @ExcludeMissing @@ -152,7 +149,7 @@ constructor( private var config: ProjectScoreConfig? = null private var description: String? = null private var name: String? = null - private var scoreType: ScoreType? = null + private var scoreType: ProjectScoreType? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -180,7 +177,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -263,7 +260,7 @@ constructor( private var config: ProjectScoreConfig? = null private var description: String? = null private var name: String? = null - private var scoreType: ScoreType? = null + private var scoreType: ProjectScoreType? = null private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -316,7 +313,7 @@ constructor( fun name(name: String) = apply { this.name = name } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -713,79 +710,4 @@ constructor( } } } - - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) - - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) - - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) - - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) - - @JvmField val ONLINE = ScoreType(JsonField.of("online")) - - @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 161b133..a1fa264 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -1324,515 +1324,6 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } } - - @JsonDeserialize(using = ToolChoice.Deserializer::class) - @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val auto: Auto? = null, - private val none: None? = null, - private val function: Function? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun auto(): Optional = Optional.ofNullable(auto) - - fun none(): Optional = Optional.ofNullable(none) - - fun function(): Optional = Optional.ofNullable(function) - - fun isAuto(): Boolean = auto != null - - fun isNone(): Boolean = none != null - - fun isFunction(): Boolean = function != null - - fun asAuto(): Auto = auto.getOrThrow("auto") - - fun asNone(): None = none.getOrThrow("none") - - fun asFunction(): Function = function.getOrThrow("function") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if (auto == null && none == null && function == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - function?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ToolChoice && - this.auto == other.auto && - this.none == other.none && - this.function == other.function - } - - override fun hashCode(): Int { - return Objects.hash( - auto, - none, - function, - ) - } - - override fun toString(): String { - return when { - auto != null -> "ToolChoice{auto=$auto}" - none != null -> "ToolChoice{none=$none}" - function != null -> "ToolChoice{function=$function}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - - @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) - - @JvmStatic - fun ofFunction(function: Function) = ToolChoice(function = function) - } - - interface Visitor { - - fun visitAuto(auto: Auto): T - - fun visitNone(none: None): T - - fun visitFunction(function: Function): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(none = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolChoice(function = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class Auto - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Auto && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Auto(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) - } - - enum class Known { - AUTO, - } - - enum class Value { - AUTO, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is None && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = None(JsonField.of("none")) - - @JvmStatic fun of(value: String) = None(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Function = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.type = function.type - this.function = function.function - additionalProperties(function.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Function = - Function( - type, - function, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } } @JsonDeserialize(builder = AnthropicModelParams.Builder::class) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt new file mode 100644 index 0000000..11d3031 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +@JsonDeserialize(builder = Scorer.Builder::class) +@NoAutoDetect +class Scorer +private constructor( + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun index(): Long = index.getRequired("index") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("index") @ExcludeMissing fun _index() = index + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scorer = apply { + if (!validated) { + type() + index() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scorer: Scorer) = apply { + this.type = scorer.type + this.index = scorer.index + additionalProperties(scorer.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { this.index = index } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Scorer = + Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SCORER = Type(JsonField.of("scorer")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + SCORER, + } + + enum class Value { + SCORER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt new file mode 100644 index 0000000..77b56f6 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +@JsonDeserialize(builder = Task.Builder::class) +@NoAutoDetect +class Task +private constructor( + private val type: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Task = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Task && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode + } + + override fun toString() = "Task{type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(task: Task) = apply { + this.type = task.type + additionalProperties(task.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Task = Task(type, additionalProperties.toUnmodifiable()) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + TASK, + } + + enum class Value { + TASK, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt new file mode 100644 index 0000000..2c6e59f --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt @@ -0,0 +1,436 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = ToolChoice.Deserializer::class) +@JsonSerialize(using = ToolChoice.Serializer::class) +class ToolChoice +private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } + + fun validate(): ToolChoice = apply { + if (!validated) { + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") + } + function?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function + } + + override fun hashCode(): Int { + return Objects.hash( + auto, + none, + function, + ) + } + + override fun toString(): String { + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + + companion object { + + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) + + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) + + @JvmStatic fun ofFunction(function: Function) = ToolChoice(function = function) + } + + interface Visitor { + + fun visitAuto(auto: Auto): T + + fun visitNone(none: None): T + + fun visitFunction(function: Function): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + } + } + + class Deserializer : BaseDeserializer(ToolChoice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } + + return ToolChoice(_json = json) + } + } + + class Serializer : BaseSerializer(ToolChoice::class) { + + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + } + + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Auto && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AUTO = Auto(JsonField.of("auto")) + + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) + } + + enum class Known { + AUTO, + } + + enum class Value { + AUTO, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is None && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val NONE = None(JsonField.of("none")) + + @JvmStatic fun of(value: String) = None(JsonField.of(value)) + } + + enum class Known { + NONE, + } + + enum class Value { + NONE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> throw BraintrustInvalidDataException("Unknown None: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun function(): FunctionToolChoice = function.getRequired("function") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("function") @ExcludeMissing fun _function() = function + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + function().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var function: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun function(function: FunctionToolChoice) = function(JsonField.of(function)) + + @JsonProperty("function") + @ExcludeMissing + fun function(function: JsonField) = apply { + this.function = function + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index 4f6dae3..59c3bca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -15,7 +15,6 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import java.util.Optional import java.util.concurrent.CompletableFuture interface FunctionServiceAsync { @@ -70,7 +69,7 @@ interface FunctionServiceAsync { fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture> + ): CompletableFuture /** * Create or replace function. If there is an existing function in the project with the same diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 0565b7c..006ad09 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -22,7 +22,6 @@ import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler import com.braintrustdata.api.services.withErrorHandler -import java.util.Optional import java.util.concurrent.CompletableFuture class FunctionServiceAsyncImpl @@ -199,7 +198,7 @@ constructor( override fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions - ): CompletableFuture> { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 33f0e99..12d58d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -15,7 +15,6 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import java.util.Optional interface FunctionService { @@ -69,7 +68,7 @@ interface FunctionService { fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none() - ): Optional + ): FunctionInvokeResponse /** * Create or replace function. If there is an existing function in the project with the same diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index a222e51..d626758 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -22,7 +22,6 @@ import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler import com.braintrustdata.api.services.withErrorHandler -import java.util.Optional class FunctionServiceImpl constructor( @@ -184,7 +183,7 @@ constructor( override fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions - ): Optional { + ): FunctionInvokeResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt index 8b8ede4..539185e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt @@ -17,12 +17,8 @@ class CodeBundleTest { CodeBundle.Location.Experiment.builder() .evalName("eval_name") .position( - CodeBundle.Location.Experiment.Position.ofType( - CodeBundle.Location.Experiment.Position.Type.builder() - .type( - CodeBundle.Location.Experiment.Position.Type.Type.TASK - ) - .build() + CodeBundle.Location.Experiment.Position.ofTask( + Task.builder().type(Task.Type.TASK).build() ) ) .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) @@ -45,10 +41,8 @@ class CodeBundleTest { CodeBundle.Location.Experiment.builder() .evalName("eval_name") .position( - CodeBundle.Location.Experiment.Position.ofType( - CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.Type.TASK) - .build() + CodeBundle.Location.Experiment.Position.ofTask( + Task.builder().type(Task.Type.TASK).build() ) ) .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt index 44fac6c..c5cc94d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt @@ -72,15 +72,7 @@ class FunctionCreateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -192,16 +184,7 @@ class FunctionCreateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -312,15 +295,7 @@ class FunctionCreateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt index ece0115..3afb5a0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt @@ -72,15 +72,7 @@ class FunctionReplaceParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -192,16 +184,7 @@ class FunctionReplaceParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -312,15 +295,7 @@ class FunctionReplaceParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt index e1d5ff1..566aec4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt @@ -80,16 +80,7 @@ class FunctionTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -205,15 +196,7 @@ class FunctionTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionToolChoiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionToolChoiceTest.kt new file mode 100644 index 0000000..6321b34 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionToolChoiceTest.kt @@ -0,0 +1,16 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionToolChoiceTest { + + @Test + fun createFunctionToolChoice() { + val functionToolChoice = FunctionToolChoice.builder().name("name").build() + assertThat(functionToolChoice).isNotNull + assertThat(functionToolChoice.name()).isEqualTo("name") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index a4047d7..e576318 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -56,15 +56,7 @@ class FunctionUpdateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -161,16 +153,7 @@ class FunctionUpdateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -263,15 +246,7 @@ class FunctionUpdateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt index 7505f8d..f507235 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt @@ -13,7 +13,7 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categories( ProjectScoreCreateParams.Categories.ofList( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -52,7 +52,7 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categories( ProjectScoreCreateParams.Categories.ofList( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -89,7 +89,7 @@ class ProjectScoreCreateParamsTest { assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(body.categories()) .isEqualTo( ProjectScoreCreateParams.Categories.ofList( @@ -129,12 +129,12 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt index a52ecdd..add5e2a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt @@ -18,11 +18,7 @@ class ProjectScoreListParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") - .scoreType( - ProjectScoreListParams.ScoreType.ofProjectScoreType( - ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER - ) - ) + .scoreType(ProjectScoreListParams.ScoreType.ofProjectScoreType(ProjectScoreType.SLIDER)) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @@ -39,9 +35,7 @@ class ProjectScoreListParamsTest { .projectName("project_name") .projectScoreName("project_score_name") .scoreType( - ProjectScoreListParams.ScoreType.ofProjectScoreType( - ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER - ) + ProjectScoreListParams.ScoreType.ofProjectScoreType(ProjectScoreType.SLIDER) ) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -63,7 +57,7 @@ class ProjectScoreListParamsTest { "score_type", listOf( ProjectScoreListParams.ScoreType.ofProjectScoreType( - ProjectScoreListParams.ProjectScoreType.SLIDER.toString() + ProjectScoreType.SLIDER.toString() ) .toString() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt index f42d347..f73213e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt @@ -13,7 +13,7 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categories( ProjectScoreReplaceParams.Categories.ofList( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -52,7 +52,7 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categories( ProjectScoreReplaceParams.Categories.ofList( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -89,7 +89,7 @@ class ProjectScoreReplaceParamsTest { assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(body.categories()) .isEqualTo( ProjectScoreReplaceParams.Categories.ofList( @@ -129,12 +129,12 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt index edfe203..49e7db8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt @@ -15,7 +15,7 @@ class ProjectScoreTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScore.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .categories( ProjectScore.Categories.ofList( @@ -55,7 +55,7 @@ class ProjectScoreTest { assertThat(projectScore.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(projectScore.name()).isEqualTo("name") assertThat(projectScore.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectScore.scoreType()).isEqualTo(ProjectScore.ScoreType.SLIDER) + assertThat(projectScore.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(projectScore.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(projectScore.categories()) .contains( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt index c67ee52..9a40ded 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt @@ -42,7 +42,7 @@ class ProjectScoreUpdateParamsTest { ) .description("description") .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() } @@ -83,7 +83,7 @@ class ProjectScoreUpdateParamsTest { ) .description("description") .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() val body = params.getBody() assertThat(body).isNotNull @@ -119,7 +119,7 @@ class ProjectScoreUpdateParamsTest { ) assertThat(body.description()).isEqualTo("description") assertThat(body.name()).isEqualTo("name") - assertThat(body.scoreType()).isEqualTo(ProjectScoreUpdateParams.ScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 54a5664..f7b2194 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -51,15 +51,7 @@ class PromptCreateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -151,16 +143,7 @@ class PromptCreateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -248,15 +231,7 @@ class PromptCreateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 8cf2119..ac9b23a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -43,15 +43,7 @@ class PromptDataTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -125,12 +117,7 @@ class PromptDataTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto( - PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 8246ec4..3031f48 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -51,15 +51,7 @@ class PromptReplaceParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -151,16 +143,7 @@ class PromptReplaceParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -248,15 +231,7 @@ class PromptReplaceParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index 2c5c390..cfdb027 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -59,16 +59,7 @@ class PromptTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -161,15 +152,7 @@ class PromptTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 8fe85bd..c75ca8b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -49,15 +49,7 @@ class PromptUpdateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -148,16 +140,7 @@ class PromptUpdateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -243,15 +226,7 @@ class PromptUpdateParamsTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScorerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScorerTest.kt new file mode 100644 index 0000000..3c30d63 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScorerTest.kt @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ScorerTest { + + @Test + fun createScorer() { + val scorer = Scorer.builder().index(123L).type(Scorer.Type.SCORER).build() + assertThat(scorer).isNotNull + assertThat(scorer.index()).isEqualTo(123L) + assertThat(scorer.type()).isEqualTo(Scorer.Type.SCORER) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TaskTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TaskTest.kt new file mode 100644 index 0000000..c8ec14d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TaskTest.kt @@ -0,0 +1,16 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class TaskTest { + + @Test + fun createTask() { + val task = Task.builder().type(Task.Type.TASK).build() + assertThat(task).isNotNull + assertThat(task.type()).isEqualTo(Task.Type.TASK) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt index 20d9d3b..91a974a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt @@ -87,17 +87,7 @@ class FunctionServiceTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -224,17 +214,7 @@ class FunctionServiceTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -444,17 +424,7 @@ class FunctionServiceTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt index b5b6d28..b6a470b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt @@ -25,7 +25,7 @@ class ProjectScoreServiceTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categories( ProjectScoreCreateParams.Categories.ofList( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -127,7 +127,7 @@ class ProjectScoreServiceTest { ) .description("description") .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .build() ) println(projectScore) @@ -178,7 +178,7 @@ class ProjectScoreServiceTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .scoreType(ProjectScoreType.SLIDER) .categories( ProjectScoreReplaceParams.Categories.ofList( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 8f861cb..bb5693e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -66,17 +66,7 @@ class PromptServiceTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -196,17 +186,7 @@ class PromptServiceTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() @@ -342,17 +322,7 @@ class PromptServiceTest { ) .stop(listOf("string")) .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) + .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) .topP(42.23) .useCache(true) .build() diff --git a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts index cf06fbd..4913adb 100755 --- a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts @@ -41,7 +41,7 @@ configure { developers { developer { name.set("Braintrust") - email.set("info@braintrustdata.com") + email.set("info-test@braintrustdata.com") } }