diff --git a/.stats.yml b/.stats.yml index f657136..e214326 100755 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 87 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-4e541327f59519ac389f4e7a3b2326cce3412b4e39e0b971f8428b5d4772bc7c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-344821ebe82661cb5df7988d5b0541cf89a5a6af89efca9723aff12d369524d2.yml diff --git a/README.md b/README.md index 99cc763..c324a9c 100755 --- a/README.md +++ b/README.md @@ -44,16 +44,7 @@ implementation("com.braintrustdata.api:braintrust-java:0.6.0") ### Configure the client -Use `BraintrustOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`: - -```java -import com.braintrustdata.api.client.BraintrustClient; -import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; - -BraintrustClient client = BraintrustOkHttpClient.builder() - .apiKey("My API Key") - .build(); -``` +Use `BraintrustOkHttpClient.builder()` to configure the client. Alternately, set the environment with `BRAINTRUST_API_KEY`, and use `BraintrustOkHttpClient.fromEnv()` to read from the environment. @@ -69,7 +60,7 @@ BraintrustClient client = BraintrustOkHttpClient.builder() | Property | Environment variable | Required | Default value | | -------- | -------------------- | -------- | ------------- | -| apiKey | `BRAINTRUST_API_KEY` | true | — | +| apiKey | `BRAINTRUST_API_KEY` | false | — | Read the documentation for more configuration options. diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 16291f7..ae986d2 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -62,7 +62,7 @@ class BraintrustOkHttpClient private constructor() { clientOptions.responseValidation(responseValidation) } - fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } fun fromEnv() = apply { clientOptions.fromEnv() } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index 307fb32..d813b98 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -62,7 +62,7 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.responseValidation(responseValidation) } - fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } fun fromEnv() = apply { clientOptions.fromEnv() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 254d218..a63ea9e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -15,7 +15,7 @@ private constructor( @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, - @get:JvmName("apiKey") val apiKey: String, + @get:JvmName("apiKey") val apiKey: String?, @get:JvmName("headers") val headers: ListMultimap, @get:JvmName("queryParams") val queryParams: ListMultimap, @get:JvmName("responseValidation") val responseValidation: Boolean, @@ -94,13 +94,12 @@ private constructor( fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } + fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } fun build(): ClientOptions { checkNotNull(httpClient) { "`httpClient` is required but was not set" } - checkNotNull(apiKey) { "`apiKey` is required but was not set" } val headers = ArrayListMultimap.create() val queryParams = ArrayListMultimap.create() @@ -125,7 +124,7 @@ private constructor( jsonMapper ?: jsonMapper(), clock, baseUrl, - apiKey!!, + apiKey, headers.toUnmodifiable(), queryParams.toUnmodifiable(), responseValidation, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt index 67a9fac..c3820e7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt @@ -2,31 +2,17 @@ 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 -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 class AclListParams constructor( private val objectId: String, - private val objectType: ObjectType?, + private val objectType: AclObjectType?, private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -38,7 +24,7 @@ constructor( fun objectId(): String = objectId - fun objectType(): Optional = Optional.ofNullable(objectType) + fun objectType(): Optional = Optional.ofNullable(objectType) fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -114,7 +100,7 @@ constructor( class Builder { private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectType: AclObjectType? = null private var endingBefore: String? = null private var ids: Ids? = null private var limit: Long? = null @@ -140,7 +126,7 @@ constructor( fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: AclObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. @@ -248,228 +234,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - class ObjectType - @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 ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) - - @JvmField val PROJECT = ObjectType(JsonField.of("project")) - - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) - - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) - - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - @JvmField val GROUP = ObjectType(JsonField.of("group")) - - @JvmField val ROLE = ObjectType(JsonField.of("role")) - - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) - - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) - - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt new file mode 100755 index 0000000..e428b8a --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt @@ -0,0 +1,120 @@ +// 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 AclObjectType +@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 AclObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = AclObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = AclObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = AclObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = AclObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = AclObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = AclObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = AclObjectType(JsonField.of("group")) + + @JvmField val ROLE = AclObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = AclObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = AclObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = AclObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = AclObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown AclObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 045d94a..5bbae4a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -245,117 +234,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateAcl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateAcl.kt new file mode 100755 index 0000000..78effe5 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateAcl.kt @@ -0,0 +1,615 @@ +// 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 +import java.util.Optional + +/** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on + * a project, they will also have read permissions on any experiment, dataset, etc. created within + * that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ +@JsonDeserialize(builder = CreateAcl.Builder::class) +@NoAutoDetect +class CreateAcl +private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val userId: JsonField, + private val groupId: JsonField, + private val permission: JsonField, + private val restrictObjectType: JsonField, + private val roleId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The object type that the ACL applies to */ + fun objectType(): Optional = + Optional.ofNullable(objectType.getNullable("object_type")) + + /** The id of the object the ACL applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId() = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("permission") @ExcludeMissing fun _permission() = permission + + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun _restrictObjectType() = restrictObjectType + + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId() = roleId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateAcl = apply { + if (!validated) { + objectType() + objectId() + userId() + groupId() + permission() + restrictObjectType() + roleId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateAcl && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.userId == other.userId && + this.groupId == other.groupId && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.roleId == other.roleId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + objectType, + objectId, + userId, + groupId, + permission, + restrictObjectType, + roleId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objectType: JsonField = JsonMissing.of() + private var objectId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var groupId: JsonField = JsonMissing.of() + private var permission: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() + private var roleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createAcl: CreateAcl) = apply { + this.objectType = createAcl.objectType + this.objectId = createAcl.objectId + this.userId = createAcl.userId + this.groupId = createAcl.groupId + this.permission = createAcl.permission + this.restrictObjectType = createAcl.restrictObjectType + this.roleId = createAcl.roleId + additionalProperties(createAcl.additionalProperties) + } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + /** The id of the object the ACL applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") + @ExcludeMissing + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("user_id") + @ExcludeMissing + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: String) = groupId(JsonField.of(groupId)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("group_id") + @ExcludeMissing + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("permission") + @ExcludeMissing + fun permission(permission: JsonField) = apply { this.permission = permission } + + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ + fun restrictObjectType(restrictObjectType: RestrictObjectType) = + restrictObjectType(JsonField.of(restrictObjectType)) + + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(roleId: String) = roleId(JsonField.of(roleId)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + @JsonProperty("role_id") + @ExcludeMissing + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + + 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(): CreateAcl = + CreateAcl( + objectType, + objectId, + userId, + groupId, + permission, + restrictObjectType, + roleId, + additionalProperties.toUnmodifiable(), + ) + } + + class ObjectType + @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 ObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = ObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = ObjectType(JsonField.of("group")) + + @JvmField val ROLE = ObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Permission + @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 Permission && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CREATE = Permission(JsonField.of("create")) + + @JvmField val READ = Permission(JsonField.of("read")) + + @JvmField val UPDATE = Permission(JsonField.of("update")) + + @JvmField val DELETE = Permission(JsonField.of("delete")) + + @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + + @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + + @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + + @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_acls")) + + @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) + } + + enum class Known { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + } + + enum class Value { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class RestrictObjectType + @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 RestrictObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + + @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt new file mode 100755 index 0000000..f8043a7 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -0,0 +1,238 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = CreateApiKeyOutput.Builder::class) +@NoAutoDetect +class CreateApiKeyOutput +private constructor( + private val id: JsonField, + private val created: JsonField, + private val name: JsonField, + private val previewName: JsonField, + private val userId: JsonField, + private val orgId: JsonField, + private val key: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Unique identifier for the api key */ + fun id(): String = id.getRequired("id") + + /** Date of api key creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** Name of the api key */ + fun name(): String = name.getRequired("name") + + fun previewName(): String = previewName.getRequired("preview_name") + + /** Unique identifier for the user */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** Unique identifier for the organization */ + fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) + + /** The raw API key. It will only be exposed this one time */ + fun key(): String = key.getRequired("key") + + /** Unique identifier for the api key */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** Date of api key creation */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Name of the api key */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName + + /** Unique identifier for the user */ + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + + /** Unique identifier for the organization */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + + /** The raw API key. It will only be exposed this one time */ + @JsonProperty("key") @ExcludeMissing fun _key() = key + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateApiKeyOutput = apply { + if (!validated) { + id() + created() + name() + previewName() + userId() + orgId() + key() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateApiKeyOutput && + this.id == other.id && + this.created == other.created && + this.name == other.name && + this.previewName == other.previewName && + this.userId == other.userId && + this.orgId == other.orgId && + this.key == other.key && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + created, + name, + previewName, + userId, + orgId, + key, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateApiKeyOutput{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var previewName: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var orgId: JsonField = JsonMissing.of() + private var key: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createApiKeyOutput: CreateApiKeyOutput) = apply { + this.id = createApiKeyOutput.id + this.created = createApiKeyOutput.created + this.name = createApiKeyOutput.name + this.previewName = createApiKeyOutput.previewName + this.userId = createApiKeyOutput.userId + this.orgId = createApiKeyOutput.orgId + this.key = createApiKeyOutput.key + additionalProperties(createApiKeyOutput.additionalProperties) + } + + /** Unique identifier for the api key */ + fun id(id: String) = id(JsonField.of(id)) + + /** Unique identifier for the api key */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** Date of api key creation */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** Date of api key creation */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** Name of the api key */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the api key */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun previewName(previewName: String) = previewName(JsonField.of(previewName)) + + @JsonProperty("preview_name") + @ExcludeMissing + fun previewName(previewName: JsonField) = apply { this.previewName = previewName } + + /** Unique identifier for the user */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** Unique identifier for the user */ + @JsonProperty("user_id") + @ExcludeMissing + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Unique identifier for the organization */ + fun orgId(orgId: String) = orgId(JsonField.of(orgId)) + + /** Unique identifier for the organization */ + @JsonProperty("org_id") + @ExcludeMissing + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + + /** The raw API key. It will only be exposed this one time */ + fun key(key: String) = key(JsonField.of(key)) + + /** The raw API key. It will only be exposed this one time */ + @JsonProperty("key") + @ExcludeMissing + fun key(key: JsonField) = apply { this.key = key } + + 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(): CreateApiKeyOutput = + CreateApiKeyOutput( + id, + created, + name, + previewName, + userId, + orgId, + key, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateDataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateDataset.kt new file mode 100755 index 0000000..fdfcf23 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateDataset.kt @@ -0,0 +1,160 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CreateDataset.Builder::class) +@NoAutoDetect +class CreateDataset +private constructor( + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(): String = name.getRequired("name") + + /** Textual description of the dataset */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Unique identifier for the project that the dataset belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Name of the dataset. Within a project, dataset names are unique */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the dataset */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateDataset = apply { + if (!validated) { + projectId() + name() + description() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateDataset && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectId, + name, + description, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateDataset{projectId=$projectId, name=$name, description=$description, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createDataset: CreateDataset) = apply { + this.projectId = createDataset.projectId + this.name = createDataset.name + this.description = createDataset.description + additionalProperties(createDataset.additionalProperties) + } + + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the dataset belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the dataset. Within a project, dataset names are unique */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the dataset */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the dataset */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + 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(): CreateDataset = + CreateDataset( + projectId, + name, + description, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateExperiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateExperiment.kt new file mode 100755 index 0000000..6038ea4 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateExperiment.kt @@ -0,0 +1,427 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CreateExperiment.Builder::class) +@NoAutoDetect +class CreateExperiment +private constructor( + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val repoInfo: JsonField, + private val baseExpId: JsonField, + private val datasetId: JsonField, + private val datasetVersion: JsonField, + private val public_: JsonField, + private val metadata: JsonField, + private val ensureNew: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the experiment */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) + + /** User-controlled metadata about the experiment */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * Normally, creating an experiment with the same name as an existing experiment will return the + * existing one un-modified. But if `ensure_new` is true, registration will generate a new + * experiment with a unique name in case of a conflict. + */ + fun ensureNew(): Optional = Optional.ofNullable(ensureNew.getNullable("ensure_new")) + + /** Unique identifier for the project that the experiment belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Name of the experiment. Within a project, experiment names are unique */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the experiment */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo() = repoInfo + + /** Id of default base experiment to compare against when viewing this experiment */ + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId() = baseExpId + + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion() = datasetVersion + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + @JsonProperty("public") @ExcludeMissing fun _public_() = public_ + + /** User-controlled metadata about the experiment */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** + * Normally, creating an experiment with the same name as an existing experiment will return the + * existing one un-modified. But if `ensure_new` is true, registration will generate a new + * experiment with a unique name in case of a conflict. + */ + @JsonProperty("ensure_new") @ExcludeMissing fun _ensureNew() = ensureNew + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateExperiment = apply { + if (!validated) { + projectId() + name() + description() + repoInfo().map { it.validate() } + baseExpId() + datasetId() + datasetVersion() + public_() + metadata().map { it.validate() } + ensureNew() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateExperiment && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.repoInfo == other.repoInfo && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.public_ == other.public_ && + this.metadata == other.metadata && + this.ensureNew == other.ensureNew && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectId, + name, + description, + repoInfo, + baseExpId, + datasetId, + datasetVersion, + public_, + metadata, + ensureNew, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateExperiment{projectId=$projectId, name=$name, description=$description, repoInfo=$repoInfo, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, metadata=$metadata, ensureNew=$ensureNew, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var repoInfo: JsonField = JsonMissing.of() + private var baseExpId: JsonField = JsonMissing.of() + private var datasetId: JsonField = JsonMissing.of() + private var datasetVersion: JsonField = JsonMissing.of() + private var public_: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var ensureNew: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createExperiment: CreateExperiment) = apply { + this.projectId = createExperiment.projectId + this.name = createExperiment.name + this.description = createExperiment.description + this.repoInfo = createExperiment.repoInfo + this.baseExpId = createExperiment.baseExpId + this.datasetId = createExperiment.datasetId + this.datasetVersion = createExperiment.datasetVersion + this.public_ = createExperiment.public_ + this.metadata = createExperiment.metadata + this.ensureNew = createExperiment.ensureNew + additionalProperties(createExperiment.additionalProperties) + } + + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the experiment belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the experiment. Within a project, experiment names are unique */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the experiment */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the experiment */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo) = repoInfo(JsonField.of(repoInfo)) + + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") + @ExcludeMissing + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: String) = baseExpId(JsonField.of(baseExpId)) + + /** Id of default base experiment to compare against when viewing this experiment */ + @JsonProperty("base_exp_id") + @ExcludeMissing + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + @JsonProperty("dataset_id") + @ExcludeMissing + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: String) = datasetVersion(JsonField.of(datasetVersion)) + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + @JsonProperty("dataset_version") + @ExcludeMissing + fun datasetVersion(datasetVersion: JsonField) = apply { + this.datasetVersion = datasetVersion + } + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean) = public_(JsonField.of(public_)) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + @JsonProperty("public") + @ExcludeMissing + fun public_(public_: JsonField) = apply { this.public_ = public_ } + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** User-controlled metadata about the experiment */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. + */ + fun ensureNew(ensureNew: Boolean) = ensureNew(JsonField.of(ensureNew)) + + /** + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. + */ + @JsonProperty("ensure_new") + @ExcludeMissing + fun ensureNew(ensureNew: JsonField) = apply { this.ensureNew = ensureNew } + + 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(): CreateExperiment = + CreateExperiment( + projectId, + name, + description, + repoInfo, + baseExpId, + datasetId, + datasetVersion, + public_, + metadata, + ensureNew, + additionalProperties.toUnmodifiable(), + ) + } + + /** User-controlled metadata about the experiment */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateFunction.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateFunction.kt new file mode 100755 index 0000000..e11836c --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateFunction.kt @@ -0,0 +1,1630 @@ +// 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(builder = CreateFunction.Builder::class) +@NoAutoDetect +class CreateFunction +private constructor( + private val projectId: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val description: JsonField, + private val promptData: JsonField, + private val tags: JsonField>, + private val functionData: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Name of the prompt */ + fun name(): String = name.getRequired("name") + + /** Unique identifier for the prompt */ + fun slug(): String = slug.getRequired("slug") + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + fun functionData(): FunctionData = functionData.getRequired("function_data") + + /** Unique identifier for the project that the prompt belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Unique identifier for the prompt */ + @JsonProperty("slug") @ExcludeMissing fun _slug() = slug + + /** Textual description of the prompt */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + + /** A list of tags for the prompt */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + @JsonProperty("function_data") @ExcludeMissing fun _functionData() = functionData + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateFunction = apply { + if (!validated) { + projectId() + name() + slug() + description() + promptData().map { it.validate() } + tags() + functionData() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateFunction && + this.projectId == other.projectId && + this.name == other.name && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.functionData == other.functionData && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectId, + name, + slug, + description, + promptData, + tags, + functionData, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateFunction{projectId=$projectId, name=$name, slug=$slug, description=$description, promptData=$promptData, tags=$tags, functionData=$functionData, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var slug: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var functionData: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createFunction: CreateFunction) = apply { + this.projectId = createFunction.projectId + this.name = createFunction.name + this.slug = createFunction.slug + this.description = createFunction.description + this.promptData = createFunction.promptData + this.tags = createFunction.tags + this.functionData = createFunction.functionData + additionalProperties(createFunction.additionalProperties) + } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the prompt belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** Unique identifier for the prompt */ + @JsonProperty("slug") + @ExcludeMissing + fun slug(slug: JsonField) = apply { this.slug = slug } + + /** Textual description of the prompt */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the prompt */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") + @ExcludeMissing + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + + /** A list of tags for the prompt */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags for the prompt */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + + @JsonProperty("function_data") + @ExcludeMissing + fun functionData(functionData: JsonField) = apply { + this.functionData = functionData + } + + 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(): CreateFunction = + CreateFunction( + projectId, + name, + slug, + description, + promptData, + tags.map { it.toUnmodifiable() }, + functionData, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = FunctionData.Deserializer::class) + @JsonSerialize(using = FunctionData.Serializer::class) + class FunctionData + private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun prompt(): Optional = Optional.ofNullable(prompt) + + fun code(): Optional = Optional.ofNullable(code) + + fun global(): Optional = Optional.ofNullable(global) + + fun isPrompt(): Boolean = prompt != null + + fun isCode(): Boolean = code != null + + fun isGlobal(): Boolean = global != null + + fun asPrompt(): Prompt = prompt.getOrThrow("prompt") + + fun asCode(): Code = code.getOrThrow("code") + + fun asGlobal(): Global = global.getOrThrow("global") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } + } + + fun validate(): FunctionData = apply { + if (!validated) { + if (prompt == null && code == null && global == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global + } + + override fun hashCode(): Int { + return Objects.hash( + prompt, + code, + global, + ) + } + + override fun toString(): String { + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } + } + + companion object { + + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + } + + interface Visitor { + + fun visitPrompt(prompt: Prompt): T + + fun visitCode(code: Code): T + + fun visitGlobal(global: Global): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown FunctionData: $json") + } + } + + class Deserializer : BaseDeserializer(FunctionData::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) + } + } + + class Serializer : BaseSerializer(FunctionData::class) { + + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } + } + } + + @JsonDeserialize(builder = Prompt.Builder::class) + @NoAutoDetect + class Prompt + 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(): Prompt = 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 Prompt && + 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() = + "Prompt{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(prompt: Prompt) = apply { + this.type = prompt.type + additionalProperties(prompt.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(): Prompt = Prompt(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 PROMPT = Type(JsonField.of("prompt")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + PROMPT, + } + + enum class Value { + PROMPT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = Code.Builder::class) + @NoAutoDetect + class Code + private constructor( + private val type: JsonField, + private val data: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun data(): Data = data.getRequired("data") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("data") @ExcludeMissing fun _data() = data + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Code = apply { + if (!validated) { + type() + data().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(code: Code) = apply { + this.type = code.type + this.data = code.data + additionalProperties(code.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun data(data: Data) = data(JsonField.of(data)) + + @JsonProperty("data") + @ExcludeMissing + fun data(data: JsonField) = apply { this.data = data } + + 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(): Code = + Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Data.Builder::class) + @NoAutoDetect + class Data + private constructor( + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + + fun location(): Location = location.getRequired("location") + + fun bundleId(): String = bundleId.getRequired("bundle_id") + + @JsonProperty("runtime_context") + @ExcludeMissing + fun _runtimeContext() = runtimeContext + + @JsonProperty("location") @ExcludeMissing fun _location() = location + + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Data = apply { + if (!validated) { + runtimeContext().validate() + location().validate() + bundleId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + runtimeContext, + location, + bundleId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var runtimeContext: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var bundleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + this.runtimeContext = data.runtimeContext + this.location = data.location + this.bundleId = data.bundleId + additionalProperties(data.additionalProperties) + } + + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) + + @JsonProperty("runtime_context") + @ExcludeMissing + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } + + fun location(location: Location) = location(JsonField.of(location)) + + @JsonProperty("location") + @ExcludeMissing + fun location(location: JsonField) = apply { this.location = location } + + fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + + @JsonProperty("bundle_id") + @ExcludeMissing + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } + + 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(): Data = + Data( + runtimeContext, + location, + bundleId, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Location.Builder::class) + @NoAutoDetect + class Location + private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun evalName(): String = evalName.getRequired("eval_name") + + fun position(): Position = position.getRequired("position") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + + @JsonProperty("position") @ExcludeMissing fun _position() = position + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Location = apply { + if (!validated) { + type() + evalName() + position() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var evalName: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(location: Location) = apply { + this.type = location.type + this.evalName = location.evalName + this.position = location.position + additionalProperties(location.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + + @JsonProperty("eval_name") + @ExcludeMissing + fun evalName(evalName: JsonField) = apply { + this.evalName = evalName + } + + fun position(position: Position) = position(JsonField.of(position)) + + @JsonProperty("position") + @ExcludeMissing + fun position(position: JsonField) = apply { + this.position = position + } + + 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(): Location = + Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = Position.Deserializer::class) + @JsonSerialize(using = Position.Serializer::class) + class Position + private constructor( + private val task: Task? = null, + private val score: Score? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun task(): Optional = Optional.ofNullable(task) + + fun score(): Optional = Optional.ofNullable(score) + + fun isTask(): Boolean = task != null + + fun isScore(): Boolean = score != null + + fun asTask(): Task = task.getOrThrow("task") + + fun asScore(): Score = score.getOrThrow("score") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + task != null -> visitor.visitTask(task) + score != null -> visitor.visitScore(score) + else -> visitor.unknown(_json) + } + } + + fun validate(): Position = apply { + if (!validated) { + if (task == null && score == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + score?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + this.task == other.task && + this.score == other.score + } + + override fun hashCode(): Int { + return Objects.hash(task, score) + } + + override fun toString(): String { + return when { + task != null -> "Position{task=$task}" + score != null -> "Position{score=$score}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } + } + + companion object { + + @JvmStatic fun ofTask(task: Task) = Position(task = task) + + @JvmStatic fun ofScore(score: Score) = Position(score = score) + } + + interface Visitor { + + fun visitTask(task: Task): T + + fun visitScore(score: Score): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Position: $json") + } + } + + class Deserializer : BaseDeserializer(Position::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Position { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Position(task = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(score = it, _json = json) + } + + return Position(_json = json) + } + } + + class Serializer : BaseSerializer(Position::class) { + + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.task != null -> generator.writeObject(value.task) + value.score != null -> generator.writeObject(value.score) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } + } + } + + class Task + @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 Task && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TASK = Task(JsonField.of("task")) + + @JvmStatic fun of(value: String) = Task(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 Task: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = Score.Builder::class) + @NoAutoDetect + class Score + private constructor( + private val score: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun score(): Double = score.getRequired("score") + + @JsonProperty("score") @ExcludeMissing fun _score() = score + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Score = apply { + if (!validated) { + score() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && + this.score == other.score && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(score, additionalProperties) + } + return hashCode + } + + override fun toString() = + "Score{score=$score, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var score: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(score: Score) = apply { + this.score = score.score + additionalProperties(score.additionalProperties) + } + + fun score(score: Double) = score(JsonField.of(score)) + + @JsonProperty("score") + @ExcludeMissing + fun score(score: JsonField) = apply { this.score = score } + + 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(): Score = + Score(score, 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 EXPERIMENT = Type(JsonField.of("experiment")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + } + + enum class Value { + EXPERIMENT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = RuntimeContext.Builder::class) + @NoAutoDetect + class RuntimeContext + private constructor( + private val runtime: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun runtime(): Runtime = runtime.getRequired("runtime") + + fun version(): String = version.getRequired("version") + + @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RuntimeContext = apply { + if (!validated) { + runtime() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var runtime: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(runtimeContext: RuntimeContext) = apply { + this.runtime = runtimeContext.runtime + this.version = runtimeContext.version + additionalProperties(runtimeContext.additionalProperties) + } + + fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + + @JsonProperty("runtime") + @ExcludeMissing + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + + fun version(version: String) = version(JsonField.of(version)) + + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + 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(): RuntimeContext = + RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) + } + + class Runtime + @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 Runtime && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val NODE = Runtime(JsonField.of("node")) + + @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) + } + + enum class Known { + NODE, + } + + enum class Value { + NODE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + NODE -> Value.NODE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + NODE -> Known.NODE + else -> + throw BraintrustInvalidDataException("Unknown Runtime: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + } + + 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 CODE = Type(JsonField.of("code")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + CODE, + } + + enum class Value { + CODE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = Global.Builder::class) + @NoAutoDetect + class Global + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun name(): String = name.getRequired("name") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Global = apply { + if (!validated) { + type() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(global: Global) = apply { + this.type = global.type + this.name = global.name + additionalProperties(global.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + 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(): Global = + Global( + type, + 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 GLOBAL = Type(JsonField.of("global")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + GLOBAL, + } + + enum class Value { + GLOBAL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateGroup.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateGroup.kt new file mode 100755 index 0000000..ec392f4 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateGroup.kt @@ -0,0 +1,244 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CreateGroup.Builder::class) +@NoAutoDetect +class CreateGroup +private constructor( + private val name: JsonField, + private val description: JsonField, + private val memberUsers: JsonField>, + private val memberGroups: JsonField>, + private val orgName: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the group */ + fun name(): String = name.getRequired("name") + + /** Textual description of the group */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Ids of users which belong to this group */ + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users + */ + fun memberGroups(): Optional> = + Optional.ofNullable(memberGroups.getNullable("member_groups")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. + */ + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the group */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the group */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** Ids of users which belong to this group */ + @JsonProperty("member_users") @ExcludeMissing fun _memberUsers() = memberUsers + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users + */ + @JsonProperty("member_groups") @ExcludeMissing fun _memberGroups() = memberGroups + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName() = orgName + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateGroup = apply { + if (!validated) { + name() + description() + memberUsers() + memberGroups() + orgName() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateGroup && + this.name == other.name && + this.description == other.description && + this.memberUsers == other.memberUsers && + this.memberGroups == other.memberGroups && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + memberUsers, + memberGroups, + orgName, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateGroup{name=$name, description=$description, memberUsers=$memberUsers, memberGroups=$memberGroups, orgName=$orgName, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var memberUsers: JsonField> = JsonMissing.of() + private var memberGroups: JsonField> = JsonMissing.of() + private var orgName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createGroup: CreateGroup) = apply { + this.name = createGroup.name + this.description = createGroup.description + this.memberUsers = createGroup.memberUsers + this.memberGroups = createGroup.memberGroups + this.orgName = createGroup.orgName + additionalProperties(createGroup.additionalProperties) + } + + /** Name of the group */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the group */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the group */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the group */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: List) = memberUsers(JsonField.of(memberUsers)) + + /** Ids of users which belong to this group */ + @JsonProperty("member_users") + @ExcludeMissing + fun memberUsers(memberUsers: JsonField>) = apply { + this.memberUsers = memberUsers + } + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + fun memberGroups(memberGroups: List) = memberGroups(JsonField.of(memberGroups)) + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + @JsonProperty("member_groups") + @ExcludeMissing + fun memberGroups(memberGroups: JsonField>) = apply { + this.memberGroups = memberGroups + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: String) = orgName(JsonField.of(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + @JsonProperty("org_name") + @ExcludeMissing + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + 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(): CreateGroup = + CreateGroup( + name, + description, + memberUsers.map { it.toUnmodifiable() }, + memberGroups.map { it.toUnmodifiable() }, + orgName, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProject.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProject.kt new file mode 100755 index 0000000..43ae8a6 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProject.kt @@ -0,0 +1,154 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CreateProject.Builder::class) +@NoAutoDetect +class CreateProject +private constructor( + private val name: JsonField, + private val orgName: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the project */ + fun name(): String = name.getRequired("name") + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * project belongs in. + */ + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the project */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * project belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName() = orgName + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateProject = apply { + if (!validated) { + name() + orgName() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateProject && + this.name == other.name && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + orgName, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateProject{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var orgName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createProject: CreateProject) = apply { + this.name = createProject.name + this.orgName = createProject.orgName + additionalProperties(createProject.additionalProperties) + } + + /** Name of the project */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. + */ + fun orgName(orgName: String) = orgName(JsonField.of(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. + */ + @JsonProperty("org_name") + @ExcludeMissing + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + 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(): CreateProject = + CreateProject( + name, + orgName, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectScore.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectScore.kt new file mode 100755 index 0000000..8c42582 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectScore.kt @@ -0,0 +1,608 @@ +// 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(builder = CreateProjectScore.Builder::class) +@NoAutoDetect +class CreateProjectScore +private constructor( + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val scoreType: JsonField, + private val categories: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Name of the project score */ + fun name(): String = name.getRequired("name") + + /** Textual description of the project score */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The type of the configured score */ + fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) + + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) + + /** Unique identifier for the project that the project score belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Name of the project score */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the project score */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** The type of the configured score */ + @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType + + @JsonProperty("categories") @ExcludeMissing fun _categories() = categories + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateProjectScore = apply { + if (!validated) { + projectId() + name() + description() + scoreType() + categories() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateProjectScore && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectId, + name, + description, + scoreType, + categories, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateProjectScore{projectId=$projectId, name=$name, description=$description, scoreType=$scoreType, categories=$categories, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var scoreType: JsonField = JsonMissing.of() + private var categories: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createProjectScore: CreateProjectScore) = apply { + this.projectId = createProjectScore.projectId + this.name = createProjectScore.name + this.description = createProjectScore.description + this.scoreType = createProjectScore.scoreType + this.categories = createProjectScore.categories + additionalProperties(createProjectScore.additionalProperties) + } + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the project score belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Name of the project score */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project score */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the project score */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the project score */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** The type of the configured score */ + fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + + /** The type of the configured score */ + @JsonProperty("score_type") + @ExcludeMissing + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + + fun categories(categories: Categories) = categories(JsonField.of(categories)) + + @JsonProperty("categories") + @ExcludeMissing + fun categories(categories: JsonField) = apply { this.categories = categories } + + 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(): CreateProjectScore = + CreateProjectScore( + projectId, + name, + description, + scoreType, + categories, + additionalProperties.toUnmodifiable(), + ) + } + + 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")) + + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Categories.Deserializer::class) + @JsonSerialize(using = Categories.Serializer::class) + class Categories + private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** For categorical-type project scores, the list of all categories */ + fun projectScoreCategories(): Optional> = + Optional.ofNullable(projectScoreCategories) + /** For weighted-type project scores, the weights of each score */ + fun weighted(): Optional = Optional.ofNullable(weighted) + /** For minimum-type project scores, the list of included scores */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isProjectScoreCategories(): Boolean = projectScoreCategories != null + + fun isWeighted(): Boolean = weighted != null + + fun isStrings(): Boolean = strings != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asProjectScoreCategories(): List = + projectScoreCategories.getOrThrow("projectScoreCategories") + + fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + projectScoreCategories != null -> + visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } + } + + fun validate(): Categories = apply { + if (!validated) { + if ( + projectScoreCategories == null && + weighted == null && + strings == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant + } + + override fun hashCode(): Int { + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) + } + + override fun toString(): String { + return when { + projectScoreCategories != null -> + "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } + } + + companion object { + + @JvmStatic + fun ofProjectScoreCategories(projectScoreCategories: List) = + Categories(projectScoreCategories = projectScoreCategories) + + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + + @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) + + @JvmStatic + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) + } + + interface Visitor { + + fun visitProjectScoreCategories(projectScoreCategories: List): T + + fun visitWeighted(weighted: Weighted): T + + fun visitStrings(strings: List): T + + fun visitNullableVariant(nullableVariant: NullableVariant): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Categories: $json") + } + } + + class Deserializer : BaseDeserializer(Categories::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Categories { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) + } + } + + class Serializer : BaseSerializer(Categories::class) { + + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.projectScoreCategories != null -> + generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } + } + } + + /** For weighted-type project scores, the weights of each score */ + @JsonDeserialize(builder = Weighted.Builder::class) + @NoAutoDetect + class Weighted + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Weighted = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Weighted && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(weighted: Weighted) = apply { + additionalProperties(weighted.additionalProperties) + } + + 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(): Weighted = Weighted(additionalProperties.toUnmodifiable()) + } + } + + @JsonDeserialize(builder = NullableVariant.Builder::class) + @NoAutoDetect + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): NullableVariant = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NullableVariant && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) + } + + 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(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectTag.kt new file mode 100755 index 0000000..e13f256 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectTag.kt @@ -0,0 +1,181 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CreateProjectTag.Builder::class) +@NoAutoDetect +class CreateProjectTag +private constructor( + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val color: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Name of the project tag */ + fun name(): String = name.getRequired("name") + + /** Textual description of the project tag */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Color of the tag for the UI */ + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) + + /** Unique identifier for the project that the project tag belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Name of the project tag */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the project tag */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** Color of the tag for the UI */ + @JsonProperty("color") @ExcludeMissing fun _color() = color + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateProjectTag = apply { + if (!validated) { + projectId() + name() + description() + color() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateProjectTag && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.color == other.color && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectId, + name, + description, + color, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateProjectTag{projectId=$projectId, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var color: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createProjectTag: CreateProjectTag) = apply { + this.projectId = createProjectTag.projectId + this.name = createProjectTag.name + this.description = createProjectTag.description + this.color = createProjectTag.color + additionalProperties(createProjectTag.additionalProperties) + } + + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the project tag belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Name of the project tag */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project tag */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the project tag */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the project tag */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** Color of the tag for the UI */ + fun color(color: String) = color(JsonField.of(color)) + + /** Color of the tag for the UI */ + @JsonProperty("color") + @ExcludeMissing + fun color(color: JsonField) = apply { this.color = color } + + 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(): CreateProjectTag = + CreateProjectTag( + projectId, + name, + description, + color, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreatePrompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreatePrompt.kt new file mode 100755 index 0000000..e63f8ce --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreatePrompt.kt @@ -0,0 +1,224 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CreatePrompt.Builder::class) +@NoAutoDetect +class CreatePrompt +private constructor( + private val projectId: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val description: JsonField, + private val promptData: JsonField, + private val tags: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Name of the prompt */ + fun name(): String = name.getRequired("name") + + /** Unique identifier for the prompt */ + fun slug(): String = slug.getRequired("slug") + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** Unique identifier for the project that the prompt belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Unique identifier for the prompt */ + @JsonProperty("slug") @ExcludeMissing fun _slug() = slug + + /** Textual description of the prompt */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + + /** A list of tags for the prompt */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreatePrompt = apply { + if (!validated) { + projectId() + name() + slug() + description() + promptData().map { it.validate() } + tags() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatePrompt && + this.projectId == other.projectId && + this.name == other.name && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectId, + name, + slug, + description, + promptData, + tags, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreatePrompt{projectId=$projectId, name=$name, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var slug: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createPrompt: CreatePrompt) = apply { + this.projectId = createPrompt.projectId + this.name = createPrompt.name + this.slug = createPrompt.slug + this.description = createPrompt.description + this.promptData = createPrompt.promptData + this.tags = createPrompt.tags + additionalProperties(createPrompt.additionalProperties) + } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the prompt belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** Unique identifier for the prompt */ + @JsonProperty("slug") + @ExcludeMissing + fun slug(slug: JsonField) = apply { this.slug = slug } + + /** Textual description of the prompt */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the prompt */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") + @ExcludeMissing + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + + /** A list of tags for the prompt */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags for the prompt */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + 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(): CreatePrompt = + CreatePrompt( + projectId, + name, + slug, + description, + promptData, + tags.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateRole.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateRole.kt new file mode 100755 index 0000000..db9c836 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateRole.kt @@ -0,0 +1,602 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CreateRole.Builder::class) +@NoAutoDetect +class CreateRole +private constructor( + private val name: JsonField, + private val description: JsonField, + private val memberPermissions: JsonField>, + private val memberRoles: JsonField>, + private val orgName: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the role */ + fun name(): String = name.getRequired("name") + + /** Textual description of the role */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions + */ + fun memberRoles(): Optional> = + Optional.ofNullable(memberRoles.getNullable("member_roles")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. + */ + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the role */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the role */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** (permission, restrict_object_type) tuples which belong to this role */ + @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions() = memberPermissions + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions + */ + @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles() = memberRoles + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName() = orgName + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateRole = apply { + if (!validated) { + name() + description() + memberPermissions().map { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateRole && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateRole{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var memberPermissions: JsonField> = JsonMissing.of() + private var memberRoles: JsonField> = JsonMissing.of() + private var orgName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createRole: CreateRole) = apply { + this.name = createRole.name + this.description = createRole.description + this.memberPermissions = createRole.memberPermissions + this.memberRoles = createRole.memberRoles + this.orgName = createRole.orgName + additionalProperties(createRole.additionalProperties) + } + + /** Name of the role */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the role */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the role */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the role */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: List) = + memberPermissions(JsonField.of(memberPermissions)) + + /** (permission, restrict_object_type) tuples which belong to this role */ + @JsonProperty("member_permissions") + @ExcludeMissing + fun memberPermissions(memberPermissions: JsonField>) = apply { + this.memberPermissions = memberPermissions + } + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(memberRoles: List) = memberRoles(JsonField.of(memberRoles)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + @JsonProperty("member_roles") + @ExcludeMissing + fun memberRoles(memberRoles: JsonField>) = apply { + this.memberRoles = memberRoles + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: String) = orgName(JsonField.of(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + @JsonProperty("org_name") + @ExcludeMissing + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + 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(): CreateRole = + CreateRole( + name, + description, + memberPermissions.map { it.toUnmodifiable() }, + memberRoles.map { it.toUnmodifiable() }, + orgName, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = MemberPermission.Builder::class) + @NoAutoDetect + class MemberPermission + private constructor( + private val permission: JsonField, + private val restrictObjectType: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into roles + */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** The object type that the ACL applies to */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into roles + */ + @JsonProperty("permission") @ExcludeMissing fun _permission() = permission + + /** The object type that the ACL applies to */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun _restrictObjectType() = restrictObjectType + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MemberPermission = apply { + if (!validated) { + permission() + restrictObjectType() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var permission: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(memberPermission: MemberPermission) = apply { + this.permission = memberPermission.permission + this.restrictObjectType = memberPermission.restrictObjectType + additionalProperties(memberPermission.additionalProperties) + } + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles + */ + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles + */ + @JsonProperty("permission") + @ExcludeMissing + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: RestrictObjectType) = + restrictObjectType(JsonField.of(restrictObjectType)) + + /** The object type that the ACL applies to */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } + + 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(): MemberPermission = + MemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) + } + + class Permission + @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 Permission && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CREATE = Permission(JsonField.of("create")) + + @JvmField val READ = Permission(JsonField.of("read")) + + @JvmField val UPDATE = Permission(JsonField.of("update")) + + @JvmField val DELETE = Permission(JsonField.of("delete")) + + @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + + @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + + @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + + @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_acls")) + + @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) + } + + enum class Known { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + } + + enum class Value { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class RestrictObjectType + @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 RestrictObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + + @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateView.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateView.kt new file mode 100755 index 0000000..6804d04 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateView.kt @@ -0,0 +1,474 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = CreateView.Builder::class) +@NoAutoDetect +class CreateView +private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val viewType: JsonField, + private val name: JsonField, + private val viewData: JsonField, + private val options: JsonField, + private val userId: JsonField, + private val deletedAt: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The object type that the ACL applies to */ + fun objectType(): Optional = + Optional.ofNullable(objectType.getNullable("object_type")) + + /** The id of the object the view applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** Type of table that the view corresponds to. */ + fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) + + /** Name of the view */ + fun name(): String = name.getRequired("name") + + /** The view definition */ + fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) + + /** Options for the view in the app */ + fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + + /** Identifies the user who created the view */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + + /** The id of the object the view applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + + /** Type of table that the view corresponds to. */ + @JsonProperty("view_type") @ExcludeMissing fun _viewType() = viewType + + /** Name of the view */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** The view definition */ + @JsonProperty("view_data") @ExcludeMissing fun _viewData() = viewData + + /** Options for the view in the app */ + @JsonProperty("options") @ExcludeMissing fun _options() = options + + /** Identifies the user who created the view */ + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + + /** Date of role deletion, or null if the role is still active */ + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreateView = apply { + if (!validated) { + objectType() + objectId() + viewType() + name() + viewData().map { it.validate() } + options().map { it.validate() } + userId() + deletedAt() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateView && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.viewType == other.viewType && + this.name == other.name && + this.viewData == other.viewData && + this.options == other.options && + this.userId == other.userId && + this.deletedAt == other.deletedAt && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + objectType, + objectId, + viewType, + name, + viewData, + options, + userId, + deletedAt, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateView{objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objectType: JsonField = JsonMissing.of() + private var objectId: JsonField = JsonMissing.of() + private var viewType: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var viewData: JsonField = JsonMissing.of() + private var options: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var deletedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createView: CreateView) = apply { + this.objectType = createView.objectType + this.objectId = createView.objectId + this.viewType = createView.viewType + this.name = createView.name + this.viewData = createView.viewData + this.options = createView.options + this.userId = createView.userId + this.deletedAt = createView.deletedAt + additionalProperties(createView.additionalProperties) + } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + /** The id of the object the view applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the view applies to */ + @JsonProperty("object_id") + @ExcludeMissing + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: ViewType) = viewType(JsonField.of(viewType)) + + /** Type of table that the view corresponds to. */ + @JsonProperty("view_type") + @ExcludeMissing + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + + /** Name of the view */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the view */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** The view definition */ + fun viewData(viewData: ViewData) = viewData(JsonField.of(viewData)) + + /** The view definition */ + @JsonProperty("view_data") + @ExcludeMissing + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + + /** Options for the view in the app */ + fun options(options: ViewOptions) = options(JsonField.of(options)) + + /** Options for the view in the app */ + @JsonProperty("options") + @ExcludeMissing + fun options(options: JsonField) = apply { this.options = options } + + /** Identifies the user who created the view */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** Identifies the user who created the view */ + @JsonProperty("user_id") + @ExcludeMissing + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + + /** Date of role deletion, or null if the role is still active */ + @JsonProperty("deleted_at") + @ExcludeMissing + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + + 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(): CreateView = + CreateView( + objectType, + objectId, + viewType, + name, + viewData, + options, + userId, + deletedAt, + additionalProperties.toUnmodifiable(), + ) + } + + class ObjectType + @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 ObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = ObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = ObjectType(JsonField.of("group")) + + @JvmField val ROLE = ObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class ViewType + @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 ViewType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PROJECTS = ViewType(JsonField.of("projects")) + + @JvmField val LOGS = ViewType(JsonField.of("logs")) + + @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + + @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + + @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + + @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + + @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + + @JvmField val DATASET = ViewType(JsonField.of("dataset")) + + @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) + } + + enum class Known { + PROJECTS, + LOGS, + EXPERIMENTS, + DATASETS, + PROMPTS, + PLAYGROUNDS, + EXPERIMENT, + DATASET, + } + + enum class Value { + PROJECTS, + LOGS, + EXPERIMENTS, + DATASETS, + PROMPTS, + PLAYGROUNDS, + EXPERIMENT, + DATASET, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequest.kt new file mode 100755 index 0000000..263bd97 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequest.kt @@ -0,0 +1,382 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CrossObjectInsertRequest.Builder::class) +@NoAutoDetect +class CrossObjectInsertRequest +private constructor( + private val experiment: JsonField, + private val dataset: JsonField, + private val projectLogs: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A mapping from experiment id to a set of log events and feedback items to insert */ + fun experiment(): Optional = + Optional.ofNullable(experiment.getNullable("experiment")) + + /** A mapping from dataset id to a set of log events and feedback items to insert */ + fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) + + /** A mapping from project id to a set of log events and feedback items to insert */ + fun projectLogs(): Optional = + Optional.ofNullable(projectLogs.getNullable("project_logs")) + + /** A mapping from experiment id to a set of log events and feedback items to insert */ + @JsonProperty("experiment") @ExcludeMissing fun _experiment() = experiment + + /** A mapping from dataset id to a set of log events and feedback items to insert */ + @JsonProperty("dataset") @ExcludeMissing fun _dataset() = dataset + + /** A mapping from project id to a set of log events and feedback items to insert */ + @JsonProperty("project_logs") @ExcludeMissing fun _projectLogs() = projectLogs + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CrossObjectInsertRequest = apply { + if (!validated) { + experiment().map { it.validate() } + dataset().map { it.validate() } + projectLogs().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CrossObjectInsertRequest && + this.experiment == other.experiment && + this.dataset == other.dataset && + this.projectLogs == other.projectLogs && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + experiment, + dataset, + projectLogs, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CrossObjectInsertRequest{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var experiment: JsonField = JsonMissing.of() + private var dataset: JsonField = JsonMissing.of() + private var projectLogs: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(crossObjectInsertRequest: CrossObjectInsertRequest) = apply { + this.experiment = crossObjectInsertRequest.experiment + this.dataset = crossObjectInsertRequest.dataset + this.projectLogs = crossObjectInsertRequest.projectLogs + additionalProperties(crossObjectInsertRequest.additionalProperties) + } + + /** A mapping from experiment id to a set of log events and feedback items to insert */ + fun experiment(experiment: Experiment) = experiment(JsonField.of(experiment)) + + /** A mapping from experiment id to a set of log events and feedback items to insert */ + @JsonProperty("experiment") + @ExcludeMissing + fun experiment(experiment: JsonField) = apply { this.experiment = experiment } + + /** A mapping from dataset id to a set of log events and feedback items to insert */ + fun dataset(dataset: Dataset) = dataset(JsonField.of(dataset)) + + /** A mapping from dataset id to a set of log events and feedback items to insert */ + @JsonProperty("dataset") + @ExcludeMissing + fun dataset(dataset: JsonField) = apply { this.dataset = dataset } + + /** A mapping from project id to a set of log events and feedback items to insert */ + fun projectLogs(projectLogs: ProjectLogs) = projectLogs(JsonField.of(projectLogs)) + + /** A mapping from project id to a set of log events and feedback items to insert */ + @JsonProperty("project_logs") + @ExcludeMissing + fun projectLogs(projectLogs: JsonField) = apply { + this.projectLogs = projectLogs + } + + 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(): CrossObjectInsertRequest = + CrossObjectInsertRequest( + experiment, + dataset, + projectLogs, + additionalProperties.toUnmodifiable(), + ) + } + + /** A mapping from dataset id to a set of log events and feedback items to insert */ + @JsonDeserialize(builder = Dataset.Builder::class) + @NoAutoDetect + class Dataset + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Dataset = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Dataset && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Dataset{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dataset: Dataset) = apply { + additionalProperties(dataset.additionalProperties) + } + + 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(): Dataset = Dataset(additionalProperties.toUnmodifiable()) + } + } + + /** A mapping from experiment id to a set of log events and feedback items to insert */ + @JsonDeserialize(builder = Experiment.Builder::class) + @NoAutoDetect + class Experiment + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Experiment = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Experiment && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Experiment{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(experiment: Experiment) = apply { + additionalProperties(experiment.additionalProperties) + } + + 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(): Experiment = Experiment(additionalProperties.toUnmodifiable()) + } + } + + /** A mapping from project id to a set of log events and feedback items to insert */ + @JsonDeserialize(builder = ProjectLogs.Builder::class) + @NoAutoDetect + class ProjectLogs + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectLogs = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectLogs && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "ProjectLogs{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectLogs: ProjectLogs) = apply { + additionalProperties(projectLogs.additionalProperties) + } + + 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(): ProjectLogs = ProjectLogs(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt new file mode 100755 index 0000000..9c3ace5 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -0,0 +1,382 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = CrossObjectInsertResponse.Builder::class) +@NoAutoDetect +class CrossObjectInsertResponse +private constructor( + private val experiment: JsonField, + private val dataset: JsonField, + private val projectLogs: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A mapping from experiment id to row ids for inserted `events` */ + fun experiment(): Optional = + Optional.ofNullable(experiment.getNullable("experiment")) + + /** A mapping from dataset id to row ids for inserted `events` */ + fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) + + /** A mapping from project id to row ids for inserted `events` */ + fun projectLogs(): Optional = + Optional.ofNullable(projectLogs.getNullable("project_logs")) + + /** A mapping from experiment id to row ids for inserted `events` */ + @JsonProperty("experiment") @ExcludeMissing fun _experiment() = experiment + + /** A mapping from dataset id to row ids for inserted `events` */ + @JsonProperty("dataset") @ExcludeMissing fun _dataset() = dataset + + /** A mapping from project id to row ids for inserted `events` */ + @JsonProperty("project_logs") @ExcludeMissing fun _projectLogs() = projectLogs + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CrossObjectInsertResponse = apply { + if (!validated) { + experiment().map { it.validate() } + dataset().map { it.validate() } + projectLogs().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CrossObjectInsertResponse && + this.experiment == other.experiment && + this.dataset == other.dataset && + this.projectLogs == other.projectLogs && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + experiment, + dataset, + projectLogs, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CrossObjectInsertResponse{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var experiment: JsonField = JsonMissing.of() + private var dataset: JsonField = JsonMissing.of() + private var projectLogs: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = apply { + this.experiment = crossObjectInsertResponse.experiment + this.dataset = crossObjectInsertResponse.dataset + this.projectLogs = crossObjectInsertResponse.projectLogs + additionalProperties(crossObjectInsertResponse.additionalProperties) + } + + /** A mapping from experiment id to row ids for inserted `events` */ + fun experiment(experiment: Experiment) = experiment(JsonField.of(experiment)) + + /** A mapping from experiment id to row ids for inserted `events` */ + @JsonProperty("experiment") + @ExcludeMissing + fun experiment(experiment: JsonField) = apply { this.experiment = experiment } + + /** A mapping from dataset id to row ids for inserted `events` */ + fun dataset(dataset: Dataset) = dataset(JsonField.of(dataset)) + + /** A mapping from dataset id to row ids for inserted `events` */ + @JsonProperty("dataset") + @ExcludeMissing + fun dataset(dataset: JsonField) = apply { this.dataset = dataset } + + /** A mapping from project id to row ids for inserted `events` */ + fun projectLogs(projectLogs: ProjectLogs) = projectLogs(JsonField.of(projectLogs)) + + /** A mapping from project id to row ids for inserted `events` */ + @JsonProperty("project_logs") + @ExcludeMissing + fun projectLogs(projectLogs: JsonField) = apply { + this.projectLogs = projectLogs + } + + 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(): CrossObjectInsertResponse = + CrossObjectInsertResponse( + experiment, + dataset, + projectLogs, + additionalProperties.toUnmodifiable(), + ) + } + + /** A mapping from dataset id to row ids for inserted `events` */ + @JsonDeserialize(builder = Dataset.Builder::class) + @NoAutoDetect + class Dataset + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Dataset = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Dataset && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Dataset{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dataset: Dataset) = apply { + additionalProperties(dataset.additionalProperties) + } + + 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(): Dataset = Dataset(additionalProperties.toUnmodifiable()) + } + } + + /** A mapping from experiment id to row ids for inserted `events` */ + @JsonDeserialize(builder = Experiment.Builder::class) + @NoAutoDetect + class Experiment + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Experiment = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Experiment && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Experiment{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(experiment: Experiment) = apply { + additionalProperties(experiment.additionalProperties) + } + + 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(): Experiment = Experiment(additionalProperties.toUnmodifiable()) + } + } + + /** A mapping from project id to row ids for inserted `events` */ + @JsonDeserialize(builder = ProjectLogs.Builder::class) + @NoAutoDetect + class ProjectLogs + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectLogs = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectLogs && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "ProjectLogs{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectLogs: ProjectLogs) = apply { + additionalProperties(projectLogs.additionalProperties) + } + + 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(): ProjectLogs = ProjectLogs(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt new file mode 100755 index 0000000..09ea860 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -0,0 +1,109 @@ +// 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 + +/** Summary of a dataset's data */ +@JsonDeserialize(builder = DataSummary.Builder::class) +@NoAutoDetect +class DataSummary +private constructor( + private val totalRecords: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Total number of records in the dataset */ + fun totalRecords(): Long = totalRecords.getRequired("total_records") + + /** Total number of records in the dataset */ + @JsonProperty("total_records") @ExcludeMissing fun _totalRecords() = totalRecords + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DataSummary = apply { + if (!validated) { + totalRecords() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataSummary && + this.totalRecords == other.totalRecords && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(totalRecords, additionalProperties) + } + return hashCode + } + + override fun toString() = + "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var totalRecords: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dataSummary: DataSummary) = apply { + this.totalRecords = dataSummary.totalRecords + additionalProperties(dataSummary.additionalProperties) + } + + /** Total number of records in the dataset */ + fun totalRecords(totalRecords: Long) = totalRecords(JsonField.of(totalRecords)) + + /** Total number of records in the dataset */ + @JsonProperty("total_records") + @ExcludeMissing + fun totalRecords(totalRecords: JsonField) = apply { this.totalRecords = totalRecords } + + 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(): DataSummary = DataSummary(totalRecords, additionalProperties.toUnmodifiable()) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt new file mode 100755 index 0000000..d10e3c0 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -0,0 +1,478 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = DatasetEvent.Builder::class) +@NoAutoDetect +class DatasetEvent +private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val datasetId: JsonField, + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val spanId: JsonField, + private val rootSpanId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + fun id(): String = id.getRequired("id") + + /** + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the dataset (see the `version` parameter) + */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** The timestamp the dataset event was created */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) + + /** Unique identifier for the dataset */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + fun expected(): JsonValue = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * A unique identifier used to link different dataset events together as part of a full trace. + * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on + * tracing + */ + fun spanId(): String = spanId.getRequired("span_id") + + /** The `span_id` of the root of the trace this dataset event belongs to */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the dataset (see the `version` parameter) + */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + + /** The timestamp the dataset event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Unique identifier for the project that the dataset belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Unique identifier for the dataset */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * A unique identifier used to link different dataset events together as part of a full trace. + * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on + * tracing + */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + + /** The `span_id` of the root of the trace this dataset event belongs to */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DatasetEvent = apply { + if (!validated) { + id() + _xactId() + created() + projectId() + datasetId() + input() + expected() + metadata().map { it.validate() } + tags() + spanId() + rootSpanId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetEvent && + this.id == other.id && + this._xactId == other._xactId && + this.created == other.created && + this.projectId == other.projectId && + this.datasetId == other.datasetId && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.spanId == other.spanId && + this.rootSpanId == other.rootSpanId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + _xactId, + created, + projectId, + datasetId, + input, + expected, + metadata, + tags, + spanId, + rootSpanId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var _xactId: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var datasetId: JsonField = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var spanId: JsonField = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetEvent: DatasetEvent) = apply { + this.id = datasetEvent.id + this._xactId = datasetEvent._xactId + this.created = datasetEvent.created + this.projectId = datasetEvent.projectId + this.datasetId = datasetEvent.datasetId + this.input = datasetEvent.input + this.expected = datasetEvent.expected + this.metadata = datasetEvent.metadata + this.tags = datasetEvent.tags + this.spanId = datasetEvent.spanId + this.rootSpanId = datasetEvent.rootSpanId + additionalProperties(datasetEvent.additionalProperties) + } + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the dataset (see the `version` parameter) + */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the dataset (see the `version` parameter) + */ + @JsonProperty("_xact_id") + @ExcludeMissing + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + /** The timestamp the dataset event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the dataset event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the dataset belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Unique identifier for the dataset */ + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** Unique identifier for the dataset */ + @JsonProperty("dataset_id") + @ExcludeMissing + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + @JsonProperty("span_id") + @ExcludeMissing + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** The `span_id` of the root of the trace this dataset event belongs to */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** The `span_id` of the root of the trace this dataset event belongs to */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + + 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(): DatasetEvent = + DatasetEvent( + id, + _xactId, + created, + projectId, + datasetId, + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + spanId, + rootSpanId, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index ace1923..c32d823 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -2,17 +2,13 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable -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.databind.annotation.JsonDeserialize import java.util.Objects @@ -20,7 +16,7 @@ import java.util.Objects class DatasetFeedbackParams constructor( private val datasetId: String, - private val feedback: List, + private val feedback: List, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -28,7 +24,7 @@ constructor( fun datasetId(): String = datasetId - fun feedback(): List = feedback + fun feedback(): List = feedback @JvmSynthetic internal fun getBody(): DatasetFeedbackBody { @@ -50,14 +46,14 @@ constructor( @NoAutoDetect class DatasetFeedbackBody internal constructor( - private val feedback: List?, + private val feedback: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of dataset feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + @JsonProperty("feedback") fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -92,7 +88,7 @@ constructor( class Builder { - private var feedback: List? = null + private var feedback: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -103,7 +99,7 @@ constructor( /** A list of dataset feedback items */ @JsonProperty("feedback") - fun feedback(feedback: List) = apply { this.feedback = feedback } + fun feedback(feedback: List) = apply { this.feedback = feedback } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -171,7 +167,7 @@ constructor( class Builder { private var datasetId: String? = null - private var feedback: MutableList = mutableListOf() + private var feedback: MutableList = mutableListOf() private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -189,13 +185,13 @@ constructor( fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset feedback items */ - fun feedback(feedback: List) = apply { + fun feedback(feedback: List) = apply { this.feedback.clear() this.feedback.addAll(feedback) } /** A list of dataset feedback items */ - fun addFeedback(feedback: Feedback) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackDatasetItem) = apply { this.feedback.add(feedback) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,269 +257,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(builder = Feedback.Builder::class) - @NoAutoDetect - class Feedback - private constructor( - private val id: String?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` - */ - @JsonProperty("id") fun id(): String? = id - - /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") fun comment(): String? = comment - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") fun source(): Source? = source - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Feedback{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var comment: String? = null - private var metadata: Metadata? = null - private var source: Source? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedback: Feedback) = apply { - this.id = feedback.id - this.comment = feedback.comment - this.metadata = feedback.metadata - this.source = feedback.source - additionalProperties(feedback.additionalProperties) - } - - /** - * The id of the dataset event to log feedback for. This is the row `id` returned by - * `POST /v1/dataset/{dataset_id}/insert` - */ - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") fun comment(comment: String) = apply { this.comment = comment } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you - * can log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") fun source(source: Source) = apply { this.source = source } - - 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(): Feedback = - Feedback( - checkNotNull(id) { "`id` is required but was not set" }, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - class Source - @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 Source && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val APP = Source(JsonField.of("app")) - - @JvmField val API = Source(JsonField.of("api")) - - @JvmField val EXTERNAL = Source(JsonField.of("external")) - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - APP, - API, - EXTERNAL, - } - - enum class Value { - APP, - API, - EXTERNAL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index a597f97..636cdc6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -2,17 +2,13 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable -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.databind.annotation.JsonDeserialize import java.util.Objects @@ -22,7 +18,7 @@ class DatasetFetchPostParams constructor( private val datasetId: String, private val cursor: String?, - private val filters: List?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -36,7 +32,7 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) + fun filters(): Optional> = Optional.ofNullable(filters) fun limit(): Optional = Optional.ofNullable(limit) @@ -75,7 +71,7 @@ constructor( class DatasetFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -98,7 +94,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - @JsonProperty("filters") fun filters(): List? = filters + @JsonProperty("filters") fun filters(): List? = filters /** * limit the number of traces fetched @@ -201,7 +197,7 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null + private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -233,7 +229,7 @@ constructor( * are supported, but we may add more in the future */ @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } + fun filters(filters: List) = apply { this.filters = filters } /** * limit the number of traces fetched @@ -372,7 +368,7 @@ constructor( private var datasetId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() + private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -411,7 +407,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - fun filters(filters: List) = apply { + fun filters(filters: List) = apply { this.filters.clear() this.filters.addAll(filters) } @@ -420,7 +416,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - fun addFilter(filter: Filter) = apply { this.filters.add(filter) } + fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } /** * limit the number of traces fetched @@ -543,186 +539,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - /** - * A path-lookup filter describes an equality comparison against a specific sub-field in the - * event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": - * {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` - */ - @JsonDeserialize(builder = Filter.Builder::class) - @NoAutoDetect - class Filter - private constructor( - private val type: Type?, - private val path: List?, - private val value: JsonValue?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") fun type(): Type? = type - - /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") fun path(): List? = path - - /** - * The value to compare equality-wise against the event value at the specified `path`. The - * value must be a "primitive", that is, any JSON-serializable object except for objects and - * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") fun value(): JsonValue? = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: Type? = null - private var path: List? = null - private var value: JsonValue? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filter: Filter) = apply { - this.type = filter.type - this.path = filter.path - this.value = filter.value - additionalProperties(filter.additionalProperties) - } - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") fun type(type: Type) = apply { this.type = type } - - /** - * List of fields describing the path to the value to be checked against. For instance, - * if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": - * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") fun path(path: List) = apply { this.path = path } - - /** - * The value to compare equality-wise against the event value at the specified `path`. - * The value must be a "primitive", that is, any JSON-serializable object except for - * objects and arrays. For instance, if you wish to filter on the value of "input.a.b.c" - * in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") fun value(value: JsonValue) = apply { this.value = value } - - 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(): Filter = - Filter( - checkNotNull(type) { "`type` is required but was not set" }, - checkNotNull(path) { "`path` is required but was not set" }.toUnmodifiable(), - value, - 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 PATH_LOOKUP = Type(JsonField.of("path_lookup")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - PATH_LOOKUP, - } - - enum class Value { - PATH_LOOKUP, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 64a774f..915b572 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -2,35 +2,21 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter 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.time.OffsetDateTime import java.util.Objects -import java.util.Optional class DatasetInsertParams constructor( private val datasetId: String, - private val events: List, + private val events: List, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -38,7 +24,7 @@ constructor( fun datasetId(): String = datasetId - fun events(): List = events + fun events(): List = events @JvmSynthetic internal fun getBody(): DatasetInsertBody { @@ -60,14 +46,14 @@ constructor( @NoAutoDetect class DatasetInsertBody internal constructor( - private val events: List?, + private val events: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of dataset events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -102,7 +88,7 @@ constructor( class Builder { - private var events: List? = null + private var events: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -112,7 +98,8 @@ constructor( } /** A list of dataset events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -180,7 +167,7 @@ constructor( class Builder { private var datasetId: String? = null - private var events: MutableList = mutableListOf() + private var events: MutableList = mutableListOf() private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -198,13 +185,13 @@ constructor( fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset events to insert */ - fun events(events: List) = apply { + fun events(events: List) = apply { this.events.clear() this.events.addAll(events) } /** A list of dataset events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: InsertDatasetEvent) = apply { this.events.add(event) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -269,1177 +256,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, - private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertDatasetEventReplace(): Optional = - Optional.ofNullable(insertDatasetEventReplace) - - fun insertDatasetEventMerge(): Optional = - Optional.ofNullable(insertDatasetEventMerge) - - fun isInsertDatasetEventReplace(): Boolean = insertDatasetEventReplace != null - - fun isInsertDatasetEventMerge(): Boolean = insertDatasetEventMerge != null - - fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = - insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") - - fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = - insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - insertDatasetEventReplace != null -> - visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) - insertDatasetEventMerge != null -> - visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertDatasetEventReplace?.validate() - insertDatasetEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.insertDatasetEventReplace == other.insertDatasetEventReplace && - this.insertDatasetEventMerge == other.insertDatasetEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) - } - - override fun toString(): String { - return when { - insertDatasetEventReplace != null -> - "Event{insertDatasetEventReplace=$insertDatasetEventReplace}" - insertDatasetEventMerge != null -> - "Event{insertDatasetEventMerge=$insertDatasetEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - @JvmStatic - fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = - Event(insertDatasetEventReplace = insertDatasetEventReplace) - - @JvmStatic - fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = - Event(insertDatasetEventMerge = insertDatasetEventMerge) - } - - interface Visitor { - - fun visitInsertDatasetEventReplace( - insertDatasetEventReplace: InsertDatasetEventReplace - ): T - - fun visitInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertDatasetEventReplace != null -> - generator.writeObject(value.insertDatasetEventReplace) - value.insertDatasetEventMerge != null -> - generator.writeObject(value.insertDatasetEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - - @JsonDeserialize(builder = InsertDatasetEventReplace.Builder::class) - @NoAutoDetect - class InsertDatasetEventReplace - private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - fun expected(): JsonValue = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** The timestamp the dataset event was created */ - fun created(): Optional = - Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Optional = - Optional.ofNullable(_isMerge.getNullable("_is_merge")) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships - * are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": - * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, - * only the root span row `"abc"` will show up in the summary view. You can view the - * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" - * row. - */ - fun _parentId(): Optional = - Optional.ofNullable(_parentId.getNullable("_parent_id")) - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships - * are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": - * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, - * only the root span row `"abc"` will show up in the summary view. You can view the - * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" - * row. - */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertDatasetEventReplace = apply { - if (!validated) { - input() - expected() - metadata().map { it.validate() } - tags() - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventReplace && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertDatasetEventReplace: InsertDatasetEventReplace) = apply { - this.input = insertDatasetEventReplace.input - this.expected = insertDatasetEventReplace.expected - this.metadata = insertDatasetEventReplace.metadata - this.tags = insertDatasetEventReplace.tags - this.id = insertDatasetEventReplace.id - this.created = insertDatasetEventReplace.created - this._objectDelete = insertDatasetEventReplace._objectDelete - this._isMerge = insertDatasetEventReplace._isMerge - this._parentId = insertDatasetEventReplace._parentId - additionalProperties(insertDatasetEventReplace.additionalProperties) - } - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the dataset event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will - * not show up in subsequent fetches for this dataset - */ - fun _objectDelete(_objectDelete: Boolean) = - _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will - * not show up in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": - * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a - * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": - * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in - * the summary view. You can view the full trace hierarchy (in this case, the - * `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": - * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a - * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": - * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in - * the summary view. You can view the full trace hierarchy (in this case, the - * `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } - - 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(): InsertDatasetEventReplace = - InsertDatasetEventReplace( - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - } - - @JsonDeserialize(builder = InsertDatasetEventMerge.Builder::class) - @NoAutoDetect - class InsertDatasetEventMerge - private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - fun expected(): JsonValue = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** The timestamp the dataset event was created */ - fun created(): Optional = - Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each - * path is a list of field names. The deep merge will not descend below any of the - * specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, - * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced - * `input.a` and `output`, but have still deep-merged `input` and `input.c`. - */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each - * path is a list of field names. The deep merge will not descend below any of the - * specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, - * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced - * `input.a` and `output`, but have still deep-merged `input` and `input.c`. - */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertDatasetEventMerge = apply { - if (!validated) { - input() - expected() - metadata().map { it.validate() } - tags() - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventMerge && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _mergePaths: JsonField>> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertDatasetEventMerge: InsertDatasetEventMerge) = apply { - this.input = insertDatasetEventMerge.input - this.expected = insertDatasetEventMerge.expected - this.metadata = insertDatasetEventMerge.metadata - this.tags = insertDatasetEventMerge.tags - this.id = insertDatasetEventMerge.id - this.created = insertDatasetEventMerge.created - this._objectDelete = insertDatasetEventMerge._objectDelete - this._isMerge = insertDatasetEventMerge._isMerge - this._mergePaths = insertDatasetEventMerge._mergePaths - additionalProperties(insertDatasetEventMerge.additionalProperties) - } - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the dataset event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will - * not show up in subsequent fetches for this dataset - */ - fun _objectDelete(_objectDelete: Boolean) = - _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will - * not show up in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where - * each path is a list of field names. The deep merge will not descend below any of - * the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will - * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": - * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have - * replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - fun _mergePaths(_mergePaths: List>) = - _mergePaths(JsonField.of(_mergePaths)) - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where - * each path is a list of field names. The deep merge will not descend below any of - * the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will - * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": - * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have - * replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths - } - - 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(): InsertDatasetEventMerge = - InsertDatasetEventMerge( - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 1aca4a3..46fdb2f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -27,6 +16,7 @@ constructor( private val ids: Ids?, private val limit: Long?, private val orgName: String?, + private val projectId: String?, private val projectName: String?, private val startingAfter: String?, private val additionalQueryParams: Map>, @@ -44,6 +34,8 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun projectId(): Optional = Optional.ofNullable(projectId) + fun projectName(): Optional = Optional.ofNullable(projectName) fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -56,6 +48,7 @@ constructor( this.ids?.let { params.put("ids", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectId?.let { params.put("project_id", listOf(it.toString())) } this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) @@ -81,6 +74,7 @@ constructor( this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && + this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && @@ -95,6 +89,7 @@ constructor( ids, limit, orgName, + projectId, projectName, startingAfter, additionalQueryParams, @@ -104,7 +99,7 @@ constructor( } override fun toString() = - "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -121,6 +116,7 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null + private var projectId: String? = null private var projectName: String? = null private var startingAfter: String? = null private var additionalQueryParams: MutableMap> = mutableMapOf() @@ -134,6 +130,7 @@ constructor( this.ids = datasetListParams.ids this.limit = datasetListParams.limit this.orgName = datasetListParams.orgName + this.projectId = datasetListParams.projectId this.projectName = datasetListParams.projectName this.startingAfter = datasetListParams.startingAfter additionalQueryParams(datasetListParams.additionalQueryParams) @@ -177,6 +174,9 @@ constructor( /** Filter search results to within a particular organization */ fun orgName(orgName: String) = apply { this.orgName = orgName } + /** Project id */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + /** Name of the project to search for */ fun projectName(projectName: String) = apply { this.projectName = projectName } @@ -250,6 +250,7 @@ constructor( ids, limit, orgName, + projectId, projectName, startingAfter, additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), @@ -257,117 +258,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DeleteView.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DeleteView.kt new file mode 100755 index 0000000..9b4bf1a --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DeleteView.kt @@ -0,0 +1,253 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = DeleteView.Builder::class) +@NoAutoDetect +class DeleteView +private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The object type that the ACL applies to */ + fun objectType(): Optional = + Optional.ofNullable(objectType.getNullable("object_type")) + + /** The id of the object the view applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + + /** The id of the object the view applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DeleteView = apply { + if (!validated) { + objectType() + objectId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeleteView && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + objectType, + objectId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DeleteView{objectType=$objectType, objectId=$objectId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objectType: JsonField = JsonMissing.of() + private var objectId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deleteView: DeleteView) = apply { + this.objectType = deleteView.objectType + this.objectId = deleteView.objectId + additionalProperties(deleteView.additionalProperties) + } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + /** The id of the object the view applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the view applies to */ + @JsonProperty("object_id") + @ExcludeMissing + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + 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(): DeleteView = + DeleteView( + objectType, + objectId, + additionalProperties.toUnmodifiable(), + ) + } + + class ObjectType + @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 ObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = ObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = ObjectType(JsonField.of("group")) + + @JvmField val ROLE = ObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt new file mode 100755 index 0000000..ec5c09a --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -0,0 +1,1480 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = ExperimentEvent.Builder::class) +@NoAutoDetect +class ExperimentEvent +private constructor( + private val id: JsonField, + private val datasetRecordId: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val experimentId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(): String = id.getRequired("id") + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + + /** + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the experiment (see the `version` parameter) + */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** The timestamp the experiment event was created */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Unique identifier for the experiment */ + fun experimentId(): String = experimentId.getRequired("experiment_id") + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical + */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question + */ + fun output(): JsonValue = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models + */ + fun expected(): JsonValue = expected + + /** The error that occurred, if any. */ + fun error(): JsonValue = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + fun spanId(): String = spanId.getRequired("span_id") + + /** + * An array of the parent `span_ids` of this experiment event. This should be empty for the root + * span of a trace, and should most often contain just one parent element for subspans + */ + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) + + /** The `span_id` of the root of the trace this experiment event belongs to */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId + + /** + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the experiment (see the `version` parameter) + */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + + /** The timestamp the experiment event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Unique identifier for the project that the experiment belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Unique identifier for the experiment */ + @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId() = experimentId + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical + */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question + */ + @JsonProperty("output") @ExcludeMissing fun _output() = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error() = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + @JsonProperty("context") @ExcludeMissing fun _context() = context + + /** + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + + /** + * An array of the parent `span_ids` of this experiment event. This should be empty for the root + * span of a trace, and should most often contain just one parent element for subspans + */ + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + + /** The `span_id` of the root of the trace this experiment event belongs to */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ExperimentEvent = apply { + if (!validated) { + id() + datasetRecordId() + _xactId() + created() + projectId() + experimentId() + input() + output() + expected() + error() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanId() + spanParents() + rootSpanId() + spanAttributes().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentEvent && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this._xactId == other._xactId && + this.created == other.created && + this.projectId == other.projectId && + this.experimentId == other.experimentId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var datasetRecordId: JsonField = JsonMissing.of() + private var _xactId: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var experimentId: JsonField = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var error: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var metrics: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var spanId: JsonField = JsonMissing.of() + private var spanParents: JsonField> = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(experimentEvent: ExperimentEvent) = apply { + this.id = experimentEvent.id + this.datasetRecordId = experimentEvent.datasetRecordId + this._xactId = experimentEvent._xactId + this.created = experimentEvent.created + this.projectId = experimentEvent.projectId + this.experimentId = experimentEvent.experimentId + this.input = experimentEvent.input + this.output = experimentEvent.output + this.expected = experimentEvent.expected + this.error = experimentEvent.error + this.scores = experimentEvent.scores + this.metadata = experimentEvent.metadata + this.tags = experimentEvent.tags + this.metrics = experimentEvent.metrics + this.context = experimentEvent.context + this.spanId = experimentEvent.spanId + this.spanParents = experimentEvent.spanParents + this.rootSpanId = experimentEvent.rootSpanId + this.spanAttributes = experimentEvent.spanAttributes + additionalProperties(experimentEvent.additionalProperties) + } + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: String) = + datasetRecordId(JsonField.of(datasetRecordId)) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun datasetRecordId(datasetRecordId: JsonField) = apply { + this.datasetRecordId = datasetRecordId + } + + /** + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + */ + @JsonProperty("_xact_id") + @ExcludeMissing + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + /** The timestamp the experiment event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the experiment event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the experiment belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Unique identifier for the experiment */ + fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) + + /** Unique identifier for the experiment */ + @JsonProperty("experiment_id") + @ExcludeMissing + fun experimentId(experimentId: JsonField) = apply { + this.experimentId = experimentId + } + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question + */ + @JsonProperty("output") + @ExcludeMissing + fun output(output: JsonValue) = apply { this.output = output } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** The error that occurred, if any. */ + @JsonProperty("error") + @ExcludeMissing + fun error(error: JsonValue) = apply { this.error = error } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonProperty("metrics") + @ExcludeMissing + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + fun context(context: Context) = context(JsonField.of(context)) + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + @JsonProperty("context") + @ExcludeMissing + fun context(context: JsonField) = apply { this.context = context } + + /** + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + @JsonProperty("span_id") + @ExcludeMissing + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans + */ + fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + + /** + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans + */ + @JsonProperty("span_parents") + @ExcludeMissing + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents + } + + /** The `span_id` of the root of the trace this experiment event belongs to */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** The `span_id` of the root of the trace this experiment event belongs to */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } + + 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(): ExperimentEvent = + ExperimentEvent( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + @JsonDeserialize(builder = Context.Builder::class) + @NoAutoDetect + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The function in code which created the experiment event */ + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) + + /** Line of code where the experiment event was created */ + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + + /** The function in code which created the experiment event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** Line of code where the experiment event was created */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Context = apply { + if (!validated) { + callerFunctionname() + callerFilename() + callerLineno() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var callerFunctionname: JsonField = JsonMissing.of() + private var callerFilename: JsonField = JsonMissing.of() + private var callerLineno: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(context: Context) = apply { + this.callerFunctionname = context.callerFunctionname + this.callerFilename = context.callerFilename + this.callerLineno = context.callerLineno + additionalProperties(context.additionalProperties) + } + + /** The function in code which created the experiment event */ + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) + + /** The function in code which created the experiment event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) + + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** Line of code where the experiment event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + + /** Line of code where the experiment event was created */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } + + 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(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonDeserialize(builder = Metrics.Builder::class) + @NoAutoDetect + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * finished + */ + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start() = start + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end() = end + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens() = completionTokens + + /** The total number of tokens in the input and output of the experiment event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metrics = apply { + if (!validated) { + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var start: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var tokens: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metrics: Metrics) = apply { + this.start = metrics.start + this.end = metrics.end + this.promptTokens = metrics.promptTokens + this.completionTokens = metrics.completionTokens + this.tokens = metrics.tokens + additionalProperties(metrics.additionalProperties) + } + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + fun start(start: Double) = start(JsonField.of(start)) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + @JsonProperty("start") + @ExcludeMissing + fun start(start: JsonField) = apply { this.start = start } + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event finished + */ + fun end(end: Double) = end(JsonField.of(end)) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event finished + */ + @JsonProperty("end") + @ExcludeMissing + fun end(end: JsonField) = apply { this.end = end } + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + + /** The total number of tokens in the input and output of the experiment event. */ + @JsonProperty("tokens") + @ExcludeMissing + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + + 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(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonDeserialize(builder = SpanAttributes.Builder::class) + @NoAutoDetect + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the span, for display purposes only */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of the span, for display purposes only */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Type of the span, for display purposes only */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanAttributes = apply { + if (!validated) { + name() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanAttributes: SpanAttributes) = apply { + this.name = spanAttributes.name + this.type = spanAttributes.type + additionalProperties(spanAttributes.additionalProperties) + } + + /** Name of the span, for display purposes only */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the span, for display purposes only */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of the span, for display purposes only */ + @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(): SpanAttributes = + SpanAttributes( + name, + 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 LLM = Type(JsonField.of("llm")) + + @JvmField val SCORE = Type(JsonField.of("score")) + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmField val EVAL = Type(JsonField.of("eval")) + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmField val TOOL = Type(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + enum class Value { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index b160982..02de4d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -2,17 +2,13 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable -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.databind.annotation.JsonDeserialize import java.util.Objects @@ -20,7 +16,7 @@ import java.util.Objects class ExperimentFeedbackParams constructor( private val experimentId: String, - private val feedback: List, + private val feedback: List, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -28,7 +24,7 @@ constructor( fun experimentId(): String = experimentId - fun feedback(): List = feedback + fun feedback(): List = feedback @JvmSynthetic internal fun getBody(): ExperimentFeedbackBody { @@ -50,14 +46,14 @@ constructor( @NoAutoDetect class ExperimentFeedbackBody internal constructor( - private val feedback: List?, + private val feedback: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of experiment feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + @JsonProperty("feedback") fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -92,7 +88,7 @@ constructor( class Builder { - private var feedback: List? = null + private var feedback: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -103,7 +99,9 @@ constructor( /** A list of experiment feedback items */ @JsonProperty("feedback") - fun feedback(feedback: List) = apply { this.feedback = feedback } + fun feedback(feedback: List) = apply { + this.feedback = feedback + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -171,7 +169,7 @@ constructor( class Builder { private var experimentId: String? = null - private var feedback: MutableList = mutableListOf() + private var feedback: MutableList = mutableListOf() private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -189,13 +187,13 @@ constructor( fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment feedback items */ - fun feedback(feedback: List) = apply { + fun feedback(feedback: List) = apply { this.feedback.clear() this.feedback.addAll(feedback) } /** A list of experiment feedback items */ - fun addFeedback(feedback: Feedback) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackExperimentItem) = apply { this.feedback.add(feedback) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,375 +259,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(builder = Feedback.Builder::class) - @NoAutoDetect - class Feedback - private constructor( - private val id: String?, - private val scores: Scores?, - private val expected: JsonValue?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` - */ - @JsonProperty("id") fun id(): String? = id - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event - */ - @JsonProperty("scores") fun scores(): Scores? = scores - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not - */ - @JsonProperty("expected") fun expected(): JsonValue? = expected - - /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") fun comment(): String? = comment - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") fun source(): Source? = source - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Feedback{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var scores: Scores? = null - private var expected: JsonValue? = null - private var comment: String? = null - private var metadata: Metadata? = null - private var source: Source? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedback: Feedback) = apply { - this.id = feedback.id - this.scores = feedback.scores - this.expected = feedback.expected - this.comment = feedback.comment - this.metadata = feedback.metadata - this.source = feedback.source - additionalProperties(feedback.additionalProperties) - } - - /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` - */ - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged - * into the existing scores for the experiment event - */ - @JsonProperty("scores") fun scores(scores: Scores) = apply { this.scores = scores } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not - */ - @JsonProperty("expected") - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") fun comment(comment: String) = apply { this.comment = comment } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you - * can log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") fun source(source: Source) = apply { this.source = source } - - 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(): Feedback = - Feedback( - checkNotNull(id) { "`id` is required but was not set" }, - scores, - expected, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - 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(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - class Source - @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 Source && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val APP = Source(JsonField.of("app")) - - @JvmField val API = Source(JsonField.of("api")) - - @JvmField val EXTERNAL = Source(JsonField.of("external")) - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - APP, - API, - EXTERNAL, - } - - enum class Value { - APP, - API, - EXTERNAL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index b8c52f0..3541954 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -2,17 +2,13 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable -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.databind.annotation.JsonDeserialize import java.util.Objects @@ -22,7 +18,7 @@ class ExperimentFetchPostParams constructor( private val experimentId: String, private val cursor: String?, - private val filters: List?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -36,7 +32,7 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) + fun filters(): Optional> = Optional.ofNullable(filters) fun limit(): Optional = Optional.ofNullable(limit) @@ -75,7 +71,7 @@ constructor( class ExperimentFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -98,7 +94,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - @JsonProperty("filters") fun filters(): List? = filters + @JsonProperty("filters") fun filters(): List? = filters /** * limit the number of traces fetched @@ -201,7 +197,7 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null + private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -233,7 +229,7 @@ constructor( * are supported, but we may add more in the future */ @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } + fun filters(filters: List) = apply { this.filters = filters } /** * limit the number of traces fetched @@ -372,7 +368,7 @@ constructor( private var experimentId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() + private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -411,7 +407,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - fun filters(filters: List) = apply { + fun filters(filters: List) = apply { this.filters.clear() this.filters.addAll(filters) } @@ -420,7 +416,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - fun addFilter(filter: Filter) = apply { this.filters.add(filter) } + fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } /** * limit the number of traces fetched @@ -543,186 +539,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - /** - * A path-lookup filter describes an equality comparison against a specific sub-field in the - * event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": - * {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` - */ - @JsonDeserialize(builder = Filter.Builder::class) - @NoAutoDetect - class Filter - private constructor( - private val type: Type?, - private val path: List?, - private val value: JsonValue?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") fun type(): Type? = type - - /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") fun path(): List? = path - - /** - * The value to compare equality-wise against the event value at the specified `path`. The - * value must be a "primitive", that is, any JSON-serializable object except for objects and - * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") fun value(): JsonValue? = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: Type? = null - private var path: List? = null - private var value: JsonValue? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filter: Filter) = apply { - this.type = filter.type - this.path = filter.path - this.value = filter.value - additionalProperties(filter.additionalProperties) - } - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") fun type(type: Type) = apply { this.type = type } - - /** - * List of fields describing the path to the value to be checked against. For instance, - * if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": - * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") fun path(path: List) = apply { this.path = path } - - /** - * The value to compare equality-wise against the event value at the specified `path`. - * The value must be a "primitive", that is, any JSON-serializable object except for - * objects and arrays. For instance, if you wish to filter on the value of "input.a.b.c" - * in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") fun value(value: JsonValue) = apply { this.value = value } - - 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(): Filter = - Filter( - checkNotNull(type) { "`type` is required but was not set" }, - checkNotNull(path) { "`path` is required but was not set" }.toUnmodifiable(), - value, - 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 PATH_LOOKUP = Type(JsonField.of("path_lookup")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - PATH_LOOKUP, - } - - enum class Value { - PATH_LOOKUP, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 36e22df..a4ca27b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -2,37 +2,21 @@ 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.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 -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.time.OffsetDateTime import java.util.Objects -import java.util.Optional class ExperimentInsertParams constructor( private val experimentId: String, - private val events: List, + private val events: List, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -40,7 +24,7 @@ constructor( fun experimentId(): String = experimentId - fun events(): List = events + fun events(): List = events @JvmSynthetic internal fun getBody(): ExperimentInsertBody { @@ -62,14 +46,14 @@ constructor( @NoAutoDetect class ExperimentInsertBody internal constructor( - private val events: List?, + private val events: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of experiment events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -104,7 +88,7 @@ constructor( class Builder { - private var events: List? = null + private var events: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -114,7 +98,8 @@ constructor( } /** A list of experiment events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -182,7 +167,7 @@ constructor( class Builder { private var experimentId: String? = null - private var events: MutableList = mutableListOf() + private var events: MutableList = mutableListOf() private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -200,13 +185,13 @@ constructor( fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment events to insert */ - fun events(events: List) = apply { + fun events(events: List) = apply { this.events.clear() this.events.addAll(events) } /** A list of experiment events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: InsertExperimentEvent) = apply { this.events.add(event) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -271,3100 +256,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, - private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertExperimentEventReplace(): Optional = - Optional.ofNullable(insertExperimentEventReplace) - - fun insertExperimentEventMerge(): Optional = - Optional.ofNullable(insertExperimentEventMerge) - - fun isInsertExperimentEventReplace(): Boolean = insertExperimentEventReplace != null - - fun isInsertExperimentEventMerge(): Boolean = insertExperimentEventMerge != null - - fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = - insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") - - fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = - insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - insertExperimentEventReplace != null -> - visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) - insertExperimentEventMerge != null -> - visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertExperimentEventReplace?.validate() - insertExperimentEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.insertExperimentEventReplace == other.insertExperimentEventReplace && - this.insertExperimentEventMerge == other.insertExperimentEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) - } - - override fun toString(): String { - return when { - insertExperimentEventReplace != null -> - "Event{insertExperimentEventReplace=$insertExperimentEventReplace}" - insertExperimentEventMerge != null -> - "Event{insertExperimentEventMerge=$insertExperimentEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - @JvmStatic - fun ofInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ) = Event(insertExperimentEventReplace = insertExperimentEventReplace) - - @JvmStatic - fun ofInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ) = Event(insertExperimentEventMerge = insertExperimentEventMerge) - } - - interface Visitor { - - fun visitInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ): T - - fun visitInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertExperimentEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertExperimentEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertExperimentEventReplace != null -> - generator.writeObject(value.insertExperimentEventReplace) - value.insertExperimentEventMerge != null -> - generator.writeObject(value.insertExperimentEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - - @JsonDeserialize(builder = InsertExperimentEventReplace.Builder::class) - @NoAutoDetect - class InsertExperimentEventReplace - private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases are - * the same between experiments, so they should not contain experiment-specific state. A - * simple rule of thumb is that if you run the same experiment twice, the `input` should - * be identical - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * your experiments while digging into analyses. However, we may later use these values - * to re-score outputs or fine-tune your models - */ - fun expected(): JsonValue = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) - - /** The timestamp the experiment event was created */ - fun created(): Optional = - Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will - * not show up in subsequent fetches for this experiment - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Optional = - Optional.ofNullable(_isMerge.getNullable("_is_merge")) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships - * are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": - * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, - * only the root span row `"abc"` will show up in the summary view. You can view the - * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" - * row. - */ - fun _parentId(): Optional = - Optional.ofNullable(_parentId.getNullable("_parent_id")) - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases are - * the same between experiments, so they should not contain experiment-specific state. A - * simple rule of thumb is that if you run the same experiment twice, the `input` should - * be identical - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * your experiments while digging into analyses. However, we may later use these values - * to re-score outputs or fine-tune your models - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun _datasetRecordId() = datasetRecordId - - /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will - * not show up in subsequent fetches for this experiment - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships - * are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": - * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, - * only the root span row `"abc"` will show up in the summary view. You can view the - * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" - * row. - */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertExperimentEventReplace = apply { - if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertExperimentEventReplace: InsertExperimentEventReplace) = - apply { - this.input = insertExperimentEventReplace.input - this.output = insertExperimentEventReplace.output - this.expected = insertExperimentEventReplace.expected - this.scores = insertExperimentEventReplace.scores - this.metadata = insertExperimentEventReplace.metadata - this.tags = insertExperimentEventReplace.tags - this.metrics = insertExperimentEventReplace.metrics - this.context = insertExperimentEventReplace.context - this.spanAttributes = insertExperimentEventReplace.spanAttributes - this.id = insertExperimentEventReplace.id - this.datasetRecordId = insertExperimentEventReplace.datasetRecordId - this.created = insertExperimentEventReplace.created - this._objectDelete = insertExperimentEventReplace._objectDelete - this._isMerge = insertExperimentEventReplace._isMerge - this._parentId = insertExperimentEventReplace._parentId - additionalProperties(insertExperimentEventReplace.additionalProperties) - } - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases - * are the same between experiments, so they should not contain experiment-specific - * state. A simple rule of thumb is that if you run the same experiment twice, the - * `input` should be identical - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should be - * the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since there - * are so many different ways to do that correctly. Instead, these values are just - * used to help you navigate your experiments while digging into analyses. However, - * we may later use these values to re-score outputs or fine-tune your models - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare experiments - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare experiments - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the experiment event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the experiment event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - - /** The timestamp the experiment event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment - */ - fun _objectDelete(_objectDelete: Boolean) = - _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": - * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a - * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": - * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in - * the summary view. You can view the full trace hierarchy (in this case, the - * `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": - * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a - * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": - * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in - * the summary view. You can view the full trace hierarchy (in this case, the - * `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } - - 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(): InsertExperimentEventReplace = - InsertExperimentEventReplace( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - - /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - 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(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the experiment event - * (only set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the experiment event - * (only set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** - * The total number of tokens in the input and output of the experiment event. - */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** - * The total number of tokens in the input and output of the experiment event. - */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - 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(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - 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(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @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(): SpanAttributes = - SpanAttributes( - name, - 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 LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - @JsonDeserialize(builder = InsertExperimentEventMerge.Builder::class) - @NoAutoDetect - class InsertExperimentEventMerge - private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases are - * the same between experiments, so they should not contain experiment-specific state. A - * simple rule of thumb is that if you run the same experiment twice, the `input` should - * be identical - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * your experiments while digging into analyses. However, we may later use these values - * to re-score outputs or fine-tune your models - */ - fun expected(): JsonValue = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) - - /** The timestamp the experiment event was created */ - fun created(): Optional = - Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will - * not show up in subsequent fetches for this experiment - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each - * path is a list of field names. The deep merge will not descend below any of the - * specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, - * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced - * `input.a` and `output`, but have still deep-merged `input` and `input.c`. - */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases are - * the same between experiments, so they should not contain experiment-specific state. A - * simple rule of thumb is that if you run the same experiment twice, the `input` should - * be identical - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * your experiments while digging into analyses. However, we may later use these values - * to re-score outputs or fine-tune your models - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun _datasetRecordId() = datasetRecordId - - /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will - * not show up in subsequent fetches for this experiment - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each - * path is a list of field names. The deep merge will not descend below any of the - * specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, - * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced - * `input.a` and `output`, but have still deep-merged `input` and `input.c`. - */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertExperimentEventMerge = apply { - if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _mergePaths: JsonField>> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertExperimentEventMerge: InsertExperimentEventMerge) = apply { - this.input = insertExperimentEventMerge.input - this.output = insertExperimentEventMerge.output - this.expected = insertExperimentEventMerge.expected - this.scores = insertExperimentEventMerge.scores - this.metadata = insertExperimentEventMerge.metadata - this.tags = insertExperimentEventMerge.tags - this.metrics = insertExperimentEventMerge.metrics - this.context = insertExperimentEventMerge.context - this.spanAttributes = insertExperimentEventMerge.spanAttributes - this.id = insertExperimentEventMerge.id - this.datasetRecordId = insertExperimentEventMerge.datasetRecordId - this.created = insertExperimentEventMerge.created - this._objectDelete = insertExperimentEventMerge._objectDelete - this._isMerge = insertExperimentEventMerge._isMerge - this._mergePaths = insertExperimentEventMerge._mergePaths - additionalProperties(insertExperimentEventMerge.additionalProperties) - } - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases - * are the same between experiments, so they should not contain experiment-specific - * state. A simple rule of thumb is that if you run the same experiment twice, the - * `input` should be identical - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should be - * the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since there - * are so many different ways to do that correctly. Instead, these values are just - * used to help you navigate your experiments while digging into analyses. However, - * we may later use these values to re-score outputs or fine-tune your models - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare experiments - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare experiments - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the experiment event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the experiment event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - - /** The timestamp the experiment event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment - */ - fun _objectDelete(_objectDelete: Boolean) = - _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where - * each path is a list of field names. The deep merge will not descend below any of - * the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will - * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": - * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have - * replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - fun _mergePaths(_mergePaths: List>) = - _mergePaths(JsonField.of(_mergePaths)) - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where - * each path is a list of field names. The deep merge will not descend below any of - * the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will - * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": - * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have - * replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths - } - - 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(): InsertExperimentEventMerge = - InsertExperimentEventMerge( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - - /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - 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(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the experiment event - * (only set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the experiment event - * (only set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** - * The total number of tokens in the input and output of the experiment event. - */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** - * The total number of tokens in the input and output of the experiment event. - */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - 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(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - 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(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @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(): SpanAttributes = - SpanAttributes( - name, - 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 LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 5a310e4..168194a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -27,6 +16,7 @@ constructor( private val ids: Ids?, private val limit: Long?, private val orgName: String?, + private val projectId: String?, private val projectName: String?, private val startingAfter: String?, private val additionalQueryParams: Map>, @@ -44,6 +34,8 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun projectId(): Optional = Optional.ofNullable(projectId) + fun projectName(): Optional = Optional.ofNullable(projectName) fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -56,6 +48,7 @@ constructor( this.ids?.let { params.put("ids", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectId?.let { params.put("project_id", listOf(it.toString())) } this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) @@ -81,6 +74,7 @@ constructor( this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && + this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && @@ -95,6 +89,7 @@ constructor( ids, limit, orgName, + projectId, projectName, startingAfter, additionalQueryParams, @@ -104,7 +99,7 @@ constructor( } override fun toString() = - "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -121,6 +116,7 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null + private var projectId: String? = null private var projectName: String? = null private var startingAfter: String? = null private var additionalQueryParams: MutableMap> = mutableMapOf() @@ -134,6 +130,7 @@ constructor( this.ids = experimentListParams.ids this.limit = experimentListParams.limit this.orgName = experimentListParams.orgName + this.projectId = experimentListParams.projectId this.projectName = experimentListParams.projectName this.startingAfter = experimentListParams.startingAfter additionalQueryParams(experimentListParams.additionalQueryParams) @@ -177,6 +174,9 @@ constructor( /** Filter search results to within a particular organization */ fun orgName(orgName: String) = apply { this.orgName = orgName } + /** Project id */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + /** Name of the project to search for */ fun projectName(projectName: String) = apply { this.projectName = projectName } @@ -250,6 +250,7 @@ constructor( ids, limit, orgName, + projectId, projectName, startingAfter, additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), @@ -257,117 +258,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequest.kt new file mode 100755 index 0000000..5583cd8 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequest.kt @@ -0,0 +1,114 @@ +// 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 = FeedbackDatasetEventRequest.Builder::class) +@NoAutoDetect +class FeedbackDatasetEventRequest +private constructor( + private val feedback: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of dataset feedback items */ + fun feedback(): List = feedback.getRequired("feedback") + + /** A list of dataset feedback items */ + @JsonProperty("feedback") @ExcludeMissing fun _feedback() = feedback + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FeedbackDatasetEventRequest = apply { + if (!validated) { + feedback().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackDatasetEventRequest && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode + } + + override fun toString() = + "FeedbackDatasetEventRequest{feedback=$feedback, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var feedback: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackDatasetEventRequest: FeedbackDatasetEventRequest) = apply { + this.feedback = feedbackDatasetEventRequest.feedback + additionalProperties(feedbackDatasetEventRequest.additionalProperties) + } + + /** A list of dataset feedback items */ + fun feedback(feedback: List) = feedback(JsonField.of(feedback)) + + /** A list of dataset feedback items */ + @JsonProperty("feedback") + @ExcludeMissing + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback + } + + 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(): FeedbackDatasetEventRequest = + FeedbackDatasetEventRequest( + feedback.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt new file mode 100755 index 0000000..7e931a6 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -0,0 +1,344 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = FeedbackDatasetItem.Builder::class) +@NoAutoDetect +class FeedbackDatasetItem +private constructor( + private val id: JsonField, + private val comment: JsonField, + private val metadata: JsonField, + private val source: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` + */ + fun id(): String = id.getRequired("id") + + /** An optional comment string to log about the dataset event */ + fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + + /** + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** An optional comment string to log about the dataset event */ + @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + @JsonProperty("source") @ExcludeMissing fun _source() = source + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FeedbackDatasetItem = apply { + if (!validated) { + id() + comment() + metadata().map { it.validate() } + source() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackDatasetItem && + this.id == other.id && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var comment: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = apply { + this.id = feedbackDatasetItem.id + this.comment = feedbackDatasetItem.comment + this.metadata = feedbackDatasetItem.metadata + this.source = feedbackDatasetItem.source + additionalProperties(feedbackDatasetItem.additionalProperties) + } + + /** + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** An optional comment string to log about the dataset event */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** An optional comment string to log about the dataset event */ + @JsonProperty("comment") + @ExcludeMissing + fun comment(comment: JsonField) = apply { this.comment = comment } + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(source: Source) = source(JsonField.of(source)) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + @JsonProperty("source") + @ExcludeMissing + fun source(source: JsonField) = apply { this.source = source } + + 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(): FeedbackDatasetItem = + FeedbackDatasetItem( + id, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + class Source + @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 Source && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val APP = Source(JsonField.of("app")) + + @JvmField val API = Source(JsonField.of("api")) + + @JvmField val EXTERNAL = Source(JsonField.of("external")) + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + enum class Known { + APP, + API, + EXTERNAL, + } + + enum class Value { + APP, + API, + EXTERNAL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequest.kt new file mode 100755 index 0000000..39f79b9 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequest.kt @@ -0,0 +1,114 @@ +// 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 = FeedbackExperimentEventRequest.Builder::class) +@NoAutoDetect +class FeedbackExperimentEventRequest +private constructor( + private val feedback: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of experiment feedback items */ + fun feedback(): List = feedback.getRequired("feedback") + + /** A list of experiment feedback items */ + @JsonProperty("feedback") @ExcludeMissing fun _feedback() = feedback + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FeedbackExperimentEventRequest = apply { + if (!validated) { + feedback().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackExperimentEventRequest && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode + } + + override fun toString() = + "FeedbackExperimentEventRequest{feedback=$feedback, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var feedback: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackExperimentEventRequest: FeedbackExperimentEventRequest) = apply { + this.feedback = feedbackExperimentEventRequest.feedback + additionalProperties(feedbackExperimentEventRequest.additionalProperties) + } + + /** A list of experiment feedback items */ + fun feedback(feedback: List) = feedback(JsonField.of(feedback)) + + /** A list of experiment feedback items */ + @JsonProperty("feedback") + @ExcludeMissing + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback + } + + 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(): FeedbackExperimentEventRequest = + FeedbackExperimentEventRequest( + feedback.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt new file mode 100755 index 0000000..2abcfe4 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -0,0 +1,480 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = FeedbackExperimentItem.Builder::class) +@NoAutoDetect +class FeedbackExperimentItem +private constructor( + private val id: JsonField, + private val scores: JsonField, + private val expected: JsonValue, + private val comment: JsonField, + private val metadata: JsonField, + private val source: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * The id of the experiment event to log feedback for. This is the row `id` returned by `POST + * /v1/experiment/{experiment_id}/insert` + */ + fun id(): String = id.getRequired("id") + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not + */ + fun expected(): JsonValue = expected + + /** An optional comment string to log about the experiment event */ + fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + + /** + * The id of the experiment event to log feedback for. This is the row `id` returned by `POST + * /v1/experiment/{experiment_id}/insert` + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** An optional comment string to log about the experiment event */ + @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + @JsonProperty("source") @ExcludeMissing fun _source() = source + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FeedbackExperimentItem = apply { + if (!validated) { + id() + scores().map { it.validate() } + expected() + comment() + metadata().map { it.validate() } + source() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackExperimentItem && + this.id == other.id && + this.scores == other.scores && + this.expected == other.expected && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var comment: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = apply { + this.id = feedbackExperimentItem.id + this.scores = feedbackExperimentItem.scores + this.expected = feedbackExperimentItem.expected + this.comment = feedbackExperimentItem.comment + this.metadata = feedbackExperimentItem.metadata + this.source = feedbackExperimentItem.source + additionalProperties(feedbackExperimentItem.additionalProperties) + } + + /** + * The id of the experiment event to log feedback for. This is the row `id` returned by + * `POST /v1/experiment/{experiment_id}/insert` + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * The id of the experiment event to log feedback for. This is the row `id` returned by + * `POST /v1/experiment/{experiment_id}/insert` + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** An optional comment string to log about the experiment event */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** An optional comment string to log about the experiment event */ + @JsonProperty("comment") + @ExcludeMissing + fun comment(comment: JsonField) = apply { this.comment = comment } + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(source: Source) = source(JsonField.of(source)) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + @JsonProperty("source") + @ExcludeMissing + fun source(source: JsonField) = apply { this.source = source } + + 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(): FeedbackExperimentItem = + FeedbackExperimentItem( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + class Source + @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 Source && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val APP = Source(JsonField.of("app")) + + @JvmField val API = Source(JsonField.of("api")) + + @JvmField val EXTERNAL = Source(JsonField.of("external")) + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + enum class Known { + APP, + API, + EXTERNAL, + } + + enum class Value { + APP, + API, + EXTERNAL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequest.kt new file mode 100755 index 0000000..effa395 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequest.kt @@ -0,0 +1,115 @@ +// 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 = FeedbackProjectLogsEventRequest.Builder::class) +@NoAutoDetect +class FeedbackProjectLogsEventRequest +private constructor( + private val feedback: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of project logs feedback items */ + fun feedback(): List = feedback.getRequired("feedback") + + /** A list of project logs feedback items */ + @JsonProperty("feedback") @ExcludeMissing fun _feedback() = feedback + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FeedbackProjectLogsEventRequest = apply { + if (!validated) { + feedback().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackProjectLogsEventRequest && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode + } + + override fun toString() = + "FeedbackProjectLogsEventRequest{feedback=$feedback, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var feedback: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackProjectLogsEventRequest: FeedbackProjectLogsEventRequest) = + apply { + this.feedback = feedbackProjectLogsEventRequest.feedback + additionalProperties(feedbackProjectLogsEventRequest.additionalProperties) + } + + /** A list of project logs feedback items */ + fun feedback(feedback: List) = feedback(JsonField.of(feedback)) + + /** A list of project logs feedback items */ + @JsonProperty("feedback") + @ExcludeMissing + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback + } + + 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(): FeedbackProjectLogsEventRequest = + FeedbackProjectLogsEventRequest( + feedback.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt new file mode 100755 index 0000000..becc234 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -0,0 +1,480 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = FeedbackProjectLogsItem.Builder::class) +@NoAutoDetect +class FeedbackProjectLogsItem +private constructor( + private val id: JsonField, + private val scores: JsonField, + private val expected: JsonValue, + private val comment: JsonField, + private val metadata: JsonField, + private val source: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * The id of the project logs event to log feedback for. This is the row `id` returned by `POST + * /v1/project_logs/{project_id}/insert` + */ + fun id(): String = id.getRequired("id") + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not + */ + fun expected(): JsonValue = expected + + /** An optional comment string to log about the project logs event */ + fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + + /** + * The id of the project logs event to log feedback for. This is the row `id` returned by `POST + * /v1/project_logs/{project_id}/insert` + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** An optional comment string to log about the project logs event */ + @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + @JsonProperty("source") @ExcludeMissing fun _source() = source + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FeedbackProjectLogsItem = apply { + if (!validated) { + id() + scores().map { it.validate() } + expected() + comment() + metadata().map { it.validate() } + source() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackProjectLogsItem && + this.id == other.id && + this.scores == other.scores && + this.expected == other.expected && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var comment: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = apply { + this.id = feedbackProjectLogsItem.id + this.scores = feedbackProjectLogsItem.scores + this.expected = feedbackProjectLogsItem.expected + this.comment = feedbackProjectLogsItem.comment + this.metadata = feedbackProjectLogsItem.metadata + this.source = feedbackProjectLogsItem.source + additionalProperties(feedbackProjectLogsItem.additionalProperties) + } + + /** + * The id of the project logs event to log feedback for. This is the row `id` returned by + * `POST /v1/project_logs/{project_id}/insert` + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * The id of the project logs event to log feedback for. This is the row `id` returned by + * `POST /v1/project_logs/{project_id}/insert` + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** An optional comment string to log about the project logs event */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** An optional comment string to log about the project logs event */ + @JsonProperty("comment") + @ExcludeMissing + fun comment(comment: JsonField) = apply { this.comment = comment } + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(source: Source) = source(JsonField.of(source)) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + @JsonProperty("source") + @ExcludeMissing + fun source(source: JsonField) = apply { this.source = source } + + 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(): FeedbackProjectLogsItem = + FeedbackProjectLogsItem( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + class Source + @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 Source && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val APP = Source(JsonField.of("app")) + + @JvmField val API = Source(JsonField.of("api")) + + @JvmField val EXTERNAL = Source(JsonField.of("external")) + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + enum class Known { + APP, + API, + EXTERNAL, + } + + enum class Value { + APP, + API, + EXTERNAL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt new file mode 100755 index 0000000..00a4726 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -0,0 +1,158 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = FetchDatasetEventsResponse.Builder::class) +@NoAutoDetect +class FetchDatasetEventsResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of fetched events */ + fun events(): List = events.getRequired("events") + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. + */ + fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) + + /** A list of fetched events */ + @JsonProperty("events") @ExcludeMissing fun _events() = events + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FetchDatasetEventsResponse = apply { + if (!validated) { + events().forEach { it.validate() } + cursor() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchDatasetEventsResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var events: JsonField> = JsonMissing.of() + private var cursor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = apply { + this.events = fetchDatasetEventsResponse.events + this.cursor = fetchDatasetEventsResponse.cursor + additionalProperties(fetchDatasetEventsResponse.additionalProperties) + } + + /** A list of fetched events */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of fetched events */ + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { this.events = events } + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + @JsonProperty("cursor") + @ExcludeMissing + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + 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(): FetchDatasetEventsResponse = + FetchDatasetEventsResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchEventsRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchEventsRequest.kt new file mode 100755 index 0000000..873abe1 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchEventsRequest.kt @@ -0,0 +1,422 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = FetchEventsRequest.Builder::class) +@NoAutoDetect +class FetchEventsRequest +private constructor( + private val limit: JsonField, + private val cursor: JsonField, + private val maxXactId: JsonField, + private val maxRootSpanId: JsonField, + private val filters: JsonField>, + private val version: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxRootSpanId(): Optional = + Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + + /** + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future + */ + fun filters(): Optional> = + Optional.ofNullable(filters.getNullable("filters")) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(): Optional = Optional.ofNullable(version.getNullable("version")) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit() = limit + + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId() = maxXactId + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId() = maxRootSpanId + + /** + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future + */ + @JsonProperty("filters") @ExcludeMissing fun _filters() = filters + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FetchEventsRequest = apply { + if (!validated) { + limit() + cursor() + maxXactId() + maxRootSpanId() + filters().map { it.forEach { it.validate() } } + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchEventsRequest && + this.limit == other.limit && + this.cursor == other.cursor && + this.maxXactId == other.maxXactId && + this.maxRootSpanId == other.maxRootSpanId && + this.filters == other.filters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + limit, + cursor, + maxXactId, + maxRootSpanId, + filters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FetchEventsRequest{limit=$limit, cursor=$cursor, maxXactId=$maxXactId, maxRootSpanId=$maxRootSpanId, filters=$filters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var limit: JsonField = JsonMissing.of() + private var cursor: JsonField = JsonMissing.of() + private var maxXactId: JsonField = JsonMissing.of() + private var maxRootSpanId: JsonField = JsonMissing.of() + private var filters: JsonField> = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fetchEventsRequest: FetchEventsRequest) = apply { + this.limit = fetchEventsRequest.limit + this.cursor = fetchEventsRequest.cursor + this.maxXactId = fetchEventsRequest.maxXactId + this.maxRootSpanId = fetchEventsRequest.maxRootSpanId + this.filters = fetchEventsRequest.filters + this.version = fetchEventsRequest.version + additionalProperties(fetchEventsRequest.additionalProperties) + } + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @JsonProperty("limit") + @ExcludeMissing + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + @JsonProperty("cursor") + @ExcludeMissing + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: String) = maxXactId(JsonField.of(maxXactId)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_xact_id") + @ExcludeMissing + fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: String) = maxRootSpanId(JsonField.of(maxRootSpanId)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_root_span_id") + @ExcludeMissing + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + this.maxRootSpanId = maxRootSpanId + } + + /** + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future + */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future + */ + @JsonProperty("filters") + @ExcludeMissing + fun filters(filters: JsonField>) = apply { this.filters = filters } + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + 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(): FetchEventsRequest = + FetchEventsRequest( + limit, + cursor, + maxXactId, + maxRootSpanId, + filters.map { it.toUnmodifiable() }, + version, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt new file mode 100755 index 0000000..318e1c7 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -0,0 +1,158 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = FetchExperimentEventsResponse.Builder::class) +@NoAutoDetect +class FetchExperimentEventsResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of fetched events */ + fun events(): List = events.getRequired("events") + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. + */ + fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) + + /** A list of fetched events */ + @JsonProperty("events") @ExcludeMissing fun _events() = events + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FetchExperimentEventsResponse = apply { + if (!validated) { + events().forEach { it.validate() } + cursor() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchExperimentEventsResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var events: JsonField> = JsonMissing.of() + private var cursor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = apply { + this.events = fetchExperimentEventsResponse.events + this.cursor = fetchExperimentEventsResponse.cursor + additionalProperties(fetchExperimentEventsResponse.additionalProperties) + } + + /** A list of fetched events */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of fetched events */ + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { this.events = events } + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + @JsonProperty("cursor") + @ExcludeMissing + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + 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(): FetchExperimentEventsResponse = + FetchExperimentEventsResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt new file mode 100755 index 0000000..7c808c8 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -0,0 +1,158 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = FetchProjectLogsEventsResponse.Builder::class) +@NoAutoDetect +class FetchProjectLogsEventsResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of fetched events */ + fun events(): List = events.getRequired("events") + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. + */ + fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) + + /** A list of fetched events */ + @JsonProperty("events") @ExcludeMissing fun _events() = events + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FetchProjectLogsEventsResponse = apply { + if (!validated) { + events().forEach { it.validate() } + cursor() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchProjectLogsEventsResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var events: JsonField> = JsonMissing.of() + private var cursor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = apply { + this.events = fetchProjectLogsEventsResponse.events + this.cursor = fetchProjectLogsEventsResponse.cursor + additionalProperties(fetchProjectLogsEventsResponse.additionalProperties) + } + + /** A list of fetched events */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of fetched events */ + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { this.events = events } + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + @JsonProperty("cursor") + @ExcludeMissing + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + 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(): FetchProjectLogsEventsResponse = + FetchProjectLogsEventsResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index d78221b..dc0a6c9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -27,6 +16,7 @@ constructor( private val ids: Ids?, private val limit: Long?, private val orgName: String?, + private val projectId: String?, private val projectName: String?, private val slug: String?, private val startingAfter: String?, @@ -46,6 +36,8 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun projectId(): Optional = Optional.ofNullable(projectId) + fun projectName(): Optional = Optional.ofNullable(projectName) fun slug(): Optional = Optional.ofNullable(slug) @@ -62,6 +54,7 @@ constructor( this.ids?.let { params.put("ids", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectId?.let { params.put("project_id", listOf(it.toString())) } this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.slug?.let { params.put("slug", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } @@ -89,6 +82,7 @@ constructor( this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && + this.projectId == other.projectId && this.projectName == other.projectName && this.slug == other.slug && this.startingAfter == other.startingAfter && @@ -105,6 +99,7 @@ constructor( ids, limit, orgName, + projectId, projectName, slug, startingAfter, @@ -116,7 +111,7 @@ constructor( } override fun toString() = - "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -133,6 +128,7 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null + private var projectId: String? = null private var projectName: String? = null private var slug: String? = null private var startingAfter: String? = null @@ -148,6 +144,7 @@ constructor( this.ids = functionListParams.ids this.limit = functionListParams.limit this.orgName = functionListParams.orgName + this.projectId = functionListParams.projectId this.projectName = functionListParams.projectName this.slug = functionListParams.slug this.startingAfter = functionListParams.startingAfter @@ -193,6 +190,9 @@ constructor( /** Filter search results to within a particular organization */ fun orgName(orgName: String) = apply { this.orgName = orgName } + /** Project id */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + /** Name of the project to search for */ fun projectName(projectName: String) = apply { this.projectName = projectName } @@ -277,6 +277,7 @@ constructor( ids, limit, orgName, + projectId, projectName, slug, startingAfter, @@ -286,117 +287,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 29db15d..85f7581 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -245,117 +234,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Ids.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Ids.kt new file mode 100755 index 0000000..0f00d50 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Ids.kt @@ -0,0 +1,127 @@ +// 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.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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 = Ids.Deserializer::class) +@JsonSerialize(using = Ids.Serializer::class) +class Ids +private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Ids = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Ids && this.string == other.string && this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash(string, strings) + } + + override fun toString(): String { + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Ids(string = string) + + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Ids: $json") + } + } + + class Deserializer : BaseDeserializer(Ids::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Ids { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) + } + } + + class Serializer : BaseSerializer(Ids::class) { + + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt new file mode 100755 index 0000000..549a3ed --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -0,0 +1,151 @@ +// 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.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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 = InsertDatasetEvent.Deserializer::class) +@JsonSerialize(using = InsertDatasetEvent.Serializer::class) +class InsertDatasetEvent +private constructor( + private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, + private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun insertDatasetEventReplace(): Optional = + Optional.ofNullable(insertDatasetEventReplace) + + fun insertDatasetEventMerge(): Optional = + Optional.ofNullable(insertDatasetEventMerge) + + fun isInsertDatasetEventReplace(): Boolean = insertDatasetEventReplace != null + + fun isInsertDatasetEventMerge(): Boolean = insertDatasetEventMerge != null + + fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = + insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") + + fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = + insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + insertDatasetEventReplace != null -> + visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) + insertDatasetEventMerge != null -> + visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) + else -> visitor.unknown(_json) + } + } + + fun validate(): InsertDatasetEvent = apply { + if (!validated) { + if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { + throw BraintrustInvalidDataException("Unknown InsertDatasetEvent: $_json") + } + insertDatasetEventReplace?.validate() + insertDatasetEventMerge?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertDatasetEvent && + this.insertDatasetEventReplace == other.insertDatasetEventReplace && + this.insertDatasetEventMerge == other.insertDatasetEventMerge + } + + override fun hashCode(): Int { + return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) + } + + override fun toString(): String { + return when { + insertDatasetEventReplace != null -> + "InsertDatasetEvent{insertDatasetEventReplace=$insertDatasetEventReplace}" + insertDatasetEventMerge != null -> + "InsertDatasetEvent{insertDatasetEventMerge=$insertDatasetEventMerge}" + _json != null -> "InsertDatasetEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InsertDatasetEvent") + } + } + + companion object { + + @JvmStatic + fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = + InsertDatasetEvent(insertDatasetEventReplace = insertDatasetEventReplace) + + @JvmStatic + fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = + InsertDatasetEvent(insertDatasetEventMerge = insertDatasetEventMerge) + } + + interface Visitor { + + fun visitInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace): T + + fun visitInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown InsertDatasetEvent: $json") + } + } + + class Deserializer : BaseDeserializer(InsertDatasetEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InsertDatasetEvent { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InsertDatasetEvent(insertDatasetEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InsertDatasetEvent(insertDatasetEventMerge = it, _json = json) + } + + return InsertDatasetEvent(_json = json) + } + } + + class Serializer : BaseSerializer(InsertDatasetEvent::class) { + + override fun serialize( + value: InsertDatasetEvent, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.insertDatasetEventReplace != null -> + generator.writeObject(value.insertDatasetEventReplace) + value.insertDatasetEventMerge != null -> + generator.writeObject(value.insertDatasetEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InsertDatasetEvent") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt new file mode 100755 index 0000000..5e2fade --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt @@ -0,0 +1,514 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = InsertDatasetEventMerge.Builder::class) +@NoAutoDetect +class InsertDatasetEventMerge +private constructor( + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + fun expected(): JsonValue = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** The timestamp the dataset event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified + * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of + * field names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The timestamp the dataset event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified + * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of + * field names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertDatasetEventMerge = apply { + if (!validated) { + input() + expected() + metadata().map { it.validate() } + tags() + id() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertDatasetEventMerge && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + expected, + metadata, + tags, + id, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var input: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var _objectDelete: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _mergePaths: JsonField>> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertDatasetEventMerge: InsertDatasetEventMerge) = apply { + this.input = insertDatasetEventMerge.input + this.expected = insertDatasetEventMerge.expected + this.metadata = insertDatasetEventMerge.metadata + this.tags = insertDatasetEventMerge.tags + this.id = insertDatasetEventMerge.id + this.created = insertDatasetEventMerge.created + this._objectDelete = insertDatasetEventMerge._objectDelete + this._isMerge = insertDatasetEventMerge._isMerge + this._mergePaths = insertDatasetEventMerge._mergePaths + additionalProperties(insertDatasetEventMerge.additionalProperties) + } + + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** The timestamp the dataset event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the dataset event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") + @ExcludeMissing + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path + * is a list of field names. The deep merge will not descend below any of the specified + * merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path + * is a list of field names. The deep merge will not descend below any of the specified + * merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + @JsonProperty("_merge_paths") + @ExcludeMissing + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths + } + + 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(): InsertDatasetEventMerge = + InsertDatasetEventMerge( + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + id, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt new file mode 100755 index 0000000..2d77d5b --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt @@ -0,0 +1,507 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = InsertDatasetEventReplace.Builder::class) +@NoAutoDetect +class InsertDatasetEventReplace +private constructor( + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + fun expected(): JsonValue = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** The timestamp the dataset event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be + * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for + * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + */ + fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The timestamp the dataset event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be + * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for + * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + */ + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertDatasetEventReplace = apply { + if (!validated) { + input() + expected() + metadata().map { it.validate() } + tags() + id() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertDatasetEventReplace && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + expected, + metadata, + tags, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var input: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var _objectDelete: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertDatasetEventReplace: InsertDatasetEventReplace) = apply { + this.input = insertDatasetEventReplace.input + this.expected = insertDatasetEventReplace.expected + this.metadata = insertDatasetEventReplace.metadata + this.tags = insertDatasetEventReplace.tags + this.id = insertDatasetEventReplace.id + this.created = insertDatasetEventReplace.created + this._objectDelete = insertDatasetEventReplace._objectDelete + this._isMerge = insertDatasetEventReplace._isMerge + this._parentId = insertDatasetEventReplace._parentId + additionalProperties(insertDatasetEventReplace.additionalProperties) + } + + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** The timestamp the dataset event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the dataset event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") + @ExcludeMissing + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot + * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are + * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + */ + fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot + * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are + * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + */ + @JsonProperty("_parent_id") + @ExcludeMissing + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + + 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(): InsertDatasetEventReplace = + InsertDatasetEventReplace( + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequest.kt new file mode 100755 index 0000000..465926b --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequest.kt @@ -0,0 +1,112 @@ +// 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 = InsertDatasetEventRequest.Builder::class) +@NoAutoDetect +class InsertDatasetEventRequest +private constructor( + private val events: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of dataset events to insert */ + fun events(): List = events.getRequired("events") + + /** A list of dataset events to insert */ + @JsonProperty("events") @ExcludeMissing fun _events() = events + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertDatasetEventRequest = apply { + if (!validated) { + events() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertDatasetEventRequest && + this.events == other.events && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode + } + + override fun toString() = + "InsertDatasetEventRequest{events=$events, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var events: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertDatasetEventRequest: InsertDatasetEventRequest) = apply { + this.events = insertDatasetEventRequest.events + additionalProperties(insertDatasetEventRequest.additionalProperties) + } + + /** A list of dataset events to insert */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of dataset events to insert */ + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { this.events = events } + + 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(): InsertDatasetEventRequest = + InsertDatasetEventRequest( + events.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt new file mode 100755 index 0000000..6646cb3 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -0,0 +1,122 @@ +// 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 = InsertEventsResponse.Builder::class) +@NoAutoDetect +class InsertEventsResponse +private constructor( + private val rowIds: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + fun rowIds(): List = rowIds.getRequired("row_ids") + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertEventsResponse = apply { + if (!validated) { + rowIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertEventsResponse && + this.rowIds == other.rowIds && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(rowIds, additionalProperties) + } + return hashCode + } + + override fun toString() = + "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var rowIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertEventsResponse: InsertEventsResponse) = apply { + this.rowIds = insertEventsResponse.rowIds + additionalProperties(insertEventsResponse.additionalProperties) + } + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + @JsonProperty("row_ids") + @ExcludeMissing + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } + + 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(): InsertEventsResponse = + InsertEventsResponse( + rowIds.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt new file mode 100755 index 0000000..ed2ef88 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -0,0 +1,156 @@ +// 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.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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 = InsertExperimentEvent.Deserializer::class) +@JsonSerialize(using = InsertExperimentEvent.Serializer::class) +class InsertExperimentEvent +private constructor( + private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, + private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun insertExperimentEventReplace(): Optional = + Optional.ofNullable(insertExperimentEventReplace) + + fun insertExperimentEventMerge(): Optional = + Optional.ofNullable(insertExperimentEventMerge) + + fun isInsertExperimentEventReplace(): Boolean = insertExperimentEventReplace != null + + fun isInsertExperimentEventMerge(): Boolean = insertExperimentEventMerge != null + + fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = + insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") + + fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = + insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + insertExperimentEventReplace != null -> + visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) + insertExperimentEventMerge != null -> + visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) + else -> visitor.unknown(_json) + } + } + + fun validate(): InsertExperimentEvent = apply { + if (!validated) { + if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { + throw BraintrustInvalidDataException("Unknown InsertExperimentEvent: $_json") + } + insertExperimentEventReplace?.validate() + insertExperimentEventMerge?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertExperimentEvent && + this.insertExperimentEventReplace == other.insertExperimentEventReplace && + this.insertExperimentEventMerge == other.insertExperimentEventMerge + } + + override fun hashCode(): Int { + return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) + } + + override fun toString(): String { + return when { + insertExperimentEventReplace != null -> + "InsertExperimentEvent{insertExperimentEventReplace=$insertExperimentEventReplace}" + insertExperimentEventMerge != null -> + "InsertExperimentEvent{insertExperimentEventMerge=$insertExperimentEventMerge}" + _json != null -> "InsertExperimentEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InsertExperimentEvent") + } + } + + companion object { + + @JvmStatic + fun ofInsertExperimentEventReplace( + insertExperimentEventReplace: InsertExperimentEventReplace + ) = InsertExperimentEvent(insertExperimentEventReplace = insertExperimentEventReplace) + + @JvmStatic + fun ofInsertExperimentEventMerge(insertExperimentEventMerge: InsertExperimentEventMerge) = + InsertExperimentEvent(insertExperimentEventMerge = insertExperimentEventMerge) + } + + interface Visitor { + + fun visitInsertExperimentEventReplace( + insertExperimentEventReplace: InsertExperimentEventReplace + ): T + + fun visitInsertExperimentEventMerge( + insertExperimentEventMerge: InsertExperimentEventMerge + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown InsertExperimentEvent: $json") + } + } + + class Deserializer : BaseDeserializer(InsertExperimentEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InsertExperimentEvent { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InsertExperimentEvent(insertExperimentEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InsertExperimentEvent(insertExperimentEventMerge = it, _json = json) + } + + return InsertExperimentEvent(_json = json) + } + } + + class Serializer : BaseSerializer(InsertExperimentEvent::class) { + + override fun serialize( + value: InsertExperimentEvent, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.insertExperimentEventReplace != null -> + generator.writeObject(value.insertExperimentEventReplace) + value.insertExperimentEventMerge != null -> + generator.writeObject(value.insertExperimentEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InsertExperimentEvent") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt new file mode 100755 index 0000000..bfc1a9f --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt @@ -0,0 +1,1478 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = InsertExperimentEventMerge.Builder::class) +@NoAutoDetect +class InsertExperimentEventMerge +private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val datasetRecordId: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical + */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question + */ + fun output(): JsonValue = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models + */ + fun expected(): JsonValue = expected + + /** The error that occurred, if any. */ + fun error(): JsonValue = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + + /** The timestamp the experiment event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified + * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of + * field names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical + */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question + */ + @JsonProperty("output") @ExcludeMissing fun _output() = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error() = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + @JsonProperty("context") @ExcludeMissing fun _context() = context + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId + + /** The timestamp the experiment event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment + */ + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified + * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of + * field names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertExperimentEventMerge = apply { + if (!validated) { + input() + output() + expected() + error() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + datasetRecordId() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertExperimentEventMerge && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var input: JsonValue = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var error: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var metrics: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var datasetRecordId: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var _objectDelete: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _mergePaths: JsonField>> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertExperimentEventMerge: InsertExperimentEventMerge) = apply { + this.input = insertExperimentEventMerge.input + this.output = insertExperimentEventMerge.output + this.expected = insertExperimentEventMerge.expected + this.error = insertExperimentEventMerge.error + this.scores = insertExperimentEventMerge.scores + this.metadata = insertExperimentEventMerge.metadata + this.tags = insertExperimentEventMerge.tags + this.metrics = insertExperimentEventMerge.metrics + this.context = insertExperimentEventMerge.context + this.spanAttributes = insertExperimentEventMerge.spanAttributes + this.id = insertExperimentEventMerge.id + this.datasetRecordId = insertExperimentEventMerge.datasetRecordId + this.created = insertExperimentEventMerge.created + this._objectDelete = insertExperimentEventMerge._objectDelete + this._isMerge = insertExperimentEventMerge._isMerge + this._mergePaths = insertExperimentEventMerge._mergePaths + additionalProperties(insertExperimentEventMerge.additionalProperties) + } + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question + */ + @JsonProperty("output") + @ExcludeMissing + fun output(output: JsonValue) = apply { this.output = output } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** The error that occurred, if any. */ + @JsonProperty("error") + @ExcludeMissing + fun error(error: JsonValue) = apply { this.error = error } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonProperty("metrics") + @ExcludeMissing + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + fun context(context: Context) = context(JsonField.of(context)) + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + @JsonProperty("context") + @ExcludeMissing + fun context(context: JsonField) = apply { this.context = context } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: String) = + datasetRecordId(JsonField.of(datasetRecordId)) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun datasetRecordId(datasetRecordId: JsonField) = apply { + this.datasetRecordId = datasetRecordId + } + + /** The timestamp the experiment event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the experiment event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") + @ExcludeMissing + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path + * is a list of field names. The deep merge will not descend below any of the specified + * merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path + * is a list of field names. The deep merge will not descend below any of the specified + * merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + @JsonProperty("_merge_paths") + @ExcludeMissing + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths + } + + 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(): InsertExperimentEventMerge = + InsertExperimentEventMerge( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + @JsonDeserialize(builder = Context.Builder::class) + @NoAutoDetect + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The function in code which created the experiment event */ + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) + + /** Line of code where the experiment event was created */ + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + + /** The function in code which created the experiment event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** Line of code where the experiment event was created */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Context = apply { + if (!validated) { + callerFunctionname() + callerFilename() + callerLineno() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var callerFunctionname: JsonField = JsonMissing.of() + private var callerFilename: JsonField = JsonMissing.of() + private var callerLineno: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(context: Context) = apply { + this.callerFunctionname = context.callerFunctionname + this.callerFilename = context.callerFilename + this.callerLineno = context.callerLineno + additionalProperties(context.additionalProperties) + } + + /** The function in code which created the experiment event */ + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) + + /** The function in code which created the experiment event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) + + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** Line of code where the experiment event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + + /** Line of code where the experiment event was created */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } + + 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(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonDeserialize(builder = Metrics.Builder::class) + @NoAutoDetect + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * finished + */ + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start() = start + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end() = end + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens() = completionTokens + + /** The total number of tokens in the input and output of the experiment event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metrics = apply { + if (!validated) { + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var start: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var tokens: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metrics: Metrics) = apply { + this.start = metrics.start + this.end = metrics.end + this.promptTokens = metrics.promptTokens + this.completionTokens = metrics.completionTokens + this.tokens = metrics.tokens + additionalProperties(metrics.additionalProperties) + } + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + fun start(start: Double) = start(JsonField.of(start)) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + @JsonProperty("start") + @ExcludeMissing + fun start(start: JsonField) = apply { this.start = start } + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event finished + */ + fun end(end: Double) = end(JsonField.of(end)) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event finished + */ + @JsonProperty("end") + @ExcludeMissing + fun end(end: JsonField) = apply { this.end = end } + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + + /** The total number of tokens in the input and output of the experiment event. */ + @JsonProperty("tokens") + @ExcludeMissing + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + + 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(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonDeserialize(builder = SpanAttributes.Builder::class) + @NoAutoDetect + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the span, for display purposes only */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of the span, for display purposes only */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Type of the span, for display purposes only */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanAttributes = apply { + if (!validated) { + name() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanAttributes: SpanAttributes) = apply { + this.name = spanAttributes.name + this.type = spanAttributes.type + additionalProperties(spanAttributes.additionalProperties) + } + + /** Name of the span, for display purposes only */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the span, for display purposes only */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of the span, for display purposes only */ + @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(): SpanAttributes = + SpanAttributes( + name, + 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 LLM = Type(JsonField.of("llm")) + + @JvmField val SCORE = Type(JsonField.of("score")) + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmField val EVAL = Type(JsonField.of("eval")) + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmField val TOOL = Type(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + enum class Value { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt new file mode 100755 index 0000000..41a1ffb --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt @@ -0,0 +1,1471 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = InsertExperimentEventReplace.Builder::class) +@NoAutoDetect +class InsertExperimentEventReplace +private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val datasetRecordId: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical + */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question + */ + fun output(): JsonValue = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models + */ + fun expected(): JsonValue = expected + + /** The error that occurred, if any. */ + fun error(): JsonValue = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + + /** The timestamp the experiment event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be + * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for + * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + */ + fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical + */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question + */ + @JsonProperty("output") @ExcludeMissing fun _output() = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error() = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + @JsonProperty("context") @ExcludeMissing fun _context() = context + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId + + /** The timestamp the experiment event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment + */ + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be + * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for + * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + */ + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertExperimentEventReplace = apply { + if (!validated) { + input() + output() + expected() + error() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + datasetRecordId() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertExperimentEventReplace && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var input: JsonValue = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var error: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var metrics: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var datasetRecordId: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var _objectDelete: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertExperimentEventReplace: InsertExperimentEventReplace) = apply { + this.input = insertExperimentEventReplace.input + this.output = insertExperimentEventReplace.output + this.expected = insertExperimentEventReplace.expected + this.error = insertExperimentEventReplace.error + this.scores = insertExperimentEventReplace.scores + this.metadata = insertExperimentEventReplace.metadata + this.tags = insertExperimentEventReplace.tags + this.metrics = insertExperimentEventReplace.metrics + this.context = insertExperimentEventReplace.context + this.spanAttributes = insertExperimentEventReplace.spanAttributes + this.id = insertExperimentEventReplace.id + this.datasetRecordId = insertExperimentEventReplace.datasetRecordId + this.created = insertExperimentEventReplace.created + this._objectDelete = insertExperimentEventReplace._objectDelete + this._isMerge = insertExperimentEventReplace._isMerge + this._parentId = insertExperimentEventReplace._parentId + additionalProperties(insertExperimentEventReplace.additionalProperties) + } + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question + */ + @JsonProperty("output") + @ExcludeMissing + fun output(output: JsonValue) = apply { this.output = output } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** The error that occurred, if any. */ + @JsonProperty("error") + @ExcludeMissing + fun error(error: JsonValue) = apply { this.error = error } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonProperty("metrics") + @ExcludeMissing + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + fun context(context: Context) = context(JsonField.of(context)) + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + @JsonProperty("context") + @ExcludeMissing + fun context(context: JsonField) = apply { this.context = context } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: String) = + datasetRecordId(JsonField.of(datasetRecordId)) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun datasetRecordId(datasetRecordId: JsonField) = apply { + this.datasetRecordId = datasetRecordId + } + + /** The timestamp the experiment event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the experiment event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") + @ExcludeMissing + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot + * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are + * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + */ + fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot + * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are + * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + */ + @JsonProperty("_parent_id") + @ExcludeMissing + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + + 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(): InsertExperimentEventReplace = + InsertExperimentEventReplace( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + @JsonDeserialize(builder = Context.Builder::class) + @NoAutoDetect + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The function in code which created the experiment event */ + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) + + /** Line of code where the experiment event was created */ + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + + /** The function in code which created the experiment event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** Line of code where the experiment event was created */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Context = apply { + if (!validated) { + callerFunctionname() + callerFilename() + callerLineno() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var callerFunctionname: JsonField = JsonMissing.of() + private var callerFilename: JsonField = JsonMissing.of() + private var callerLineno: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(context: Context) = apply { + this.callerFunctionname = context.callerFunctionname + this.callerFilename = context.callerFilename + this.callerLineno = context.callerLineno + additionalProperties(context.additionalProperties) + } + + /** The function in code which created the experiment event */ + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) + + /** The function in code which created the experiment event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) + + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** Line of code where the experiment event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + + /** Line of code where the experiment event was created */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } + + 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(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonDeserialize(builder = Metrics.Builder::class) + @NoAutoDetect + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * finished + */ + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start() = start + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end() = end + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens() = completionTokens + + /** The total number of tokens in the input and output of the experiment event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metrics = apply { + if (!validated) { + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var start: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var tokens: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metrics: Metrics) = apply { + this.start = metrics.start + this.end = metrics.end + this.promptTokens = metrics.promptTokens + this.completionTokens = metrics.completionTokens + this.tokens = metrics.tokens + additionalProperties(metrics.additionalProperties) + } + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + fun start(start: Double) = start(JsonField.of(start)) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + @JsonProperty("start") + @ExcludeMissing + fun start(start: JsonField) = apply { this.start = start } + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event finished + */ + fun end(end: Double) = end(JsonField.of(end)) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event finished + */ + @JsonProperty("end") + @ExcludeMissing + fun end(end: JsonField) = apply { this.end = end } + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + + /** The total number of tokens in the input and output of the experiment event. */ + @JsonProperty("tokens") + @ExcludeMissing + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + + 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(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonDeserialize(builder = SpanAttributes.Builder::class) + @NoAutoDetect + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the span, for display purposes only */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of the span, for display purposes only */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Type of the span, for display purposes only */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanAttributes = apply { + if (!validated) { + name() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanAttributes: SpanAttributes) = apply { + this.name = spanAttributes.name + this.type = spanAttributes.type + additionalProperties(spanAttributes.additionalProperties) + } + + /** Name of the span, for display purposes only */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the span, for display purposes only */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of the span, for display purposes only */ + @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(): SpanAttributes = + SpanAttributes( + name, + 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 LLM = Type(JsonField.of("llm")) + + @JvmField val SCORE = Type(JsonField.of("score")) + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmField val EVAL = Type(JsonField.of("eval")) + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmField val TOOL = Type(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + enum class Value { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequest.kt new file mode 100755 index 0000000..f88d21e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequest.kt @@ -0,0 +1,112 @@ +// 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 = InsertExperimentEventRequest.Builder::class) +@NoAutoDetect +class InsertExperimentEventRequest +private constructor( + private val events: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of experiment events to insert */ + fun events(): List = events.getRequired("events") + + /** A list of experiment events to insert */ + @JsonProperty("events") @ExcludeMissing fun _events() = events + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertExperimentEventRequest = apply { + if (!validated) { + events() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertExperimentEventRequest && + this.events == other.events && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode + } + + override fun toString() = + "InsertExperimentEventRequest{events=$events, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var events: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertExperimentEventRequest: InsertExperimentEventRequest) = apply { + this.events = insertExperimentEventRequest.events + additionalProperties(insertExperimentEventRequest.additionalProperties) + } + + /** A list of experiment events to insert */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of experiment events to insert */ + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { this.events = events } + + 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(): InsertExperimentEventRequest = + InsertExperimentEventRequest( + events.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt new file mode 100755 index 0000000..5fca10e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -0,0 +1,157 @@ +// 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.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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 = InsertProjectLogsEvent.Deserializer::class) +@JsonSerialize(using = InsertProjectLogsEvent.Serializer::class) +class InsertProjectLogsEvent +private constructor( + private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, + private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun insertProjectLogsEventReplace(): Optional = + Optional.ofNullable(insertProjectLogsEventReplace) + + fun insertProjectLogsEventMerge(): Optional = + Optional.ofNullable(insertProjectLogsEventMerge) + + fun isInsertProjectLogsEventReplace(): Boolean = insertProjectLogsEventReplace != null + + fun isInsertProjectLogsEventMerge(): Boolean = insertProjectLogsEventMerge != null + + fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = + insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") + + fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = + insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + insertProjectLogsEventReplace != null -> + visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) + insertProjectLogsEventMerge != null -> + visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) + else -> visitor.unknown(_json) + } + } + + fun validate(): InsertProjectLogsEvent = apply { + if (!validated) { + if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { + throw BraintrustInvalidDataException("Unknown InsertProjectLogsEvent: $_json") + } + insertProjectLogsEventReplace?.validate() + insertProjectLogsEventMerge?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertProjectLogsEvent && + this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && + this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge + } + + override fun hashCode(): Int { + return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) + } + + override fun toString(): String { + return when { + insertProjectLogsEventReplace != null -> + "InsertProjectLogsEvent{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" + insertProjectLogsEventMerge != null -> + "InsertProjectLogsEvent{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" + _json != null -> "InsertProjectLogsEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InsertProjectLogsEvent") + } + } + + companion object { + + @JvmStatic + fun ofInsertProjectLogsEventReplace( + insertProjectLogsEventReplace: InsertProjectLogsEventReplace + ) = InsertProjectLogsEvent(insertProjectLogsEventReplace = insertProjectLogsEventReplace) + + @JvmStatic + fun ofInsertProjectLogsEventMerge( + insertProjectLogsEventMerge: InsertProjectLogsEventMerge + ) = InsertProjectLogsEvent(insertProjectLogsEventMerge = insertProjectLogsEventMerge) + } + + interface Visitor { + + fun visitInsertProjectLogsEventReplace( + insertProjectLogsEventReplace: InsertProjectLogsEventReplace + ): T + + fun visitInsertProjectLogsEventMerge( + insertProjectLogsEventMerge: InsertProjectLogsEventMerge + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown InsertProjectLogsEvent: $json") + } + } + + class Deserializer : BaseDeserializer(InsertProjectLogsEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InsertProjectLogsEvent { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InsertProjectLogsEvent(insertProjectLogsEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InsertProjectLogsEvent(insertProjectLogsEventMerge = it, _json = json) + } + + return InsertProjectLogsEvent(_json = json) + } + } + + class Serializer : BaseSerializer(InsertProjectLogsEvent::class) { + + override fun serialize( + value: InsertProjectLogsEvent, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.insertProjectLogsEventReplace != null -> + generator.writeObject(value.insertProjectLogsEventReplace) + value.insertProjectLogsEventMerge != null -> + generator.writeObject(value.insertProjectLogsEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InsertProjectLogsEvent") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt new file mode 100755 index 0000000..ed3b51b --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt @@ -0,0 +1,1428 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = InsertProjectLogsEventMerge.Builder::class) +@NoAutoDetect +class InsertProjectLogsEventMerge +private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. + */ + fun output(): JsonValue = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. + */ + fun expected(): JsonValue = expected + + /** The error that occurred, if any. */ + fun error(): JsonValue = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** The timestamp the project logs event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified + * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of + * field names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. + */ + @JsonProperty("output") @ExcludeMissing fun _output() = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error() = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + @JsonProperty("context") @ExcludeMissing fun _context() = context + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The timestamp the project logs event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs + */ + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified + * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of + * field names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertProjectLogsEventMerge = apply { + if (!validated) { + input() + output() + expected() + error() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertProjectLogsEventMerge && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var input: JsonValue = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var error: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var metrics: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var _objectDelete: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _mergePaths: JsonField>> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertProjectLogsEventMerge: InsertProjectLogsEventMerge) = apply { + this.input = insertProjectLogsEventMerge.input + this.output = insertProjectLogsEventMerge.output + this.expected = insertProjectLogsEventMerge.expected + this.error = insertProjectLogsEventMerge.error + this.scores = insertProjectLogsEventMerge.scores + this.metadata = insertProjectLogsEventMerge.metadata + this.tags = insertProjectLogsEventMerge.tags + this.metrics = insertProjectLogsEventMerge.metrics + this.context = insertProjectLogsEventMerge.context + this.spanAttributes = insertProjectLogsEventMerge.spanAttributes + this.id = insertProjectLogsEventMerge.id + this.created = insertProjectLogsEventMerge.created + this._objectDelete = insertProjectLogsEventMerge._objectDelete + this._isMerge = insertProjectLogsEventMerge._isMerge + this._mergePaths = insertProjectLogsEventMerge._mergePaths + additionalProperties(insertProjectLogsEventMerge.additionalProperties) + } + + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. + */ + @JsonProperty("output") + @ExcludeMissing + fun output(output: JsonValue) = apply { this.output = output } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** The error that occurred, if any. */ + @JsonProperty("error") + @ExcludeMissing + fun error(error: JsonValue) = apply { this.error = error } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + @JsonProperty("metrics") + @ExcludeMissing + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: Context) = context(JsonField.of(context)) + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + @JsonProperty("context") + @ExcludeMissing + fun context(context: JsonField) = apply { this.context = context } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** The timestamp the project logs event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the project logs event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") + @ExcludeMissing + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path + * is a list of field names. The deep merge will not descend below any of the specified + * merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + + /** + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path + * is a list of field names. The deep merge will not descend below any of the specified + * merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + @JsonProperty("_merge_paths") + @ExcludeMissing + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths + } + + 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(): InsertProjectLogsEventMerge = + InsertProjectLogsEventMerge( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + @JsonDeserialize(builder = Context.Builder::class) + @NoAutoDetect + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The function in code which created the project logs event */ + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) + + /** Line of code where the project logs event was created */ + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + + /** The function in code which created the project logs event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** Line of code where the project logs event was created */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Context = apply { + if (!validated) { + callerFunctionname() + callerFilename() + callerLineno() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var callerFunctionname: JsonField = JsonMissing.of() + private var callerFilename: JsonField = JsonMissing.of() + private var callerLineno: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(context: Context) = apply { + this.callerFunctionname = context.callerFunctionname + this.callerFilename = context.callerFilename + this.callerLineno = context.callerLineno + additionalProperties(context.additionalProperties) + } + + /** The function in code which created the project logs event */ + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) + + /** The function in code which created the project logs event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) + + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** Line of code where the project logs event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + + /** Line of code where the project logs event was created */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } + + 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(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + @JsonDeserialize(builder = Metrics.Builder::class) + @NoAutoDetect + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * finished + */ + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) + */ + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start() = start + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end() = end + + /** + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens() = completionTokens + + /** The total number of tokens in the input and output of the project logs event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metrics = apply { + if (!validated) { + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var start: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var tokens: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metrics: Metrics) = apply { + this.start = metrics.start + this.end = metrics.end + this.promptTokens = metrics.promptTokens + this.completionTokens = metrics.completionTokens + this.tokens = metrics.tokens + additionalProperties(metrics.additionalProperties) + } + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + fun start(start: Double) = start(JsonField.of(start)) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + @JsonProperty("start") + @ExcludeMissing + fun start(start: JsonField) = apply { this.start = start } + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event finished + */ + fun end(end: Double) = end(JsonField.of(end)) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event finished + */ + @JsonProperty("end") + @ExcludeMissing + fun end(end: JsonField) = apply { this.end = end } + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + + /** The total number of tokens in the input and output of the project logs event. */ + @JsonProperty("tokens") + @ExcludeMissing + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + + 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(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonDeserialize(builder = SpanAttributes.Builder::class) + @NoAutoDetect + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the span, for display purposes only */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of the span, for display purposes only */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Type of the span, for display purposes only */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanAttributes = apply { + if (!validated) { + name() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanAttributes: SpanAttributes) = apply { + this.name = spanAttributes.name + this.type = spanAttributes.type + additionalProperties(spanAttributes.additionalProperties) + } + + /** Name of the span, for display purposes only */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the span, for display purposes only */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of the span, for display purposes only */ + @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(): SpanAttributes = + SpanAttributes( + name, + 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 LLM = Type(JsonField.of("llm")) + + @JvmField val SCORE = Type(JsonField.of("score")) + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmField val EVAL = Type(JsonField.of("eval")) + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmField val TOOL = Type(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + enum class Value { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt new file mode 100755 index 0000000..26089ae --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt @@ -0,0 +1,1421 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = InsertProjectLogsEventReplace.Builder::class) +@NoAutoDetect +class InsertProjectLogsEventReplace +private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. + */ + fun output(): JsonValue = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. + */ + fun expected(): JsonValue = expected + + /** The error that occurred, if any. */ + fun error(): JsonValue = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** The timestamp the project logs event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be + * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for + * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + */ + fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. + */ + @JsonProperty("output") @ExcludeMissing fun _output() = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error() = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + @JsonProperty("context") @ExcludeMissing fun _context() = context + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The timestamp the project logs event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs + */ + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be + * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for + * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + */ + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertProjectLogsEventReplace = apply { + if (!validated) { + input() + output() + expected() + error() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertProjectLogsEventReplace && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var input: JsonValue = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var error: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var metrics: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var _objectDelete: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertProjectLogsEventReplace: InsertProjectLogsEventReplace) = apply { + this.input = insertProjectLogsEventReplace.input + this.output = insertProjectLogsEventReplace.output + this.expected = insertProjectLogsEventReplace.expected + this.error = insertProjectLogsEventReplace.error + this.scores = insertProjectLogsEventReplace.scores + this.metadata = insertProjectLogsEventReplace.metadata + this.tags = insertProjectLogsEventReplace.tags + this.metrics = insertProjectLogsEventReplace.metrics + this.context = insertProjectLogsEventReplace.context + this.spanAttributes = insertProjectLogsEventReplace.spanAttributes + this.id = insertProjectLogsEventReplace.id + this.created = insertProjectLogsEventReplace.created + this._objectDelete = insertProjectLogsEventReplace._objectDelete + this._isMerge = insertProjectLogsEventReplace._isMerge + this._parentId = insertProjectLogsEventReplace._parentId + additionalProperties(insertProjectLogsEventReplace.additionalProperties) + } + + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. + */ + @JsonProperty("output") + @ExcludeMissing + fun output(output: JsonValue) = apply { this.output = output } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** The error that occurred, if any. */ + @JsonProperty("error") + @ExcludeMissing + fun error(error: JsonValue) = apply { this.error = error } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + @JsonProperty("metrics") + @ExcludeMissing + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: Context) = context(JsonField.of(context)) + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + @JsonProperty("context") + @ExcludeMissing + fun context(context: JsonField) = apply { this.context = context } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** The timestamp the project logs event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the project logs event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") + @ExcludeMissing + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot + * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are + * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + */ + fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot + * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are + * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + */ + @JsonProperty("_parent_id") + @ExcludeMissing + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + + 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(): InsertProjectLogsEventReplace = + InsertProjectLogsEventReplace( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + @JsonDeserialize(builder = Context.Builder::class) + @NoAutoDetect + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The function in code which created the project logs event */ + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) + + /** Line of code where the project logs event was created */ + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + + /** The function in code which created the project logs event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** Line of code where the project logs event was created */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Context = apply { + if (!validated) { + callerFunctionname() + callerFilename() + callerLineno() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var callerFunctionname: JsonField = JsonMissing.of() + private var callerFilename: JsonField = JsonMissing.of() + private var callerLineno: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(context: Context) = apply { + this.callerFunctionname = context.callerFunctionname + this.callerFilename = context.callerFilename + this.callerLineno = context.callerLineno + additionalProperties(context.additionalProperties) + } + + /** The function in code which created the project logs event */ + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) + + /** The function in code which created the project logs event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) + + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** Line of code where the project logs event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + + /** Line of code where the project logs event was created */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } + + 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(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + @JsonDeserialize(builder = Metrics.Builder::class) + @NoAutoDetect + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * finished + */ + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) + */ + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start() = start + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end() = end + + /** + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens() = completionTokens + + /** The total number of tokens in the input and output of the project logs event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metrics = apply { + if (!validated) { + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var start: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var tokens: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metrics: Metrics) = apply { + this.start = metrics.start + this.end = metrics.end + this.promptTokens = metrics.promptTokens + this.completionTokens = metrics.completionTokens + this.tokens = metrics.tokens + additionalProperties(metrics.additionalProperties) + } + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + fun start(start: Double) = start(JsonField.of(start)) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + @JsonProperty("start") + @ExcludeMissing + fun start(start: JsonField) = apply { this.start = start } + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event finished + */ + fun end(end: Double) = end(JsonField.of(end)) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event finished + */ + @JsonProperty("end") + @ExcludeMissing + fun end(end: JsonField) = apply { this.end = end } + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + + /** The total number of tokens in the input and output of the project logs event. */ + @JsonProperty("tokens") + @ExcludeMissing + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + + 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(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonDeserialize(builder = SpanAttributes.Builder::class) + @NoAutoDetect + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the span, for display purposes only */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of the span, for display purposes only */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Type of the span, for display purposes only */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanAttributes = apply { + if (!validated) { + name() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanAttributes: SpanAttributes) = apply { + this.name = spanAttributes.name + this.type = spanAttributes.type + additionalProperties(spanAttributes.additionalProperties) + } + + /** Name of the span, for display purposes only */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the span, for display purposes only */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of the span, for display purposes only */ + @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(): SpanAttributes = + SpanAttributes( + name, + 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 LLM = Type(JsonField.of("llm")) + + @JvmField val SCORE = Type(JsonField.of("score")) + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmField val EVAL = Type(JsonField.of("eval")) + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmField val TOOL = Type(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + enum class Value { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequest.kt new file mode 100755 index 0000000..8d0c254 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequest.kt @@ -0,0 +1,112 @@ +// 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 = InsertProjectLogsEventRequest.Builder::class) +@NoAutoDetect +class InsertProjectLogsEventRequest +private constructor( + private val events: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** A list of project logs events to insert */ + fun events(): List = events.getRequired("events") + + /** A list of project logs events to insert */ + @JsonProperty("events") @ExcludeMissing fun _events() = events + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertProjectLogsEventRequest = apply { + if (!validated) { + events() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsertProjectLogsEventRequest && + this.events == other.events && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode + } + + override fun toString() = + "InsertProjectLogsEventRequest{events=$events, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var events: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertProjectLogsEventRequest: InsertProjectLogsEventRequest) = apply { + this.events = insertProjectLogsEventRequest.events + additionalProperties(insertProjectLogsEventRequest.additionalProperties) + } + + /** A list of project logs events to insert */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of project logs events to insert */ + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { this.events = events } + + 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(): InsertProjectLogsEventRequest = + InsertProjectLogsEventRequest( + events.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt new file mode 100755 index 0000000..5927af4 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -0,0 +1,223 @@ +// 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 +import java.util.Optional + +/** Summary of a metric's performance */ +@JsonDeserialize(builder = MetricSummary.Builder::class) +@NoAutoDetect +class MetricSummary +private constructor( + private val name: JsonField, + private val metric: JsonField, + private val unit: JsonField, + private val diff: JsonField, + private val improvements: JsonField, + private val regressions: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the metric */ + fun name(): String = name.getRequired("name") + + /** Average metric across all examples */ + fun metric(): Double = metric.getRequired("metric") + + /** Unit label for the metric */ + fun unit(): String = unit.getRequired("unit") + + /** Difference in metric between the current and comparison experiment */ + fun diff(): Optional = Optional.ofNullable(diff.getNullable("diff")) + + /** Number of improvements in the metric */ + fun improvements(): Long = improvements.getRequired("improvements") + + /** Number of regressions in the metric */ + fun regressions(): Long = regressions.getRequired("regressions") + + /** Name of the metric */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Average metric across all examples */ + @JsonProperty("metric") @ExcludeMissing fun _metric() = metric + + /** Unit label for the metric */ + @JsonProperty("unit") @ExcludeMissing fun _unit() = unit + + /** Difference in metric between the current and comparison experiment */ + @JsonProperty("diff") @ExcludeMissing fun _diff() = diff + + /** Number of improvements in the metric */ + @JsonProperty("improvements") @ExcludeMissing fun _improvements() = improvements + + /** Number of regressions in the metric */ + @JsonProperty("regressions") @ExcludeMissing fun _regressions() = regressions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MetricSummary = apply { + if (!validated) { + name() + metric() + unit() + diff() + improvements() + regressions() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricSummary && + this.name == other.name && + this.metric == other.metric && + this.unit == other.unit && + this.diff == other.diff && + this.improvements == other.improvements && + this.regressions == other.regressions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + metric, + unit, + diff, + improvements, + regressions, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "MetricSummary{name=$name, metric=$metric, unit=$unit, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var metric: JsonField = JsonMissing.of() + private var unit: JsonField = JsonMissing.of() + private var diff: JsonField = JsonMissing.of() + private var improvements: JsonField = JsonMissing.of() + private var regressions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricSummary: MetricSummary) = apply { + this.name = metricSummary.name + this.metric = metricSummary.metric + this.unit = metricSummary.unit + this.diff = metricSummary.diff + this.improvements = metricSummary.improvements + this.regressions = metricSummary.regressions + additionalProperties(metricSummary.additionalProperties) + } + + /** Name of the metric */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the metric */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Average metric across all examples */ + fun metric(metric: Double) = metric(JsonField.of(metric)) + + /** Average metric across all examples */ + @JsonProperty("metric") + @ExcludeMissing + fun metric(metric: JsonField) = apply { this.metric = metric } + + /** Unit label for the metric */ + fun unit(unit: String) = unit(JsonField.of(unit)) + + /** Unit label for the metric */ + @JsonProperty("unit") + @ExcludeMissing + fun unit(unit: JsonField) = apply { this.unit = unit } + + /** Difference in metric between the current and comparison experiment */ + fun diff(diff: Double) = diff(JsonField.of(diff)) + + /** Difference in metric between the current and comparison experiment */ + @JsonProperty("diff") + @ExcludeMissing + fun diff(diff: JsonField) = apply { this.diff = diff } + + /** Number of improvements in the metric */ + fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) + + /** Number of improvements in the metric */ + @JsonProperty("improvements") + @ExcludeMissing + fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + + /** Number of regressions in the metric */ + fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) + + /** Number of regressions in the metric */ + @JsonProperty("regressions") + @ExcludeMissing + fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + + 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(): MetricSummary = + MetricSummary( + name, + metric, + unit, + diff, + improvements, + regressions, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 0050b8e..b0f649a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -247,117 +236,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchDataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchDataset.kt new file mode 100755 index 0000000..ef6aed5 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchDataset.kt @@ -0,0 +1,233 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchDataset.Builder::class) +@NoAutoDetect +class PatchDataset +private constructor( + private val name: JsonField, + private val description: JsonField, + private val metadata: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the dataset */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** User-controlled metadata about the dataset */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Name of the dataset. Within a project, dataset names are unique */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the dataset */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** User-controlled metadata about the dataset */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchDataset = apply { + if (!validated) { + name() + description() + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchDataset && + this.name == other.name && + this.description == other.description && + this.metadata == other.metadata && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + metadata, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchDataset{name=$name, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchDataset: PatchDataset) = apply { + this.name = patchDataset.name + this.description = patchDataset.description + this.metadata = patchDataset.metadata + additionalProperties(patchDataset.additionalProperties) + } + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the dataset. Within a project, dataset names are unique */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the dataset */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the dataset */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** User-controlled metadata about the dataset */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + 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(): PatchDataset = + PatchDataset( + name, + description, + metadata, + additionalProperties.toUnmodifiable(), + ) + } + + /** User-controlled metadata about the dataset */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchExperiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchExperiment.kt new file mode 100755 index 0000000..60315d7 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchExperiment.kt @@ -0,0 +1,369 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchExperiment.Builder::class) +@NoAutoDetect +class PatchExperiment +private constructor( + private val name: JsonField, + private val description: JsonField, + private val repoInfo: JsonField, + private val baseExpId: JsonField, + private val datasetId: JsonField, + private val datasetVersion: JsonField, + private val public_: JsonField, + private val metadata: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the experiment */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) + + /** User-controlled metadata about the experiment */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Name of the experiment. Within a project, experiment names are unique */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the experiment */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo() = repoInfo + + /** Id of default base experiment to compare against when viewing this experiment */ + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId() = baseExpId + + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion() = datasetVersion + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + @JsonProperty("public") @ExcludeMissing fun _public_() = public_ + + /** User-controlled metadata about the experiment */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchExperiment = apply { + if (!validated) { + name() + description() + repoInfo().map { it.validate() } + baseExpId() + datasetId() + datasetVersion() + public_() + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchExperiment && + this.name == other.name && + this.description == other.description && + this.repoInfo == other.repoInfo && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.public_ == other.public_ && + this.metadata == other.metadata && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + repoInfo, + baseExpId, + datasetId, + datasetVersion, + public_, + metadata, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchExperiment{name=$name, description=$description, repoInfo=$repoInfo, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, metadata=$metadata, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var repoInfo: JsonField = JsonMissing.of() + private var baseExpId: JsonField = JsonMissing.of() + private var datasetId: JsonField = JsonMissing.of() + private var datasetVersion: JsonField = JsonMissing.of() + private var public_: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchExperiment: PatchExperiment) = apply { + this.name = patchExperiment.name + this.description = patchExperiment.description + this.repoInfo = patchExperiment.repoInfo + this.baseExpId = patchExperiment.baseExpId + this.datasetId = patchExperiment.datasetId + this.datasetVersion = patchExperiment.datasetVersion + this.public_ = patchExperiment.public_ + this.metadata = patchExperiment.metadata + additionalProperties(patchExperiment.additionalProperties) + } + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the experiment. Within a project, experiment names are unique */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the experiment */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the experiment */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo) = repoInfo(JsonField.of(repoInfo)) + + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") + @ExcludeMissing + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: String) = baseExpId(JsonField.of(baseExpId)) + + /** Id of default base experiment to compare against when viewing this experiment */ + @JsonProperty("base_exp_id") + @ExcludeMissing + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + @JsonProperty("dataset_id") + @ExcludeMissing + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: String) = datasetVersion(JsonField.of(datasetVersion)) + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + @JsonProperty("dataset_version") + @ExcludeMissing + fun datasetVersion(datasetVersion: JsonField) = apply { + this.datasetVersion = datasetVersion + } + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean) = public_(JsonField.of(public_)) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + @JsonProperty("public") + @ExcludeMissing + fun public_(public_: JsonField) = apply { this.public_ = public_ } + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** User-controlled metadata about the experiment */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + 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(): PatchExperiment = + PatchExperiment( + name, + description, + repoInfo, + baseExpId, + datasetId, + datasetVersion, + public_, + metadata, + additionalProperties.toUnmodifiable(), + ) + } + + /** User-controlled metadata about the experiment */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchFunction.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchFunction.kt new file mode 100755 index 0000000..d342ef3 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchFunction.kt @@ -0,0 +1,1687 @@ +// 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(builder = PatchFunction.Builder::class) +@NoAutoDetect +class PatchFunction +private constructor( + private val name: JsonField, + private val description: JsonField, + private val promptData: JsonField, + private val functionData: JsonField, + private val tags: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the prompt */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + fun functionData(): Optional = + Optional.ofNullable(functionData.getNullable("function_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the prompt */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + + @JsonProperty("function_data") @ExcludeMissing fun _functionData() = functionData + + /** A list of tags for the prompt */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchFunction = apply { + if (!validated) { + name() + description() + promptData().map { it.validate() } + functionData() + tags() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchFunction && + this.name == other.name && + this.description == other.description && + this.promptData == other.promptData && + this.functionData == other.functionData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + promptData, + functionData, + tags, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchFunction{name=$name, description=$description, promptData=$promptData, functionData=$functionData, tags=$tags, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var functionData: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchFunction: PatchFunction) = apply { + this.name = patchFunction.name + this.description = patchFunction.description + this.promptData = patchFunction.promptData + this.functionData = patchFunction.functionData + this.tags = patchFunction.tags + additionalProperties(patchFunction.additionalProperties) + } + + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the prompt */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the prompt */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") + @ExcludeMissing + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + + fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + + @JsonProperty("function_data") + @ExcludeMissing + fun functionData(functionData: JsonField) = apply { + this.functionData = functionData + } + + /** A list of tags for the prompt */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags for the prompt */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + 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(): PatchFunction = + PatchFunction( + name, + description, + promptData, + functionData, + tags.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = FunctionData.Deserializer::class) + @JsonSerialize(using = FunctionData.Serializer::class) + class FunctionData + private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun prompt(): Optional = Optional.ofNullable(prompt) + + fun code(): Optional = Optional.ofNullable(code) + + fun global(): Optional = Optional.ofNullable(global) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isPrompt(): Boolean = prompt != null + + fun isCode(): Boolean = code != null + + fun isGlobal(): Boolean = global != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asPrompt(): Prompt = prompt.getOrThrow("prompt") + + fun asCode(): Code = code.getOrThrow("code") + + fun asGlobal(): Global = global.getOrThrow("global") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } + } + + fun validate(): FunctionData = apply { + if (!validated) { + if (prompt == null && code == null && global == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + nullableVariant?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global && + this.nullableVariant == other.nullableVariant + } + + override fun hashCode(): Int { + return Objects.hash( + prompt, + code, + global, + nullableVariant, + ) + } + + override fun toString(): String { + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + nullableVariant != null -> "FunctionData{nullableVariant=$nullableVariant}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } + } + + companion object { + + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + + @JvmStatic + fun ofNullableVariant(nullableVariant: NullableVariant) = + FunctionData(nullableVariant = nullableVariant) + } + + interface Visitor { + + fun visitPrompt(prompt: Prompt): T + + fun visitCode(code: Code): T + + fun visitGlobal(global: Global): T + + fun visitNullableVariant(nullableVariant: NullableVariant): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown FunctionData: $json") + } + } + + class Deserializer : BaseDeserializer(FunctionData::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(nullableVariant = it, _json = json) + } + + return FunctionData(_json = json) + } + } + + class Serializer : BaseSerializer(FunctionData::class) { + + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } + } + } + + @JsonDeserialize(builder = Prompt.Builder::class) + @NoAutoDetect + class Prompt + 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(): Prompt = 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 Prompt && + 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() = + "Prompt{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(prompt: Prompt) = apply { + this.type = prompt.type + additionalProperties(prompt.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(): Prompt = Prompt(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 PROMPT = Type(JsonField.of("prompt")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + PROMPT, + } + + enum class Value { + PROMPT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = Code.Builder::class) + @NoAutoDetect + class Code + private constructor( + private val type: JsonField, + private val data: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun data(): Data = data.getRequired("data") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("data") @ExcludeMissing fun _data() = data + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Code = apply { + if (!validated) { + type() + data().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(code: Code) = apply { + this.type = code.type + this.data = code.data + additionalProperties(code.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun data(data: Data) = data(JsonField.of(data)) + + @JsonProperty("data") + @ExcludeMissing + fun data(data: JsonField) = apply { this.data = data } + + 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(): Code = + Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Data.Builder::class) + @NoAutoDetect + class Data + private constructor( + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + + fun location(): Location = location.getRequired("location") + + fun bundleId(): String = bundleId.getRequired("bundle_id") + + @JsonProperty("runtime_context") + @ExcludeMissing + fun _runtimeContext() = runtimeContext + + @JsonProperty("location") @ExcludeMissing fun _location() = location + + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Data = apply { + if (!validated) { + runtimeContext().validate() + location().validate() + bundleId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + runtimeContext, + location, + bundleId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var runtimeContext: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var bundleId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + this.runtimeContext = data.runtimeContext + this.location = data.location + this.bundleId = data.bundleId + additionalProperties(data.additionalProperties) + } + + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) + + @JsonProperty("runtime_context") + @ExcludeMissing + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } + + fun location(location: Location) = location(JsonField.of(location)) + + @JsonProperty("location") + @ExcludeMissing + fun location(location: JsonField) = apply { this.location = location } + + fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + + @JsonProperty("bundle_id") + @ExcludeMissing + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } + + 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(): Data = + Data( + runtimeContext, + location, + bundleId, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Location.Builder::class) + @NoAutoDetect + class Location + private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun evalName(): String = evalName.getRequired("eval_name") + + fun position(): Position = position.getRequired("position") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + + @JsonProperty("position") @ExcludeMissing fun _position() = position + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Location = apply { + if (!validated) { + type() + evalName() + position() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var evalName: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(location: Location) = apply { + this.type = location.type + this.evalName = location.evalName + this.position = location.position + additionalProperties(location.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + + @JsonProperty("eval_name") + @ExcludeMissing + fun evalName(evalName: JsonField) = apply { + this.evalName = evalName + } + + fun position(position: Position) = position(JsonField.of(position)) + + @JsonProperty("position") + @ExcludeMissing + fun position(position: JsonField) = apply { + this.position = position + } + + 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(): Location = + Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = Position.Deserializer::class) + @JsonSerialize(using = Position.Serializer::class) + class Position + private constructor( + private val task: Task? = null, + private val score: Score? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun task(): Optional = Optional.ofNullable(task) + + fun score(): Optional = Optional.ofNullable(score) + + fun isTask(): Boolean = task != null + + fun isScore(): Boolean = score != null + + fun asTask(): Task = task.getOrThrow("task") + + fun asScore(): Score = score.getOrThrow("score") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + task != null -> visitor.visitTask(task) + score != null -> visitor.visitScore(score) + else -> visitor.unknown(_json) + } + } + + fun validate(): Position = apply { + if (!validated) { + if (task == null && score == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + score?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Position && + this.task == other.task && + this.score == other.score + } + + override fun hashCode(): Int { + return Objects.hash(task, score) + } + + override fun toString(): String { + return when { + task != null -> "Position{task=$task}" + score != null -> "Position{score=$score}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } + } + + companion object { + + @JvmStatic fun ofTask(task: Task) = Position(task = task) + + @JvmStatic fun ofScore(score: Score) = Position(score = score) + } + + interface Visitor { + + fun visitTask(task: Task): T + + fun visitScore(score: Score): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Position: $json") + } + } + + class Deserializer : BaseDeserializer(Position::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Position { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Position(task = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(score = it, _json = json) + } + + return Position(_json = json) + } + } + + class Serializer : BaseSerializer(Position::class) { + + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.task != null -> generator.writeObject(value.task) + value.score != null -> generator.writeObject(value.score) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } + } + } + + class Task + @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 Task && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TASK = Task(JsonField.of("task")) + + @JvmStatic fun of(value: String) = Task(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 Task: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = Score.Builder::class) + @NoAutoDetect + class Score + private constructor( + private val score: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun score(): Double = score.getRequired("score") + + @JsonProperty("score") @ExcludeMissing fun _score() = score + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Score = apply { + if (!validated) { + score() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && + this.score == other.score && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(score, additionalProperties) + } + return hashCode + } + + override fun toString() = + "Score{score=$score, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var score: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(score: Score) = apply { + this.score = score.score + additionalProperties(score.additionalProperties) + } + + fun score(score: Double) = score(JsonField.of(score)) + + @JsonProperty("score") + @ExcludeMissing + fun score(score: JsonField) = apply { this.score = score } + + 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(): Score = + Score(score, 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 EXPERIMENT = Type(JsonField.of("experiment")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + } + + enum class Value { + EXPERIMENT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = RuntimeContext.Builder::class) + @NoAutoDetect + class RuntimeContext + private constructor( + private val runtime: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun runtime(): Runtime = runtime.getRequired("runtime") + + fun version(): String = version.getRequired("version") + + @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RuntimeContext = apply { + if (!validated) { + runtime() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var runtime: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(runtimeContext: RuntimeContext) = apply { + this.runtime = runtimeContext.runtime + this.version = runtimeContext.version + additionalProperties(runtimeContext.additionalProperties) + } + + fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + + @JsonProperty("runtime") + @ExcludeMissing + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + + fun version(version: String) = version(JsonField.of(version)) + + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + 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(): RuntimeContext = + RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) + } + + class Runtime + @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 Runtime && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val NODE = Runtime(JsonField.of("node")) + + @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) + } + + enum class Known { + NODE, + } + + enum class Value { + NODE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + NODE -> Value.NODE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + NODE -> Known.NODE + else -> + throw BraintrustInvalidDataException("Unknown Runtime: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + } + + 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 CODE = Type(JsonField.of("code")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + CODE, + } + + enum class Value { + CODE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = Global.Builder::class) + @NoAutoDetect + class Global + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun name(): String = name.getRequired("name") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Global = apply { + if (!validated) { + type() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(global: Global) = apply { + this.type = global.type + this.name = global.name + additionalProperties(global.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + 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(): Global = + Global( + type, + 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 GLOBAL = Type(JsonField.of("global")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + GLOBAL, + } + + enum class Value { + GLOBAL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = NullableVariant.Builder::class) + @NoAutoDetect + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): NullableVariant = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NullableVariant && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) + } + + 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(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchGroup.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchGroup.kt new file mode 100755 index 0000000..9e1c5a1 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchGroup.kt @@ -0,0 +1,243 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchGroup.Builder::class) +@NoAutoDetect +class PatchGroup +private constructor( + private val description: JsonField, + private val name: JsonField, + private val addMemberUsers: JsonField>, + private val removeMemberUsers: JsonField>, + private val addMemberGroups: JsonField>, + private val removeMemberGroups: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Textual description of the group */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the group */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** A list of user IDs to add to the group */ + fun addMemberUsers(): Optional> = + Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) + + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(): Optional> = + Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) + + /** A list of group IDs to add to the group's inheriting-from set */ + fun addMemberGroups(): Optional> = + Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(): Optional> = + Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) + + /** Textual description of the group */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** Name of the group */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** A list of user IDs to add to the group */ + @JsonProperty("add_member_users") @ExcludeMissing fun _addMemberUsers() = addMemberUsers + + /** A list of user IDs to remove from the group */ + @JsonProperty("remove_member_users") + @ExcludeMissing + fun _removeMemberUsers() = removeMemberUsers + + /** A list of group IDs to add to the group's inheriting-from set */ + @JsonProperty("add_member_groups") @ExcludeMissing fun _addMemberGroups() = addMemberGroups + + /** A list of group IDs to remove from the group's inheriting-from set */ + @JsonProperty("remove_member_groups") + @ExcludeMissing + fun _removeMemberGroups() = removeMemberGroups + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchGroup = apply { + if (!validated) { + description() + name() + addMemberUsers() + removeMemberUsers() + addMemberGroups() + removeMemberGroups() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchGroup && + this.description == other.description && + this.name == other.name && + this.addMemberUsers == other.addMemberUsers && + this.removeMemberUsers == other.removeMemberUsers && + this.addMemberGroups == other.addMemberGroups && + this.removeMemberGroups == other.removeMemberGroups && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + description, + name, + addMemberUsers, + removeMemberUsers, + addMemberGroups, + removeMemberGroups, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchGroup{description=$description, name=$name, addMemberUsers=$addMemberUsers, removeMemberUsers=$removeMemberUsers, addMemberGroups=$addMemberGroups, removeMemberGroups=$removeMemberGroups, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var addMemberUsers: JsonField> = JsonMissing.of() + private var removeMemberUsers: JsonField> = JsonMissing.of() + private var addMemberGroups: JsonField> = JsonMissing.of() + private var removeMemberGroups: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchGroup: PatchGroup) = apply { + this.description = patchGroup.description + this.name = patchGroup.name + this.addMemberUsers = patchGroup.addMemberUsers + this.removeMemberUsers = patchGroup.removeMemberUsers + this.addMemberGroups = patchGroup.addMemberGroups + this.removeMemberGroups = patchGroup.removeMemberGroups + additionalProperties(patchGroup.additionalProperties) + } + + /** Textual description of the group */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the group */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** Name of the group */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the group */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** A list of user IDs to add to the group */ + fun addMemberUsers(addMemberUsers: List) = + addMemberUsers(JsonField.of(addMemberUsers)) + + /** A list of user IDs to add to the group */ + @JsonProperty("add_member_users") + @ExcludeMissing + fun addMemberUsers(addMemberUsers: JsonField>) = apply { + this.addMemberUsers = addMemberUsers + } + + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(removeMemberUsers: List) = + removeMemberUsers(JsonField.of(removeMemberUsers)) + + /** A list of user IDs to remove from the group */ + @JsonProperty("remove_member_users") + @ExcludeMissing + fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { + this.removeMemberUsers = removeMemberUsers + } + + /** A list of group IDs to add to the group's inheriting-from set */ + fun addMemberGroups(addMemberGroups: List) = + addMemberGroups(JsonField.of(addMemberGroups)) + + /** A list of group IDs to add to the group's inheriting-from set */ + @JsonProperty("add_member_groups") + @ExcludeMissing + fun addMemberGroups(addMemberGroups: JsonField>) = apply { + this.addMemberGroups = addMemberGroups + } + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(removeMemberGroups: List) = + removeMemberGroups(JsonField.of(removeMemberGroups)) + + /** A list of group IDs to remove from the group's inheriting-from set */ + @JsonProperty("remove_member_groups") + @ExcludeMissing + fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { + this.removeMemberGroups = removeMemberGroups + } + + 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(): PatchGroup = + PatchGroup( + description, + name, + addMemberUsers.map { it.toUnmodifiable() }, + removeMemberUsers.map { it.toUnmodifiable() }, + addMemberGroups.map { it.toUnmodifiable() }, + removeMemberGroups.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganization.kt new file mode 100755 index 0000000..329e532 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganization.kt @@ -0,0 +1,189 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchOrganization.Builder::class) +@NoAutoDetect +class PatchOrganization +private constructor( + private val name: JsonField, + private val apiUrl: JsonField, + private val isUniversalApi: JsonField, + private val proxyUrl: JsonField, + private val realtimeUrl: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the organization */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) + + fun isUniversalApi(): Optional = + Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + + fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) + + fun realtimeUrl(): Optional = + Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + + /** Name of the organization */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("api_url") @ExcludeMissing fun _apiUrl() = apiUrl + + @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi() = isUniversalApi + + @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl() = proxyUrl + + @JsonProperty("realtime_url") @ExcludeMissing fun _realtimeUrl() = realtimeUrl + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchOrganization = apply { + if (!validated) { + name() + apiUrl() + isUniversalApi() + proxyUrl() + realtimeUrl() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchOrganization && + this.name == other.name && + this.apiUrl == other.apiUrl && + this.isUniversalApi == other.isUniversalApi && + this.proxyUrl == other.proxyUrl && + this.realtimeUrl == other.realtimeUrl && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + apiUrl, + isUniversalApi, + proxyUrl, + realtimeUrl, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchOrganization{name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var apiUrl: JsonField = JsonMissing.of() + private var isUniversalApi: JsonField = JsonMissing.of() + private var proxyUrl: JsonField = JsonMissing.of() + private var realtimeUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchOrganization: PatchOrganization) = apply { + this.name = patchOrganization.name + this.apiUrl = patchOrganization.apiUrl + this.isUniversalApi = patchOrganization.isUniversalApi + this.proxyUrl = patchOrganization.proxyUrl + this.realtimeUrl = patchOrganization.realtimeUrl + additionalProperties(patchOrganization.additionalProperties) + } + + /** Name of the organization */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the organization */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun apiUrl(apiUrl: String) = apiUrl(JsonField.of(apiUrl)) + + @JsonProperty("api_url") + @ExcludeMissing + fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + + fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(JsonField.of(isUniversalApi)) + + @JsonProperty("is_universal_api") + @ExcludeMissing + fun isUniversalApi(isUniversalApi: JsonField) = apply { + this.isUniversalApi = isUniversalApi + } + + fun proxyUrl(proxyUrl: String) = proxyUrl(JsonField.of(proxyUrl)) + + @JsonProperty("proxy_url") + @ExcludeMissing + fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + + fun realtimeUrl(realtimeUrl: String) = realtimeUrl(JsonField.of(realtimeUrl)) + + @JsonProperty("realtime_url") + @ExcludeMissing + fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } + + 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(): PatchOrganization = + PatchOrganization( + name, + apiUrl, + isUniversalApi, + proxyUrl, + realtimeUrl, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembers.kt new file mode 100755 index 0000000..832c3f9 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembers.kt @@ -0,0 +1,557 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchOrganizationMembers.Builder::class) +@NoAutoDetect +class PatchOrganizationMembers +private constructor( + private val inviteUsers: JsonField, + private val removeUsers: JsonField, + private val orgName: JsonField, + private val orgId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Users to invite to the organization */ + fun inviteUsers(): Optional = + Optional.ofNullable(inviteUsers.getNullable("invite_users")) + + /** Users to remove from the organization */ + fun removeUsers(): Optional = + Optional.ofNullable(removeUsers.getNullable("remove_users")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the name of the organization. + */ + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the id of the organization. + */ + fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) + + /** Users to invite to the organization */ + @JsonProperty("invite_users") @ExcludeMissing fun _inviteUsers() = inviteUsers + + /** Users to remove from the organization */ + @JsonProperty("remove_users") @ExcludeMissing fun _removeUsers() = removeUsers + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the name of the organization. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName() = orgName + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the id of the organization. + */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchOrganizationMembers = apply { + if (!validated) { + inviteUsers().map { it.validate() } + removeUsers().map { it.validate() } + orgName() + orgId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchOrganizationMembers && + this.inviteUsers == other.inviteUsers && + this.removeUsers == other.removeUsers && + this.orgName == other.orgName && + this.orgId == other.orgId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + inviteUsers, + removeUsers, + orgName, + orgId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchOrganizationMembers{inviteUsers=$inviteUsers, removeUsers=$removeUsers, orgName=$orgName, orgId=$orgId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var inviteUsers: JsonField = JsonMissing.of() + private var removeUsers: JsonField = JsonMissing.of() + private var orgName: JsonField = JsonMissing.of() + private var orgId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchOrganizationMembers: PatchOrganizationMembers) = apply { + this.inviteUsers = patchOrganizationMembers.inviteUsers + this.removeUsers = patchOrganizationMembers.removeUsers + this.orgName = patchOrganizationMembers.orgName + this.orgId = patchOrganizationMembers.orgId + additionalProperties(patchOrganizationMembers.additionalProperties) + } + + /** Users to invite to the organization */ + fun inviteUsers(inviteUsers: InviteUsers) = inviteUsers(JsonField.of(inviteUsers)) + + /** Users to invite to the organization */ + @JsonProperty("invite_users") + @ExcludeMissing + fun inviteUsers(inviteUsers: JsonField) = apply { + this.inviteUsers = inviteUsers + } + + /** Users to remove from the organization */ + fun removeUsers(removeUsers: RemoveUsers) = removeUsers(JsonField.of(removeUsers)) + + /** Users to remove from the organization */ + @JsonProperty("remove_users") + @ExcludeMissing + fun removeUsers(removeUsers: JsonField) = apply { + this.removeUsers = removeUsers + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. + */ + fun orgName(orgName: String) = orgName(JsonField.of(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. + */ + @JsonProperty("org_name") + @ExcludeMissing + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. + */ + fun orgId(orgId: String) = orgId(JsonField.of(orgId)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. + */ + @JsonProperty("org_id") + @ExcludeMissing + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + + 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(): PatchOrganizationMembers = + PatchOrganizationMembers( + inviteUsers, + removeUsers, + orgName, + orgId, + additionalProperties.toUnmodifiable(), + ) + } + + /** Users to invite to the organization */ + @JsonDeserialize(builder = InviteUsers.Builder::class) + @NoAutoDetect + class InviteUsers + private constructor( + private val ids: JsonField>, + private val emails: JsonField>, + private val sendInviteEmails: JsonField, + private val groupId: JsonField, + private val groupName: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Ids of existing users to invite */ + fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) + + /** Emails of users to invite */ + fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) + + /** If true, send invite emails to the users who wore actually added */ + fun sendInviteEmails(): Optional = + Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) + + /** + * Optional id of a group to add newly-invited users to. Cannot specify both a group id and + * a group name. + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** + * Optional name of a group to add newly-invited users to. Cannot specify both a group id + * and a group name. + */ + fun groupName(): Optional = Optional.ofNullable(groupName.getNullable("group_name")) + + /** Ids of existing users to invite */ + @JsonProperty("ids") @ExcludeMissing fun _ids() = ids + + /** Emails of users to invite */ + @JsonProperty("emails") @ExcludeMissing fun _emails() = emails + + /** If true, send invite emails to the users who wore actually added */ + @JsonProperty("send_invite_emails") + @ExcludeMissing + fun _sendInviteEmails() = sendInviteEmails + + /** + * Optional id of a group to add newly-invited users to. Cannot specify both a group id and + * a group name. + */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId() = groupId + + /** + * Optional name of a group to add newly-invited users to. Cannot specify both a group id + * and a group name. + */ + @JsonProperty("group_name") @ExcludeMissing fun _groupName() = groupName + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InviteUsers = apply { + if (!validated) { + ids() + emails() + sendInviteEmails() + groupId() + groupName() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InviteUsers && + this.ids == other.ids && + this.emails == other.emails && + this.sendInviteEmails == other.sendInviteEmails && + this.groupId == other.groupId && + this.groupName == other.groupName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + ids, + emails, + sendInviteEmails, + groupId, + groupName, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var ids: JsonField> = JsonMissing.of() + private var emails: JsonField> = JsonMissing.of() + private var sendInviteEmails: JsonField = JsonMissing.of() + private var groupId: JsonField = JsonMissing.of() + private var groupName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inviteUsers: InviteUsers) = apply { + this.ids = inviteUsers.ids + this.emails = inviteUsers.emails + this.sendInviteEmails = inviteUsers.sendInviteEmails + this.groupId = inviteUsers.groupId + this.groupName = inviteUsers.groupName + additionalProperties(inviteUsers.additionalProperties) + } + + /** Ids of existing users to invite */ + fun ids(ids: List) = ids(JsonField.of(ids)) + + /** Ids of existing users to invite */ + @JsonProperty("ids") + @ExcludeMissing + fun ids(ids: JsonField>) = apply { this.ids = ids } + + /** Emails of users to invite */ + fun emails(emails: List) = emails(JsonField.of(emails)) + + /** Emails of users to invite */ + @JsonProperty("emails") + @ExcludeMissing + fun emails(emails: JsonField>) = apply { this.emails = emails } + + /** If true, send invite emails to the users who wore actually added */ + fun sendInviteEmails(sendInviteEmails: Boolean) = + sendInviteEmails(JsonField.of(sendInviteEmails)) + + /** If true, send invite emails to the users who wore actually added */ + @JsonProperty("send_invite_emails") + @ExcludeMissing + fun sendInviteEmails(sendInviteEmails: JsonField) = apply { + this.sendInviteEmails = sendInviteEmails + } + + /** + * Optional id of a group to add newly-invited users to. Cannot specify both a group id + * and a group name. + */ + fun groupId(groupId: String) = groupId(JsonField.of(groupId)) + + /** + * Optional id of a group to add newly-invited users to. Cannot specify both a group id + * and a group name. + */ + @JsonProperty("group_id") + @ExcludeMissing + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** + * Optional name of a group to add newly-invited users to. Cannot specify both a group + * id and a group name. + */ + fun groupName(groupName: String) = groupName(JsonField.of(groupName)) + + /** + * Optional name of a group to add newly-invited users to. Cannot specify both a group + * id and a group name. + */ + @JsonProperty("group_name") + @ExcludeMissing + fun groupName(groupName: JsonField) = apply { this.groupName = groupName } + + 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(): InviteUsers = + InviteUsers( + ids.map { it.toUnmodifiable() }, + emails.map { it.toUnmodifiable() }, + sendInviteEmails, + groupId, + groupName, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** Users to remove from the organization */ + @JsonDeserialize(builder = RemoveUsers.Builder::class) + @NoAutoDetect + class RemoveUsers + private constructor( + private val ids: JsonField>, + private val emails: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Ids of users to remove */ + fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) + + /** Emails of users to remove */ + fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) + + /** Ids of users to remove */ + @JsonProperty("ids") @ExcludeMissing fun _ids() = ids + + /** Emails of users to remove */ + @JsonProperty("emails") @ExcludeMissing fun _emails() = emails + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RemoveUsers = apply { + if (!validated) { + ids() + emails() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveUsers && + this.ids == other.ids && + this.emails == other.emails && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + ids, + emails, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var ids: JsonField> = JsonMissing.of() + private var emails: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeUsers: RemoveUsers) = apply { + this.ids = removeUsers.ids + this.emails = removeUsers.emails + additionalProperties(removeUsers.additionalProperties) + } + + /** Ids of users to remove */ + fun ids(ids: List) = ids(JsonField.of(ids)) + + /** Ids of users to remove */ + @JsonProperty("ids") + @ExcludeMissing + fun ids(ids: JsonField>) = apply { this.ids = ids } + + /** Emails of users to remove */ + fun emails(emails: List) = emails(JsonField.of(emails)) + + /** Emails of users to remove */ + @JsonProperty("emails") + @ExcludeMissing + fun emails(emails: JsonField>) = apply { this.emails = emails } + + 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(): RemoveUsers = + RemoveUsers( + ids.map { it.toUnmodifiable() }, + emails.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProject.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProject.kt new file mode 100755 index 0000000..6f43ee8 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProject.kt @@ -0,0 +1,250 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchProject.Builder::class) +@NoAutoDetect +class PatchProject +private constructor( + private val name: JsonField, + private val settings: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the project */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) + + /** Name of the project */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + @JsonProperty("settings") @ExcludeMissing fun _settings() = settings + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchProject = apply { + if (!validated) { + name() + settings().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchProject && + this.name == other.name && + this.settings == other.settings && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + settings, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchProject{name=$name, settings=$settings, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var settings: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchProject: PatchProject) = apply { + this.name = patchProject.name + this.settings = patchProject.settings + additionalProperties(patchProject.additionalProperties) + } + + /** Name of the project */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun settings(settings: Settings) = settings(JsonField.of(settings)) + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + @JsonProperty("settings") + @ExcludeMissing + fun settings(settings: JsonField) = apply { this.settings = settings } + + 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(): PatchProject = + PatchProject( + name, + settings, + additionalProperties.toUnmodifiable(), + ) + } + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + @JsonDeserialize(builder = Settings.Builder::class) + @NoAutoDetect + class Settings + private constructor( + private val comparisonKey: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The key used to join two experiments (defaults to `input`). */ + fun comparisonKey(): Optional = + Optional.ofNullable(comparisonKey.getNullable("comparison_key")) + + /** The key used to join two experiments (defaults to `input`). */ + @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey() = comparisonKey + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Settings = apply { + if (!validated) { + comparisonKey() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Settings && + this.comparisonKey == other.comparisonKey && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(comparisonKey, additionalProperties) + } + return hashCode + } + + override fun toString() = + "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var comparisonKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(settings: Settings) = apply { + this.comparisonKey = settings.comparisonKey + additionalProperties(settings.additionalProperties) + } + + /** The key used to join two experiments (defaults to `input`). */ + fun comparisonKey(comparisonKey: String) = comparisonKey(JsonField.of(comparisonKey)) + + /** The key used to join two experiments (defaults to `input`). */ + @JsonProperty("comparison_key") + @ExcludeMissing + fun comparisonKey(comparisonKey: JsonField) = apply { + this.comparisonKey = comparisonKey + } + + 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(): Settings = Settings(comparisonKey, additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectScore.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectScore.kt new file mode 100755 index 0000000..92de170 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectScore.kt @@ -0,0 +1,587 @@ +// 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(builder = PatchProjectScore.Builder::class) +@NoAutoDetect +class PatchProjectScore +private constructor( + private val name: JsonField, + private val description: JsonField, + private val scoreType: JsonField, + private val categories: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the project score */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the project score */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The type of the configured score */ + fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) + + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) + + /** Name of the project score */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the project score */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** The type of the configured score */ + @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType + + @JsonProperty("categories") @ExcludeMissing fun _categories() = categories + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchProjectScore = apply { + if (!validated) { + name() + description() + scoreType() + categories() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchProjectScore && + this.name == other.name && + this.description == other.description && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + scoreType, + categories, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchProjectScore{name=$name, description=$description, scoreType=$scoreType, categories=$categories, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var scoreType: JsonField = JsonMissing.of() + private var categories: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchProjectScore: PatchProjectScore) = apply { + this.name = patchProjectScore.name + this.description = patchProjectScore.description + this.scoreType = patchProjectScore.scoreType + this.categories = patchProjectScore.categories + additionalProperties(patchProjectScore.additionalProperties) + } + + /** Name of the project score */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project score */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the project score */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the project score */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** The type of the configured score */ + fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + + /** The type of the configured score */ + @JsonProperty("score_type") + @ExcludeMissing + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + + fun categories(categories: Categories) = categories(JsonField.of(categories)) + + @JsonProperty("categories") + @ExcludeMissing + fun categories(categories: JsonField) = apply { this.categories = categories } + + 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(): PatchProjectScore = + PatchProjectScore( + name, + description, + scoreType, + categories, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = Categories.Deserializer::class) + @JsonSerialize(using = Categories.Serializer::class) + class Categories + private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** For categorical-type project scores, the list of all categories */ + fun projectScoreCategories(): Optional> = + Optional.ofNullable(projectScoreCategories) + /** For weighted-type project scores, the weights of each score */ + fun weighted(): Optional = Optional.ofNullable(weighted) + /** For minimum-type project scores, the list of included scores */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isProjectScoreCategories(): Boolean = projectScoreCategories != null + + fun isWeighted(): Boolean = weighted != null + + fun isStrings(): Boolean = strings != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asProjectScoreCategories(): List = + projectScoreCategories.getOrThrow("projectScoreCategories") + + fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + projectScoreCategories != null -> + visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } + } + + fun validate(): Categories = apply { + if (!validated) { + if ( + projectScoreCategories == null && + weighted == null && + strings == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant + } + + override fun hashCode(): Int { + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) + } + + override fun toString(): String { + return when { + projectScoreCategories != null -> + "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } + } + + companion object { + + @JvmStatic + fun ofProjectScoreCategories(projectScoreCategories: List) = + Categories(projectScoreCategories = projectScoreCategories) + + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + + @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) + + @JvmStatic + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) + } + + interface Visitor { + + fun visitProjectScoreCategories(projectScoreCategories: List): T + + fun visitWeighted(weighted: Weighted): T + + fun visitStrings(strings: List): T + + fun visitNullableVariant(nullableVariant: NullableVariant): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Categories: $json") + } + } + + class Deserializer : BaseDeserializer(Categories::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Categories { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) + } + } + + class Serializer : BaseSerializer(Categories::class) { + + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.projectScoreCategories != null -> + generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } + } + } + + /** For weighted-type project scores, the weights of each score */ + @JsonDeserialize(builder = Weighted.Builder::class) + @NoAutoDetect + class Weighted + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Weighted = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Weighted && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(weighted: Weighted) = apply { + additionalProperties(weighted.additionalProperties) + } + + 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(): Weighted = Weighted(additionalProperties.toUnmodifiable()) + } + } + + @JsonDeserialize(builder = NullableVariant.Builder::class) + @NoAutoDetect + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): NullableVariant = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NullableVariant && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) + } + + 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(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) + } + } + } + + 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")) + + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectTag.kt new file mode 100755 index 0000000..cbb5574 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectTag.kt @@ -0,0 +1,160 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchProjectTag.Builder::class) +@NoAutoDetect +class PatchProjectTag +private constructor( + private val name: JsonField, + private val description: JsonField, + private val color: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the project tag */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the project tag */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Color of the tag for the UI */ + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) + + /** Name of the project tag */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the project tag */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** Color of the tag for the UI */ + @JsonProperty("color") @ExcludeMissing fun _color() = color + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchProjectTag = apply { + if (!validated) { + name() + description() + color() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchProjectTag && + this.name == other.name && + this.description == other.description && + this.color == other.color && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + color, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchProjectTag{name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var color: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchProjectTag: PatchProjectTag) = apply { + this.name = patchProjectTag.name + this.description = patchProjectTag.description + this.color = patchProjectTag.color + additionalProperties(patchProjectTag.additionalProperties) + } + + /** Name of the project tag */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project tag */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the project tag */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the project tag */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** Color of the tag for the UI */ + fun color(color: String) = color(JsonField.of(color)) + + /** Color of the tag for the UI */ + @JsonProperty("color") + @ExcludeMissing + fun color(color: JsonField) = apply { this.color = color } + + 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(): PatchProjectTag = + PatchProjectTag( + name, + description, + color, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchPrompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchPrompt.kt new file mode 100755 index 0000000..327cfbe --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchPrompt.kt @@ -0,0 +1,182 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchPrompt.Builder::class) +@NoAutoDetect +class PatchPrompt +private constructor( + private val name: JsonField, + private val description: JsonField, + private val promptData: JsonField, + private val tags: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the prompt */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the prompt */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + + /** A list of tags for the prompt */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchPrompt = apply { + if (!validated) { + name() + description() + promptData().map { it.validate() } + tags() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchPrompt && + this.name == other.name && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + promptData, + tags, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchPrompt{name=$name, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchPrompt: PatchPrompt) = apply { + this.name = patchPrompt.name + this.description = patchPrompt.description + this.promptData = patchPrompt.promptData + this.tags = patchPrompt.tags + additionalProperties(patchPrompt.additionalProperties) + } + + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the prompt */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the prompt */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) + + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") + @ExcludeMissing + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + + /** A list of tags for the prompt */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags for the prompt */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + 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(): PatchPrompt = + PatchPrompt( + name, + description, + promptData, + tags.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchRole.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchRole.kt new file mode 100755 index 0000000..051f14e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchRole.kt @@ -0,0 +1,958 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchRole.Builder::class) +@NoAutoDetect +class PatchRole +private constructor( + private val description: JsonField, + private val name: JsonField, + private val addMemberPermissions: JsonField>, + private val removeMemberPermissions: JsonField>, + private val addMemberRoles: JsonField>, + private val removeMemberRoles: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Textual description of the role */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the role */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** A list of permissions to add to the role */ + fun addMemberPermissions(): Optional> = + Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) + + /** A list of permissions to remove from the role */ + fun removeMemberPermissions(): Optional> = + Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) + + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(): Optional> = + Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(): Optional> = + Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) + + /** Textual description of the role */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** Name of the role */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** A list of permissions to add to the role */ + @JsonProperty("add_member_permissions") + @ExcludeMissing + fun _addMemberPermissions() = addMemberPermissions + + /** A list of permissions to remove from the role */ + @JsonProperty("remove_member_permissions") + @ExcludeMissing + fun _removeMemberPermissions() = removeMemberPermissions + + /** A list of role IDs to add to the role's inheriting-from set */ + @JsonProperty("add_member_roles") @ExcludeMissing fun _addMemberRoles() = addMemberRoles + + /** A list of role IDs to remove from the role's inheriting-from set */ + @JsonProperty("remove_member_roles") + @ExcludeMissing + fun _removeMemberRoles() = removeMemberRoles + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchRole = apply { + if (!validated) { + description() + name() + addMemberPermissions().map { it.forEach { it.validate() } } + removeMemberPermissions().map { it.forEach { it.validate() } } + addMemberRoles() + removeMemberRoles() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchRole && + this.description == other.description && + this.name == other.name && + this.addMemberPermissions == other.addMemberPermissions && + this.removeMemberPermissions == other.removeMemberPermissions && + this.addMemberRoles == other.addMemberRoles && + this.removeMemberRoles == other.removeMemberRoles && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + description, + name, + addMemberPermissions, + removeMemberPermissions, + addMemberRoles, + removeMemberRoles, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchRole{description=$description, name=$name, addMemberPermissions=$addMemberPermissions, removeMemberPermissions=$removeMemberPermissions, addMemberRoles=$addMemberRoles, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var addMemberPermissions: JsonField> = JsonMissing.of() + private var removeMemberPermissions: JsonField> = + JsonMissing.of() + private var addMemberRoles: JsonField> = JsonMissing.of() + private var removeMemberRoles: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchRole: PatchRole) = apply { + this.description = patchRole.description + this.name = patchRole.name + this.addMemberPermissions = patchRole.addMemberPermissions + this.removeMemberPermissions = patchRole.removeMemberPermissions + this.addMemberRoles = patchRole.addMemberRoles + this.removeMemberRoles = patchRole.removeMemberRoles + additionalProperties(patchRole.additionalProperties) + } + + /** Textual description of the role */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the role */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** Name of the role */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the role */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** A list of permissions to add to the role */ + fun addMemberPermissions(addMemberPermissions: List) = + addMemberPermissions(JsonField.of(addMemberPermissions)) + + /** A list of permissions to add to the role */ + @JsonProperty("add_member_permissions") + @ExcludeMissing + fun addMemberPermissions(addMemberPermissions: JsonField>) = + apply { + this.addMemberPermissions = addMemberPermissions + } + + /** A list of permissions to remove from the role */ + fun removeMemberPermissions(removeMemberPermissions: List) = + removeMemberPermissions(JsonField.of(removeMemberPermissions)) + + /** A list of permissions to remove from the role */ + @JsonProperty("remove_member_permissions") + @ExcludeMissing + fun removeMemberPermissions( + removeMemberPermissions: JsonField> + ) = apply { this.removeMemberPermissions = removeMemberPermissions } + + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(addMemberRoles: List) = + addMemberRoles(JsonField.of(addMemberRoles)) + + /** A list of role IDs to add to the role's inheriting-from set */ + @JsonProperty("add_member_roles") + @ExcludeMissing + fun addMemberRoles(addMemberRoles: JsonField>) = apply { + this.addMemberRoles = addMemberRoles + } + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(removeMemberRoles: List) = + removeMemberRoles(JsonField.of(removeMemberRoles)) + + /** A list of role IDs to remove from the role's inheriting-from set */ + @JsonProperty("remove_member_roles") + @ExcludeMissing + fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { + this.removeMemberRoles = removeMemberRoles + } + + 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(): PatchRole = + PatchRole( + description, + name, + addMemberPermissions.map { it.toUnmodifiable() }, + removeMemberPermissions.map { it.toUnmodifiable() }, + addMemberRoles.map { it.toUnmodifiable() }, + removeMemberRoles.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = AddMemberPermission.Builder::class) + @NoAutoDetect + class AddMemberPermission + private constructor( + private val permission: JsonField, + private val restrictObjectType: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into roles + */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** The object type that the ACL applies to */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into roles + */ + @JsonProperty("permission") @ExcludeMissing fun _permission() = permission + + /** The object type that the ACL applies to */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun _restrictObjectType() = restrictObjectType + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AddMemberPermission = apply { + if (!validated) { + permission() + restrictObjectType() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddMemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var permission: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addMemberPermission: AddMemberPermission) = apply { + this.permission = addMemberPermission.permission + this.restrictObjectType = addMemberPermission.restrictObjectType + additionalProperties(addMemberPermission.additionalProperties) + } + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles + */ + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles + */ + @JsonProperty("permission") + @ExcludeMissing + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: RestrictObjectType) = + restrictObjectType(JsonField.of(restrictObjectType)) + + /** The object type that the ACL applies to */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } + + 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(): AddMemberPermission = + AddMemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) + } + + class Permission + @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 Permission && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CREATE = Permission(JsonField.of("create")) + + @JvmField val READ = Permission(JsonField.of("read")) + + @JvmField val UPDATE = Permission(JsonField.of("update")) + + @JvmField val DELETE = Permission(JsonField.of("delete")) + + @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + + @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + + @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + + @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_acls")) + + @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) + } + + enum class Known { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + } + + enum class Value { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class RestrictObjectType + @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 RestrictObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + + @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = RemoveMemberPermission.Builder::class) + @NoAutoDetect + class RemoveMemberPermission + private constructor( + private val permission: JsonField, + private val restrictObjectType: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into roles + */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** The object type that the ACL applies to */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into roles + */ + @JsonProperty("permission") @ExcludeMissing fun _permission() = permission + + /** The object type that the ACL applies to */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun _restrictObjectType() = restrictObjectType + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RemoveMemberPermission = apply { + if (!validated) { + permission() + restrictObjectType() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveMemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var permission: JsonField = JsonMissing.of() + private var restrictObjectType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeMemberPermission: RemoveMemberPermission) = apply { + this.permission = removeMemberPermission.permission + this.restrictObjectType = removeMemberPermission.restrictObjectType + additionalProperties(removeMemberPermission.additionalProperties) + } + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles + */ + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * Each permission permits a certain type of operation on an object in the system + * + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles + */ + @JsonProperty("permission") + @ExcludeMissing + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: RestrictObjectType) = + restrictObjectType(JsonField.of(restrictObjectType)) + + /** The object type that the ACL applies to */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } + + 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(): RemoveMemberPermission = + RemoveMemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) + } + + class Permission + @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 Permission && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CREATE = Permission(JsonField.of("create")) + + @JvmField val READ = Permission(JsonField.of("read")) + + @JvmField val UPDATE = Permission(JsonField.of("update")) + + @JvmField val DELETE = Permission(JsonField.of("delete")) + + @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + + @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + + @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + + @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_acls")) + + @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) + } + + enum class Known { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + } + + enum class Value { + CREATE, + READ, + UPDATE, + DELETE, + CREATE_ACLS, + READ_ACLS, + UPDATE_ACLS, + DELETE_ACLS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class RestrictObjectType + @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 RestrictObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + + @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchView.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchView.kt new file mode 100755 index 0000000..34d9608 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchView.kt @@ -0,0 +1,451 @@ +// 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 +import java.util.Optional + +@JsonDeserialize(builder = PatchView.Builder::class) +@NoAutoDetect +class PatchView +private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val viewType: JsonField, + private val name: JsonField, + private val viewData: JsonField, + private val options: JsonField, + private val userId: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The object type that the ACL applies to */ + fun objectType(): Optional = + Optional.ofNullable(objectType.getNullable("object_type")) + + /** The id of the object the view applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** Type of table that the view corresponds to. */ + fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) + + /** Name of the view */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** The view definition */ + fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) + + /** Options for the view in the app */ + fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + + /** Identifies the user who created the view */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + + /** The id of the object the view applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + + /** Type of table that the view corresponds to. */ + @JsonProperty("view_type") @ExcludeMissing fun _viewType() = viewType + + /** Name of the view */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** The view definition */ + @JsonProperty("view_data") @ExcludeMissing fun _viewData() = viewData + + /** Options for the view in the app */ + @JsonProperty("options") @ExcludeMissing fun _options() = options + + /** Identifies the user who created the view */ + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PatchView = apply { + if (!validated) { + objectType() + objectId() + viewType() + name() + viewData().map { it.validate() } + options().map { it.validate() } + userId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchView && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.viewType == other.viewType && + this.name == other.name && + this.viewData == other.viewData && + this.options == other.options && + this.userId == other.userId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + objectType, + objectId, + viewType, + name, + viewData, + options, + userId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PatchView{objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, viewData=$viewData, options=$options, userId=$userId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objectType: JsonField = JsonMissing.of() + private var objectId: JsonField = JsonMissing.of() + private var viewType: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var viewData: JsonField = JsonMissing.of() + private var options: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patchView: PatchView) = apply { + this.objectType = patchView.objectType + this.objectId = patchView.objectId + this.viewType = patchView.viewType + this.name = patchView.name + this.viewData = patchView.viewData + this.options = patchView.options + this.userId = patchView.userId + additionalProperties(patchView.additionalProperties) + } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + /** The id of the object the view applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the view applies to */ + @JsonProperty("object_id") + @ExcludeMissing + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: ViewType) = viewType(JsonField.of(viewType)) + + /** Type of table that the view corresponds to. */ + @JsonProperty("view_type") + @ExcludeMissing + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + + /** Name of the view */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the view */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** The view definition */ + fun viewData(viewData: ViewData) = viewData(JsonField.of(viewData)) + + /** The view definition */ + @JsonProperty("view_data") + @ExcludeMissing + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + + /** Options for the view in the app */ + fun options(options: ViewOptions) = options(JsonField.of(options)) + + /** Options for the view in the app */ + @JsonProperty("options") + @ExcludeMissing + fun options(options: JsonField) = apply { this.options = options } + + /** Identifies the user who created the view */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** Identifies the user who created the view */ + @JsonProperty("user_id") + @ExcludeMissing + fun userId(userId: JsonField) = apply { this.userId = userId } + + 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(): PatchView = + PatchView( + objectType, + objectId, + viewType, + name, + viewData, + options, + userId, + additionalProperties.toUnmodifiable(), + ) + } + + class ObjectType + @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 ObjectType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + + @JvmField val PROJECT = ObjectType(JsonField.of("project")) + + @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + + @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + + @JvmField val GROUP = ObjectType(JsonField.of("group")) + + @JvmField val ROLE = ObjectType(JsonField.of("role")) + + @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + + @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + + @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + enum class Known { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + } + + enum class Value { + ORGANIZATION, + PROJECT, + EXPERIMENT, + DATASET, + PROMPT, + PROMPT_SESSION, + GROUP, + ROLE, + ORG_MEMBER, + PROJECT_LOG, + ORG_PROJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class ViewType + @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 ViewType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PROJECTS = ViewType(JsonField.of("projects")) + + @JvmField val LOGS = ViewType(JsonField.of("logs")) + + @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + + @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + + @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + + @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + + @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + + @JvmField val DATASET = ViewType(JsonField.of("dataset")) + + @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) + } + + enum class Known { + PROJECTS, + LOGS, + EXPERIMENTS, + DATASETS, + PROMPTS, + PLAYGROUNDS, + EXPERIMENT, + DATASET, + } + + enum class Value { + PROJECTS, + LOGS, + EXPERIMENTS, + DATASETS, + PROMPTS, + PLAYGROUNDS, + EXPERIMENT, + DATASET, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt new file mode 100755 index 0000000..d1127b0 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt @@ -0,0 +1,245 @@ +// 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 + +/** + * A path-lookup filter describes an equality comparison against a specific sub-field in the event + * row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": + * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` + */ +@JsonDeserialize(builder = PathLookupFilter.Builder::class) +@NoAutoDetect +class PathLookupFilter +private constructor( + private val type: JsonField, + private val path: JsonField>, + private val value: JsonValue, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Denotes the type of filter as a path-lookup filter */ + fun type(): Type = type.getRequired("type") + + /** + * List of fields describing the path to the value to be checked against. For instance, if you + * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + fun path(): List = path.getRequired("path") + + /** + * The value to compare equality-wise against the event value at the specified `path`. The value + * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. + * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": + * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + */ + fun value(): JsonValue = value + + /** Denotes the type of filter as a path-lookup filter */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + /** + * List of fields describing the path to the value to be checked against. For instance, if you + * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + @JsonProperty("path") @ExcludeMissing fun _path() = path + + /** + * The value to compare equality-wise against the event value at the specified `path`. The value + * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. + * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": + * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + */ + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PathLookupFilter = apply { + if (!validated) { + type() + path() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PathLookupFilter && + this.type == other.type && + this.path == other.path && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + path, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var path: JsonField> = JsonMissing.of() + private var value: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pathLookupFilter: PathLookupFilter) = apply { + this.type = pathLookupFilter.type + this.path = pathLookupFilter.path + this.value = pathLookupFilter.value + additionalProperties(pathLookupFilter.additionalProperties) + } + + /** Denotes the type of filter as a path-lookup filter */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Denotes the type of filter as a path-lookup filter */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + /** + * List of fields describing the path to the value to be checked against. For instance, if + * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + fun path(path: List) = path(JsonField.of(path)) + + /** + * List of fields describing the path to the value to be checked against. For instance, if + * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + @JsonProperty("path") + @ExcludeMissing + fun path(path: JsonField>) = apply { this.path = path } + + /** + * The value to compare equality-wise against the event value at the specified `path`. The + * value must be a "primitive", that is, any JSON-serializable object except for objects and + * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + */ + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonValue) = apply { this.value = value } + + 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(): PathLookupFilter = + PathLookupFilter( + type, + path.map { it.toUnmodifiable() }, + value, + 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 PATH_LOOKUP = Type(JsonField.of("path_lookup")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + PATH_LOOKUP, + } + + enum class Value { + PATH_LOOKUP, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PATH_LOOKUP -> Value.PATH_LOOKUP + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PATH_LOOKUP -> Known.PATH_LOOKUP + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 24ded19..b811568 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -245,117 +234,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 3ac09d2..5d6b101 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -2,17 +2,13 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable -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.databind.annotation.JsonDeserialize import java.util.Objects @@ -20,7 +16,7 @@ import java.util.Objects class ProjectLogFeedbackParams constructor( private val projectId: String, - private val feedback: List, + private val feedback: List, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -28,7 +24,7 @@ constructor( fun projectId(): String = projectId - fun feedback(): List = feedback + fun feedback(): List = feedback @JvmSynthetic internal fun getBody(): ProjectLogFeedbackBody { @@ -50,14 +46,14 @@ constructor( @NoAutoDetect class ProjectLogFeedbackBody internal constructor( - private val feedback: List?, + private val feedback: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of project logs feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + @JsonProperty("feedback") fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -92,7 +88,7 @@ constructor( class Builder { - private var feedback: List? = null + private var feedback: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -103,7 +99,9 @@ constructor( /** A list of project logs feedback items */ @JsonProperty("feedback") - fun feedback(feedback: List) = apply { this.feedback = feedback } + fun feedback(feedback: List) = apply { + this.feedback = feedback + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -171,7 +169,7 @@ constructor( class Builder { private var projectId: String? = null - private var feedback: MutableList = mutableListOf() + private var feedback: MutableList = mutableListOf() private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -189,13 +187,13 @@ constructor( fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs feedback items */ - fun feedback(feedback: List) = apply { + fun feedback(feedback: List) = apply { this.feedback.clear() this.feedback.addAll(feedback) } /** A list of project logs feedback items */ - fun addFeedback(feedback: Feedback) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { this.feedback.add(feedback) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,375 +259,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(builder = Feedback.Builder::class) - @NoAutoDetect - class Feedback - private constructor( - private val id: String?, - private val scores: Scores?, - private val expected: JsonValue?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** - * The id of the project logs event to log feedback for. This is the row `id` returned by - * `POST /v1/project_logs/{project_id}/insert` - */ - @JsonProperty("id") fun id(): String? = id - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event - */ - @JsonProperty("scores") fun scores(): Scores? = scores - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not - */ - @JsonProperty("expected") fun expected(): JsonValue? = expected - - /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") fun comment(): String? = comment - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") fun source(): Source? = source - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Feedback{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var scores: Scores? = null - private var expected: JsonValue? = null - private var comment: String? = null - private var metadata: Metadata? = null - private var source: Source? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedback: Feedback) = apply { - this.id = feedback.id - this.scores = feedback.scores - this.expected = feedback.expected - this.comment = feedback.comment - this.metadata = feedback.metadata - this.source = feedback.source - additionalProperties(feedback.additionalProperties) - } - - /** - * The id of the project logs event to log feedback for. This is the row `id` returned - * by `POST /v1/project_logs/{project_id}/insert` - */ - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged - * into the existing scores for the project logs event - */ - @JsonProperty("scores") fun scores(scores: Scores) = apply { this.scores = scores } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not - */ - @JsonProperty("expected") - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") fun comment(comment: String) = apply { this.comment = comment } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you - * can log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") fun source(source: Source) = apply { this.source = source } - - 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(): Feedback = - Feedback( - checkNotNull(id) { "`id` is required but was not set" }, - scores, - expected, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - 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(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - class Source - @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 Source && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val APP = Source(JsonField.of("app")) - - @JvmField val API = Source(JsonField.of("api")) - - @JvmField val EXTERNAL = Source(JsonField.of("external")) - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - APP, - API, - EXTERNAL, - } - - enum class Value { - APP, - API, - EXTERNAL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 541c014..ecb46ed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -2,17 +2,13 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable -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.databind.annotation.JsonDeserialize import java.util.Objects @@ -22,7 +18,7 @@ class ProjectLogFetchPostParams constructor( private val projectId: String, private val cursor: String?, - private val filters: List?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -36,7 +32,7 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) + fun filters(): Optional> = Optional.ofNullable(filters) fun limit(): Optional = Optional.ofNullable(limit) @@ -75,7 +71,7 @@ constructor( class ProjectLogFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -98,7 +94,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - @JsonProperty("filters") fun filters(): List? = filters + @JsonProperty("filters") fun filters(): List? = filters /** * limit the number of traces fetched @@ -201,7 +197,7 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null + private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -233,7 +229,7 @@ constructor( * are supported, but we may add more in the future */ @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } + fun filters(filters: List) = apply { this.filters = filters } /** * limit the number of traces fetched @@ -372,7 +368,7 @@ constructor( private var projectId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() + private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -411,7 +407,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - fun filters(filters: List) = apply { + fun filters(filters: List) = apply { this.filters.clear() this.filters.addAll(filters) } @@ -420,7 +416,7 @@ constructor( * A list of filters on the events to fetch. Currently, only path-lookup type filters are * supported, but we may add more in the future */ - fun addFilter(filter: Filter) = apply { this.filters.add(filter) } + fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } /** * limit the number of traces fetched @@ -543,186 +539,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - /** - * A path-lookup filter describes an equality comparison against a specific sub-field in the - * event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": - * {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` - */ - @JsonDeserialize(builder = Filter.Builder::class) - @NoAutoDetect - class Filter - private constructor( - private val type: Type?, - private val path: List?, - private val value: JsonValue?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") fun type(): Type? = type - - /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") fun path(): List? = path - - /** - * The value to compare equality-wise against the event value at the specified `path`. The - * value must be a "primitive", that is, any JSON-serializable object except for objects and - * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") fun value(): JsonValue? = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: Type? = null - private var path: List? = null - private var value: JsonValue? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filter: Filter) = apply { - this.type = filter.type - this.path = filter.path - this.value = filter.value - additionalProperties(filter.additionalProperties) - } - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") fun type(type: Type) = apply { this.type = type } - - /** - * List of fields describing the path to the value to be checked against. For instance, - * if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": - * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") fun path(path: List) = apply { this.path = path } - - /** - * The value to compare equality-wise against the event value at the specified `path`. - * The value must be a "primitive", that is, any JSON-serializable object except for - * objects and arrays. For instance, if you wish to filter on the value of "input.a.b.c" - * in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") fun value(value: JsonValue) = apply { this.value = value } - - 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(): Filter = - Filter( - checkNotNull(type) { "`type` is required but was not set" }, - checkNotNull(path) { "`path` is required but was not set" }.toUnmodifiable(), - value, - 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 PATH_LOOKUP = Type(JsonField.of("path_lookup")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - PATH_LOOKUP, - } - - enum class Value { - PATH_LOOKUP, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 2da5010..28aa2a3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -2,37 +2,21 @@ 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.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 -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.time.OffsetDateTime import java.util.Objects -import java.util.Optional class ProjectLogInsertParams constructor( private val projectId: String, - private val events: List, + private val events: List, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -40,7 +24,7 @@ constructor( fun projectId(): String = projectId - fun events(): List = events + fun events(): List = events @JvmSynthetic internal fun getBody(): ProjectLogInsertBody { @@ -62,14 +46,14 @@ constructor( @NoAutoDetect class ProjectLogInsertBody internal constructor( - private val events: List?, + private val events: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of project logs events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -104,7 +88,7 @@ constructor( class Builder { - private var events: List? = null + private var events: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -114,7 +98,8 @@ constructor( } /** A list of project logs events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -182,7 +167,7 @@ constructor( class Builder { private var projectId: String? = null - private var events: MutableList = mutableListOf() + private var events: MutableList = mutableListOf() private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -200,13 +185,13 @@ constructor( fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs events to insert */ - fun events(events: List) = apply { + fun events(events: List) = apply { this.events.clear() this.events.addAll(events) } /** A list of project logs events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: InsertProjectLogsEvent) = apply { this.events.add(event) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -271,3001 +256,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, - private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertProjectLogsEventReplace(): Optional = - Optional.ofNullable(insertProjectLogsEventReplace) - - fun insertProjectLogsEventMerge(): Optional = - Optional.ofNullable(insertProjectLogsEventMerge) - - fun isInsertProjectLogsEventReplace(): Boolean = insertProjectLogsEventReplace != null - - fun isInsertProjectLogsEventMerge(): Boolean = insertProjectLogsEventMerge != null - - fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = - insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") - - fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = - insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - insertProjectLogsEventReplace != null -> - visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) - insertProjectLogsEventMerge != null -> - visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertProjectLogsEventReplace?.validate() - insertProjectLogsEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && - this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) - } - - override fun toString(): String { - return when { - insertProjectLogsEventReplace != null -> - "Event{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" - insertProjectLogsEventMerge != null -> - "Event{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - @JvmStatic - fun ofInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ) = Event(insertProjectLogsEventReplace = insertProjectLogsEventReplace) - - @JvmStatic - fun ofInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ) = Event(insertProjectLogsEventMerge = insertProjectLogsEventMerge) - } - - interface Visitor { - - fun visitInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ): T - - fun visitInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertProjectLogsEventReplace != null -> - generator.writeObject(value.insertProjectLogsEventReplace) - value.insertProjectLogsEventMerge != null -> - generator.writeObject(value.insertProjectLogsEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - - @JsonDeserialize(builder = InsertProjectLogsEventReplace.Builder::class) - @NoAutoDetect - class InsertProjectLogsEventReplace - private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question. - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * while digging into analyses. However, we may later use these values to re-score - * outputs or fine-tune your models. - */ - fun expected(): JsonValue = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** The timestamp the project logs event was created */ - fun created(): Optional = - Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Optional = - Optional.ofNullable(_isMerge.getNullable("_is_merge")) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships - * are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": - * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, - * only the root span row `"abc"` will show up in the summary view. You can view the - * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" - * row. - */ - fun _parentId(): Optional = - Optional.ofNullable(_parentId.getNullable("_parent_id")) - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question. - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * while digging into analyses. However, we may later use these values to re-score - * outputs or fine-tune your models. - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships - * are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": - * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, - * only the root span row `"abc"` will show up in the summary view. You can view the - * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" - * row. - */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertProjectLogsEventReplace = apply { - if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertProjectLogsEventReplace: InsertProjectLogsEventReplace) = - apply { - this.input = insertProjectLogsEventReplace.input - this.output = insertProjectLogsEventReplace.output - this.expected = insertProjectLogsEventReplace.expected - this.scores = insertProjectLogsEventReplace.scores - this.metadata = insertProjectLogsEventReplace.metadata - this.tags = insertProjectLogsEventReplace.tags - this.metrics = insertProjectLogsEventReplace.metrics - this.context = insertProjectLogsEventReplace.context - this.spanAttributes = insertProjectLogsEventReplace.spanAttributes - this.id = insertProjectLogsEventReplace.id - this.created = insertProjectLogsEventReplace.created - this._objectDelete = insertProjectLogsEventReplace._objectDelete - this._isMerge = insertProjectLogsEventReplace._isMerge - this._parentId = insertProjectLogsEventReplace._parentId - additionalProperties(insertProjectLogsEventReplace.additionalProperties) - } - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should be - * the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since there - * are so many different ways to do that correctly. Instead, these values are just - * used to help you navigate while digging into analyses. However, we may later use - * these values to re-score outputs or fine-tune your models. - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare logs. - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare logs. - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the project logs event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - fun _objectDelete(_objectDelete: Boolean) = - _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": - * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a - * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": - * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in - * the summary view. You can view the full trace hierarchy (in this case, the - * `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It - * cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": - * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a - * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": - * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in - * the summary view. You can view the full trace hierarchy (in this case, the - * `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } - - 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(): InsertProjectLogsEventReplace = - InsertProjectLogsEventReplace( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - - /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - 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(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the project logs event - * (only set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the project logs event - * (only set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** - * The total number of tokens in the input and output of the project logs event. - */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** - * The total number of tokens in the input and output of the project logs event. - */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - 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(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - 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(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @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(): SpanAttributes = - SpanAttributes( - name, - 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 LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - @JsonDeserialize(builder = InsertProjectLogsEventMerge.Builder::class) - @NoAutoDetect - class InsertProjectLogsEventMerge - private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question. - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * while digging into analyses. However, we may later use these values to re-score - * outputs or fine-tune your models. - */ - fun expected(): JsonValue = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** The timestamp the project logs event was created */ - fun created(): Optional = - Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each - * path is a list of field names. The deep merge will not descend below any of the - * specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, - * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced - * `input.a` and `output`, but have still deep-merged `input` and `input.c`. - */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question. - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * while digging into analyses. However, we may later use these values to re-score - * outputs or fine-tune your models. - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the - * same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is deep-merged - * into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, - * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": - * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": - * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the - * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each - * path is a list of field names. The deep merge will not descend below any of the - * specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, - * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced - * `input.a` and `output`, but have still deep-merged `input` and `input.c`. - */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertProjectLogsEventMerge = apply { - if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _mergePaths: JsonField>> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertProjectLogsEventMerge: InsertProjectLogsEventMerge) = - apply { - this.input = insertProjectLogsEventMerge.input - this.output = insertProjectLogsEventMerge.output - this.expected = insertProjectLogsEventMerge.expected - this.scores = insertProjectLogsEventMerge.scores - this.metadata = insertProjectLogsEventMerge.metadata - this.tags = insertProjectLogsEventMerge.tags - this.metrics = insertProjectLogsEventMerge.metrics - this.context = insertProjectLogsEventMerge.context - this.spanAttributes = insertProjectLogsEventMerge.spanAttributes - this.id = insertProjectLogsEventMerge.id - this.created = insertProjectLogsEventMerge.created - this._objectDelete = insertProjectLogsEventMerge._objectDelete - this._isMerge = insertProjectLogsEventMerge._isMerge - this._mergePaths = insertProjectLogsEventMerge._mergePaths - additionalProperties(insertProjectLogsEventMerge.additionalProperties) - } - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should be - * the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since there - * are so many different ways to do that correctly. Instead, these values are just - * used to help you navigate while digging into analyses. However, we may later use - * these values to re-score outputs or fine-tune your models. - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare logs. - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth summary. - * The word similarity score could help you determine whether the summarization was - * covering similar concepts or not. You can use these scores to help you sort, - * filter, and compare logs. - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the project logs event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - fun _objectDelete(_objectDelete: Boolean) = - _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events - * will not show up in subsequent fetches for this project logs - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", - * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": - * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": - * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": - * 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where - * each path is a list of field names. The deep merge will not descend below any of - * the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will - * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": - * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have - * replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - fun _mergePaths(_mergePaths: List>) = - _mergePaths(JsonField.of(_mergePaths)) - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where - * each path is a list of field names. The deep merge will not descend below any of - * the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": - * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": - * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will - * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": - * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have - * replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths - } - - 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(): InsertProjectLogsEventMerge = - InsertProjectLogsEventMerge( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - - /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - 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(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the - * project logs event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the project logs event - * (only set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the project logs event - * (only set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if - * this is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** - * The total number of tokens in the input and output of the project logs event. - */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** - * The total number of tokens in the input and output of the project logs event. - */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - 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(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - 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(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @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(): SpanAttributes = - SpanAttributes( - name, - 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 LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt new file mode 100755 index 0000000..7fec382 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -0,0 +1,1502 @@ +// 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.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = ProjectLogsEvent.Builder::class) +@NoAutoDetect +class ProjectLogsEvent +private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val orgId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(): String = id.getRequired("id") + + /** + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the project logs (see the `version` parameter) + */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** The timestamp the project logs event was created */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** Unique id for the organization that the project belongs under */ + fun orgId(): String = orgId.getRequired("org_id") + + /** Unique identifier for the project */ + fun projectId(): String = projectId.getRequired("project_id") + + /** A literal 'g' which identifies the log as a project log */ + fun logId(): LogId = logId.getRequired("log_id") + + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. + */ + fun output(): JsonValue = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. + */ + fun expected(): JsonValue = expected + + /** The error that occurred, if any. */ + fun error(): JsonValue = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + fun spanId(): String = spanId.getRequired("span_id") + + /** + * An array of the parent `span_ids` of this project logs event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans + */ + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) + + /** The `span_id` of the root of the trace this project logs event belongs to */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the project logs (see the `version` parameter) + */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + + /** The timestamp the project logs event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Unique id for the organization that the project belongs under */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + + /** Unique identifier for the project */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** A literal 'g' which identifies the log as a project log */ + @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId + + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. + */ + @JsonProperty("output") @ExcludeMissing fun _output() = output + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error() = error + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + @JsonProperty("context") @ExcludeMissing fun _context() = context + + /** + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + + /** + * An array of the parent `span_ids` of this project logs event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans + */ + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + + /** The `span_id` of the root of the trace this project logs event belongs to */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectLogsEvent = apply { + if (!validated) { + id() + _xactId() + created() + orgId() + projectId() + logId() + input() + output() + expected() + error() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanId() + spanParents() + rootSpanId() + spanAttributes().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectLogsEvent && + this.id == other.id && + this._xactId == other._xactId && + this.created == other.created && + this.orgId == other.orgId && + this.projectId == other.projectId && + this.logId == other.logId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var _xactId: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var orgId: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var logId: JsonField = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var error: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var metrics: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var spanId: JsonField = JsonMissing.of() + private var spanParents: JsonField> = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectLogsEvent: ProjectLogsEvent) = apply { + this.id = projectLogsEvent.id + this._xactId = projectLogsEvent._xactId + this.created = projectLogsEvent.created + this.orgId = projectLogsEvent.orgId + this.projectId = projectLogsEvent.projectId + this.logId = projectLogsEvent.logId + this.input = projectLogsEvent.input + this.output = projectLogsEvent.output + this.expected = projectLogsEvent.expected + this.error = projectLogsEvent.error + this.scores = projectLogsEvent.scores + this.metadata = projectLogsEvent.metadata + this.tags = projectLogsEvent.tags + this.metrics = projectLogsEvent.metrics + this.context = projectLogsEvent.context + this.spanId = projectLogsEvent.spanId + this.spanParents = projectLogsEvent.spanParents + this.rootSpanId = projectLogsEvent.rootSpanId + this.spanAttributes = projectLogsEvent.spanAttributes + additionalProperties(projectLogsEvent.additionalProperties) + } + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) + */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) + */ + @JsonProperty("_xact_id") + @ExcludeMissing + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + /** The timestamp the project logs event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the project logs event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** Unique id for the organization that the project belongs under */ + fun orgId(orgId: String) = orgId(JsonField.of(orgId)) + + /** Unique id for the organization that the project belongs under */ + @JsonProperty("org_id") + @ExcludeMissing + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + + /** Unique identifier for the project */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** A literal 'g' which identifies the log as a project log */ + fun logId(logId: LogId) = logId(JsonField.of(logId)) + + /** A literal 'g' which identifies the log as a project log */ + @JsonProperty("log_id") + @ExcludeMissing + fun logId(logId: JsonField) = apply { this.logId = logId } + + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. + */ + @JsonProperty("output") + @ExcludeMissing + fun output(output: JsonValue) = apply { this.output = output } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** The error that occurred, if any. */ + @JsonProperty("error") + @ExcludeMissing + fun error(error: JsonValue) = apply { this.error = error } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. + */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. + */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + @JsonProperty("metrics") + @ExcludeMissing + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: Context) = context(JsonField.of(context)) + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + @JsonProperty("context") + @ExcludeMissing + fun context(context: JsonField) = apply { this.context = context } + + /** + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + @JsonProperty("span_id") + @ExcludeMissing + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans + */ + fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + + /** + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans + */ + @JsonProperty("span_parents") + @ExcludeMissing + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents + } + + /** The `span_id` of the root of the trace this project logs event belongs to */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** The `span_id` of the root of the trace this project logs event belongs to */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } + + 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(): ProjectLogsEvent = + ProjectLogsEvent( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) + } + + class LogId + @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 LogId && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val G = LogId(JsonField.of("g")) + + @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) + } + + enum class Known { + G, + } + + enum class Value { + G, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + G -> Value.G + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + G -> Known.G + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + @JsonDeserialize(builder = Context.Builder::class) + @NoAutoDetect + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The function in code which created the project logs event */ + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) + + /** Line of code where the project logs event was created */ + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + + /** The function in code which created the project logs event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** Line of code where the project logs event was created */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Context = apply { + if (!validated) { + callerFunctionname() + callerFilename() + callerLineno() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var callerFunctionname: JsonField = JsonMissing.of() + private var callerFilename: JsonField = JsonMissing.of() + private var callerLineno: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(context: Context) = apply { + this.callerFunctionname = context.callerFunctionname + this.callerFilename = context.callerFilename + this.callerLineno = context.callerLineno + additionalProperties(context.additionalProperties) + } + + /** The function in code which created the project logs event */ + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) + + /** The function in code which created the project logs event */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) + + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** Line of code where the project logs event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + + /** Line of code where the project logs event was created */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } + + 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(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + 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(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + } + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + @JsonDeserialize(builder = Metrics.Builder::class) + @NoAutoDetect + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * finished + */ + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) + */ + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start() = start + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end() = end + + /** + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + + /** + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens() = completionTokens + + /** The total number of tokens in the input and output of the project logs event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metrics = apply { + if (!validated) { + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var start: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var tokens: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metrics: Metrics) = apply { + this.start = metrics.start + this.end = metrics.end + this.promptTokens = metrics.promptTokens + this.completionTokens = metrics.completionTokens + this.tokens = metrics.tokens + additionalProperties(metrics.additionalProperties) + } + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + fun start(start: Double) = start(JsonField.of(start)) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + @JsonProperty("start") + @ExcludeMissing + fun start(start: JsonField) = apply { this.start = start } + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event finished + */ + fun end(end: Double) = end(JsonField.of(end)) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event finished + */ + @JsonProperty("end") + @ExcludeMissing + fun end(end: JsonField) = apply { this.end = end } + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + + /** The total number of tokens in the input and output of the project logs event. */ + @JsonProperty("tokens") + @ExcludeMissing + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + + 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(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonDeserialize(builder = SpanAttributes.Builder::class) + @NoAutoDetect + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the span, for display purposes only */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of the span, for display purposes only */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Type of the span, for display purposes only */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanAttributes = apply { + if (!validated) { + name() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanAttributes: SpanAttributes) = apply { + this.name = spanAttributes.name + this.type = spanAttributes.type + additionalProperties(spanAttributes.additionalProperties) + } + + /** Name of the span, for display purposes only */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the span, for display purposes only */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of the span, for display purposes only */ + @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(): SpanAttributes = + SpanAttributes( + name, + 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 LLM = Type(JsonField.of("llm")) + + @JvmField val SCORE = Type(JsonField.of("score")) + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmField val EVAL = Type(JsonField.of("eval")) + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmField val TOOL = Type(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + enum class Value { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} 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 c5fca8c..bb6f531 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 @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -26,6 +15,7 @@ constructor( private val ids: Ids?, private val limit: Long?, private val orgName: String?, + private val projectId: String?, private val projectName: String?, private val projectScoreName: String?, private val startingAfter: String?, @@ -42,6 +32,8 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun projectId(): Optional = Optional.ofNullable(projectId) + fun projectName(): Optional = Optional.ofNullable(projectName) fun projectScoreName(): Optional = Optional.ofNullable(projectScoreName) @@ -55,6 +47,7 @@ constructor( this.ids?.let { params.put("ids", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectId?.let { params.put("project_id", listOf(it.toString())) } this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.projectScoreName?.let { params.put("project_score_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } @@ -80,6 +73,7 @@ constructor( this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && + this.projectId == other.projectId && this.projectName == other.projectName && this.projectScoreName == other.projectScoreName && this.startingAfter == other.startingAfter && @@ -94,6 +88,7 @@ constructor( ids, limit, orgName, + projectId, projectName, projectScoreName, startingAfter, @@ -104,7 +99,7 @@ constructor( } override fun toString() = - "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, projectScoreName=$projectScoreName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -120,6 +115,7 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null + private var projectId: String? = null private var projectName: String? = null private var projectScoreName: String? = null private var startingAfter: String? = null @@ -133,6 +129,7 @@ constructor( this.ids = projectScoreListParams.ids this.limit = projectScoreListParams.limit this.orgName = projectScoreListParams.orgName + this.projectId = projectScoreListParams.projectId this.projectName = projectScoreListParams.projectName this.projectScoreName = projectScoreListParams.projectScoreName this.startingAfter = projectScoreListParams.startingAfter @@ -174,6 +171,9 @@ constructor( /** Filter search results to within a particular organization */ fun orgName(orgName: String) = apply { this.orgName = orgName } + /** Project id */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + /** Name of the project to search for */ fun projectName(projectName: String) = apply { this.projectName = projectName } @@ -251,6 +251,7 @@ constructor( ids, limit, orgName, + projectId, projectName, projectScoreName, startingAfter, @@ -259,117 +260,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index f3d6edb..2138471 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -26,6 +15,7 @@ constructor( private val ids: Ids?, private val limit: Long?, private val orgName: String?, + private val projectId: String?, private val projectName: String?, private val projectTagName: String?, private val startingAfter: String?, @@ -42,6 +32,8 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun projectId(): Optional = Optional.ofNullable(projectId) + fun projectName(): Optional = Optional.ofNullable(projectName) fun projectTagName(): Optional = Optional.ofNullable(projectTagName) @@ -55,6 +47,7 @@ constructor( this.ids?.let { params.put("ids", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectId?.let { params.put("project_id", listOf(it.toString())) } this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.projectTagName?.let { params.put("project_tag_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } @@ -80,6 +73,7 @@ constructor( this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && + this.projectId == other.projectId && this.projectName == other.projectName && this.projectTagName == other.projectTagName && this.startingAfter == other.startingAfter && @@ -94,6 +88,7 @@ constructor( ids, limit, orgName, + projectId, projectName, projectTagName, startingAfter, @@ -104,7 +99,7 @@ constructor( } override fun toString() = - "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -120,6 +115,7 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null + private var projectId: String? = null private var projectName: String? = null private var projectTagName: String? = null private var startingAfter: String? = null @@ -133,6 +129,7 @@ constructor( this.ids = projectTagListParams.ids this.limit = projectTagListParams.limit this.orgName = projectTagListParams.orgName + this.projectId = projectTagListParams.projectId this.projectName = projectTagListParams.projectName this.projectTagName = projectTagListParams.projectTagName this.startingAfter = projectTagListParams.startingAfter @@ -174,6 +171,9 @@ constructor( /** Filter search results to within a particular organization */ fun orgName(orgName: String) = apply { this.orgName = orgName } + /** Project id */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + /** Name of the project to search for */ fun projectName(projectName: String) = apply { this.projectName = projectName } @@ -249,6 +249,7 @@ constructor( ids, limit, orgName, + projectId, projectName, projectTagName, startingAfter, @@ -257,117 +258,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 87d24bb..ef92a00 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -26,6 +15,7 @@ constructor( private val ids: Ids?, private val limit: Long?, private val orgName: String?, + private val projectId: String?, private val projectName: String?, private val promptName: String?, private val slug: String?, @@ -44,6 +34,8 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun projectId(): Optional = Optional.ofNullable(projectId) + fun projectName(): Optional = Optional.ofNullable(projectName) fun promptName(): Optional = Optional.ofNullable(promptName) @@ -61,6 +53,7 @@ constructor( this.ids?.let { params.put("ids", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectId?.let { params.put("project_id", listOf(it.toString())) } this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.promptName?.let { params.put("prompt_name", listOf(it.toString())) } this.slug?.let { params.put("slug", listOf(it.toString())) } @@ -88,6 +81,7 @@ constructor( this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && + this.projectId == other.projectId && this.projectName == other.projectName && this.promptName == other.promptName && this.slug == other.slug && @@ -104,6 +98,7 @@ constructor( ids, limit, orgName, + projectId, projectName, promptName, slug, @@ -116,7 +111,7 @@ constructor( } override fun toString() = - "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -132,6 +127,7 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null + private var projectId: String? = null private var projectName: String? = null private var promptName: String? = null private var slug: String? = null @@ -147,6 +143,7 @@ constructor( this.ids = promptListParams.ids this.limit = promptListParams.limit this.orgName = promptListParams.orgName + this.projectId = promptListParams.projectId this.projectName = promptListParams.projectName this.promptName = promptListParams.promptName this.slug = promptListParams.slug @@ -190,6 +187,9 @@ constructor( /** Filter search results to within a particular organization */ fun orgName(orgName: String) = apply { this.orgName = orgName } + /** Project id */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + /** Name of the project to search for */ fun projectName(projectName: String) = apply { this.projectName = projectName } @@ -276,6 +276,7 @@ constructor( ids, limit, orgName, + projectId, projectName, promptName, slug, @@ -286,117 +287,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 99c8bad..c7a5fd5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -2,21 +2,10 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 @@ -245,117 +234,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt new file mode 100755 index 0000000..3eed5fb --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -0,0 +1,202 @@ +// 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 +import java.util.Optional + +/** Summary of a score's performance */ +@JsonDeserialize(builder = ScoreSummary.Builder::class) +@NoAutoDetect +class ScoreSummary +private constructor( + private val name: JsonField, + private val score: JsonField, + private val diff: JsonField, + private val improvements: JsonField, + private val regressions: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the score */ + fun name(): String = name.getRequired("name") + + /** Average score across all examples */ + fun score(): Double = score.getRequired("score") + + /** Difference in score between the current and comparison experiment */ + fun diff(): Optional = Optional.ofNullable(diff.getNullable("diff")) + + /** Number of improvements in the score */ + fun improvements(): Long = improvements.getRequired("improvements") + + /** Number of regressions in the score */ + fun regressions(): Long = regressions.getRequired("regressions") + + /** Name of the score */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Average score across all examples */ + @JsonProperty("score") @ExcludeMissing fun _score() = score + + /** Difference in score between the current and comparison experiment */ + @JsonProperty("diff") @ExcludeMissing fun _diff() = diff + + /** Number of improvements in the score */ + @JsonProperty("improvements") @ExcludeMissing fun _improvements() = improvements + + /** Number of regressions in the score */ + @JsonProperty("regressions") @ExcludeMissing fun _regressions() = regressions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ScoreSummary = apply { + if (!validated) { + name() + score() + diff() + improvements() + regressions() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScoreSummary && + this.name == other.name && + this.score == other.score && + this.diff == other.diff && + this.improvements == other.improvements && + this.regressions == other.regressions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + score, + diff, + improvements, + regressions, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ScoreSummary{name=$name, score=$score, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var score: JsonField = JsonMissing.of() + private var diff: JsonField = JsonMissing.of() + private var improvements: JsonField = JsonMissing.of() + private var regressions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scoreSummary: ScoreSummary) = apply { + this.name = scoreSummary.name + this.score = scoreSummary.score + this.diff = scoreSummary.diff + this.improvements = scoreSummary.improvements + this.regressions = scoreSummary.regressions + additionalProperties(scoreSummary.additionalProperties) + } + + /** Name of the score */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the score */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Average score across all examples */ + fun score(score: Double) = score(JsonField.of(score)) + + /** Average score across all examples */ + @JsonProperty("score") + @ExcludeMissing + fun score(score: JsonField) = apply { this.score = score } + + /** Difference in score between the current and comparison experiment */ + fun diff(diff: Double) = diff(JsonField.of(diff)) + + /** Difference in score between the current and comparison experiment */ + @JsonProperty("diff") + @ExcludeMissing + fun diff(diff: JsonField) = apply { this.diff = diff } + + /** Number of improvements in the score */ + fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) + + /** Number of improvements in the score */ + @JsonProperty("improvements") + @ExcludeMissing + fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + + /** Number of regressions in the score */ + fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) + + /** Number of regressions in the score */ + @JsonProperty("regressions") + @ExcludeMissing + fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + + 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(): ScoreSummary = + ScoreSummary( + name, + score, + diff, + improvements, + regressions, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt new file mode 100755 index 0000000..4b2fdaf --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -0,0 +1,205 @@ +// 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 +import java.util.Optional + +/** Summary of a dataset */ +@JsonDeserialize(builder = SummarizeDatasetResponse.Builder::class) +@NoAutoDetect +class SummarizeDatasetResponse +private constructor( + private val projectName: JsonField, + private val datasetName: JsonField, + private val projectUrl: JsonField, + private val datasetUrl: JsonField, + private val dataSummary: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the project that the dataset belongs to */ + fun projectName(): String = projectName.getRequired("project_name") + + /** Name of the dataset */ + fun datasetName(): String = datasetName.getRequired("dataset_name") + + /** URL to the project's page in the Braintrust app */ + fun projectUrl(): String = projectUrl.getRequired("project_url") + + /** URL to the dataset's page in the Braintrust app */ + fun datasetUrl(): String = datasetUrl.getRequired("dataset_url") + + /** Summary of a dataset's data */ + fun dataSummary(): Optional = + Optional.ofNullable(dataSummary.getNullable("data_summary")) + + /** Name of the project that the dataset belongs to */ + @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + + /** Name of the dataset */ + @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName() = datasetName + + /** URL to the project's page in the Braintrust app */ + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl + + /** URL to the dataset's page in the Braintrust app */ + @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl() = datasetUrl + + /** Summary of a dataset's data */ + @JsonProperty("data_summary") @ExcludeMissing fun _dataSummary() = dataSummary + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SummarizeDatasetResponse = apply { + if (!validated) { + projectName() + datasetName() + projectUrl() + datasetUrl() + dataSummary().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SummarizeDatasetResponse && + this.projectName == other.projectName && + this.datasetName == other.datasetName && + this.projectUrl == other.projectUrl && + this.datasetUrl == other.datasetUrl && + this.dataSummary == other.dataSummary && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectName, + datasetName, + projectUrl, + datasetUrl, + dataSummary, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SummarizeDatasetResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectName: JsonField = JsonMissing.of() + private var datasetName: JsonField = JsonMissing.of() + private var projectUrl: JsonField = JsonMissing.of() + private var datasetUrl: JsonField = JsonMissing.of() + private var dataSummary: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = apply { + this.projectName = summarizeDatasetResponse.projectName + this.datasetName = summarizeDatasetResponse.datasetName + this.projectUrl = summarizeDatasetResponse.projectUrl + this.datasetUrl = summarizeDatasetResponse.datasetUrl + this.dataSummary = summarizeDatasetResponse.dataSummary + additionalProperties(summarizeDatasetResponse.additionalProperties) + } + + /** Name of the project that the dataset belongs to */ + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + /** Name of the project that the dataset belongs to */ + @JsonProperty("project_name") + @ExcludeMissing + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + + /** Name of the dataset */ + fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) + + /** Name of the dataset */ + @JsonProperty("dataset_name") + @ExcludeMissing + fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } + + /** URL to the project's page in the Braintrust app */ + fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) + + /** URL to the project's page in the Braintrust app */ + @JsonProperty("project_url") + @ExcludeMissing + fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + + /** URL to the dataset's page in the Braintrust app */ + fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) + + /** URL to the dataset's page in the Braintrust app */ + @JsonProperty("dataset_url") + @ExcludeMissing + fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } + + /** Summary of a dataset's data */ + fun dataSummary(dataSummary: DataSummary) = dataSummary(JsonField.of(dataSummary)) + + /** Summary of a dataset's data */ + @JsonProperty("data_summary") + @ExcludeMissing + fun dataSummary(dataSummary: JsonField) = apply { + this.dataSummary = dataSummary + } + + 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(): SummarizeDatasetResponse = + SummarizeDatasetResponse( + projectName, + datasetName, + projectUrl, + datasetUrl, + dataSummary, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt new file mode 100755 index 0000000..8a391f6 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -0,0 +1,400 @@ +// 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 +import java.util.Optional + +/** Summary of an experiment */ +@JsonDeserialize(builder = SummarizeExperimentResponse.Builder::class) +@NoAutoDetect +class SummarizeExperimentResponse +private constructor( + private val projectName: JsonField, + private val experimentName: JsonField, + private val projectUrl: JsonField, + private val experimentUrl: JsonField, + private val comparisonExperimentName: JsonField, + private val scores: JsonField, + private val metrics: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Name of the project that the experiment belongs to */ + fun projectName(): String = projectName.getRequired("project_name") + + /** Name of the experiment */ + fun experimentName(): String = experimentName.getRequired("experiment_name") + + /** URL to the project's page in the Braintrust app */ + fun projectUrl(): String = projectUrl.getRequired("project_url") + + /** URL to the experiment's page in the Braintrust app */ + fun experimentUrl(): String = experimentUrl.getRequired("experiment_url") + + /** The experiment which scores are baselined against */ + fun comparisonExperimentName(): Optional = + Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) + + /** Summary of the experiment's scores */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** Summary of the experiment's metrics */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** Name of the project that the experiment belongs to */ + @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + + /** Name of the experiment */ + @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName() = experimentName + + /** URL to the project's page in the Braintrust app */ + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl + + /** URL to the experiment's page in the Braintrust app */ + @JsonProperty("experiment_url") @ExcludeMissing fun _experimentUrl() = experimentUrl + + /** The experiment which scores are baselined against */ + @JsonProperty("comparison_experiment_name") + @ExcludeMissing + fun _comparisonExperimentName() = comparisonExperimentName + + /** Summary of the experiment's scores */ + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + + /** Summary of the experiment's metrics */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SummarizeExperimentResponse = apply { + if (!validated) { + projectName() + experimentName() + projectUrl() + experimentUrl() + comparisonExperimentName() + scores().map { it.validate() } + metrics().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SummarizeExperimentResponse && + this.projectName == other.projectName && + this.experimentName == other.experimentName && + this.projectUrl == other.projectUrl && + this.experimentUrl == other.experimentUrl && + this.comparisonExperimentName == other.comparisonExperimentName && + this.scores == other.scores && + this.metrics == other.metrics && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + projectName, + experimentName, + projectUrl, + experimentUrl, + comparisonExperimentName, + scores, + metrics, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SummarizeExperimentResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var projectName: JsonField = JsonMissing.of() + private var experimentName: JsonField = JsonMissing.of() + private var projectUrl: JsonField = JsonMissing.of() + private var experimentUrl: JsonField = JsonMissing.of() + private var comparisonExperimentName: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var metrics: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = apply { + this.projectName = summarizeExperimentResponse.projectName + this.experimentName = summarizeExperimentResponse.experimentName + this.projectUrl = summarizeExperimentResponse.projectUrl + this.experimentUrl = summarizeExperimentResponse.experimentUrl + this.comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName + this.scores = summarizeExperimentResponse.scores + this.metrics = summarizeExperimentResponse.metrics + additionalProperties(summarizeExperimentResponse.additionalProperties) + } + + /** Name of the project that the experiment belongs to */ + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + /** Name of the project that the experiment belongs to */ + @JsonProperty("project_name") + @ExcludeMissing + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + + /** Name of the experiment */ + fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) + + /** Name of the experiment */ + @JsonProperty("experiment_name") + @ExcludeMissing + fun experimentName(experimentName: JsonField) = apply { + this.experimentName = experimentName + } + + /** URL to the project's page in the Braintrust app */ + fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) + + /** URL to the project's page in the Braintrust app */ + @JsonProperty("project_url") + @ExcludeMissing + fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + + /** URL to the experiment's page in the Braintrust app */ + fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) + + /** URL to the experiment's page in the Braintrust app */ + @JsonProperty("experiment_url") + @ExcludeMissing + fun experimentUrl(experimentUrl: JsonField) = apply { + this.experimentUrl = experimentUrl + } + + /** The experiment which scores are baselined against */ + fun comparisonExperimentName(comparisonExperimentName: String) = + comparisonExperimentName(JsonField.of(comparisonExperimentName)) + + /** The experiment which scores are baselined against */ + @JsonProperty("comparison_experiment_name") + @ExcludeMissing + fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { + this.comparisonExperimentName = comparisonExperimentName + } + + /** Summary of the experiment's scores */ + fun scores(scores: Scores) = scores(JsonField.of(scores)) + + /** Summary of the experiment's scores */ + @JsonProperty("scores") + @ExcludeMissing + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** Summary of the experiment's metrics */ + fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + + /** Summary of the experiment's metrics */ + @JsonProperty("metrics") + @ExcludeMissing + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + 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(): SummarizeExperimentResponse = + SummarizeExperimentResponse( + projectName, + experimentName, + projectUrl, + experimentUrl, + comparisonExperimentName, + scores, + metrics, + additionalProperties.toUnmodifiable(), + ) + } + + /** Summary of the experiment's metrics */ + @JsonDeserialize(builder = Metrics.Builder::class) + @NoAutoDetect + class Metrics + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metrics = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metrics && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Metrics{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metrics: Metrics) = apply { + additionalProperties(metrics.additionalProperties) + } + + 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(): Metrics = Metrics(additionalProperties.toUnmodifiable()) + } + } + + /** Summary of the experiment's scores */ + @JsonDeserialize(builder = Scores.Builder::class) + @NoAutoDetect + class Scores + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scores = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scores && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scores: Scores) = apply { + additionalProperties(scores.additionalProperties) + } + + 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(): Scores = Scores(additionalProperties.toUnmodifiable()) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserEmail.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserEmail.kt new file mode 100755 index 0000000..8dad70f --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserEmail.kt @@ -0,0 +1,131 @@ +// 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.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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 = UserEmail.Deserializer::class) +@JsonSerialize(using = UserEmail.Serializer::class) +class UserEmail +private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): UserEmail = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown UserEmail: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserEmail && this.string == other.string && this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash(string, strings) + } + + override fun toString(): String { + return when { + string != null -> "UserEmail{string=$string}" + strings != null -> "UserEmail{strings=$strings}" + _json != null -> "UserEmail{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UserEmail") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = UserEmail(string = string) + + @JvmStatic fun ofStrings(strings: List) = UserEmail(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown UserEmail: $json") + } + } + + class Deserializer : BaseDeserializer(UserEmail::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UserEmail { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return UserEmail(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return UserEmail(strings = it, _json = json) + } + + return UserEmail(_json = json) + } + } + + class Serializer : BaseSerializer(UserEmail::class) { + + override fun serialize( + value: UserEmail, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UserEmail") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserFamilyName.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserFamilyName.kt new file mode 100755 index 0000000..9191128 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserFamilyName.kt @@ -0,0 +1,133 @@ +// 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.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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 = UserFamilyName.Deserializer::class) +@JsonSerialize(using = UserFamilyName.Serializer::class) +class UserFamilyName +private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): UserFamilyName = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown UserFamilyName: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserFamilyName && + this.string == other.string && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash(string, strings) + } + + override fun toString(): String { + return when { + string != null -> "UserFamilyName{string=$string}" + strings != null -> "UserFamilyName{strings=$strings}" + _json != null -> "UserFamilyName{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UserFamilyName") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = UserFamilyName(string = string) + + @JvmStatic fun ofStrings(strings: List) = UserFamilyName(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown UserFamilyName: $json") + } + } + + class Deserializer : BaseDeserializer(UserFamilyName::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UserFamilyName { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return UserFamilyName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return UserFamilyName(strings = it, _json = json) + } + + return UserFamilyName(_json = json) + } + } + + class Serializer : BaseSerializer(UserFamilyName::class) { + + override fun serialize( + value: UserFamilyName, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UserFamilyName") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserGivenName.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserGivenName.kt new file mode 100755 index 0000000..b03d6ae --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserGivenName.kt @@ -0,0 +1,133 @@ +// 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.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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 = UserGivenName.Deserializer::class) +@JsonSerialize(using = UserGivenName.Serializer::class) +class UserGivenName +private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): UserGivenName = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown UserGivenName: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserGivenName && + this.string == other.string && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash(string, strings) + } + + override fun toString(): String { + return when { + string != null -> "UserGivenName{string=$string}" + strings != null -> "UserGivenName{strings=$strings}" + _json != null -> "UserGivenName{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UserGivenName") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = UserGivenName(string = string) + + @JvmStatic fun ofStrings(strings: List) = UserGivenName(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown UserGivenName: $json") + } + } + + class Deserializer : BaseDeserializer(UserGivenName::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UserGivenName { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return UserGivenName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return UserGivenName(strings = it, _json = json) + } + + return UserGivenName(_json = json) + } + } + + class Serializer : BaseSerializer(UserGivenName::class) { + + override fun serialize( + value: UserGivenName, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UserGivenName") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index c4c09bc..57d0584 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -2,30 +2,19 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer 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.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 class UserListParams constructor( - private val email: Email?, + private val email: UserEmail?, private val endingBefore: String?, - private val familyName: FamilyName?, - private val givenName: GivenName?, + private val familyName: UserFamilyName?, + private val givenName: UserGivenName?, private val ids: Ids?, private val limit: Long?, private val orgName: String?, @@ -35,13 +24,13 @@ constructor( private val additionalBodyProperties: Map, ) { - fun email(): Optional = Optional.ofNullable(email) + fun email(): Optional = Optional.ofNullable(email) fun endingBefore(): Optional = Optional.ofNullable(endingBefore) - fun familyName(): Optional = Optional.ofNullable(familyName) + fun familyName(): Optional = Optional.ofNullable(familyName) - fun givenName(): Optional = Optional.ofNullable(givenName) + fun givenName(): Optional = Optional.ofNullable(givenName) fun ids(): Optional = Optional.ofNullable(ids) @@ -122,10 +111,10 @@ constructor( @NoAutoDetect class Builder { - private var email: Email? = null + private var email: UserEmail? = null private var endingBefore: String? = null - private var familyName: FamilyName? = null - private var givenName: GivenName? = null + private var familyName: UserFamilyName? = null + private var givenName: UserGivenName? = null private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null @@ -153,19 +142,19 @@ constructor( * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun email(email: Email) = apply { this.email = email } + fun email(email: UserEmail) = apply { this.email = email } /** * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun email(string: String) = apply { this.email = Email.ofString(string) } + fun email(string: String) = apply { this.email = UserEmail.ofString(string) } /** * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun email(strings: List) = apply { this.email = Email.ofStrings(strings) } + fun email(strings: List) = apply { this.email = UserEmail.ofStrings(strings) } /** * Pagination cursor id. @@ -180,40 +169,40 @@ constructor( * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ - fun familyName(familyName: FamilyName) = apply { this.familyName = familyName } + fun familyName(familyName: UserFamilyName) = apply { this.familyName = familyName } /** * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ - fun familyName(string: String) = apply { this.familyName = FamilyName.ofString(string) } + fun familyName(string: String) = apply { this.familyName = UserFamilyName.ofString(string) } /** * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ fun familyName(strings: List) = apply { - this.familyName = FamilyName.ofStrings(strings) + this.familyName = UserFamilyName.ofStrings(strings) } /** * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ - fun givenName(givenName: GivenName) = apply { this.givenName = givenName } + fun givenName(givenName: UserGivenName) = apply { this.givenName = givenName } /** * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ - fun givenName(string: String) = apply { this.givenName = GivenName.ofString(string) } + fun givenName(string: String) = apply { this.givenName = UserGivenName.ofString(string) } /** * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ fun givenName(strings: List) = apply { - this.givenName = GivenName.ofStrings(strings) + this.givenName = UserGivenName.ofStrings(strings) } /** @@ -318,460 +307,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - @JsonDeserialize(using = Email.Deserializer::class) - @JsonSerialize(using = Email.Serializer::class) - class Email - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Email = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Email: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Email && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Email{string=$string}" - strings != null -> "Email{strings=$strings}" - _json != null -> "Email{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Email") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Email(string = string) - - @JvmStatic fun ofStrings(strings: List) = Email(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Email: $json") - } - } - - class Deserializer : BaseDeserializer(Email::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Email { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Email(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Email(strings = it, _json = json) - } - - return Email(_json = json) - } - } - - class Serializer : BaseSerializer(Email::class) { - - override fun serialize( - value: Email, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Email") - } - } - } - } - - @JsonDeserialize(using = FamilyName.Deserializer::class) - @JsonSerialize(using = FamilyName.Serializer::class) - class FamilyName - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): FamilyName = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown FamilyName: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FamilyName && - this.string == other.string && - this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "FamilyName{string=$string}" - strings != null -> "FamilyName{strings=$strings}" - _json != null -> "FamilyName{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FamilyName") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = FamilyName(string = string) - - @JvmStatic fun ofStrings(strings: List) = FamilyName(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FamilyName: $json") - } - } - - class Deserializer : BaseDeserializer(FamilyName::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FamilyName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return FamilyName(strings = it, _json = json) - } - - return FamilyName(_json = json) - } - } - - class Serializer : BaseSerializer(FamilyName::class) { - - override fun serialize( - value: FamilyName, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FamilyName") - } - } - } - } - - @JsonDeserialize(using = GivenName.Deserializer::class) - @JsonSerialize(using = GivenName.Serializer::class) - class GivenName - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): GivenName = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown GivenName: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GivenName && - this.string == other.string && - this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "GivenName{string=$string}" - strings != null -> "GivenName{strings=$strings}" - _json != null -> "GivenName{_unknown=$_json}" - else -> throw IllegalStateException("Invalid GivenName") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = GivenName(string = string) - - @JvmStatic fun ofStrings(strings: List) = GivenName(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown GivenName: $json") - } - } - - class Deserializer : BaseDeserializer(GivenName::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): GivenName { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return GivenName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return GivenName(strings = it, _json = json) - } - - return GivenName(_json = json) - } - } - - class Serializer : BaseSerializer(GivenName::class) { - - override fun serialize( - value: GivenName, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid GivenName") - } - } - } - } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt index 208dce0..07fa5c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt @@ -2,35 +2,20 @@ 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 -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 class ViewListParams constructor( private val objectId: String, - private val objectType: ObjectType?, + private val objectType: AclObjectType?, private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, - private val projectName: String?, private val startingAfter: String?, private val viewName: String?, private val viewType: ViewType?, @@ -41,7 +26,7 @@ constructor( fun objectId(): String = objectId - fun objectType(): Optional = Optional.ofNullable(objectType) + fun objectType(): Optional = Optional.ofNullable(objectType) fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -49,8 +34,6 @@ constructor( fun limit(): Optional = Optional.ofNullable(limit) - fun projectName(): Optional = Optional.ofNullable(projectName) - fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun viewName(): Optional = Optional.ofNullable(viewName) @@ -65,7 +48,6 @@ constructor( this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } this.ids?.let { params.put("ids", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } this.viewName?.let { params.put("view_name", listOf(it.toString())) } this.viewType?.let { params.put("view_type", listOf(it.toString())) } @@ -92,7 +74,6 @@ constructor( this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && - this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.viewName == other.viewName && this.viewType == other.viewType && @@ -108,7 +89,6 @@ constructor( endingBefore, ids, limit, - projectName, startingAfter, viewName, viewType, @@ -119,7 +99,7 @@ constructor( } override fun toString() = - "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, projectName=$projectName, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -132,11 +112,10 @@ constructor( class Builder { private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectType: AclObjectType? = null private var endingBefore: String? = null private var ids: Ids? = null private var limit: Long? = null - private var projectName: String? = null private var startingAfter: String? = null private var viewName: String? = null private var viewType: ViewType? = null @@ -151,7 +130,6 @@ constructor( this.endingBefore = viewListParams.endingBefore this.ids = viewListParams.ids this.limit = viewListParams.limit - this.projectName = viewListParams.projectName this.startingAfter = viewListParams.startingAfter this.viewName = viewListParams.viewName this.viewType = viewListParams.viewType @@ -164,7 +142,7 @@ constructor( fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: AclObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. @@ -196,9 +174,6 @@ constructor( /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } - /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } - /** * Pagination cursor id. * @@ -275,7 +250,6 @@ constructor( endingBefore, ids, limit, - projectName, startingAfter, viewName, viewType, @@ -284,321 +258,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - class ObjectType - @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 ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) - - @JvmField val PROJECT = ObjectType(JsonField.of("project")) - - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) - - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) - - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - @JvmField val GROUP = ObjectType(JsonField.of("group")) - - @JvmField val ROLE = ObjectType(JsonField.of("role")) - - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) - - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) - - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - @JvmStatic fun ofString(string: String) = Ids(string = string) - - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } - - class ViewType - @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 ViewType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val PROJECTS = ViewType(JsonField.of("projects")) - - @JvmField val LOGS = ViewType(JsonField.of("logs")) - - @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) - - @JvmField val DATASETS = ViewType(JsonField.of("datasets")) - - @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) - - @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) - - @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) - - @JvmField val DATASET = ViewType(JsonField.of("dataset")) - - @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) - } - - enum class Known { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - } - - enum class Value { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt index 698e35c..53f2038 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt @@ -2,14 +2,10 @@ 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.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional @@ -17,7 +13,7 @@ class ViewRetrieveParams constructor( private val viewId: String, private val objectId: String, - private val objectType: ObjectType?, + private val objectType: AclObjectType?, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, @@ -27,7 +23,7 @@ constructor( fun objectId(): String = objectId - fun objectType(): Optional = Optional.ofNullable(objectType) + fun objectType(): Optional = Optional.ofNullable(objectType) @JvmSynthetic internal fun getQueryParams(): Map> { @@ -93,7 +89,7 @@ constructor( private var viewId: String? = null private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectType: AclObjectType? = null private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -115,7 +111,7 @@ constructor( fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: AclObjectType) = apply { this.objectType = objectType } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -181,115 +177,4 @@ constructor( additionalBodyProperties.toUnmodifiable(), ) } - - class ObjectType - @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 ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) - - @JvmField val PROJECT = ObjectType(JsonField.of("project")) - - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) - - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) - - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - @JvmField val GROUP = ObjectType(JsonField.of("group")) - - @JvmField val ROLE = ObjectType(JsonField.of("role")) - - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) - - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) - - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt new file mode 100755 index 0000000..6f79468 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt @@ -0,0 +1,102 @@ +// 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 ViewType +@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 ViewType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PROJECTS = ViewType(JsonField.of("projects")) + + @JvmField val LOGS = ViewType(JsonField.of("logs")) + + @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + + @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + + @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + + @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + + @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + + @JvmField val DATASET = ViewType(JsonField.of("dataset")) + + @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) + } + + enum class Known { + PROJECTS, + LOGS, + EXPERIMENTS, + DATASETS, + PROMPTS, + PLAYGROUNDS, + EXPERIMENT, + DATASET, + } + + enum class Value { + PROJECTS, + LOGS, + EXPERIMENTS, + DATASETS, + PROMPTS, + PLAYGROUNDS, + EXPERIMENT, + DATASET, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } + + fun asString(): String = _value().asStringOrThrow() +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index ba78510..3dab404 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyCreateResponse import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams +import com.braintrustdata.api.models.CreateApiKeyOutput import java.util.concurrent.CompletableFuture interface ApiKeyServiceAsync { @@ -24,7 +24,7 @@ interface ApiKeyServiceAsync { fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Get an api_key object by its id */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index ce4661f..5228efa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyCreateResponse import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams +import com.braintrustdata.api.models.CreateApiKeyOutput import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler @@ -28,8 +28,8 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Create a new api_key. It is possible to have multiple API keys with the same name. There is @@ -38,7 +38,7 @@ constructor( override fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index eeaf345..93e0e33 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -11,16 +11,15 @@ import com.braintrustdata.api.models.DatasetDeleteParams import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams -import com.braintrustdata.api.models.DatasetFetchPostResponse -import com.braintrustdata.api.models.DatasetFetchResponse import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetInsertResponse import com.braintrustdata.api.models.DatasetListPageAsync import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams -import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams +import com.braintrustdata.api.models.FetchDatasetEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeDatasetResponse import java.util.concurrent.CompletableFuture interface DatasetServiceAsync { @@ -85,7 +84,7 @@ interface DatasetServiceAsync { fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the @@ -95,19 +94,19 @@ interface DatasetServiceAsync { fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Insert a set of events into the dataset */ @JvmOverloads fun insert( params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Summarize dataset */ @JvmOverloads fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index f46fe0d..df47e05 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -14,16 +14,15 @@ import com.braintrustdata.api.models.DatasetDeleteParams import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams -import com.braintrustdata.api.models.DatasetFetchPostResponse -import com.braintrustdata.api.models.DatasetFetchResponse import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetInsertResponse import com.braintrustdata.api.models.DatasetListPageAsync import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams -import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams +import com.braintrustdata.api.models.FetchDatasetEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeDatasetResponse import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json @@ -221,8 +220,9 @@ constructor( } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the @@ -231,7 +231,7 @@ constructor( override fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -253,8 +253,8 @@ constructor( } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -264,7 +264,7 @@ constructor( override fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -287,14 +287,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the dataset */ override fun insert( params: DatasetInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -317,15 +317,15 @@ constructor( } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** Summarize dataset */ override fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index 0fdcd09..87d4c55 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -11,16 +11,15 @@ import com.braintrustdata.api.models.ExperimentDeleteParams import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams -import com.braintrustdata.api.models.ExperimentFetchPostResponse -import com.braintrustdata.api.models.ExperimentFetchResponse import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams -import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams +import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture interface ExperimentServiceAsync { @@ -85,7 +84,7 @@ interface ExperimentServiceAsync { fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the @@ -95,19 +94,19 @@ interface ExperimentServiceAsync { fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Insert a set of events into the experiment */ @JvmOverloads fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Summarize experiment */ @JvmOverloads fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 851da98..06e29e2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -14,16 +14,15 @@ import com.braintrustdata.api.models.ExperimentDeleteParams import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams -import com.braintrustdata.api.models.ExperimentFetchPostResponse -import com.braintrustdata.api.models.ExperimentFetchResponse import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams -import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams +import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeExperimentResponse import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json @@ -221,8 +220,8 @@ constructor( } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -232,7 +231,7 @@ constructor( override fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -254,8 +253,8 @@ constructor( } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -265,7 +264,7 @@ constructor( override fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -288,15 +287,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -319,15 +317,15 @@ constructor( } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** Summarize experiment */ override fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index f8fd649..805e10f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -18,8 +18,8 @@ import java.util.concurrent.CompletableFuture interface ViewServiceAsync { /** - * Create a new view. If there is an existing view in the project with the same name as the one - * specified in the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one specified in + * the request, will return the existing view unmodified */ @JvmOverloads fun create( @@ -63,8 +63,8 @@ interface ViewServiceAsync { ): CompletableFuture /** - * Create or replace view. If there is an existing view in the project with the same name as the - * one specified in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the one specified + * in the request, will replace the existing view with the provided fields */ @JvmOverloads fun replace( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index c7a4a62..9a9874e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -33,8 +33,8 @@ constructor( jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new view. If there is an existing view in the project with the same name as the one - * specified in the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one specified in + * the request, will return the existing view unmodified */ override fun create( params: ViewCreateParams, @@ -193,8 +193,8 @@ constructor( jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace view. If there is an existing view in the project with the same name as the - * one specified in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the one specified + * in the request, will replace the existing view with the provided fields */ override fun replace( params: ViewReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index c719215..8589ae8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -5,13 +5,12 @@ package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture interface LogServiceAsync { @@ -31,7 +30,7 @@ interface LogServiceAsync { fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the @@ -41,12 +40,12 @@ interface LogServiceAsync { fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Insert a set of events into the project logs */ @JvmOverloads fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 78f67b8..7835f25 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -8,13 +8,12 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json @@ -52,8 +51,8 @@ constructor( } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -63,7 +62,7 @@ constructor( override fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -85,8 +84,8 @@ constructor( } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -96,7 +95,7 @@ constructor( override fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -119,15 +118,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, 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/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index 147576e..a98e1d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyCreateResponse import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams +import com.braintrustdata.api.models.CreateApiKeyOutput interface ApiKeyService { @@ -23,7 +23,7 @@ interface ApiKeyService { fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none() - ): ApiKeyCreateResponse + ): CreateApiKeyOutput /** Get an api_key object by its id */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index f8b088f..5b705c6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyCreateResponse import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams +import com.braintrustdata.api.models.CreateApiKeyOutput import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler @@ -27,8 +27,8 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Create a new api_key. It is possible to have multiple API keys with the same name. There is @@ -37,7 +37,7 @@ constructor( override fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions - ): ApiKeyCreateResponse { + ): CreateApiKeyOutput { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index ce1e5d9..16fcfa1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -11,16 +11,15 @@ import com.braintrustdata.api.models.DatasetDeleteParams import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams -import com.braintrustdata.api.models.DatasetFetchPostResponse -import com.braintrustdata.api.models.DatasetFetchResponse import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetInsertResponse import com.braintrustdata.api.models.DatasetListPage import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams -import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams +import com.braintrustdata.api.models.FetchDatasetEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeDatasetResponse interface DatasetService { @@ -84,7 +83,7 @@ interface DatasetService { fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none() - ): DatasetFetchResponse + ): FetchDatasetEventsResponse /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the @@ -94,19 +93,19 @@ interface DatasetService { fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none() - ): DatasetFetchPostResponse + ): FetchDatasetEventsResponse /** Insert a set of events into the dataset */ @JvmOverloads fun insert( params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): DatasetInsertResponse + ): InsertEventsResponse /** Summarize dataset */ @JvmOverloads fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none() - ): DatasetSummarizeResponse + ): SummarizeDatasetResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index fefb964..aafe705 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -14,16 +14,15 @@ import com.braintrustdata.api.models.DatasetDeleteParams import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams -import com.braintrustdata.api.models.DatasetFetchPostResponse -import com.braintrustdata.api.models.DatasetFetchResponse import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetInsertResponse import com.braintrustdata.api.models.DatasetListPage import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams -import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams +import com.braintrustdata.api.models.FetchDatasetEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeDatasetResponse import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json @@ -196,8 +195,9 @@ constructor( } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the @@ -206,7 +206,7 @@ constructor( override fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions - ): DatasetFetchResponse { + ): FetchDatasetEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -227,8 +227,8 @@ constructor( } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -238,7 +238,7 @@ constructor( override fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions - ): DatasetFetchPostResponse { + ): FetchDatasetEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -260,14 +260,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the dataset */ override fun insert( params: DatasetInsertParams, requestOptions: RequestOptions - ): DatasetInsertResponse { + ): InsertEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -289,15 +289,15 @@ constructor( } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** Summarize dataset */ override fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions - ): DatasetSummarizeResponse { + ): SummarizeDatasetResponse { val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 3156a0e..9a9777f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -11,16 +11,15 @@ import com.braintrustdata.api.models.ExperimentDeleteParams import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams -import com.braintrustdata.api.models.ExperimentFetchPostResponse -import com.braintrustdata.api.models.ExperimentFetchResponse import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams -import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams +import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeExperimentResponse interface ExperimentService { @@ -84,7 +83,7 @@ interface ExperimentService { fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentFetchResponse + ): FetchExperimentEventsResponse /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the @@ -94,19 +93,19 @@ interface ExperimentService { fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentFetchPostResponse + ): FetchExperimentEventsResponse /** Insert a set of events into the experiment */ @JvmOverloads fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentInsertResponse + ): InsertEventsResponse /** Summarize experiment */ @JvmOverloads fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentSummarizeResponse + ): SummarizeExperimentResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 7df45f8..3f67064 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -14,16 +14,15 @@ import com.braintrustdata.api.models.ExperimentDeleteParams import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams -import com.braintrustdata.api.models.ExperimentFetchPostResponse -import com.braintrustdata.api.models.ExperimentFetchResponse import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams -import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams +import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse +import com.braintrustdata.api.models.SummarizeExperimentResponse import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json @@ -211,8 +210,8 @@ constructor( } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -222,7 +221,7 @@ constructor( override fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions - ): ExperimentFetchResponse { + ): FetchExperimentEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -243,8 +242,8 @@ constructor( } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -254,7 +253,7 @@ constructor( override fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions - ): ExperimentFetchPostResponse { + ): FetchExperimentEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -276,15 +275,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): ExperimentInsertResponse { + ): InsertEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -306,15 +304,15 @@ constructor( } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** Summarize experiment */ override fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions - ): ExperimentSummarizeResponse { + ): SummarizeExperimentResponse { val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index c9b1648..d71f5ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -17,8 +17,8 @@ import com.braintrustdata.api.models.ViewUpdateParams interface ViewService { /** - * Create a new view. If there is an existing view in the project with the same name as the one - * specified in the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one specified in + * the request, will return the existing view unmodified */ @JvmOverloads fun create( @@ -62,8 +62,8 @@ interface ViewService { ): View /** - * Create or replace view. If there is an existing view in the project with the same name as the - * one specified in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the one specified + * in the request, will replace the existing view with the provided fields */ @JvmOverloads fun replace( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index fc8dd34..f682e6d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -32,8 +32,8 @@ constructor( jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new view. If there is an existing view in the project with the same name as the one - * specified in the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one specified in + * the request, will return the existing view unmodified */ override fun create(params: ViewCreateParams, requestOptions: RequestOptions): View { val request = @@ -171,8 +171,8 @@ constructor( jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace view. If there is an existing view in the project with the same name as the - * one specified in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the one specified + * in the request, will replace the existing view with the provided fields */ override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): View { val request = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index 1ce6166..018cb4a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -5,13 +5,12 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse interface LogService { @@ -30,7 +29,7 @@ interface LogService { fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectLogFetchResponse + ): FetchProjectLogsEventsResponse /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the @@ -40,12 +39,12 @@ interface LogService { fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectLogFetchPostResponse + ): FetchProjectLogsEventsResponse /** Insert a set of events into the project logs */ @JvmOverloads fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectLogInsertResponse + ): InsertEventsResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index d8d6192..07baf95 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -8,13 +8,12 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json @@ -47,8 +46,8 @@ constructor( } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -58,7 +57,7 @@ constructor( override fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions - ): ProjectLogFetchResponse { + ): FetchProjectLogsEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -79,8 +78,8 @@ constructor( } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -90,7 +89,7 @@ constructor( override fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions - ): ProjectLogFetchPostResponse { + ): FetchProjectLogsEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -112,15 +111,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): ProjectLogInsertResponse { + ): InsertEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt index aa22dbb..4d70563 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt @@ -12,9 +12,9 @@ class AclListParamsTest { fun createAclListParams() { AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -25,15 +25,15 @@ class AclListParamsTest { val params = AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = mutableMapOf>() expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(AclListParams.ObjectType.ORGANIZATION.toString())) + expected.put("object_type", listOf(AclObjectType.ORGANIZATION.toString())) expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put( "ids", diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index e749c8e..52934c7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -13,7 +13,7 @@ class ApiKeyListParamsTest { ApiKeyListParams.builder() .apiKeyName("api_key_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -26,7 +26,7 @@ class ApiKeyListParamsTest { ApiKeyListParams.builder() .apiKeyName("api_key_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateAclTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateAclTest.kt new file mode 100755 index 0000000..bb5a764 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateAclTest.kt @@ -0,0 +1,32 @@ +// 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 CreateAclTest { + + @Test + fun createCreateAcl() { + val createAcl = + CreateAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(CreateAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(CreateAcl.Permission.CREATE) + .restrictObjectType(CreateAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(createAcl).isNotNull + assertThat(createAcl.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createAcl.objectType()).contains(CreateAcl.ObjectType.ORGANIZATION) + assertThat(createAcl.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createAcl.permission()).contains(CreateAcl.Permission.CREATE) + assertThat(createAcl.restrictObjectType()) + .contains(CreateAcl.RestrictObjectType.ORGANIZATION) + assertThat(createAcl.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createAcl.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt new file mode 100755 index 0000000..6bfead2 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CreateApiKeyOutputTest { + + @Test + fun createCreateApiKeyOutput() { + val createApiKeyOutput = + CreateApiKeyOutput.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .key("key") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(createApiKeyOutput).isNotNull + assertThat(createApiKeyOutput.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.key()).isEqualTo("key") + assertThat(createApiKeyOutput.name()).isEqualTo("name") + assertThat(createApiKeyOutput.previewName()).isEqualTo("preview_name") + assertThat(createApiKeyOutput.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createApiKeyOutput.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateDatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateDatasetTest.kt new file mode 100755 index 0000000..6d20761 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateDatasetTest.kt @@ -0,0 +1,23 @@ +// 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 CreateDatasetTest { + + @Test + fun createCreateDataset() { + val createDataset = + CreateDataset.builder() + .name("name") + .description("description") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(createDataset).isNotNull + assertThat(createDataset.name()).isEqualTo("name") + assertThat(createDataset.description()).contains("description") + assertThat(createDataset.projectId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateExperimentTest.kt new file mode 100755 index 0000000..220ea20 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateExperimentTest.kt @@ -0,0 +1,63 @@ +// 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 CreateExperimentTest { + + @Test + fun createCreateExperiment() { + val createExperiment = + CreateExperiment.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(CreateExperiment.Metadata.builder().build()) + .name("name") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + assertThat(createExperiment).isNotNull + assertThat(createExperiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createExperiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createExperiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createExperiment.datasetVersion()).contains("dataset_version") + assertThat(createExperiment.description()).contains("description") + assertThat(createExperiment.ensureNew()).contains(true) + assertThat(createExperiment.metadata()) + .contains(CreateExperiment.Metadata.builder().build()) + assertThat(createExperiment.name()).contains("name") + assertThat(createExperiment.public_()).contains(true) + assertThat(createExperiment.repoInfo()) + .contains( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateFunctionTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateFunctionTest.kt new file mode 100755 index 0000000..554517c --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateFunctionTest.kt @@ -0,0 +1,183 @@ +// 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 CreateFunctionTest { + + @Test + fun createCreateFunction() { + val createFunction = + CreateFunction.builder() + .functionData( + CreateFunction.FunctionData.ofPrompt( + CreateFunction.FunctionData.Prompt.builder() + .type(CreateFunction.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(createFunction).isNotNull + assertThat(createFunction.functionData()) + .isEqualTo( + CreateFunction.FunctionData.ofPrompt( + CreateFunction.FunctionData.Prompt.builder() + .type(CreateFunction.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(createFunction.name()).isEqualTo("name") + assertThat(createFunction.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createFunction.slug()).isEqualTo("slug") + assertThat(createFunction.description()).contains("description") + assertThat(createFunction.promptData()) + .contains( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams.FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + assertThat(createFunction.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateGroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateGroupTest.kt new file mode 100755 index 0000000..f78234f --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateGroupTest.kt @@ -0,0 +1,29 @@ +// 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 CreateGroupTest { + + @Test + fun createCreateGroup() { + val createGroup = + CreateGroup.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + assertThat(createGroup).isNotNull + assertThat(createGroup.name()).isEqualTo("name") + assertThat(createGroup.description()).contains("description") + assertThat(createGroup.memberGroups().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createGroup.memberUsers().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createGroup.orgName()).contains("org_name") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectScoreTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectScoreTest.kt new file mode 100755 index 0000000..21f1cc7 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectScoreTest.kt @@ -0,0 +1,36 @@ +// 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 CreateProjectScoreTest { + + @Test + fun createCreateProjectScore() { + val createProjectScore = + CreateProjectScore.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(CreateProjectScore.ScoreType.SLIDER) + .categories( + CreateProjectScore.Categories.ofList( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) + ) + .description("description") + .build() + assertThat(createProjectScore).isNotNull + assertThat(createProjectScore.name()).isEqualTo("name") + assertThat(createProjectScore.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createProjectScore.scoreType()).contains(CreateProjectScore.ScoreType.SLIDER) + assertThat(createProjectScore.categories()) + .contains( + CreateProjectScore.Categories.ofList( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) + ) + assertThat(createProjectScore.description()).contains("description") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTagTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTagTest.kt new file mode 100755 index 0000000..6ead372 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTagTest.kt @@ -0,0 +1,25 @@ +// 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 CreateProjectTagTest { + + @Test + fun createCreateProjectTag() { + val createProjectTag = + CreateProjectTag.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + assertThat(createProjectTag).isNotNull + assertThat(createProjectTag.name()).isEqualTo("name") + assertThat(createProjectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createProjectTag.color()).contains("color") + assertThat(createProjectTag.description()).contains("description") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTest.kt new file mode 100755 index 0000000..4ce7bd2 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTest.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 CreateProjectTest { + + @Test + fun createCreateProject() { + val createProject = CreateProject.builder().name("name").orgName("org_name").build() + assertThat(createProject).isNotNull + assertThat(createProject.name()).isEqualTo("name") + assertThat(createProject.orgName()).contains("org_name") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreatePromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreatePromptTest.kt new file mode 100755 index 0000000..7850e10 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreatePromptTest.kt @@ -0,0 +1,168 @@ +// 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 CreatePromptTest { + + @Test + fun createCreatePrompt() { + val createPrompt = + CreatePrompt.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(createPrompt).isNotNull + assertThat(createPrompt.name()).isEqualTo("name") + assertThat(createPrompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createPrompt.slug()).isEqualTo("slug") + assertThat(createPrompt.description()).contains("description") + assertThat(createPrompt.promptData()) + .contains( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams.FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + assertThat(createPrompt.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateRoleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateRoleTest.kt new file mode 100755 index 0000000..6606746 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateRoleTest.kt @@ -0,0 +1,43 @@ +// 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 CreateRoleTest { + + @Test + fun createCreateRole() { + val createRole = + CreateRole.builder() + .name("name") + .description("description") + .memberPermissions( + listOf( + CreateRole.MemberPermission.builder() + .permission(CreateRole.MemberPermission.Permission.CREATE) + .restrictObjectType( + CreateRole.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + assertThat(createRole).isNotNull + assertThat(createRole.name()).isEqualTo("name") + assertThat(createRole.description()).contains("description") + assertThat(createRole.memberPermissions().get()) + .containsExactly( + CreateRole.MemberPermission.builder() + .permission(CreateRole.MemberPermission.Permission.CREATE) + .restrictObjectType(CreateRole.MemberPermission.RestrictObjectType.ORGANIZATION) + .build() + ) + assertThat(createRole.memberRoles().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createRole.orgName()).contains("org_name") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateViewTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateViewTest.kt new file mode 100755 index 0000000..2f7e59d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateViewTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CreateViewTest { + + @Test + fun createCreateView() { + val createView = + CreateView.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(CreateView.ObjectType.ORGANIZATION) + .viewType(CreateView.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + assertThat(createView).isNotNull + assertThat(createView.name()).isEqualTo("name") + assertThat(createView.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createView.objectType()).contains(CreateView.ObjectType.ORGANIZATION) + assertThat(createView.viewType()).contains(CreateView.ViewType.PROJECTS) + assertThat(createView.deletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createView.options()) + .contains( + ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build() + ) + assertThat(createView.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createView.viewData()) + .contains( + ViewData.builder() + .search( + ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequestTest.kt new file mode 100755 index 0000000..733b028 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequestTest.kt @@ -0,0 +1,26 @@ +// 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 CrossObjectInsertRequestTest { + + @Test + fun createCrossObjectInsertRequest() { + val crossObjectInsertRequest = + CrossObjectInsertRequest.builder() + .dataset(CrossObjectInsertRequest.Dataset.builder().build()) + .experiment(CrossObjectInsertRequest.Experiment.builder().build()) + .projectLogs(CrossObjectInsertRequest.ProjectLogs.builder().build()) + .build() + assertThat(crossObjectInsertRequest).isNotNull + assertThat(crossObjectInsertRequest.dataset()) + .contains(CrossObjectInsertRequest.Dataset.builder().build()) + assertThat(crossObjectInsertRequest.experiment()) + .contains(CrossObjectInsertRequest.Experiment.builder().build()) + assertThat(crossObjectInsertRequest.projectLogs()) + .contains(CrossObjectInsertRequest.ProjectLogs.builder().build()) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt new file mode 100755 index 0000000..dca2c6f --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -0,0 +1,26 @@ +// 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 CrossObjectInsertResponseTest { + + @Test + fun createCrossObjectInsertResponse() { + val crossObjectInsertResponse = + CrossObjectInsertResponse.builder() + .dataset(CrossObjectInsertResponse.Dataset.builder().build()) + .experiment(CrossObjectInsertResponse.Experiment.builder().build()) + .projectLogs(CrossObjectInsertResponse.ProjectLogs.builder().build()) + .build() + assertThat(crossObjectInsertResponse).isNotNull + assertThat(crossObjectInsertResponse.dataset()) + .contains(CrossObjectInsertResponse.Dataset.builder().build()) + assertThat(crossObjectInsertResponse.experiment()) + .contains(CrossObjectInsertResponse.Experiment.builder().build()) + assertThat(crossObjectInsertResponse.projectLogs()) + .contains(CrossObjectInsertResponse.ProjectLogs.builder().build()) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt new file mode 100755 index 0000000..544c8f0 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.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 DataSummaryTest { + + @Test + fun createDataSummary() { + val dataSummary = DataSummary.builder().totalRecords(123L).build() + assertThat(dataSummary).isNotNull + assertThat(dataSummary.totalRecords()).isEqualTo(123L) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt new file mode 100755 index 0000000..6c397ee --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class DatasetEventTest { + + @Test + fun createDatasetEvent() { + val datasetEvent = + DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(DatasetEvent.Metadata.builder().build()) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tags(listOf("string")) + .build() + assertThat(datasetEvent).isNotNull + assertThat(datasetEvent.id()).isEqualTo("id") + assertThat(datasetEvent._xactId()).isEqualTo("_xact_id") + assertThat(datasetEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetEvent.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(datasetEvent.spanId()).isEqualTo("span_id") + assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent.metadata()).contains(DatasetEvent.Metadata.builder().build()) + assertThat(datasetEvent.projectId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index a91ce93..e5ec92f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -14,11 +14,11 @@ class DatasetFeedbackParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - DatasetFeedbackParams.Feedback.builder() + FeedbackDatasetItem.builder() .id("id") .comment("comment") - .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) - .source(DatasetFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) .build() ) ) @@ -32,11 +32,11 @@ class DatasetFeedbackParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - DatasetFeedbackParams.Feedback.builder() + FeedbackDatasetItem.builder() .id("id") .comment("comment") - .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) - .source(DatasetFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) .build() ) ) @@ -46,11 +46,11 @@ class DatasetFeedbackParamsTest { assertThat(body.feedback()) .isEqualTo( listOf( - DatasetFeedbackParams.Feedback.builder() + FeedbackDatasetItem.builder() .id("id") .comment("comment") - .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) - .source(DatasetFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) .build() ) ) @@ -61,12 +61,12 @@ class DatasetFeedbackParamsTest { val params = DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(DatasetFeedbackParams.Feedback.builder().id("id").build())) + .feedback(listOf(FeedbackDatasetItem.builder().id("id").build())) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.feedback()) - .isEqualTo(listOf(DatasetFeedbackParams.Feedback.builder().id("id").build())) + .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) } @Test @@ -74,7 +74,7 @@ class DatasetFeedbackParamsTest { val params = DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(DatasetFeedbackParams.Feedback.builder().id("id").build())) + .feedback(listOf(FeedbackDatasetItem.builder().id("id").build())) .build() assertThat(params).isNotNull // path param "datasetId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index e4188df..b43e0a1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -16,9 +16,9 @@ class DatasetFetchPostParamsTest { .cursor("cursor") .filters( listOf( - DatasetFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -38,9 +38,9 @@ class DatasetFetchPostParamsTest { .cursor("cursor") .filters( listOf( - DatasetFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -56,9 +56,9 @@ class DatasetFetchPostParamsTest { assertThat(body.filters()) .isEqualTo( listOf( - DatasetFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 209f3ae..c2ddba2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -16,8 +16,8 @@ class DatasetInsertParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - DatasetInsertParams.Event.InsertDatasetEventReplace.builder() + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) @@ -25,11 +25,7 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) .tags(listOf("string")) .build() ) @@ -45,8 +41,8 @@ class DatasetInsertParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - DatasetInsertParams.Event.InsertDatasetEventReplace.builder() + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) @@ -54,11 +50,7 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) .tags(listOf("string")) .build() ) @@ -70,8 +62,8 @@ class DatasetInsertParamsTest { assertThat(body.events()) .isEqualTo( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - DatasetInsertParams.Event.InsertDatasetEventReplace.builder() + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) @@ -79,11 +71,7 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) .tags(listOf("string")) .build() ) @@ -98,8 +86,8 @@ class DatasetInsertParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build() + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder().build() ) ) ) @@ -109,8 +97,8 @@ class DatasetInsertParamsTest { assertThat(body.events()) .isEqualTo( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build() + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder().build() ) ) ) @@ -123,8 +111,8 @@ class DatasetInsertParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build() + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder().build() ) ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index 66937ca..377c269 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -13,9 +13,10 @@ class DatasetListParamsTest { DatasetListParams.builder() .datasetName("dataset_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -27,9 +28,10 @@ class DatasetListParamsTest { DatasetListParams.builder() .datasetName("dataset_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -44,6 +46,7 @@ class DatasetListParamsTest { ) expected.put("limit", listOf("123")) expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put("project_name", listOf("project_name")) expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(params.getQueryParams()).isEqualTo(expected) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DeleteViewTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DeleteViewTest.kt new file mode 100755 index 0000000..68b4dbb --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DeleteViewTest.kt @@ -0,0 +1,21 @@ +// 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 DeleteViewTest { + + @Test + fun createDeleteView() { + val deleteView = + DeleteView.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DeleteView.ObjectType.ORGANIZATION) + .build() + assertThat(deleteView).isNotNull + assertThat(deleteView.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(deleteView.objectType()).contains(DeleteView.ObjectType.ORGANIZATION) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt new file mode 100755 index 0000000..49f8ce8 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExperimentEventTest { + + @Test + fun createExperimentEvent() { + val experimentEvent = + ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ExperimentEvent.Metadata.builder().build()) + .metrics( + ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder().build()) + .spanAttributes( + ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build() + ) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + assertThat(experimentEvent).isNotNull + assertThat(experimentEvent.id()).isEqualTo("id") + assertThat(experimentEvent._xactId()).isEqualTo("_xact_id") + assertThat(experimentEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experimentEvent.experimentId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(experimentEvent.spanId()).isEqualTo("span_id") + assertThat(experimentEvent.context()) + .contains( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.metadata()).contains(ExperimentEvent.Metadata.builder().build()) + assertThat(experimentEvent.metrics()) + .contains( + ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.scores()).contains(ExperimentEvent.Scores.builder().build()) + assertThat(experimentEvent.spanAttributes()) + .contains( + ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build() + ) + assertThat(experimentEvent.spanParents().get()).containsExactly("string") + assertThat(experimentEvent.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index 852f6f6..59d68ce 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -15,13 +15,13 @@ class ExperimentFeedbackParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - ExperimentFeedbackParams.Feedback.builder() + FeedbackExperimentItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) - .source(ExperimentFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) .build() ) ) @@ -35,13 +35,13 @@ class ExperimentFeedbackParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - ExperimentFeedbackParams.Feedback.builder() + FeedbackExperimentItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) - .source(ExperimentFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) .build() ) ) @@ -51,13 +51,13 @@ class ExperimentFeedbackParamsTest { assertThat(body.feedback()) .isEqualTo( listOf( - ExperimentFeedbackParams.Feedback.builder() + FeedbackExperimentItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) - .source(ExperimentFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) .build() ) ) @@ -68,12 +68,12 @@ class ExperimentFeedbackParamsTest { val params = ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ExperimentFeedbackParams.Feedback.builder().id("id").build())) + .feedback(listOf(FeedbackExperimentItem.builder().id("id").build())) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.feedback()) - .isEqualTo(listOf(ExperimentFeedbackParams.Feedback.builder().id("id").build())) + .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) } @Test @@ -81,7 +81,7 @@ class ExperimentFeedbackParamsTest { val params = ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ExperimentFeedbackParams.Feedback.builder().id("id").build())) + .feedback(listOf(FeedbackExperimentItem.builder().id("id").build())) .build() assertThat(params).isNotNull // path param "experimentId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index 990e491..45a9cd0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -16,9 +16,9 @@ class ExperimentFetchPostParamsTest { .cursor("cursor") .filters( listOf( - ExperimentFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -38,9 +38,9 @@ class ExperimentFetchPostParamsTest { .cursor("cursor") .filters( listOf( - ExperimentFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -56,9 +56,9 @@ class ExperimentFetchPostParamsTest { assertThat(body.filters()) .isEqualTo( listOf( - ExperimentFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt index 1d1da8c..d0a06f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt @@ -16,15 +16,14 @@ class ExperimentInsertParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Context - .builder() + InsertExperimentEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) @@ -32,16 +31,12 @@ class ExperimentInsertParamsTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) .metrics( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Metrics - .builder() + InsertExperimentEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -50,22 +45,11 @@ class ExperimentInsertParamsTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores - .builder() - .build() - ) + .scores(InsertExperimentEventReplace.Scores.builder().build()) .spanAttributes( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .SpanAttributes - .builder() + InsertExperimentEventReplace.SpanAttributes.builder() .name("name") - .type( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .SpanAttributes - .Type - .LLM - ) + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) .build() ) .tags(listOf("string")) @@ -83,16 +67,14 @@ class ExperimentInsertParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .Context - .builder() + InsertExperimentEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) @@ -100,18 +82,12 @@ class ExperimentInsertParamsTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .Metadata - .builder() - .build() - ) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) .metrics( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .Metrics - .builder() + InsertExperimentEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -120,23 +96,11 @@ class ExperimentInsertParamsTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores - .builder() - .build() - ) + .scores(InsertExperimentEventReplace.Scores.builder().build()) .spanAttributes( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .SpanAttributes - .builder() + InsertExperimentEventReplace.SpanAttributes.builder() .name("name") - .type( - ExperimentInsertParams.Event - .InsertExperimentEventReplace - .SpanAttributes - .Type - .LLM - ) + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) .build() ) .tags(listOf("string")) @@ -150,15 +114,14 @@ class ExperimentInsertParamsTest { assertThat(body.events()) .isEqualTo( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Context - .builder() + InsertExperimentEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) @@ -166,16 +129,12 @@ class ExperimentInsertParamsTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) .metrics( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Metrics - .builder() + InsertExperimentEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -184,22 +143,11 @@ class ExperimentInsertParamsTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores - .builder() - .build() - ) + .scores(InsertExperimentEventReplace.Scores.builder().build()) .spanAttributes( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .SpanAttributes - .builder() + InsertExperimentEventReplace.SpanAttributes.builder() .name("name") - .type( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .SpanAttributes - .Type - .LLM - ) + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) .build() ) .tags(listOf("string")) @@ -216,9 +164,8 @@ class ExperimentInsertParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() - .build() + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder().build() ) ) ) @@ -228,8 +175,8 @@ class ExperimentInsertParamsTest { assertThat(body.events()) .isEqualTo( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - ExperimentInsertParams.Event.InsertExperimentEventReplace.builder().build() + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder().build() ) ) ) @@ -242,9 +189,8 @@ class ExperimentInsertParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() - .build() + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder().build() ) ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 266edf8..51109ec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -13,9 +13,10 @@ class ExperimentListParamsTest { ExperimentListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -27,9 +28,10 @@ class ExperimentListParamsTest { ExperimentListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -44,6 +46,7 @@ class ExperimentListParamsTest { ) expected.put("limit", listOf("123")) expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put("project_name", listOf("project_name")) expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(params.getQueryParams()).isEqualTo(expected) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequestTest.kt new file mode 100755 index 0000000..a98a49a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequestTest.kt @@ -0,0 +1,36 @@ +// 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 FeedbackDatasetEventRequestTest { + + @Test + fun createFeedbackDatasetEventRequest() { + val feedbackDatasetEventRequest = + FeedbackDatasetEventRequest.builder() + .feedback( + listOf( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build() + ) + ) + .build() + assertThat(feedbackDatasetEventRequest).isNotNull + assertThat(feedbackDatasetEventRequest.feedback()) + .containsExactly( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt new file mode 100755 index 0000000..76dd0db --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -0,0 +1,26 @@ +// 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 FeedbackDatasetItemTest { + + @Test + fun createFeedbackDatasetItem() { + val feedbackDatasetItem = + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build() + assertThat(feedbackDatasetItem).isNotNull + assertThat(feedbackDatasetItem.id()).isEqualTo("id") + assertThat(feedbackDatasetItem.comment()).contains("comment") + assertThat(feedbackDatasetItem.metadata()) + .contains(FeedbackDatasetItem.Metadata.builder().build()) + assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequestTest.kt new file mode 100755 index 0000000..e94155c --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequestTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FeedbackExperimentEventRequestTest { + + @Test + fun createFeedbackExperimentEventRequest() { + val feedbackExperimentEventRequest = + FeedbackExperimentEventRequest.builder() + .feedback( + listOf( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build() + ) + ) + .build() + assertThat(feedbackExperimentEventRequest).isNotNull + assertThat(feedbackExperimentEventRequest.feedback()) + .containsExactly( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt new file mode 100755 index 0000000..01b9475 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FeedbackExperimentItemTest { + + @Test + fun createFeedbackExperimentItem() { + val feedbackExperimentItem = + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build() + assertThat(feedbackExperimentItem).isNotNull + assertThat(feedbackExperimentItem.id()).isEqualTo("id") + assertThat(feedbackExperimentItem.comment()).contains("comment") + assertThat(feedbackExperimentItem._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackExperimentItem.metadata()) + .contains(FeedbackExperimentItem.Metadata.builder().build()) + assertThat(feedbackExperimentItem.scores()) + .contains(FeedbackExperimentItem.Scores.builder().build()) + assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequestTest.kt new file mode 100755 index 0000000..78255f5 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequestTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FeedbackProjectLogsEventRequestTest { + + @Test + fun createFeedbackProjectLogsEventRequest() { + val feedbackProjectLogsEventRequest = + FeedbackProjectLogsEventRequest.builder() + .feedback( + listOf( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build() + ) + ) + .build() + assertThat(feedbackProjectLogsEventRequest).isNotNull + assertThat(feedbackProjectLogsEventRequest.feedback()) + .containsExactly( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt new file mode 100755 index 0000000..faea304 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FeedbackProjectLogsItemTest { + + @Test + fun createFeedbackProjectLogsItem() { + val feedbackProjectLogsItem = + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build() + assertThat(feedbackProjectLogsItem).isNotNull + assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") + assertThat(feedbackProjectLogsItem.comment()).contains("comment") + assertThat(feedbackProjectLogsItem._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackProjectLogsItem.metadata()) + .contains(FeedbackProjectLogsItem.Metadata.builder().build()) + assertThat(feedbackProjectLogsItem.scores()) + .contains(FeedbackProjectLogsItem.Scores.builder().build()) + assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt new file mode 100755 index 0000000..c60eb1c --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FetchDatasetEventsResponseTest { + + @Test + fun createFetchDatasetEventsResponse() { + val fetchDatasetEventsResponse = + FetchDatasetEventsResponse.builder() + .events( + listOf( + DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(DatasetEvent.Metadata.builder().build()) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tags(listOf("string")) + .build() + ) + ) + .cursor("cursor") + .build() + assertThat(fetchDatasetEventsResponse).isNotNull + assertThat(fetchDatasetEventsResponse.events()) + .containsExactly( + DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(DatasetEvent.Metadata.builder().build()) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tags(listOf("string")) + .build() + ) + assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchEventsRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchEventsRequestTest.kt new file mode 100755 index 0000000..0b309dc --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchEventsRequestTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FetchEventsRequestTest { + + @Test + fun createFetchEventsRequest() { + val fetchEventsRequest = + FetchEventsRequest.builder() + .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + assertThat(fetchEventsRequest).isNotNull + assertThat(fetchEventsRequest.cursor()).contains("cursor") + assertThat(fetchEventsRequest.filters().get()) + .containsExactly( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + assertThat(fetchEventsRequest.limit()).contains(123L) + assertThat(fetchEventsRequest.maxRootSpanId()).contains("max_root_span_id") + assertThat(fetchEventsRequest.maxXactId()).contains("max_xact_id") + assertThat(fetchEventsRequest.version()).contains("version") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt new file mode 100755 index 0000000..bf0118f --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FetchExperimentEventsResponseTest { + + @Test + fun createFetchExperimentEventsResponse() { + val fetchExperimentEventsResponse = + FetchExperimentEventsResponse.builder() + .events( + listOf( + ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ExperimentEvent.Metadata.builder().build()) + .metrics( + ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder().build()) + .spanAttributes( + ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build() + ) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + ) + ) + .cursor("cursor") + .build() + assertThat(fetchExperimentEventsResponse).isNotNull + assertThat(fetchExperimentEventsResponse.events()) + .containsExactly( + ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ExperimentEvent.Metadata.builder().build()) + .metrics( + ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder().build()) + .spanAttributes( + ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build() + ) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + ) + assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt new file mode 100755 index 0000000..621d5e9 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FetchProjectLogsEventsResponseTest { + + @Test + fun createFetchProjectLogsEventsResponse() { + val fetchProjectLogsEventsResponse = + FetchProjectLogsEventsResponse.builder() + .events( + listOf( + ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metrics( + ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder().build()) + .spanAttributes( + ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build() + ) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + ) + ) + .cursor("cursor") + .build() + assertThat(fetchProjectLogsEventsResponse).isNotNull + assertThat(fetchProjectLogsEventsResponse.events()) + .containsExactly( + ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metrics( + ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder().build()) + .spanAttributes( + ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build() + ) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + ) + assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index d34d684..15dc60c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -13,9 +13,10 @@ class FunctionListParamsTest { FunctionListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .functionName("function_name") - .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .slug("slug") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -29,9 +30,10 @@ class FunctionListParamsTest { FunctionListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .functionName("function_name") - .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .slug("slug") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -48,6 +50,7 @@ class FunctionListParamsTest { ) expected.put("limit", listOf("123")) expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put("project_name", listOf("project_name")) expected.put("slug", listOf("slug")) expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index 33587c1..404be33 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -13,7 +13,7 @@ class GroupListParamsTest { GroupListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -26,7 +26,7 @@ class GroupListParamsTest { GroupListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt new file mode 100755 index 0000000..4bc4a86 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertDatasetEventMergeTest { + + @Test + fun createInsertDatasetEventMerge() { + val insertDatasetEventMerge = + InsertDatasetEventMerge.builder() + ._isMerge(true) + .id("id") + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventMerge.Metadata.builder().build()) + .tags(listOf("string")) + .build() + assertThat(insertDatasetEventMerge).isNotNull + assertThat(insertDatasetEventMerge._isMerge()).isEqualTo(true) + assertThat(insertDatasetEventMerge.id()).contains("id") + assertThat(insertDatasetEventMerge._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertDatasetEventMerge._objectDelete()).contains(true) + assertThat(insertDatasetEventMerge.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEventMerge._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventMerge._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventMerge.metadata()) + .contains(InsertDatasetEventMerge.Metadata.builder().build()) + assertThat(insertDatasetEventMerge.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt new file mode 100755 index 0000000..5c1ce7d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertDatasetEventReplaceTest { + + @Test + fun createInsertDatasetEventReplace() { + val insertDatasetEventReplace = + InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build() + assertThat(insertDatasetEventReplace).isNotNull + assertThat(insertDatasetEventReplace.id()).contains("id") + assertThat(insertDatasetEventReplace._isMerge()).contains(true) + assertThat(insertDatasetEventReplace._objectDelete()).contains(true) + assertThat(insertDatasetEventReplace._parentId()).contains("_parent_id") + assertThat(insertDatasetEventReplace.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEventReplace._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventReplace._input()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventReplace.metadata()) + .contains(InsertDatasetEventReplace.Metadata.builder().build()) + assertThat(insertDatasetEventReplace.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequestTest.kt new file mode 100755 index 0000000..4418668 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequestTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertDatasetEventRequestTest { + + @Test + fun createInsertDatasetEventRequest() { + val insertDatasetEventRequest = + InsertDatasetEventRequest.builder() + .events( + listOf( + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() + assertThat(insertDatasetEventRequest).isNotNull + assertThat(insertDatasetEventRequest.events()) + .containsExactly( + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build() + ) + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt new file mode 100755 index 0000000..a55a120 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.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 InsertEventsResponseTest { + + @Test + fun createInsertEventsResponse() { + val insertEventsResponse = InsertEventsResponse.builder().rowIds(listOf("string")).build() + assertThat(insertEventsResponse).isNotNull + assertThat(insertEventsResponse.rowIds()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt new file mode 100755 index 0000000..513ee1a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertExperimentEventMergeTest { + + @Test + fun createInsertExperimentEventMerge() { + val insertExperimentEventMerge = + InsertExperimentEventMerge.builder() + ._isMerge(true) + .id("id") + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + .context( + InsertExperimentEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventMerge.Metadata.builder().build()) + .metrics( + InsertExperimentEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventMerge.Scores.builder().build()) + .spanAttributes( + InsertExperimentEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(insertExperimentEventMerge).isNotNull + assertThat(insertExperimentEventMerge._isMerge()).isEqualTo(true) + assertThat(insertExperimentEventMerge.id()).contains("id") + assertThat(insertExperimentEventMerge._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertExperimentEventMerge._objectDelete()).contains(true) + assertThat(insertExperimentEventMerge.context()) + .contains( + InsertExperimentEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(insertExperimentEventMerge.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEventMerge.datasetRecordId()).contains("dataset_record_id") + assertThat(insertExperimentEventMerge._error()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge._input()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge.metadata()) + .contains(InsertExperimentEventMerge.Metadata.builder().build()) + assertThat(insertExperimentEventMerge.metrics()) + .contains( + InsertExperimentEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(insertExperimentEventMerge._output()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge.scores()) + .contains(InsertExperimentEventMerge.Scores.builder().build()) + assertThat(insertExperimentEventMerge.spanAttributes()) + .contains( + InsertExperimentEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) + .build() + ) + assertThat(insertExperimentEventMerge.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt new file mode 100755 index 0000000..ebe7a08 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertExperimentEventReplaceTest { + + @Test + fun createInsertExperimentEventReplace() { + val insertExperimentEventReplace = + InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics( + InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes( + InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(insertExperimentEventReplace).isNotNull + assertThat(insertExperimentEventReplace.id()).contains("id") + assertThat(insertExperimentEventReplace._isMerge()).contains(true) + assertThat(insertExperimentEventReplace._objectDelete()).contains(true) + assertThat(insertExperimentEventReplace._parentId()).contains("_parent_id") + assertThat(insertExperimentEventReplace.context()) + .contains( + InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(insertExperimentEventReplace.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEventReplace.datasetRecordId()).contains("dataset_record_id") + assertThat(insertExperimentEventReplace._error()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace._input()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace.metadata()) + .contains(InsertExperimentEventReplace.Metadata.builder().build()) + assertThat(insertExperimentEventReplace.metrics()) + .contains( + InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(insertExperimentEventReplace._output()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace.scores()) + .contains(InsertExperimentEventReplace.Scores.builder().build()) + assertThat(insertExperimentEventReplace.spanAttributes()) + .contains( + InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build() + ) + assertThat(insertExperimentEventReplace.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequestTest.kt new file mode 100755 index 0000000..fb9188a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequestTest.kt @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertExperimentEventRequestTest { + + @Test + fun createInsertExperimentEventRequest() { + val insertExperimentEventRequest = + InsertExperimentEventRequest.builder() + .events( + listOf( + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics( + InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes( + InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() + assertThat(insertExperimentEventRequest).isNotNull + assertThat(insertExperimentEventRequest.events()) + .containsExactly( + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics( + InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes( + InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt new file mode 100755 index 0000000..f6dedc8 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertProjectLogsEventMergeTest { + + @Test + fun createInsertProjectLogsEventMerge() { + val insertProjectLogsEventMerge = + InsertProjectLogsEventMerge.builder() + ._isMerge(true) + .id("id") + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + .context( + InsertProjectLogsEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventMerge.Metadata.builder().build()) + .metrics( + InsertProjectLogsEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventMerge.Scores.builder().build()) + .spanAttributes( + InsertProjectLogsEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(insertProjectLogsEventMerge).isNotNull + assertThat(insertProjectLogsEventMerge._isMerge()).isEqualTo(true) + assertThat(insertProjectLogsEventMerge.id()).contains("id") + assertThat(insertProjectLogsEventMerge._mergePaths().get()) + .containsExactly(listOf("string")) + assertThat(insertProjectLogsEventMerge._objectDelete()).contains(true) + assertThat(insertProjectLogsEventMerge.context()) + .contains( + InsertProjectLogsEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(insertProjectLogsEventMerge.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEventMerge._error()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge._input()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge.metadata()) + .contains(InsertProjectLogsEventMerge.Metadata.builder().build()) + assertThat(insertProjectLogsEventMerge.metrics()) + .contains( + InsertProjectLogsEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(insertProjectLogsEventMerge._output()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge.scores()) + .contains(InsertProjectLogsEventMerge.Scores.builder().build()) + assertThat(insertProjectLogsEventMerge.spanAttributes()) + .contains( + InsertProjectLogsEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) + .build() + ) + assertThat(insertProjectLogsEventMerge.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt new file mode 100755 index 0000000..eb3caa6 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertProjectLogsEventReplaceTest { + + @Test + fun createInsertProjectLogsEventReplace() { + val insertProjectLogsEventReplace = + InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics( + InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes( + InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(insertProjectLogsEventReplace).isNotNull + assertThat(insertProjectLogsEventReplace.id()).contains("id") + assertThat(insertProjectLogsEventReplace._isMerge()).contains(true) + assertThat(insertProjectLogsEventReplace._objectDelete()).contains(true) + assertThat(insertProjectLogsEventReplace._parentId()).contains("_parent_id") + assertThat(insertProjectLogsEventReplace.context()) + .contains( + InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(insertProjectLogsEventReplace.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEventReplace._error()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace._input()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace.metadata()) + .contains(InsertProjectLogsEventReplace.Metadata.builder().build()) + assertThat(insertProjectLogsEventReplace.metrics()) + .contains( + InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(insertProjectLogsEventReplace._output()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace.scores()) + .contains(InsertProjectLogsEventReplace.Scores.builder().build()) + assertThat(insertProjectLogsEventReplace.spanAttributes()) + .contains( + InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build() + ) + assertThat(insertProjectLogsEventReplace.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequestTest.kt new file mode 100755 index 0000000..1d81bdb --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequestTest.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertProjectLogsEventRequestTest { + + @Test + fun createInsertProjectLogsEventRequest() { + val insertProjectLogsEventRequest = + InsertProjectLogsEventRequest.builder() + .events( + listOf( + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics( + InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes( + InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() + assertThat(insertProjectLogsEventRequest).isNotNull + assertThat(insertProjectLogsEventRequest.events()) + .containsExactly( + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics( + InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes( + InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt new file mode 100755 index 0000000..50e74b1 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt @@ -0,0 +1,29 @@ +// 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 MetricSummaryTest { + + @Test + fun createMetricSummary() { + val metricSummary = + MetricSummary.builder() + .improvements(123L) + .metric(42.23) + .name("name") + .regressions(123L) + .unit("unit") + .diff(42.23) + .build() + assertThat(metricSummary).isNotNull + assertThat(metricSummary.improvements()).isEqualTo(123L) + assertThat(metricSummary.metric()).isEqualTo(42.23) + assertThat(metricSummary.name()).isEqualTo("name") + assertThat(metricSummary.regressions()).isEqualTo(123L) + assertThat(metricSummary.unit()).isEqualTo("unit") + assertThat(metricSummary.diff()).contains(42.23) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index c0ddb5b..2c532d8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -12,7 +12,7 @@ class OrganizationListParamsTest { fun createOrganizationListParams() { OrganizationListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .organizationName("organization_name") @@ -25,7 +25,7 @@ class OrganizationListParamsTest { val params = OrganizationListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .organizationName("organization_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchDatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchDatasetTest.kt new file mode 100755 index 0000000..9eec1e4 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchDatasetTest.kt @@ -0,0 +1,23 @@ +// 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 PatchDatasetTest { + + @Test + fun createPatchDataset() { + val patchDataset = + PatchDataset.builder() + .description("description") + .metadata(PatchDataset.Metadata.builder().build()) + .name("name") + .build() + assertThat(patchDataset).isNotNull + assertThat(patchDataset.description()).contains("description") + assertThat(patchDataset.metadata()).contains(PatchDataset.Metadata.builder().build()) + assertThat(patchDataset.name()).contains("name") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchExperimentTest.kt new file mode 100755 index 0000000..91597c6 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchExperimentTest.kt @@ -0,0 +1,58 @@ +// 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 PatchExperimentTest { + + @Test + fun createPatchExperiment() { + val patchExperiment = + PatchExperiment.builder() + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(PatchExperiment.Metadata.builder().build()) + .name("name") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + assertThat(patchExperiment).isNotNull + assertThat(patchExperiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchExperiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchExperiment.datasetVersion()).contains("dataset_version") + assertThat(patchExperiment.description()).contains("description") + assertThat(patchExperiment.metadata()).contains(PatchExperiment.Metadata.builder().build()) + assertThat(patchExperiment.name()).contains("name") + assertThat(patchExperiment.public_()).contains(true) + assertThat(patchExperiment.repoInfo()) + .contains( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchFunctionTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchFunctionTest.kt new file mode 100755 index 0000000..d990aab --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchFunctionTest.kt @@ -0,0 +1,179 @@ +// 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 PatchFunctionTest { + + @Test + fun createPatchFunction() { + val patchFunction = + PatchFunction.builder() + .description("description") + .functionData( + PatchFunction.FunctionData.ofPrompt( + PatchFunction.FunctionData.Prompt.builder() + .type(PatchFunction.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .promptData( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(patchFunction).isNotNull + assertThat(patchFunction.description()).contains("description") + assertThat(patchFunction.functionData()) + .contains( + PatchFunction.FunctionData.ofPrompt( + PatchFunction.FunctionData.Prompt.builder() + .type(PatchFunction.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(patchFunction.name()).contains("name") + assertThat(patchFunction.promptData()) + .contains( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams.FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + assertThat(patchFunction.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchGroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchGroupTest.kt new file mode 100755 index 0000000..1b31132 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchGroupTest.kt @@ -0,0 +1,33 @@ +// 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 PatchGroupTest { + + @Test + fun createPatchGroup() { + val patchGroup = + PatchGroup.builder() + .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + assertThat(patchGroup).isNotNull + assertThat(patchGroup.addMemberGroups().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchGroup.addMemberUsers().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchGroup.description()).contains("description") + assertThat(patchGroup.name()).contains("name") + assertThat(patchGroup.removeMemberGroups().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchGroup.removeMemberUsers().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersTest.kt new file mode 100755 index 0000000..f59e3df --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersTest.kt @@ -0,0 +1,53 @@ +// 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 PatchOrganizationMembersTest { + + @Test + fun createPatchOrganizationMembers() { + val patchOrganizationMembers = + PatchOrganizationMembers.builder() + .inviteUsers( + PatchOrganizationMembers.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + PatchOrganizationMembers.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + .build() + assertThat(patchOrganizationMembers).isNotNull + assertThat(patchOrganizationMembers.inviteUsers()) + .contains( + PatchOrganizationMembers.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build() + ) + assertThat(patchOrganizationMembers.orgId()).contains("org_id") + assertThat(patchOrganizationMembers.orgName()).contains("org_name") + assertThat(patchOrganizationMembers.removeUsers()) + .contains( + PatchOrganizationMembers.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationTest.kt new file mode 100755 index 0000000..4f5a607 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationTest.kt @@ -0,0 +1,27 @@ +// 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 PatchOrganizationTest { + + @Test + fun createPatchOrganization() { + val patchOrganization = + PatchOrganization.builder() + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + assertThat(patchOrganization).isNotNull + assertThat(patchOrganization.apiUrl()).contains("api_url") + assertThat(patchOrganization.isUniversalApi()).contains(true) + assertThat(patchOrganization.name()).contains("name") + assertThat(patchOrganization.proxyUrl()).contains("proxy_url") + assertThat(patchOrganization.realtimeUrl()).contains("realtime_url") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectScoreTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectScoreTest.kt new file mode 100755 index 0000000..43c7bbc --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectScoreTest.kt @@ -0,0 +1,34 @@ +// 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 PatchProjectScoreTest { + + @Test + fun createPatchProjectScore() { + val patchProjectScore = + PatchProjectScore.builder() + .categories( + PatchProjectScore.Categories.ofList( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) + ) + .description("description") + .name("name") + .scoreType(PatchProjectScore.ScoreType.SLIDER) + .build() + assertThat(patchProjectScore).isNotNull + assertThat(patchProjectScore.categories()) + .contains( + PatchProjectScore.Categories.ofList( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) + ) + assertThat(patchProjectScore.description()).contains("description") + assertThat(patchProjectScore.name()).contains("name") + assertThat(patchProjectScore.scoreType()).contains(PatchProjectScore.ScoreType.SLIDER) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTagTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTagTest.kt new file mode 100755 index 0000000..2544000 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTagTest.kt @@ -0,0 +1,19 @@ +// 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 PatchProjectTagTest { + + @Test + fun createPatchProjectTag() { + val patchProjectTag = + PatchProjectTag.builder().color("color").description("description").name("name").build() + assertThat(patchProjectTag).isNotNull + assertThat(patchProjectTag.color()).contains("color") + assertThat(patchProjectTag.description()).contains("description") + assertThat(patchProjectTag.name()).contains("name") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTest.kt new file mode 100755 index 0000000..d6b7801 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTest.kt @@ -0,0 +1,22 @@ +// 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 PatchProjectTest { + + @Test + fun createPatchProject() { + val patchProject = + PatchProject.builder() + .name("name") + .settings(PatchProject.Settings.builder().comparisonKey("comparison_key").build()) + .build() + assertThat(patchProject).isNotNull + assertThat(patchProject.name()).contains("name") + assertThat(patchProject.settings()) + .contains(PatchProject.Settings.builder().comparisonKey("comparison_key").build()) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchPromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchPromptTest.kt new file mode 100755 index 0000000..cd065ae --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchPromptTest.kt @@ -0,0 +1,164 @@ +// 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 PatchPromptTest { + + @Test + fun createPatchPrompt() { + val patchPrompt = + PatchPrompt.builder() + .description("description") + .name("name") + .promptData( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(patchPrompt).isNotNull + assertThat(patchPrompt.description()).contains("description") + assertThat(patchPrompt.name()).contains("name") + assertThat(patchPrompt.promptData()) + .contains( + PromptData.builder() + .options( + PromptData.Options.builder() + .model("model") + .params( + PromptData.Options.Params.ofOpenAIModelParams( + PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptData.Options.Params.OpenAIModelParams.FunctionCall + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + assertThat(patchPrompt.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchRoleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchRoleTest.kt new file mode 100755 index 0000000..0c894a2 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchRoleTest.kt @@ -0,0 +1,65 @@ +// 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 PatchRoleTest { + + @Test + fun createPatchRole() { + val patchRole = + PatchRole.builder() + .addMemberPermissions( + listOf( + PatchRole.AddMemberPermission.builder() + .permission(PatchRole.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + PatchRole.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberPermissions( + listOf( + PatchRole.RemoveMemberPermission.builder() + .permission(PatchRole.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + PatchRole.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + assertThat(patchRole).isNotNull + assertThat(patchRole.addMemberPermissions().get()) + .containsExactly( + PatchRole.AddMemberPermission.builder() + .permission(PatchRole.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + PatchRole.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + assertThat(patchRole.addMemberRoles().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchRole.description()).contains("description") + assertThat(patchRole.name()).contains("name") + assertThat(patchRole.removeMemberPermissions().get()) + .containsExactly( + PatchRole.RemoveMemberPermission.builder() + .permission(PatchRole.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + PatchRole.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + assertThat(patchRole.removeMemberRoles().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchViewTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchViewTest.kt new file mode 100755 index 0000000..56c6906 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchViewTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PatchViewTest { + + @Test + fun createPatchView() { + val patchView = + PatchView.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(PatchView.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .viewType(PatchView.ViewType.PROJECTS) + .build() + assertThat(patchView).isNotNull + assertThat(patchView.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchView.objectType()).contains(PatchView.ObjectType.ORGANIZATION) + assertThat(patchView.name()).contains("name") + assertThat(patchView.options()) + .contains( + ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build() + ) + assertThat(patchView.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(patchView.viewData()) + .contains( + ViewData.builder() + .search( + ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + assertThat(patchView.viewType()).contains(PatchView.ViewType.PROJECTS) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt new file mode 100755 index 0000000..ed4abcb --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PathLookupFilterTest { + + @Test + fun createPathLookupFilter() { + val pathLookupFilter = + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + assertThat(pathLookupFilter).isNotNull + assertThat(pathLookupFilter.path()).containsExactly("string") + assertThat(pathLookupFilter.type()).isEqualTo(PathLookupFilter.Type.PATH_LOOKUP) + assertThat(pathLookupFilter._value()).isEqualTo(JsonValue.from(mapOf())) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 233ceaa..74c4782 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -12,7 +12,7 @@ class ProjectListParamsTest { fun createProjectListParams() { ProjectListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .projectName("project_name") @@ -25,7 +25,7 @@ class ProjectListParamsTest { val params = ProjectListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .projectName("project_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index 038fe4a..021b656 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -15,13 +15,13 @@ class ProjectLogFeedbackParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - ProjectLogFeedbackParams.Feedback.builder() + FeedbackProjectLogsItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) - .source(ProjectLogFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) .build() ) ) @@ -35,13 +35,13 @@ class ProjectLogFeedbackParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - ProjectLogFeedbackParams.Feedback.builder() + FeedbackProjectLogsItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) - .source(ProjectLogFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) .build() ) ) @@ -51,13 +51,13 @@ class ProjectLogFeedbackParamsTest { assertThat(body.feedback()) .isEqualTo( listOf( - ProjectLogFeedbackParams.Feedback.builder() + FeedbackProjectLogsItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) - .source(ProjectLogFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) .build() ) ) @@ -68,12 +68,12 @@ class ProjectLogFeedbackParamsTest { val params = ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder().id("id").build())) + .feedback(listOf(FeedbackProjectLogsItem.builder().id("id").build())) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.feedback()) - .isEqualTo(listOf(ProjectLogFeedbackParams.Feedback.builder().id("id").build())) + .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) } @Test @@ -81,7 +81,7 @@ class ProjectLogFeedbackParamsTest { val params = ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder().id("id").build())) + .feedback(listOf(FeedbackProjectLogsItem.builder().id("id").build())) .build() assertThat(params).isNotNull // path param "projectId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index fbd4551..8e3129b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -16,9 +16,9 @@ class ProjectLogFetchPostParamsTest { .cursor("cursor") .filters( listOf( - ProjectLogFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -38,9 +38,9 @@ class ProjectLogFetchPostParamsTest { .cursor("cursor") .filters( listOf( - ProjectLogFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -56,9 +56,9 @@ class ProjectLogFetchPostParamsTest { assertThat(body.filters()) .isEqualTo( listOf( - ProjectLogFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt index e5d7104..2d53615 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt @@ -16,31 +16,26 @@ class ProjectLogInsertParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Context - .builder() + InsertProjectLogsEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) .metrics( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metrics - .builder() + InsertProjectLogsEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -49,22 +44,11 @@ class ProjectLogInsertParamsTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Scores - .builder() - .build() - ) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) .spanAttributes( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .SpanAttributes - .builder() + InsertProjectLogsEventReplace.SpanAttributes.builder() .name("name") - .type( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .SpanAttributes - .Type - .LLM - ) + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) .build() ) .tags(listOf("string")) @@ -82,34 +66,26 @@ class ProjectLogInsertParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Context - .builder() + InsertProjectLogsEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Metadata - .builder() - .build() - ) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) .metrics( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Metrics - .builder() + InsertProjectLogsEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -118,24 +94,11 @@ class ProjectLogInsertParamsTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Scores - .builder() - .build() - ) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) .spanAttributes( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .SpanAttributes - .builder() + InsertProjectLogsEventReplace.SpanAttributes.builder() .name("name") - .type( - ProjectLogInsertParams.Event - .InsertProjectLogsEventReplace - .SpanAttributes - .Type - .LLM - ) + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) .build() ) .tags(listOf("string")) @@ -149,31 +112,26 @@ class ProjectLogInsertParamsTest { assertThat(body.events()) .isEqualTo( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Context - .builder() + InsertProjectLogsEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) .metrics( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metrics - .builder() + InsertProjectLogsEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -182,22 +140,11 @@ class ProjectLogInsertParamsTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Scores - .builder() - .build() - ) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) .spanAttributes( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .SpanAttributes - .builder() + InsertProjectLogsEventReplace.SpanAttributes.builder() .name("name") - .type( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .SpanAttributes - .Type - .LLM - ) + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) .build() ) .tags(listOf("string")) @@ -214,9 +161,8 @@ class ProjectLogInsertParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() - .build() + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder().build() ) ) ) @@ -226,8 +172,8 @@ class ProjectLogInsertParamsTest { assertThat(body.events()) .isEqualTo( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder().build() + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder().build() ) ) ) @@ -240,9 +186,8 @@ class ProjectLogInsertParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() - .build() + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder().build() ) ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt new file mode 100755 index 0000000..a4a9fca --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectLogsEventTest { + + @Test + fun createProjectLogsEvent() { + val projectLogsEvent = + ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metrics( + ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder().build()) + .spanAttributes( + ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build() + ) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + assertThat(projectLogsEvent).isNotNull + assertThat(projectLogsEvent.id()).isEqualTo("id") + assertThat(projectLogsEvent._xactId()).isEqualTo("_xact_id") + assertThat(projectLogsEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectLogsEvent.logId()).isEqualTo(ProjectLogsEvent.LogId.G) + assertThat(projectLogsEvent.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(projectLogsEvent.spanId()).isEqualTo("span_id") + assertThat(projectLogsEvent.context()) + .contains( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.metadata()) + .contains(ProjectLogsEvent.Metadata.builder().build()) + assertThat(projectLogsEvent.metrics()) + .contains( + ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.scores()).contains(ProjectLogsEvent.Scores.builder().build()) + assertThat(projectLogsEvent.spanAttributes()) + .contains( + ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build() + ) + assertThat(projectLogsEvent.spanParents().get()).containsExactly("string") + assertThat(projectLogsEvent.tags().get()).containsExactly("string") + } +} 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 b01ca07..8e0e01a 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 @@ -12,9 +12,10 @@ class ProjectScoreListParamsTest { fun createProjectScoreListParams() { ProjectScoreListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -26,9 +27,10 @@ class ProjectScoreListParamsTest { val params = ProjectScoreListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -44,6 +46,7 @@ class ProjectScoreListParamsTest { ) expected.put("limit", listOf("123")) expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put("project_name", listOf("project_name")) expected.put("project_score_name", listOf("project_score_name")) expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index 672c32d..72d58b4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -12,9 +12,10 @@ class ProjectTagListParamsTest { fun createProjectTagListParams() { ProjectTagListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectTagName("project_tag_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -26,9 +27,10 @@ class ProjectTagListParamsTest { val params = ProjectTagListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectTagName("project_tag_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -43,6 +45,7 @@ class ProjectTagListParamsTest { ) expected.put("limit", listOf("123")) expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put("project_name", listOf("project_name")) expected.put("project_tag_name", listOf("project_tag_name")) expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index ddede59..cde627c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -12,9 +12,10 @@ class PromptListParamsTest { fun createPromptListParams() { PromptListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .promptName("prompt_name") .slug("slug") @@ -28,9 +29,10 @@ class PromptListParamsTest { val params = PromptListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .promptName("prompt_name") .slug("slug") @@ -45,6 +47,7 @@ class PromptListParamsTest { ) expected.put("limit", listOf("123")) expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put("project_name", listOf("project_name")) expected.put("prompt_name", listOf("prompt_name")) expected.put("slug", listOf("slug")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 2db9679..88c82f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -12,7 +12,7 @@ class RoleListParamsTest { fun createRoleListParams() { RoleListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .roleName("role_name") @@ -25,7 +25,7 @@ class RoleListParamsTest { val params = RoleListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .roleName("role_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt new file mode 100755 index 0000000..8081fbb --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt @@ -0,0 +1,27 @@ +// 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 ScoreSummaryTest { + + @Test + fun createScoreSummary() { + val scoreSummary = + ScoreSummary.builder() + .improvements(123L) + .name("name") + .regressions(123L) + .score(1.0) + .diff(1.0) + .build() + assertThat(scoreSummary).isNotNull + assertThat(scoreSummary.improvements()).isEqualTo(123L) + assertThat(scoreSummary.name()).isEqualTo("name") + assertThat(scoreSummary.regressions()).isEqualTo(123L) + assertThat(scoreSummary.score()).isEqualTo(1.0) + assertThat(scoreSummary.diff()).contains(1.0) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt new file mode 100755 index 0000000..ab202a1 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt @@ -0,0 +1,28 @@ +// 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 SummarizeDatasetResponseTest { + + @Test + fun createSummarizeDatasetResponse() { + val summarizeDatasetResponse = + SummarizeDatasetResponse.builder() + .datasetName("dataset_name") + .datasetUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .dataSummary(DataSummary.builder().totalRecords(123L).build()) + .build() + assertThat(summarizeDatasetResponse).isNotNull + assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") + assertThat(summarizeDatasetResponse.datasetUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.dataSummary()) + .contains(DataSummary.builder().totalRecords(123L).build()) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt new file mode 100755 index 0000000..75a7957 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -0,0 +1,34 @@ +// 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 SummarizeExperimentResponseTest { + + @Test + fun createSummarizeExperimentResponse() { + val summarizeExperimentResponse = + SummarizeExperimentResponse.builder() + .experimentName("experiment_name") + .experimentUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .comparisonExperimentName("comparison_experiment_name") + .metrics(SummarizeExperimentResponse.Metrics.builder().build()) + .scores(SummarizeExperimentResponse.Scores.builder().build()) + .build() + assertThat(summarizeExperimentResponse).isNotNull + assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") + assertThat(summarizeExperimentResponse.experimentUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeExperimentResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.comparisonExperimentName()) + .contains("comparison_experiment_name") + assertThat(summarizeExperimentResponse.metrics()) + .contains(SummarizeExperimentResponse.Metrics.builder().build()) + assertThat(summarizeExperimentResponse.scores()) + .contains(SummarizeExperimentResponse.Scores.builder().build()) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 45d5d6c..6551f79 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -11,11 +11,11 @@ class UserListParamsTest { @Test fun createUserListParams() { UserListParams.builder() - .email(UserListParams.Email.ofString("string")) + .email(UserEmail.ofString("string")) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName(UserListParams.FamilyName.ofString("string")) - .givenName(UserListParams.GivenName.ofString("string")) - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .familyName(UserFamilyName.ofString("string")) + .givenName(UserGivenName.ofString("string")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -26,20 +26,26 @@ class UserListParamsTest { fun getQueryParams() { val params = UserListParams.builder() - .email(UserListParams.Email.ofString("string")) + .email(UserEmail.ofString("string")) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName(UserListParams.FamilyName.ofString("string")) - .givenName(UserListParams.GivenName.ofString("string")) - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .familyName(UserFamilyName.ofString("string")) + .givenName(UserGivenName.ofString("string")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = mutableMapOf>() - expected.put("email", listOf(UserListParams.Email.ofString("string").toString())) + expected.put("email", listOf(UserListParams.UserEmail.ofString("string").toString())) expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("family_name", listOf(UserListParams.FamilyName.ofString("string").toString())) - expected.put("given_name", listOf(UserListParams.GivenName.ofString("string").toString())) + expected.put( + "family_name", + listOf(UserListParams.UserFamilyName.ofString("string").toString()) + ) + expected.put( + "given_name", + listOf(UserListParams.UserGivenName.ofString("string").toString()) + ) expected.put( "ids", listOf(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt index 5b51a37..93eec0d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt @@ -12,14 +12,13 @@ class ViewListParamsTest { fun createViewListParams() { ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) - .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .viewName("view_name") - .viewType(ViewListParams.ViewType.PROJECTS) + .viewType(ViewType.PROJECTS) .build() } @@ -28,28 +27,26 @@ class ViewListParamsTest { val params = ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .ids(Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .limit(123L) - .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .viewName("view_name") - .viewType(ViewListParams.ViewType.PROJECTS) + .viewType(ViewType.PROJECTS) .build() val expected = mutableMapOf>() expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewListParams.ObjectType.ORGANIZATION.toString())) + expected.put("object_type", listOf(AclObjectType.ORGANIZATION.toString())) expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put( "ids", listOf(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) ) expected.put("limit", listOf("123")) - expected.put("project_name", listOf("project_name")) expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put("view_name", listOf("view_name")) - expected.put("view_type", listOf(ViewListParams.ViewType.PROJECTS.toString())) + expected.put("view_type", listOf(ViewType.PROJECTS.toString())) assertThat(params.getQueryParams()).isEqualTo(expected) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt index 9e08a8b..ef1d496 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt @@ -13,7 +13,7 @@ class ViewRetrieveParamsTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() } @@ -23,11 +23,11 @@ class ViewRetrieveParamsTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() val expected = mutableMapOf>() expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewRetrieveParams.ObjectType.ORGANIZATION.toString())) + expected.put("object_type", listOf(AclObjectType.ORGANIZATION.toString())) assertThat(params.getQueryParams()).isEqualTo(expected) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index a19bfd9..bef4662 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -20,12 +20,12 @@ class ApiKeyServiceTest { .apiKey("My API Key") .build() val apiKeyService = client.apiKeys() - val apiKeyCreateResponse = + val createApiKeyOutput = apiKeyService.create( ApiKeyCreateParams.builder().name("name").orgName("org_name").build() ) - println(apiKeyCreateResponse) - apiKeyCreateResponse.validate() + println(createApiKeyOutput) + createApiKeyOutput.validate() } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index ce2d55c..41f719a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -117,11 +117,11 @@ class DatasetServiceTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - DatasetFeedbackParams.Feedback.builder() + FeedbackDatasetItem.builder() .id("id") .comment("comment") - .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) - .source(DatasetFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) .build() ) ) @@ -137,7 +137,7 @@ class DatasetServiceTest { .apiKey("My API Key") .build() val datasetService = client.datasets() - val datasetFetchResponse = + val fetchDatasetEventsResponse = datasetService.fetch( DatasetFetchParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -147,8 +147,8 @@ class DatasetServiceTest { .version("version") .build() ) - println(datasetFetchResponse) - datasetFetchResponse.validate() + println(fetchDatasetEventsResponse) + fetchDatasetEventsResponse.validate() } @Test @@ -159,16 +159,16 @@ class DatasetServiceTest { .apiKey("My API Key") .build() val datasetService = client.datasets() - val datasetFetchPostResponse = + val fetchDatasetEventsResponse = datasetService.fetchPost( DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") .filters( listOf( - DatasetFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -179,8 +179,8 @@ class DatasetServiceTest { .version("version") .build() ) - println(datasetFetchPostResponse) - datasetFetchPostResponse.validate() + println(fetchDatasetEventsResponse) + fetchDatasetEventsResponse.validate() } @Test @@ -191,14 +191,14 @@ class DatasetServiceTest { .apiKey("My API Key") .build() val datasetService = client.datasets() - val datasetInsertResponse = + val insertEventsResponse = datasetService.insert( DatasetInsertParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - DatasetInsertParams.Event.InsertDatasetEventReplace.builder() + InsertDatasetEvent.ofInsertDatasetEventReplace( + InsertDatasetEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) @@ -206,11 +206,7 @@ class DatasetServiceTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata - .builder() - .build() - ) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) .tags(listOf("string")) .build() ) @@ -218,8 +214,8 @@ class DatasetServiceTest { ) .build() ) - println(datasetInsertResponse) - datasetInsertResponse.validate() + println(insertEventsResponse) + insertEventsResponse.validate() } @Test @@ -230,14 +226,14 @@ class DatasetServiceTest { .apiKey("My API Key") .build() val datasetService = client.datasets() - val datasetSummarizeResponse = + val summarizeDatasetResponse = datasetService.summarize( DatasetSummarizeParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .summarizeData(true) .build() ) - println(datasetSummarizeResponse) - datasetSummarizeResponse.validate() + println(summarizeDatasetResponse) + summarizeDatasetResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt index 7555b29..26b9035 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt @@ -153,13 +153,13 @@ class ExperimentServiceTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - ExperimentFeedbackParams.Feedback.builder() + FeedbackExperimentItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) - .source(ExperimentFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) .build() ) ) @@ -175,7 +175,7 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val experimentFetchResponse = + val fetchExperimentEventsResponse = experimentService.fetch( ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -185,8 +185,8 @@ class ExperimentServiceTest { .version("version") .build() ) - println(experimentFetchResponse) - experimentFetchResponse.validate() + println(fetchExperimentEventsResponse) + fetchExperimentEventsResponse.validate() } @Test @@ -197,16 +197,16 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val experimentFetchPostResponse = + val fetchExperimentEventsResponse = experimentService.fetchPost( ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") .filters( listOf( - ExperimentFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -217,8 +217,8 @@ class ExperimentServiceTest { .version("version") .build() ) - println(experimentFetchPostResponse) - experimentFetchPostResponse.validate() + println(fetchExperimentEventsResponse) + fetchExperimentEventsResponse.validate() } @Test @@ -229,22 +229,20 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val experimentInsertResponse = + val insertEventsResponse = experimentService.insert( ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + InsertExperimentEvent.ofInsertExperimentEventReplace( + InsertExperimentEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .Context - .builder() + InsertExperimentEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) @@ -252,18 +250,14 @@ class ExperimentServiceTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .Metadata - .builder() - .build() + InsertExperimentEventReplace.Metadata.builder().build() ) .metrics( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .Metrics - .builder() + InsertExperimentEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -272,23 +266,12 @@ class ExperimentServiceTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .Scores - .builder() - .build() - ) + .scores(InsertExperimentEventReplace.Scores.builder().build()) .spanAttributes( - ExperimentInsertParams.Event.InsertExperimentEventReplace - .SpanAttributes - .builder() + InsertExperimentEventReplace.SpanAttributes.builder() .name("name") .type( - ExperimentInsertParams.Event - .InsertExperimentEventReplace - .SpanAttributes - .Type - .LLM + InsertExperimentEventReplace.SpanAttributes.Type.LLM ) .build() ) @@ -299,8 +282,8 @@ class ExperimentServiceTest { ) .build() ) - println(experimentInsertResponse) - experimentInsertResponse.validate() + println(insertEventsResponse) + insertEventsResponse.validate() } @Test @@ -311,7 +294,7 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val experimentSummarizeResponse = + val summarizeExperimentResponse = experimentService.summarize( ExperimentSummarizeParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -319,7 +302,7 @@ class ExperimentServiceTest { .summarizeScores(true) .build() ) - println(experimentSummarizeResponse) - experimentSummarizeResponse.validate() + println(summarizeExperimentResponse) + summarizeExperimentResponse.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt index ad9a4cf..594930a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt @@ -69,7 +69,7 @@ class ViewServiceTest { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .objectType(AclObjectType.ORGANIZATION) .build() ) println(view) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt index 859bdd5..3eb8a7a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt @@ -26,13 +26,13 @@ class LogServiceTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( - ProjectLogFeedbackParams.Feedback.builder() + FeedbackProjectLogsItem.builder() .id("id") .comment("comment") .expected(JsonValue.from(mapOf())) - .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) - .source(ProjectLogFeedbackParams.Feedback.Source.APP) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) .build() ) ) @@ -48,7 +48,7 @@ class LogServiceTest { .apiKey("My API Key") .build() val logService = client.projects().logs() - val projectLogFetchResponse = + val fetchProjectLogsEventsResponse = logService.fetch( ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -58,8 +58,8 @@ class LogServiceTest { .version("version") .build() ) - println(projectLogFetchResponse) - projectLogFetchResponse.validate() + println(fetchProjectLogsEventsResponse) + fetchProjectLogsEventsResponse.validate() } @Test @@ -70,16 +70,16 @@ class LogServiceTest { .apiKey("My API Key") .build() val logService = client.projects().logs() - val projectLogFetchPostResponse = + val fetchProjectLogsEventsResponse = logService.fetchPost( ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") .filters( listOf( - ProjectLogFetchPostParams.Filter.builder() + PathLookupFilter.builder() .path(listOf("string")) - .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) + .type(PathLookupFilter.Type.PATH_LOOKUP) .value(JsonValue.from(mapOf())) .build() ) @@ -90,8 +90,8 @@ class LogServiceTest { .version("version") .build() ) - println(projectLogFetchPostResponse) - projectLogFetchPostResponse.validate() + println(fetchProjectLogsEventsResponse) + fetchProjectLogsEventsResponse.validate() } @Test @@ -102,40 +102,34 @@ class LogServiceTest { .apiKey("My API Key") .build() val logService = client.projects().logs() - val projectLogInsertResponse = + val insertEventsResponse = logService.insert( ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + InsertProjectLogsEvent.ofInsertProjectLogsEventReplace( + InsertProjectLogsEventReplace.builder() .id("id") ._isMerge(true) ._objectDelete(true) ._parentId("_parent_id") .context( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Context - .builder() + InsertProjectLogsEventReplace.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Metadata - .builder() - .build() + InsertProjectLogsEventReplace.Metadata.builder().build() ) .metrics( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Metrics - .builder() + InsertProjectLogsEventReplace.Metrics.builder() .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -144,22 +138,12 @@ class LogServiceTest { .build() ) .output(JsonValue.from(mapOf())) - .scores( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .Scores - .builder() - .build() - ) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) .spanAttributes( - ProjectLogInsertParams.Event.InsertProjectLogsEventReplace - .SpanAttributes - .builder() + InsertProjectLogsEventReplace.SpanAttributes.builder() .name("name") .type( - ProjectLogInsertParams.Event - .InsertProjectLogsEventReplace - .SpanAttributes - .Type + InsertProjectLogsEventReplace.SpanAttributes.Type .LLM ) .build() @@ -171,7 +155,7 @@ class LogServiceTest { ) .build() ) - println(projectLogInsertResponse) - projectLogInsertResponse.validate() + println(insertEventsResponse) + insertEventsResponse.validate() } }