diff --git a/.stats.yml b/.stats.yml index bb136169..d949f1f0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-ce135a587d4ea037e39949984ed8f98578043e8c3a90fa203d24f28d234d8675.yml +configured_endpoints: 109 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-f5b152de2bdc5370d7c823d3ca415e1b914897ad98b117f1f0db213f44c0798f.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index baafa57f..b0cad87e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -36,6 +36,9 @@ private constructor( @ExcludeMissing private val previewSecret: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + private val updatedAt: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -58,6 +61,10 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + /** Date of last AI secret update */ + fun updatedAt(): Optional = + Optional.ofNullable(updatedAt.getNullable("updated_at")) + /** Unique identifier for the AI secret */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @@ -78,6 +85,11 @@ private constructor( @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** Date of last AI secret update */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -96,6 +108,7 @@ private constructor( metadata().ifPresent { it.validate() } previewSecret() type() + updatedAt() validated = true } @@ -126,6 +139,7 @@ private constructor( private var metadata: JsonField = JsonMissing.of() private var previewSecret: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -137,6 +151,7 @@ private constructor( metadata = aiSecret.metadata previewSecret = aiSecret.previewSecret type = aiSecret.type + updatedAt = aiSecret.updatedAt additionalProperties = aiSecret.additionalProperties.toMutableMap() } @@ -189,6 +204,15 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } + /** Date of last AI secret update */ + fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) + + /** Date of last AI secret update */ + fun updatedAt(updatedAt: Optional) = updatedAt(updatedAt.getOrNull()) + + /** Date of last AI secret update */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -217,6 +241,7 @@ private constructor( metadata, previewSecret, type, + updatedAt, additionalProperties.toImmutable(), ) } @@ -305,15 +330,15 @@ private constructor( return true } - return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && updatedAt == other.updatedAt && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, orgId, created, metadata, previewSecret, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, orgId, created, metadata, previewSecret, type, updatedAt, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" + "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt deleted file mode 100644 index c7232bb9..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt +++ /dev/null @@ -1,2216 +0,0 @@ -// 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.Params -import com.braintrustdata.api.core.checkKnown -import com.braintrustdata.api.core.checkRequired -import com.braintrustdata.api.core.http.Headers -import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.core.immutableEmptyMap -import com.braintrustdata.api.core.toImmutable -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 java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have no - * effect, and removing acls which do not exist will have no effect. - */ -class AclBatchUpdateParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * 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. - */ - fun addAcls(): Optional> = body.addAcls() - - /** - * 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. - */ - fun removeAcls(): Optional> = body.removeAcls() - - /** - * 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. - */ - fun _addAcls(): JsonField> = body._addAcls() - - /** - * 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. - */ - fun _removeAcls(): JsonField> = body._removeAcls() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - @JvmSynthetic internal fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_acls") - @ExcludeMissing - private val addAcls: JsonField> = JsonMissing.of(), - @JsonProperty("remove_acls") - @ExcludeMissing - private val removeAcls: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * 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. - */ - fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) - - /** - * 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. - */ - fun removeAcls(): Optional> = - Optional.ofNullable(removeAcls.getNullable("remove_acls")) - - /** - * 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. - */ - @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls - - /** - * 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. - */ - @JsonProperty("remove_acls") - @ExcludeMissing - fun _removeAcls(): JsonField> = removeAcls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - addAcls().ifPresent { it.forEach { it.validate() } } - removeAcls().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var addAcls: JsonField>? = null - private var removeAcls: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - addAcls = body.addAcls.map { it.toMutableList() } - removeAcls = body.removeAcls.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * 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. - */ - fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) - - /** - * 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. - */ - fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) - - /** - * 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. - */ - fun addAcls(addAcls: JsonField>) = apply { - this.addAcls = addAcls.map { it.toMutableList() } - } - - /** - * 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. - */ - fun addAddAcl(addAcl: AddAcl) = apply { - addAcls = - (addAcls ?: JsonField.of(mutableListOf())).also { - checkKnown("addAcls", it).add(addAcl) - } - } - - /** - * 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. - */ - fun removeAcls(removeAcls: List?) = - removeAcls(JsonField.ofNullable(removeAcls)) - - /** - * 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. - */ - fun removeAcls(removeAcls: Optional>) = - removeAcls(removeAcls.getOrNull()) - - /** - * 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. - */ - fun removeAcls(removeAcls: JsonField>) = apply { - this.removeAcls = removeAcls.map { it.toMutableList() } - } - - /** - * 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. - */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { - removeAcls = - (removeAcls ?: JsonField.of(mutableListOf())).also { - checkKnown("removeAcls", it).add(removeAcl) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = - Body( - (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, - (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(addAcls, removeAcls, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AclBatchUpdateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AclBatchUpdateParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AclBatchUpdateParams]. */ - @NoAutoDetect - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { - body = aclBatchUpdateParams.body.toBuilder() - additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() - } - - /** - * 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. - */ - fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } - - /** - * 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. - */ - fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) - - /** - * 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. - */ - fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } - - /** - * 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. - */ - fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } - - /** - * 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. - */ - fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } - - /** - * 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. - */ - fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) - - /** - * 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. - */ - fun removeAcls(removeAcls: JsonField>) = apply { - body.removeAcls(removeAcls) - } - - /** - * 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. - */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun build(): AclBatchUpdateParams = - AclBatchUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - /** - * 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. - */ - @NoAutoDetect - class AddAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the object the ACL applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** - * 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")) - - /** - * 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")) - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - /** - * 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(): JsonField = groupId - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - @ExcludeMissing - fun _permission(): JsonField = 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(): JsonField = restrictObjectType - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId - - /** - * 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(): JsonField = userId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddAcl = apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AddAcl]. - * - * The following fields are required: - * ```java - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddAcl]. */ - class Builder internal constructor() { - - private var objectId: JsonField? = null - private var objectType: JsonField? = null - 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 userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addAcl: AddAcl) = apply { - objectId = addAcl.objectId - objectType = addAcl.objectType - groupId = addAcl.groupId - permission = addAcl.permission - restrictObjectType = addAcl.restrictObjectType - roleId = addAcl.roleId - userId = addAcl.userId - additionalProperties = addAcl.additionalProperties.toMutableMap() - } - - /** 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 */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - /** - * 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.ofNullable(groupId)) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - 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.ofNullable(permission)) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: Optional) = permission(permission.getOrNull()) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - 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.ofNullable(restrictObjectType)) - - /** - * 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: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) - - /** - * 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: 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.ofNullable(roleId)) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } - - /** - * 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.ofNullable(userId)) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): AddAcl = - AddAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), - ) - } - - /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ORGANIZATION = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - 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 - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - 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") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - 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 - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - 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") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ORGANIZATION = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - 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 - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - 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") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" - } - - /** - * 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. - */ - @NoAutoDetect - class RemoveAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the object the ACL applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** - * 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")) - - /** - * 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")) - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - /** - * 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(): JsonField = groupId - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - @ExcludeMissing - fun _permission(): JsonField = 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(): JsonField = restrictObjectType - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId - - /** - * 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(): JsonField = userId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RemoveAcl = apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RemoveAcl]. - * - * The following fields are required: - * ```java - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveAcl]. */ - class Builder internal constructor() { - - private var objectId: JsonField? = null - private var objectType: JsonField? = null - 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 userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removeAcl: RemoveAcl) = apply { - objectId = removeAcl.objectId - objectType = removeAcl.objectType - groupId = removeAcl.groupId - permission = removeAcl.permission - restrictObjectType = removeAcl.restrictObjectType - roleId = removeAcl.roleId - userId = removeAcl.userId - additionalProperties = removeAcl.additionalProperties.toMutableMap() - } - - /** 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 */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - /** - * 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.ofNullable(groupId)) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - 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.ofNullable(permission)) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: Optional) = permission(permission.getOrNull()) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - 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.ofNullable(restrictObjectType)) - - /** - * 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: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) - - /** - * 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: 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.ofNullable(roleId)) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } - - /** - * 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.ofNullable(userId)) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): RemoveAcl = - RemoveAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), - ) - } - - /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ORGANIZATION = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - 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 - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - 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") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CREATE = of("create") - - @JvmField val READ = of("read") - - @JvmField val UPDATE = of("update") - - @JvmField val DELETE = of("delete") - - @JvmField val CREATE_ACLS = of("create_acls") - - @JvmField val READ_ACLS = of("read_acls") - - @JvmField val UPDATE_ACLS = of("update_acls") - - @JvmField val DELETE_ACLS = of("delete_acls") - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - /** An enum containing [Permission]'s known values. */ - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - /** - * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Permission] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - /** - * An enum member indicating that [Permission] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - 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 - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - 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") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ORGANIZATION = of("organization") - - @JvmField val PROJECT = of("project") - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val GROUP = of("group") - - @JvmField val ROLE = of("role") - - @JvmField val ORG_MEMBER = of("org_member") - - @JvmField val PROJECT_LOG = of("project_log") - - @JvmField val ORG_PROJECT = of("org_project") - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - /** An enum containing [RestrictObjectType]'s known values. */ - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RestrictObjectType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - /** - * An enum member indicating that [RestrictObjectType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - 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 - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - 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") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} 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 index 9552e3d7..b60821c8 100755 --- 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 @@ -2,7 +2,6 @@ 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 @@ -12,7 +11,6 @@ import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -55,7 +53,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("origin") @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + private val origin: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @@ -116,7 +114,7 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -166,7 +164,7 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @@ -231,7 +229,7 @@ private constructor( private var input: JsonValue = JsonMissing.of() private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -368,13 +366,13 @@ private constructor( fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Indicates the event was copied from another object. */ - fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.getOrNull()) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { this.origin = origin } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -441,10 +439,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -456,6 +463,7 @@ private constructor( return@apply } + model() validated = true } @@ -470,176 +478,23 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** Indicates the event was copied from another object. */ - @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** ID of the original event. */ - fun id(): String = id.getRequired("id") - - /** Transaction ID of the original event. */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Origin = apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Origin]. - * - * The following fields are required: - * ```java - * .id() - * ._xactId() - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Origin]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var _xactId: JsonField? = null - private var objectId: JsonField? = null - private var objectType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } - - /** ID of the original event. */ - fun id(id: String) = id(JsonField.of(id)) - - /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) - /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -660,143 +515,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Origin = - Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), - ) - } - - /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val FUNCTION = of("function") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val PROJECT_LOGS = of("project_logs") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - FUNCTION -> Value.FUNCTION - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_LOGS -> Value.PROJECT_LOGS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - FUNCTION -> Known.FUNCTION - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_LOGS -> Known.PROJECT_LOGS - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -804,17 +523,17 @@ private constructor( return true } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + "Metadata{model=$model, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 84bb86ae..13823ba0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -99,6 +99,9 @@ private constructor( */ fun metadata(): Optional = body.metadata() + /** Options for tracing the evaluation */ + fun parent(): Optional = body.parent() + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(): Optional = body.repoInfo() @@ -173,6 +176,9 @@ private constructor( */ fun _metadata(): JsonField = body._metadata() + /** Options for tracing the evaluation */ + fun _parent(): JsonField = body._parent() + /** Metadata about the state of the repo when the experiment was created */ fun _repoInfo(): JsonField = body._repoInfo() @@ -241,6 +247,9 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), @@ -313,6 +322,9 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** Options for tracing the evaluation */ + fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) @@ -398,6 +410,9 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** Options for tracing the evaluation */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @@ -445,6 +460,7 @@ private constructor( isPublic() maxConcurrency() metadata().ifPresent { it.validate() } + parent().ifPresent { it.validate() } repoInfo().ifPresent { it.validate() } stream() timeout() @@ -484,6 +500,7 @@ private constructor( private var isPublic: JsonField = JsonMissing.of() private var maxConcurrency: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var parent: JsonField = JsonMissing.of() private var repoInfo: JsonField = JsonMissing.of() private var stream: JsonField = JsonMissing.of() private var timeout: JsonField = JsonMissing.of() @@ -503,6 +520,7 @@ private constructor( isPublic = body.isPublic maxConcurrency = body.maxConcurrency metadata = body.metadata + parent = body.parent repoInfo = body.repoInfo stream = body.stream timeout = body.timeout @@ -523,6 +541,9 @@ private constructor( fun data(projectDatasetName: Data.ProjectDatasetName) = data(Data.ofProjectDatasetName(projectDatasetName)) + /** Dataset rows */ + fun data(datasetRows: Data.DatasetRows) = data(Data.ofDatasetRows(datasetRows)) + /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -726,6 +747,19 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Options for tracing the evaluation */ + fun parent(parent: Parent) = parent(JsonField.of(parent)) + + /** Options for tracing the evaluation */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + /** Span parent properties */ + fun parent(spanParentStruct: Parent.SpanParentStruct) = + parent(Parent.ofSpanParentStruct(spanParentStruct)) + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun parent(string: String) = parent(Parent.ofString(string)) + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -833,6 +867,7 @@ private constructor( isPublic, maxConcurrency, metadata, + parent, repoInfo, stream, timeout, @@ -846,17 +881,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && parent == other.parent && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, parent, repoInfo, stream, timeout, trialCount, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" + "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, parent=$parent, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -906,6 +941,9 @@ private constructor( body.data(projectDatasetName) } + /** Dataset rows */ + fun data(datasetRows: Data.DatasetRows) = apply { body.data(datasetRows) } + /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = apply { body.projectId(projectId) } @@ -1099,6 +1137,20 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** Options for tracing the evaluation */ + fun parent(parent: Parent) = apply { body.parent(parent) } + + /** Options for tracing the evaluation */ + fun parent(parent: JsonField) = apply { body.parent(parent) } + + /** Span parent properties */ + fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { + body.parent(spanParentStruct) + } + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun parent(string: String) = apply { body.parent(string) } + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } @@ -1302,6 +1354,7 @@ private constructor( private constructor( private val datasetId: DatasetId? = null, private val projectDatasetName: ProjectDatasetName? = null, + private val datasetRows: DatasetRows? = null, private val _json: JsonValue? = null, ) { @@ -1312,10 +1365,15 @@ private constructor( fun projectDatasetName(): Optional = Optional.ofNullable(projectDatasetName) + /** Dataset rows */ + fun datasetRows(): Optional = Optional.ofNullable(datasetRows) + fun isDatasetId(): Boolean = datasetId != null fun isProjectDatasetName(): Boolean = projectDatasetName != null + fun isDatasetRows(): Boolean = datasetRows != null + /** Dataset id */ fun asDatasetId(): DatasetId = datasetId.getOrThrow("datasetId") @@ -1323,12 +1381,16 @@ private constructor( fun asProjectDatasetName(): ProjectDatasetName = projectDatasetName.getOrThrow("projectDatasetName") + /** Dataset rows */ + fun asDatasetRows(): DatasetRows = datasetRows.getOrThrow("datasetRows") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { datasetId != null -> visitor.visitDatasetId(datasetId) projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) + datasetRows != null -> visitor.visitDatasetRows(datasetRows) else -> visitor.unknown(_json) } } @@ -1349,6 +1411,10 @@ private constructor( override fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName) { projectDatasetName.validate() } + + override fun visitDatasetRows(datasetRows: DatasetRows) { + datasetRows.validate() + } } ) validated = true @@ -1359,15 +1425,16 @@ private constructor( return true } - return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ + return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName && datasetRows == other.datasetRows /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName, datasetRows) /* spotless:on */ override fun toString(): String = when { datasetId != null -> "Data{datasetId=$datasetId}" projectDatasetName != null -> "Data{projectDatasetName=$projectDatasetName}" + datasetRows != null -> "Data{datasetRows=$datasetRows}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } @@ -1381,6 +1448,9 @@ private constructor( @JvmStatic fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = Data(projectDatasetName = projectDatasetName) + + /** Dataset rows */ + @JvmStatic fun ofDatasetRows(datasetRows: DatasetRows) = Data(datasetRows = datasetRows) } /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ @@ -1392,6 +1462,9 @@ private constructor( /** Project and dataset name */ fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName): T + /** Dataset rows */ + fun visitDatasetRows(datasetRows: DatasetRows): T + /** * Maps an unknown variant of [Data] to a value of type [T]. * @@ -1419,6 +1492,10 @@ private constructor( ?.let { return Data(projectDatasetName = it, _json = json) } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(datasetRows = it, _json = json) + } return Data(_json = json) } @@ -1435,6 +1512,7 @@ private constructor( value.datasetId != null -> generator.writeObject(value.datasetId) value.projectDatasetName != null -> generator.writeObject(value.projectDatasetName) + value.datasetRows != null -> generator.writeObject(value.datasetRows) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Data") } @@ -1449,16 +1527,26 @@ private constructor( @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("_internal_btql") + @ExcludeMissing + private val _internalBtql: JsonField<_InternalBtql> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { fun datasetId(): String = datasetId.getRequired("dataset_id") + fun _internalBtql(): Optional<_InternalBtql> = + Optional.ofNullable(_internalBtql.getNullable("_internal_btql")) + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("_internal_btql") + @ExcludeMissing + fun __internalBtql(): JsonField<_InternalBtql> = _internalBtql + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1471,6 +1559,7 @@ private constructor( } datasetId() + _internalBtql().ifPresent { it.validate() } validated = true } @@ -1493,11 +1582,13 @@ private constructor( class Builder internal constructor() { private var datasetId: JsonField? = null + private var _internalBtql: JsonField<_InternalBtql> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetId: DatasetId) = apply { this.datasetId = datasetId.datasetId + _internalBtql = datasetId._internalBtql additionalProperties = datasetId.additionalProperties.toMutableMap() } @@ -1505,6 +1596,16 @@ private constructor( fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun _internalBtql(_internalBtql: _InternalBtql?) = + _internalBtql(JsonField.ofNullable(_internalBtql)) + + fun _internalBtql(_internalBtql: Optional<_InternalBtql>) = + _internalBtql(_internalBtql.getOrNull()) + + fun _internalBtql(_internalBtql: JsonField<_InternalBtql>) = apply { + this._internalBtql = _internalBtql + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1530,26 +1631,112 @@ private constructor( fun build(): DatasetId = DatasetId( checkRequired("datasetId", datasetId), + _internalBtql, additionalProperties.toImmutable(), ) } + @NoAutoDetect + class _InternalBtql + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): _InternalBtql = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [_InternalBtql]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [_InternalBtql]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_internalBtql: _InternalBtql) = apply { + additionalProperties = _internalBtql.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): _InternalBtql = _InternalBtql(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is _InternalBtql && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "_InternalBtql{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && _internalBtql == other._internalBtql && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(datasetId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(datasetId, _internalBtql, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" + "DatasetId{datasetId=$datasetId, _internalBtql=$_internalBtql, additionalProperties=$additionalProperties}" } /** Project and dataset name */ @@ -1563,6 +1750,9 @@ private constructor( @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("_internal_btql") + @ExcludeMissing + private val _internalBtql: JsonField<_InternalBtql> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1571,6 +1761,9 @@ private constructor( fun projectName(): String = projectName.getRequired("project_name") + fun _internalBtql(): Optional<_InternalBtql> = + Optional.ofNullable(_internalBtql.getNullable("_internal_btql")) + @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName(): JsonField = datasetName @@ -1579,6 +1772,10 @@ private constructor( @ExcludeMissing fun _projectName(): JsonField = projectName + @JsonProperty("_internal_btql") + @ExcludeMissing + fun __internalBtql(): JsonField<_InternalBtql> = _internalBtql + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1592,6 +1789,7 @@ private constructor( datasetName() projectName() + _internalBtql().ifPresent { it.validate() } validated = true } @@ -1616,12 +1814,14 @@ private constructor( private var datasetName: JsonField? = null private var projectName: JsonField? = null + private var _internalBtql: JsonField<_InternalBtql> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectDatasetName: ProjectDatasetName) = apply { datasetName = projectDatasetName.datasetName projectName = projectDatasetName.projectName + _internalBtql = projectDatasetName._internalBtql additionalProperties = projectDatasetName.additionalProperties.toMutableMap() } @@ -1637,6 +1837,16 @@ private constructor( this.projectName = projectName } + fun _internalBtql(_internalBtql: _InternalBtql?) = + _internalBtql(JsonField.ofNullable(_internalBtql)) + + fun _internalBtql(_internalBtql: Optional<_InternalBtql>) = + _internalBtql(_internalBtql.getOrNull()) + + fun _internalBtql(_internalBtql: JsonField<_InternalBtql>) = apply { + this._internalBtql = _internalBtql + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1663,78 +1873,282 @@ private constructor( ProjectDatasetName( checkRequired("datasetName", datasetName), checkRequired("projectName", projectName), + _internalBtql, additionalProperties.toImmutable(), ) } + @NoAutoDetect + class _InternalBtql + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): _InternalBtql = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [_InternalBtql]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [_InternalBtql]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_internalBtql: _InternalBtql) = apply { + additionalProperties = _internalBtql.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): _InternalBtql = _InternalBtql(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is _InternalBtql && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "_InternalBtql{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && _internalBtql == other._internalBtql && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(datasetName, projectName, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(datasetName, projectName, _internalBtql, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" + "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, _internalBtql=$_internalBtql, additionalProperties=$additionalProperties}" } - } - /** The function to evaluate */ - @JsonDeserialize(using = Score.Deserializer::class) - @JsonSerialize(using = Score.Serializer::class) - class Score - private constructor( - private val functionId: FunctionId? = null, - private val projectSlug: ProjectSlug? = null, - private val globalFunction: GlobalFunction? = null, - private val promptSessionId: PromptSessionId? = null, - private val inlineCode: InlineCode? = null, - private val inlinePrompt: InlinePrompt? = null, - private val _json: JsonValue? = null, - ) { + /** Dataset rows */ + @NoAutoDetect + class DatasetRows + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - /** Function id */ - fun functionId(): Optional = Optional.ofNullable(functionId) + fun data(): List = data.getRequired("data") - /** Project name and slug */ - fun projectSlug(): Optional = Optional.ofNullable(projectSlug) + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data - /** Global function name */ - fun globalFunction(): Optional = Optional.ofNullable(globalFunction) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** Prompt session id */ - fun promptSessionId(): Optional = Optional.ofNullable(promptSessionId) + private var validated: Boolean = false - /** Inline code function */ - fun inlineCode(): Optional = Optional.ofNullable(inlineCode) + fun validate(): DatasetRows = apply { + if (validated) { + return@apply + } - /** Inline prompt definition */ - fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt) + data() + validated = true + } - fun isFunctionId(): Boolean = functionId != null + fun toBuilder() = Builder().from(this) - fun isProjectSlug(): Boolean = projectSlug != null + companion object { - fun isGlobalFunction(): Boolean = globalFunction != null + /** + * Returns a mutable builder for constructing an instance of [DatasetRows]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isPromptSessionId(): Boolean = promptSessionId != null + /** A builder for [DatasetRows]. */ + class Builder internal constructor() { - fun isInlineCode(): Boolean = inlineCode != null + private var data: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isInlinePrompt(): Boolean = inlinePrompt != null + @JvmSynthetic + internal fun from(datasetRows: DatasetRows) = apply { + data = datasetRows.data.map { it.toMutableList() } + additionalProperties = datasetRows.additionalProperties.toMutableMap() + } - /** Function id */ - fun asFunctionId(): FunctionId = functionId.getOrThrow("functionId") + fun data(data: List) = data(JsonField.of(data)) - /** Project name and slug */ - fun asProjectSlug(): ProjectSlug = projectSlug.getOrThrow("projectSlug") + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: JsonValue) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): DatasetRows = + DatasetRows( + checkRequired("data", data).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetRows && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetRows{data=$data, additionalProperties=$additionalProperties}" + } + } + + /** The function to evaluate */ + @JsonDeserialize(using = Score.Deserializer::class) + @JsonSerialize(using = Score.Serializer::class) + class Score + private constructor( + private val functionId: FunctionId? = null, + private val projectSlug: ProjectSlug? = null, + private val globalFunction: GlobalFunction? = null, + private val promptSessionId: PromptSessionId? = null, + private val inlineCode: InlineCode? = null, + private val inlinePrompt: InlinePrompt? = null, + private val _json: JsonValue? = null, + ) { + + /** Function id */ + fun functionId(): Optional = Optional.ofNullable(functionId) + + /** Project name and slug */ + fun projectSlug(): Optional = Optional.ofNullable(projectSlug) + + /** Global function name */ + fun globalFunction(): Optional = Optional.ofNullable(globalFunction) + + /** Prompt session id */ + fun promptSessionId(): Optional = Optional.ofNullable(promptSessionId) + + /** Inline code function */ + fun inlineCode(): Optional = Optional.ofNullable(inlineCode) + + /** Inline prompt definition */ + fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt) + + fun isFunctionId(): Boolean = functionId != null + + fun isProjectSlug(): Boolean = projectSlug != null + + fun isGlobalFunction(): Boolean = globalFunction != null + + fun isPromptSessionId(): Boolean = promptSessionId != null + + fun isInlineCode(): Boolean = inlineCode != null + + fun isInlinePrompt(): Boolean = inlinePrompt != null + + /** Function id */ + fun asFunctionId(): FunctionId = functionId.getOrThrow("functionId") + + /** Project name and slug */ + fun asProjectSlug(): ProjectSlug = projectSlug.getOrThrow("projectSlug") /** Global function name */ fun asGlobalFunction(): GlobalFunction = globalFunction.getOrThrow("globalFunction") @@ -4895,6 +5309,687 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** Options for tracing the evaluation */ + @JsonDeserialize(using = Parent.Deserializer::class) + @JsonSerialize(using = Parent.Serializer::class) + class Parent + private constructor( + private val spanParentStruct: SpanParentStruct? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + /** Span parent properties */ + fun spanParentStruct(): Optional = Optional.ofNullable(spanParentStruct) + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun string(): Optional = Optional.ofNullable(string) + + fun isSpanParentStruct(): Boolean = spanParentStruct != null + + fun isString(): Boolean = string != null + + /** Span parent properties */ + fun asSpanParentStruct(): SpanParentStruct = spanParentStruct.getOrThrow("spanParentStruct") + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): Parent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSpanParentStruct(spanParentStruct: SpanParentStruct) { + spanParentStruct.validate() + } + + override fun visitString(string: String) {} + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ + + override fun toString(): String = + when { + spanParentStruct != null -> "Parent{spanParentStruct=$spanParentStruct}" + string != null -> "Parent{string=$string}" + _json != null -> "Parent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Parent") + } + + companion object { + + /** Span parent properties */ + @JvmStatic + fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = + Parent(spanParentStruct = spanParentStruct) + + /** The parent's span identifier, created by calling `.export()` on a span */ + @JvmStatic fun ofString(string: String) = Parent(string = string) + } + + /** An interface that defines how to map each variant of [Parent] to a value of type [T]. */ + interface Visitor { + + /** Span parent properties */ + fun visitSpanParentStruct(spanParentStruct: SpanParentStruct): T + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Parent] to a value of type [T]. + * + * An instance of [Parent] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Parent: $json") + } + } + + internal class Deserializer : BaseDeserializer(Parent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Parent { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parent(spanParentStruct = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Parent(string = it, _json = json) + } + + return Parent(_json = json) + } + } + + internal class Serializer : BaseSerializer(Parent::class) { + + override fun serialize( + value: Parent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Parent") + } + } + } + + /** Span parent properties */ + @NoAutoDetect + class SpanParentStruct + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("propagated_event") + @ExcludeMissing + private val propagatedEvent: JsonField = JsonMissing.of(), + @JsonProperty("row_ids") + @ExcludeMissing + private val rowIds: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The id of the container object you are logging to */ + fun objectId(): String = objectId.getRequired("object_id") + + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(): Optional = + Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) + + /** The id of the container object you are logging to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** Include these properties in every span created under this parent */ + @JsonProperty("propagated_event") + @ExcludeMissing + fun _propagatedEvent(): JsonField = propagatedEvent + + /** Identifiers for the row to to log a subspan under */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SpanParentStruct = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + propagatedEvent().ifPresent { it.validate() } + rowIds().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SpanParentStruct]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpanParentStruct]. */ + class Builder internal constructor() { + + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var propagatedEvent: JsonField = JsonMissing.of() + private var rowIds: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanParentStruct: SpanParentStruct) = apply { + objectId = spanParentStruct.objectId + objectType = spanParentStruct.objectType + propagatedEvent = spanParentStruct.propagatedEvent + rowIds = spanParentStruct.rowIds + additionalProperties = spanParentStruct.additionalProperties.toMutableMap() + } + + /** The id of the container object you are logging to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the container object you are logging to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(propagatedEvent: PropagatedEvent?) = + propagatedEvent(JsonField.ofNullable(propagatedEvent)) + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(propagatedEvent: Optional) = + propagatedEvent(propagatedEvent.getOrNull()) + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(propagatedEvent: JsonField) = apply { + this.propagatedEvent = propagatedEvent + } + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): SpanParentStruct = + SpanParentStruct( + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + propagatedEvent, + rowIds, + additionalProperties.toImmutable(), + ) + } + + class ObjectType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PROJECT_LOGS = of("project_logs") + + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUND_LOGS = of("playground_logs") + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + /** An enum containing [ObjectType]'s known values. */ + enum class Known { + PROJECT_LOGS, + EXPERIMENT, + PLAYGROUND_LOGS, + } + + /** + * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ObjectType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PROJECT_LOGS, + EXPERIMENT, + PLAYGROUND_LOGS, + /** + * An enum member indicating that [ObjectType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PROJECT_LOGS -> Value.PROJECT_LOGS + EXPERIMENT -> Value.EXPERIMENT + PLAYGROUND_LOGS -> Value.PLAYGROUND_LOGS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PROJECT_LOGS -> Known.PROJECT_LOGS + EXPERIMENT -> Known.EXPERIMENT + PLAYGROUND_LOGS -> Known.PLAYGROUND_LOGS + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Include these properties in every span created under this parent */ + @NoAutoDetect + class PropagatedEvent + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PropagatedEvent = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PropagatedEvent]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PropagatedEvent]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(propagatedEvent: PropagatedEvent) = apply { + additionalProperties = propagatedEvent.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): PropagatedEvent = + PropagatedEvent(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PropagatedEvent{additionalProperties=$additionalProperties}" + } + + /** Identifiers for the row to to log a subspan under */ + @NoAutoDetect + class RowIds + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The id of the row */ + fun id(): String = id.getRequired("id") + + /** The root_span_id of the row */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") + + /** The span_id of the row */ + fun spanId(): String = spanId.getRequired("span_id") + + /** The id of the row */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The root_span_id of the row */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId + + /** The span_id of the row */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): RowIds = apply { + if (validated) { + return@apply + } + + id() + rootSpanId() + spanId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RowIds]. + * + * The following fields are required: + * ```java + * .id() + * .rootSpanId() + * .spanId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RowIds]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var rootSpanId: JsonField? = null + private var spanId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rowIds: RowIds) = apply { + id = rowIds.id + rootSpanId = rowIds.rootSpanId + spanId = rowIds.spanId + additionalProperties = rowIds.additionalProperties.toMutableMap() + } + + /** The id of the row */ + fun id(id: String) = id(JsonField.of(id)) + + /** The id of the row */ + fun id(id: JsonField) = apply { this.id = id } + + /** The root_span_id of the row */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** The root_span_id of the row */ + fun rootSpanId(rootSpanId: JsonField) = apply { + this.rootSpanId = rootSpanId + } + + /** The span_id of the row */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** The span_id of the row */ + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): RowIds = + RowIds( + checkRequired("id", id), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, rootSpanId, spanId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, propagatedEvent, rowIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 index e49339eb..d05a1609 100755 --- 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 @@ -2,7 +2,6 @@ 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 @@ -12,7 +11,6 @@ import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -48,9 +46,6 @@ private constructor( @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), @@ -65,7 +60,7 @@ private constructor( private val metrics: JsonField = JsonMissing.of(), @JsonProperty("origin") @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("scores") @ExcludeMissing @@ -121,13 +116,6 @@ private constructor( */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - /** - * 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 error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error @@ -169,7 +157,7 @@ private constructor( fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** * The output of your application, including post-processing (an arbitrary, JSON serializable @@ -246,14 +234,6 @@ private constructor( */ @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - /** - * 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(): JsonField = datasetRecordId - /** Whether this span is a root span */ @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot @@ -274,7 +254,7 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety @@ -322,7 +302,6 @@ private constructor( rootSpanId() spanId() context().ifPresent { it.validate() } - datasetRecordId() isRoot() metadata().ifPresent { it.validate() } metrics().ifPresent { it.validate() } @@ -366,14 +345,13 @@ private constructor( private var rootSpanId: JsonField? = null private var spanId: JsonField? = null private var context: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() private var error: JsonValue = JsonMissing.of() private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var scores: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() @@ -391,7 +369,6 @@ private constructor( rootSpanId = experimentEvent.rootSpanId spanId = experimentEvent.spanId context = experimentEvent.context - datasetRecordId = experimentEvent.datasetRecordId error = experimentEvent.error expected = experimentEvent.expected input = experimentEvent.input @@ -494,28 +471,6 @@ private constructor( */ fun context(context: JsonField) = apply { this.context = context } - /** - * 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.ofNullable(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - /** The error that occurred, if any. */ fun error(error: JsonValue) = apply { this.error = error } @@ -598,13 +553,13 @@ private constructor( fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ - fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.getOrNull()) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { this.origin = origin } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -737,7 +692,6 @@ private constructor( checkRequired("rootSpanId", rootSpanId), checkRequired("spanId", spanId), context, - datasetRecordId, error, expected, input, @@ -941,10 +895,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -956,6 +919,7 @@ private constructor( return@apply } + model() validated = true } @@ -970,13 +934,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -996,7 +971,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1004,16 +979,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1356,307 +1332,6 @@ private constructor( "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } - /** Indicates the event was copied from another object. */ - @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** ID of the original event. */ - fun id(): String = id.getRequired("id") - - /** Transaction ID of the original event. */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Origin = apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Origin]. - * - * The following fields are required: - * ```java - * .id() - * ._xactId() - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Origin]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var _xactId: JsonField? = null - private var objectId: JsonField? = null - private var objectType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } - - /** ID of the original event. */ - fun id(id: String) = id(JsonField.of(id)) - - /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Origin = - Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), - ) - } - - /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val FUNCTION = of("function") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val PROJECT_LOGS = of("project_logs") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - FUNCTION -> Value.FUNCTION - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_LOGS -> Value.PROJECT_LOGS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - FUNCTION -> Known.FUNCTION - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_LOGS -> Known.PROJECT_LOGS - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" - } - /** * 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 @@ -1750,15 +1425,15 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, experimentId, projectId, rootSpanId, spanId, context, datasetRecordId, error, expected, input, isRoot, metadata, metrics, origin, output, scores, spanAttributes, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, experimentId, projectId, rootSpanId, spanId, context, error, expected, input, isRoot, metadata, metrics, origin, output, scores, spanAttributes, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 2792f617..4cdd84ba 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -46,12 +46,18 @@ private constructor( /** Function id */ fun functionId(): String = functionId + /** The expected output of the function */ + fun _expected(): JsonValue = body._expected() + /** Argument to the function, which can be any JSON serializable value */ fun _input(): JsonValue = body._input() /** If the function is an LLM, additional messages to pass along to it */ fun messages(): Optional> = body.messages() + /** Any relevant metadata */ + fun metadata(): Optional = body.metadata() + /** The mode format of the returned value (defaults to 'auto') */ fun mode(): Optional = body.mode() @@ -70,6 +76,9 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun _messages(): JsonField> = body._messages() + /** Any relevant metadata */ + fun _metadata(): JsonField = body._metadata() + /** The mode format of the returned value (defaults to 'auto') */ fun _mode(): JsonField = body._mode() @@ -109,10 +118,16 @@ private constructor( class Body @JsonCreator private constructor( + @JsonProperty("expected") + @ExcludeMissing + private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonProperty("mode") @ExcludeMissing private val mode: JsonField = JsonMissing.of(), @JsonProperty("parent") @ExcludeMissing @@ -127,6 +142,9 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The expected output of the function */ + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + /** Argument to the function, which can be any JSON serializable value */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input @@ -134,6 +152,9 @@ private constructor( fun messages(): Optional> = Optional.ofNullable(messages.getNullable("messages")) + /** Any relevant metadata */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** The mode format of the returned value (defaults to 'auto') */ fun mode(): Optional = Optional.ofNullable(mode.getNullable("mode")) @@ -154,6 +175,9 @@ private constructor( @ExcludeMissing fun _messages(): JsonField> = messages + /** Any relevant metadata */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** The mode format of the returned value (defaults to 'auto') */ @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode @@ -181,6 +205,7 @@ private constructor( } messages().ifPresent { it.forEach { it.validate() } } + metadata().ifPresent { it.validate() } mode() parent().ifPresent { it.validate() } stream() @@ -199,8 +224,10 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var messages: JsonField>? = null + private var metadata: JsonField = JsonMissing.of() private var mode: JsonField = JsonMissing.of() private var parent: JsonField = JsonMissing.of() private var stream: JsonField = JsonMissing.of() @@ -209,8 +236,10 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + expected = body.expected input = body.input messages = body.messages.map { it.toMutableList() } + metadata = body.metadata mode = body.mode parent = body.parent stream = body.stream @@ -218,6 +247,9 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** The expected output of the function */ + fun expected(expected: JsonValue) = apply { this.expected = expected } + /** Argument to the function, which can be any JSON serializable value */ fun input(input: JsonValue) = apply { this.input = input } @@ -256,6 +288,15 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) + /** Any relevant metadata */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Any relevant metadata */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** Any relevant metadata */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode?) = mode(JsonField.ofNullable(mode)) @@ -329,8 +370,10 @@ private constructor( fun build(): Body = Body( + expected, input, (messages ?: JsonMissing.of()).map { it.toImmutable() }, + metadata, mode, parent, stream, @@ -344,17 +387,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && expected == other.expected && input == other.input && messages == other.messages && metadata == other.metadata && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(input, messages, mode, parent, stream, version, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(expected, input, messages, metadata, mode, parent, stream, version, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" + "Body{expected=$expected, input=$input, messages=$messages, metadata=$metadata, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -392,6 +435,9 @@ private constructor( /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } + /** The expected output of the function */ + fun expected(expected: JsonValue) = apply { body.expected(expected) } + /** Argument to the function, which can be any JSON serializable value */ fun input(input: JsonValue) = apply { body.input(input) } @@ -422,6 +468,15 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(fallback: Message.Fallback) = apply { body.addMessage(fallback) } + /** Any relevant metadata */ + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Any relevant metadata */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** Any relevant metadata */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode?) = apply { body.mode(mode) } @@ -2716,6 +2771,86 @@ private constructor( } } + /** Any relevant metadata */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + /** The mode format of the returned value (defaults to 'auto') */ class Mode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3144,6 +3279,8 @@ private constructor( @JvmField val EXPERIMENT = of("experiment") + @JvmField val PLAYGROUND_LOGS = of("playground_logs") + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) } @@ -3151,6 +3288,7 @@ private constructor( enum class Known { PROJECT_LOGS, EXPERIMENT, + PLAYGROUND_LOGS, } /** @@ -3165,6 +3303,7 @@ private constructor( enum class Value { PROJECT_LOGS, EXPERIMENT, + PLAYGROUND_LOGS, /** * An enum member indicating that [ObjectType] was instantiated with an unknown * value. @@ -3183,6 +3322,7 @@ private constructor( when (this) { PROJECT_LOGS -> Value.PROJECT_LOGS EXPERIMENT -> Value.EXPERIMENT + PLAYGROUND_LOGS -> Value.PLAYGROUND_LOGS else -> Value._UNKNOWN } @@ -3199,6 +3339,7 @@ private constructor( when (this) { PROJECT_LOGS -> Known.PROJECT_LOGS EXPERIMENT -> Known.EXPERIMENT + PLAYGROUND_LOGS -> Known.PLAYGROUND_LOGS else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index d052b992..41527b6b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -215,7 +215,11 @@ private constructor( this.description = description } - fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + fun functionData(functionData: FunctionData?) = + functionData(JsonField.ofNullable(functionData)) + + fun functionData(functionData: Optional) = + functionData(functionData.getOrNull()) fun functionData(functionData: JsonField) = apply { this.functionData = functionData @@ -229,9 +233,6 @@ private constructor( fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) - fun functionData(nullableVariant: FunctionData.NullableVariant) = - functionData(FunctionData.ofNullableVariant(nullableVariant)) - /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -361,7 +362,10 @@ private constructor( /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData?) = apply { body.functionData(functionData) } + + fun functionData(functionData: Optional) = + functionData(functionData.getOrNull()) fun functionData(functionData: JsonField) = apply { body.functionData(functionData) @@ -373,10 +377,6 @@ private constructor( fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } - fun functionData(nullableVariant: FunctionData.NullableVariant) = apply { - body.functionData(nullableVariant) - } - /** Name of the prompt */ fun name(name: String?) = apply { body.name(name) } @@ -540,7 +540,6 @@ 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, ) { @@ -550,24 +549,18 @@ private constructor( 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 { @@ -575,7 +568,6 @@ private constructor( prompt != null -> visitor.visitPrompt(prompt) code != null -> visitor.visitCode(code) global != null -> visitor.visitGlobal(global) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -600,10 +592,6 @@ private constructor( override fun visitGlobal(global: Global) { global.validate() } - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -614,17 +602,16 @@ private constructor( return true } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ override fun toString(): String = 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") } @@ -636,10 +623,6 @@ private constructor( @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - FunctionData(nullableVariant = nullableVariant) } /** @@ -654,8 +637,6 @@ private constructor( fun visitGlobal(global: Global): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * @@ -688,10 +669,6 @@ private constructor( ?.let { return FunctionData(global = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(nullableVariant = it, _json = json) - } return FunctionData(_json = json) } @@ -708,7 +685,6 @@ private constructor( 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") } @@ -2309,88 +2285,6 @@ private constructor( override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { 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 index c726e52b..95ab2268 100644 --- 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 @@ -45,6 +45,9 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), @@ -104,6 +107,10 @@ private constructor( Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -140,10 +147,13 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -159,9 +169,9 @@ private constructor( fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -177,9 +187,9 @@ private constructor( fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -244,6 +254,10 @@ private constructor( fun __objectDelete(): JsonField = _objectDelete /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -271,10 +285,13 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -290,9 +307,9 @@ private constructor( @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -308,9 +325,9 @@ private constructor( @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -348,6 +365,7 @@ private constructor( _parentId() created() metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } rootSpanId() spanId() spanParents() @@ -375,6 +393,7 @@ private constructor( private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() private var spanId: JsonField = JsonMissing.of() private var spanParents: JsonField>? = null @@ -392,6 +411,7 @@ private constructor( expected = insertDatasetEvent.expected input = insertDatasetEvent.input metadata = insertDatasetEvent.metadata + origin = insertDatasetEvent.origin rootSpanId = insertDatasetEvent.rootSpanId spanId = insertDatasetEvent.spanId spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } @@ -571,6 +591,10 @@ private constructor( } /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -587,6 +611,10 @@ private constructor( fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -603,6 +631,10 @@ private constructor( fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -665,10 +697,19 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Indicates the event was copied from another object. */ + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.getOrNull()) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -685,9 +726,9 @@ private constructor( fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -704,9 +745,9 @@ private constructor( fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -723,9 +764,9 @@ private constructor( fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -742,9 +783,9 @@ private constructor( fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -761,9 +802,9 @@ private constructor( fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -780,9 +821,9 @@ private constructor( fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -799,9 +840,9 @@ private constructor( fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -818,9 +859,9 @@ private constructor( fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -839,9 +880,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -908,6 +949,7 @@ private constructor( expected, input, metadata, + origin, rootSpanId, spanId, (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, @@ -927,10 +969,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -942,6 +993,7 @@ private constructor( return@apply } + model() validated = true } @@ -956,13 +1008,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -982,7 +1045,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -990,16 +1053,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1007,15 +1071,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && origin == other.origin && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, created, expected, input, metadata, rootSpanId, spanId, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, created, expected, input, metadata, origin, rootSpanId, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, origin=$origin, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } 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 index 3b414e84..924c9baf 100644 --- 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 @@ -43,9 +43,6 @@ private constructor( @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), @@ -55,6 +52,9 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("root_span_id") @ExcludeMissing @@ -121,6 +121,10 @@ private constructor( Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -146,13 +150,6 @@ private constructor( /** The timestamp the experiment event was created */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** - * 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 error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error @@ -190,6 +187,9 @@ private constructor( */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** * 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 @@ -200,9 +200,9 @@ private constructor( @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -233,9 +233,9 @@ private constructor( Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -251,9 +251,9 @@ private constructor( fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -318,6 +318,10 @@ private constructor( fun __objectDelete(): JsonField = _objectDelete /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -343,14 +347,6 @@ private constructor( /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** - * 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(): JsonField = datasetRecordId - /** * 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 @@ -367,10 +363,13 @@ private constructor( */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -402,9 +401,9 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -420,9 +419,9 @@ private constructor( @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -460,9 +459,9 @@ private constructor( _parentId() context().ifPresent { it.validate() } created() - datasetRecordId() metadata().ifPresent { it.validate() } metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } rootSpanId() scores().ifPresent { it.validate() } spanAttributes().ifPresent { it.validate() } @@ -490,12 +489,12 @@ private constructor( private var _parentId: JsonField = JsonMissing.of() private var context: JsonField = JsonMissing.of() private var created: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() private var error: JsonValue = JsonMissing.of() private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() private var scores: JsonField = JsonMissing.of() @@ -514,12 +513,12 @@ private constructor( _parentId = insertExperimentEvent._parentId context = insertExperimentEvent.context created = insertExperimentEvent.created - datasetRecordId = insertExperimentEvent.datasetRecordId error = insertExperimentEvent.error expected = insertExperimentEvent.expected input = insertExperimentEvent.input metadata = insertExperimentEvent.metadata metrics = insertExperimentEvent.metrics + origin = insertExperimentEvent.origin output = insertExperimentEvent.output rootSpanId = insertExperimentEvent.rootSpanId scores = insertExperimentEvent.scores @@ -702,6 +701,10 @@ private constructor( } /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -718,6 +721,10 @@ private constructor( fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -734,6 +741,10 @@ private constructor( fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -779,28 +790,6 @@ private constructor( /** The timestamp the experiment event was created */ fun created(created: JsonField) = apply { this.created = created } - /** - * 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.ofNullable(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - /** The error that occurred, if any. */ fun error(error: JsonValue) = apply { this.error = error } @@ -870,6 +859,15 @@ private constructor( */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + /** Indicates the event was copied from another object. */ + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.getOrNull()) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + /** * 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. @@ -880,9 +878,9 @@ private constructor( fun output(output: JsonValue) = apply { this.output = output } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -899,9 +897,9 @@ private constructor( fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -918,9 +916,9 @@ private constructor( fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -983,9 +981,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1002,9 +1000,9 @@ private constructor( fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1021,9 +1019,9 @@ private constructor( fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1040,9 +1038,9 @@ private constructor( fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1059,9 +1057,9 @@ private constructor( fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1078,9 +1076,9 @@ private constructor( fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1099,9 +1097,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1166,12 +1164,12 @@ private constructor( _parentId, context, created, - datasetRecordId, error, expected, input, metadata, metrics, + origin, output, rootSpanId, scores, @@ -1370,10 +1368,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1385,6 +1392,7 @@ private constructor( return@apply } + model() validated = true } @@ -1399,13 +1407,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1425,7 +1444,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1433,16 +1452,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1878,15 +1898,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, datasetRecordId, error, expected, input, metadata, metrics, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, error, expected, input, metadata, metrics, origin, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } 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 index abf02697..977fb221 100644 --- 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 @@ -52,6 +52,9 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("root_span_id") @ExcludeMissing @@ -118,6 +121,10 @@ private constructor( Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -175,6 +182,9 @@ private constructor( */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** * 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 @@ -185,9 +195,9 @@ private constructor( @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -218,9 +228,9 @@ private constructor( Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -236,9 +246,9 @@ private constructor( fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -303,6 +313,10 @@ private constructor( fun __objectDelete(): JsonField = _objectDelete /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -344,10 +358,13 @@ private constructor( */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -379,9 +396,9 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -397,9 +414,9 @@ private constructor( @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -439,6 +456,7 @@ private constructor( created() metadata().ifPresent { it.validate() } metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } rootSpanId() scores().ifPresent { it.validate() } spanAttributes().ifPresent { it.validate() } @@ -471,6 +489,7 @@ private constructor( private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() private var scores: JsonField = JsonMissing.of() @@ -494,6 +513,7 @@ private constructor( input = insertProjectLogsEvent.input metadata = insertProjectLogsEvent.metadata metrics = insertProjectLogsEvent.metrics + origin = insertProjectLogsEvent.origin output = insertProjectLogsEvent.output rootSpanId = insertProjectLogsEvent.rootSpanId scores = insertProjectLogsEvent.scores @@ -676,6 +696,10 @@ private constructor( } /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -692,6 +716,10 @@ private constructor( fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -708,6 +736,10 @@ private constructor( fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -819,6 +851,15 @@ private constructor( */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + /** Indicates the event was copied from another object. */ + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.getOrNull()) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + /** * 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. @@ -829,9 +870,9 @@ private constructor( fun output(output: JsonValue) = apply { this.output = output } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -848,9 +889,9 @@ private constructor( fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -867,9 +908,9 @@ private constructor( fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -932,9 +973,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -951,9 +992,9 @@ private constructor( fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -970,9 +1011,9 @@ private constructor( fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -989,9 +1030,9 @@ private constructor( fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1008,9 +1049,9 @@ private constructor( fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1027,9 +1068,9 @@ private constructor( fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1048,9 +1089,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1120,6 +1161,7 @@ private constructor( input, metadata, metrics, + origin, output, rootSpanId, scores, @@ -1318,10 +1360,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1333,6 +1384,7 @@ private constructor( return@apply } + model() validated = true } @@ -1347,13 +1399,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1373,7 +1436,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1381,16 +1444,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1826,15 +1890,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, error, expected, input, metadata, metrics, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, error, expected, input, metadata, metrics, origin, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt new file mode 100644 index 00000000..9ebd640e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt @@ -0,0 +1,339 @@ +// 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.checkRequired +import com.braintrustdata.api.core.immutableEmptyMap +import com.braintrustdata.api.core.toImmutable +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 java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Indicates the event was copied from another object. */ +@NoAutoDetect +class ObjectReference +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** ID of the original event. */ + fun id(): String = id.getRequired("id") + + /** Transaction ID of the original event. */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** ID of the object the event is originating from. */ + fun objectId(): String = objectId.getRequired("object_id") + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** ID of the original event. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** Created timestamp of the original event. Used to help sort in the UI */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ObjectReference = apply { + if (validated) { + return@apply + } + + id() + _xactId() + objectId() + objectType() + created() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ObjectReference]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .objectId() + * .objectType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectReference]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var created: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectReference: ObjectReference) = apply { + id = objectReference.id + _xactId = objectReference._xactId + objectId = objectReference.objectId + objectType = objectReference.objectType + created = objectReference.created + additionalProperties = objectReference.additionalProperties.toMutableMap() + } + + /** ID of the original event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** ID of the original event. */ + fun id(id: JsonField) = apply { this.id = id } + + /** Transaction ID of the original event. */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** Transaction ID of the original event. */ + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(created: String?) = created(JsonField.ofNullable(created)) + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(created: Optional) = created(created.getOrNull()) + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(created: JsonField) = apply { this.created = created } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ObjectReference = + ObjectReference( + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + created, + additionalProperties.toImmutable(), + ) + } + + /** Type of the object the event is originating from. */ + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val DATASET = of("dataset") + + @JvmField val PROMPT = of("prompt") + + @JvmField val FUNCTION = of("function") + + @JvmField val PROMPT_SESSION = of("prompt_session") + + @JvmField val PROJECT_LOGS = of("project_logs") + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + /** An enum containing [ObjectType]'s known values. */ + enum class Known { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + } + + /** + * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ObjectType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + /** + * An enum member indicating that [ObjectType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + FUNCTION -> Value.FUNCTION + PROMPT_SESSION -> Value.PROMPT_SESSION + PROJECT_LOGS -> Value.PROJECT_LOGS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + FUNCTION -> Known.FUNCTION + PROMPT_SESSION -> Known.PROMPT_SESSION + PROJECT_LOGS -> Known.PROJECT_LOGS + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws BraintrustInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ObjectReference && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, created, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectReference{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, created=$created, additionalProperties=$additionalProperties}" +} 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 index 94a6ee65..760777fa 100755 --- 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 @@ -61,7 +61,7 @@ private constructor( private val metrics: JsonField = JsonMissing.of(), @JsonProperty("origin") @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("scores") @ExcludeMissing @@ -156,7 +156,7 @@ private constructor( fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** * The output of your application, including post-processing (an arbitrary, JSON serializable @@ -254,7 +254,7 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety @@ -354,7 +354,7 @@ private constructor( private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var scores: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() @@ -558,13 +558,13 @@ private constructor( fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ - fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.getOrNull()) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { this.origin = origin } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -1000,10 +1000,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1015,6 +1024,7 @@ private constructor( return@apply } + model() validated = true } @@ -1029,13 +1039,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1055,7 +1076,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1063,16 +1084,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1415,307 +1437,6 @@ private constructor( "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } - /** Indicates the event was copied from another object. */ - @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** ID of the original event. */ - fun id(): String = id.getRequired("id") - - /** Transaction ID of the original event. */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Origin = apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Origin]. - * - * The following fields are required: - * ```java - * .id() - * ._xactId() - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Origin]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var _xactId: JsonField? = null - private var objectId: JsonField? = null - private var objectType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } - - /** ID of the original event. */ - fun id(id: String) = id(JsonField.of(id)) - - /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Origin = - Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), - ) - } - - /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val FUNCTION = of("function") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val PROJECT_LOGS = of("project_logs") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - } - - /** - * An enum containing [ObjectType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ObjectType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - FUNCTION -> Value.FUNCTION - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_LOGS -> Value.PROJECT_LOGS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - FUNCTION -> Known.FUNCTION - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_LOGS -> Known.PROJECT_LOGS - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" - } - /** * 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 diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt index 6144049c..fd3e6e1c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt @@ -227,7 +227,10 @@ private constructor( fun userId(userId: JsonField) = apply { this.userId = userId } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { this.categories = categories } @@ -242,10 +245,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -341,6 +340,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -352,6 +353,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -370,6 +372,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -391,6 +394,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -411,6 +415,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } @@ -449,7 +454,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -462,16 +466,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -481,8 +481,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -490,7 +488,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -513,10 +510,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -527,17 +520,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -554,10 +546,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -574,8 +562,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -609,10 +595,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -629,7 +611,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -718,88 +699,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 82cf7754..c612a666 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -2,7 +2,6 @@ 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 @@ -10,7 +9,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -25,7 +23,7 @@ class ProjectScoreConfig private constructor( @JsonProperty("destination") @ExcludeMissing - private val destination: JsonField = JsonMissing.of(), + private val destination: JsonField = JsonMissing.of(), @JsonProperty("multi_select") @ExcludeMissing private val multiSelect: JsonField = JsonMissing.of(), @@ -35,7 +33,7 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun destination(): Optional = + fun destination(): Optional = Optional.ofNullable(destination.getNullable("destination")) fun multiSelect(): Optional = @@ -43,9 +41,7 @@ private constructor( fun online(): Optional = Optional.ofNullable(online.getNullable("online")) - @JsonProperty("destination") - @ExcludeMissing - fun _destination(): JsonField = destination + @JsonProperty("destination") @ExcludeMissing fun _destination(): JsonField = destination @JsonProperty("multi_select") @ExcludeMissing @@ -81,7 +77,7 @@ private constructor( /** A builder for [ProjectScoreConfig]. */ class Builder internal constructor() { - private var destination: JsonField = JsonMissing.of() + private var destination: JsonField = JsonMissing.of() private var multiSelect: JsonField = JsonMissing.of() private var online: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -94,13 +90,11 @@ private constructor( additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() } - fun destination(destination: Destination?) = destination(JsonField.ofNullable(destination)) + fun destination(destination: String?) = destination(JsonField.ofNullable(destination)) - fun destination(destination: Optional) = destination(destination.getOrNull()) + fun destination(destination: Optional) = destination(destination.getOrNull()) - fun destination(destination: JsonField) = apply { - this.destination = destination - } + fun destination(destination: JsonField) = apply { this.destination = destination } fun multiSelect(multiSelect: Boolean?) = multiSelect(JsonField.ofNullable(multiSelect)) @@ -139,103 +133,6 @@ private constructor( ProjectScoreConfig(destination, multiSelect, online, additionalProperties.toImmutable()) } - class Destination @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPECTED = of("expected") - - @JvmStatic fun of(value: String) = Destination(JsonField.of(value)) - } - - /** An enum containing [Destination]'s known values. */ - enum class Known { - EXPECTED - } - - /** - * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Destination] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPECTED, - /** - * An enum member indicating that [Destination] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPECTED -> Value.EXPECTED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws BraintrustInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPECTED -> Known.EXPECTED - else -> throw BraintrustInvalidDataException("Unknown Destination: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws BraintrustInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt index 49401ff2..51091ebd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt @@ -240,7 +240,10 @@ private constructor( fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { @@ -259,10 +262,6 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -380,7 +379,10 @@ private constructor( fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories?) = apply { body.categories(categories) } + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { body.categories(categories) } @@ -396,11 +398,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) @@ -568,6 +565,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -579,6 +578,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -597,6 +597,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -618,6 +619,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -638,6 +640,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } @@ -676,7 +679,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -689,16 +691,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -708,8 +706,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -717,7 +713,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -740,10 +735,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -754,17 +745,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -781,10 +771,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -801,8 +787,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -836,10 +820,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -856,7 +836,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -945,88 +924,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { 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 6f86bc5e..2899a11f 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 @@ -641,6 +641,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) } @@ -652,6 +654,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -671,6 +674,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ProjectScoreType] was instantiated with an * unknown value. @@ -693,6 +697,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -713,6 +718,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") } @@ -772,6 +778,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) } @@ -783,6 +791,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -802,6 +811,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ProjectScoreType] was instantiated with an * unknown value. @@ -824,6 +834,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -844,6 +855,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt index 8373825d..c4ef2e87 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt @@ -241,7 +241,10 @@ private constructor( fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { @@ -260,10 +263,6 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -381,7 +380,10 @@ private constructor( fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories?) = apply { body.categories(categories) } + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { body.categories(categories) } @@ -397,11 +399,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) @@ -569,6 +566,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -580,6 +579,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -598,6 +598,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -619,6 +620,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -639,6 +641,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } @@ -677,7 +680,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -690,16 +692,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -709,8 +707,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -718,7 +714,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -741,10 +736,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -755,17 +746,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -782,10 +772,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -802,8 +788,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -837,10 +821,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -857,7 +837,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -946,88 +925,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt index 4784736c..6813268c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt @@ -208,7 +208,10 @@ private constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { @@ -227,10 +230,6 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -350,7 +349,10 @@ private constructor( fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories?) = apply { body.categories(categories) } + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { body.categories(categories) } @@ -366,11 +368,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) @@ -538,7 +535,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -551,16 +547,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -570,8 +562,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -579,7 +569,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -602,10 +591,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -616,17 +601,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -643,10 +627,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -663,8 +643,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -698,10 +676,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -718,7 +692,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -807,88 +780,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } /** The type of the configured score */ @@ -918,6 +809,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -929,6 +822,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -947,6 +841,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -968,6 +863,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -988,6 +884,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 9c9bfe47..6a1912e4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -2,13 +2,17 @@ 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.checkKnown +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -21,21 +25,45 @@ import kotlin.jvm.optionals.getOrNull class ProjectSettings @JsonCreator private constructor( + @JsonProperty("baseline_experiment_id") + @ExcludeMissing + private val baselineExperimentId: JsonField = JsonMissing.of(), @JsonProperty("comparison_key") @ExcludeMissing private val comparisonKey: JsonField = JsonMissing.of(), + @JsonProperty("spanFieldOrder") + @ExcludeMissing + private val spanFieldOrder: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The key used to join two experiments (defaults to `input`). */ + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(): Optional = + Optional.ofNullable(baselineExperimentId.getNullable("baseline_experiment_id")) + + /** 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`). */ + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(): Optional> = + Optional.ofNullable(spanFieldOrder.getNullable("spanFieldOrder")) + + /** The id of the experiment to use as the default baseline for comparisons */ + @JsonProperty("baseline_experiment_id") + @ExcludeMissing + fun _baselineExperimentId(): JsonField = baselineExperimentId + + /** The key used to join two experiments (defaults to `input`) */ @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey(): JsonField = comparisonKey + /** The order of the fields to display in the trace view */ + @JsonProperty("spanFieldOrder") + @ExcludeMissing + fun _spanFieldOrder(): JsonField> = spanFieldOrder + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -47,7 +75,9 @@ private constructor( return@apply } + baselineExperimentId() comparisonKey() + spanFieldOrder().ifPresent { it.forEach { it.validate() } } validated = true } @@ -62,28 +92,66 @@ private constructor( /** A builder for [ProjectSettings]. */ class Builder internal constructor() { + private var baselineExperimentId: JsonField = JsonMissing.of() private var comparisonKey: JsonField = JsonMissing.of() + private var spanFieldOrder: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectSettings: ProjectSettings) = apply { + baselineExperimentId = projectSettings.baselineExperimentId comparisonKey = projectSettings.comparisonKey + spanFieldOrder = projectSettings.spanFieldOrder.map { it.toMutableList() } additionalProperties = projectSettings.additionalProperties.toMutableMap() } - /** The key used to join two experiments (defaults to `input`). */ + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(baselineExperimentId: String?) = + baselineExperimentId(JsonField.ofNullable(baselineExperimentId)) + + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(baselineExperimentId: Optional) = + baselineExperimentId(baselineExperimentId.getOrNull()) + + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(baselineExperimentId: JsonField) = apply { + this.baselineExperimentId = baselineExperimentId + } + + /** The key used to join two experiments (defaults to `input`) */ fun comparisonKey(comparisonKey: String?) = comparisonKey(JsonField.ofNullable(comparisonKey)) - /** The key used to join two experiments (defaults to `input`). */ + /** The key used to join two experiments (defaults to `input`) */ fun comparisonKey(comparisonKey: Optional) = comparisonKey(comparisonKey.getOrNull()) - /** The key used to join two experiments (defaults to `input`). */ + /** The key used to join two experiments (defaults to `input`) */ fun comparisonKey(comparisonKey: JsonField) = apply { this.comparisonKey = comparisonKey } + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(spanFieldOrder: List?) = + spanFieldOrder(JsonField.ofNullable(spanFieldOrder)) + + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(spanFieldOrder: Optional>) = + spanFieldOrder(spanFieldOrder.getOrNull()) + + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(spanFieldOrder: JsonField>) = apply { + this.spanFieldOrder = spanFieldOrder.map { it.toMutableList() } + } + + /** The order of the fields to display in the trace view */ + fun addSpanFieldOrder(spanFieldOrder: SpanFieldOrder) = apply { + this.spanFieldOrder = + (this.spanFieldOrder ?: JsonField.of(mutableListOf())).also { + checkKnown("spanFieldOrder", it).add(spanFieldOrder) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -104,7 +172,270 @@ private constructor( } fun build(): ProjectSettings = - ProjectSettings(comparisonKey, additionalProperties.toImmutable()) + ProjectSettings( + baselineExperimentId, + comparisonKey, + (spanFieldOrder ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class SpanFieldOrder + @JsonCreator + private constructor( + @JsonProperty("column_id") + @ExcludeMissing + private val columnId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("layout") + @ExcludeMissing + private val layout: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun columnId(): String = columnId.getRequired("column_id") + + fun objectType(): String = objectType.getRequired("object_type") + + fun position(): String = position.getRequired("position") + + fun layout(): Optional = Optional.ofNullable(layout.getNullable("layout")) + + @JsonProperty("column_id") @ExcludeMissing fun _columnId(): JsonField = columnId + + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + @JsonProperty("layout") @ExcludeMissing fun _layout(): JsonField = layout + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SpanFieldOrder = apply { + if (validated) { + return@apply + } + + columnId() + objectType() + position() + layout() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SpanFieldOrder]. + * + * The following fields are required: + * ```java + * .columnId() + * .objectType() + * .position() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpanFieldOrder]. */ + class Builder internal constructor() { + + private var columnId: JsonField? = null + private var objectType: JsonField? = null + private var position: JsonField? = null + private var layout: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanFieldOrder: SpanFieldOrder) = apply { + columnId = spanFieldOrder.columnId + objectType = spanFieldOrder.objectType + position = spanFieldOrder.position + layout = spanFieldOrder.layout + additionalProperties = spanFieldOrder.additionalProperties.toMutableMap() + } + + fun columnId(columnId: String) = columnId(JsonField.of(columnId)) + + fun columnId(columnId: JsonField) = apply { this.columnId = columnId } + + fun objectType(objectType: String) = objectType(JsonField.of(objectType)) + + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + fun position(position: String) = position(JsonField.of(position)) + + fun position(position: JsonField) = apply { this.position = position } + + fun layout(layout: Layout?) = layout(JsonField.ofNullable(layout)) + + fun layout(layout: Optional) = layout(layout.getOrNull()) + + fun layout(layout: JsonField) = apply { this.layout = layout } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): SpanFieldOrder = + SpanFieldOrder( + checkRequired("columnId", columnId), + checkRequired("objectType", objectType), + checkRequired("position", position), + layout, + additionalProperties.toImmutable(), + ) + } + + class Layout @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FULL = of("full") + + @JvmField val TWO_COLUMN = of("two_column") + + @JvmStatic fun of(value: String) = Layout(JsonField.of(value)) + } + + /** An enum containing [Layout]'s known values. */ + enum class Known { + FULL, + TWO_COLUMN, + } + + /** + * An enum containing [Layout]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Layout] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FULL, + TWO_COLUMN, + /** + * An enum member indicating that [Layout] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FULL -> Value.FULL + TWO_COLUMN -> Value.TWO_COLUMN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + FULL -> Known.FULL + TWO_COLUMN -> Known.TWO_COLUMN + else -> throw BraintrustInvalidDataException("Unknown Layout: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BraintrustInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Layout && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanFieldOrder && columnId == other.columnId && objectType == other.objectType && position == other.position && layout == other.layout && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(columnId, objectType, position, layout, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpanFieldOrder{columnId=$columnId, objectType=$objectType, position=$position, layout=$layout, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -112,15 +443,15 @@ private constructor( return true } - return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSettings && baselineExperimentId == other.baselineExperimentId && comparisonKey == other.comparisonKey && spanFieldOrder == other.spanFieldOrder && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(comparisonKey, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(baselineExperimentId, comparisonKey, spanFieldOrder, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + "ProjectSettings{baselineExperimentId=$baselineExperimentId, comparisonKey=$comparisonKey, spanFieldOrder=$spanFieldOrder, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index c9faaa96..cd072c2a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -142,7 +142,9 @@ private constructor( fun parser(parser: JsonField) = apply { this.parser = parser } - fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) + fun prompt(prompt: Prompt?) = prompt(JsonField.ofNullable(prompt)) + + fun prompt(prompt: Optional) = prompt(prompt.getOrNull()) fun prompt(prompt: JsonField) = apply { this.prompt = prompt } @@ -150,9 +152,6 @@ private constructor( fun prompt(chat: Prompt.Chat) = prompt(Prompt.ofChat(chat)) - fun prompt(nullableVariant: Prompt.NullableVariant) = - prompt(Prompt.ofNullableVariant(nullableVariant)) - fun toolFunctions(toolFunctions: List?) = toolFunctions(JsonField.ofNullable(toolFunctions)) @@ -655,7 +654,6 @@ private constructor( private constructor( private val completion: Completion? = null, private val chat: Chat? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -663,27 +661,20 @@ private constructor( fun chat(): Optional = Optional.ofNullable(chat) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCompletion(): Boolean = completion != null fun isChat(): Boolean = chat != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asCompletion(): Completion = completion.getOrThrow("completion") fun asChat(): Chat = chat.getOrThrow("chat") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { completion != null -> visitor.visitCompletion(completion) chat != null -> visitor.visitChat(chat) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -704,10 +695,6 @@ private constructor( override fun visitChat(chat: Chat) { chat.validate() } - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -718,16 +705,15 @@ private constructor( return true } - return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat) /* spotless:on */ override fun toString(): String = when { completion != null -> "Prompt{completion=$completion}" chat != null -> "Prompt{chat=$chat}" - nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" _json != null -> "Prompt{_unknown=$_json}" else -> throw IllegalStateException("Invalid Prompt") } @@ -737,10 +723,6 @@ private constructor( @JvmStatic fun ofCompletion(completion: Completion) = Prompt(completion = completion) @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Prompt(nullableVariant = nullableVariant) } /** An interface that defines how to map each variant of [Prompt] to a value of type [T]. */ @@ -750,8 +732,6 @@ private constructor( fun visitChat(chat: Chat): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Prompt] to a value of type [T]. * @@ -780,10 +760,6 @@ private constructor( ?.let { return Prompt(chat = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(nullableVariant = it, _json = json) - } return Prompt(_json = json) } @@ -799,7 +775,6 @@ private constructor( when { value.completion != null -> generator.writeObject(value.completion) value.chat != null -> generator.writeObject(value.chat) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Prompt") } @@ -3492,88 +3467,6 @@ private constructor( override fun toString() = "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } @JsonDeserialize(using = ToolFunction.Deserializer::class) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 5ac95496..86756e3f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -365,6 +365,9 @@ private constructor( @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("max_completion_tokens") + @ExcludeMissing + private val maxCompletionTokens: JsonField = JsonMissing.of(), @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), @@ -372,6 +375,9 @@ private constructor( @JsonProperty("presence_penalty") @ExcludeMissing private val presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("reasoning_effort") + @ExcludeMissing + private val reasoningEffort: JsonField = JsonMissing.of(), @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), @@ -400,6 +406,10 @@ private constructor( fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + /** The successor to max_tokens */ + fun maxCompletionTokens(): Optional = + Optional.ofNullable(maxCompletionTokens.getNullable("max_completion_tokens")) + fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) @@ -408,6 +418,9 @@ private constructor( fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun reasoningEffort(): Optional = + Optional.ofNullable(reasoningEffort.getNullable("reasoning_effort")) + fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) @@ -432,6 +445,11 @@ private constructor( @ExcludeMissing fun _functionCall(): JsonField = functionCall + /** The successor to max_tokens */ + @JsonProperty("max_completion_tokens") + @ExcludeMissing + fun _maxCompletionTokens(): JsonField = maxCompletionTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens @@ -442,6 +460,10 @@ private constructor( @ExcludeMissing fun _presencePenalty(): JsonField = presencePenalty + @JsonProperty("reasoning_effort") + @ExcludeMissing + fun _reasoningEffort(): JsonField = reasoningEffort + @JsonProperty("response_format") @ExcludeMissing fun _responseFormat(): JsonField = responseFormat @@ -475,9 +497,11 @@ private constructor( frequencyPenalty() functionCall().ifPresent { it.validate() } + maxCompletionTokens() maxTokens() n() presencePenalty() + reasoningEffort() responseFormat().ifPresent { it.validate() } stop() temperature() @@ -502,9 +526,11 @@ private constructor( private var frequencyPenalty: JsonField = JsonMissing.of() private var functionCall: JsonField = JsonMissing.of() + private var maxCompletionTokens: JsonField = JsonMissing.of() private var maxTokens: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var presencePenalty: JsonField = JsonMissing.of() + private var reasoningEffort: JsonField = JsonMissing.of() private var responseFormat: JsonField = JsonMissing.of() private var stop: JsonField>? = null private var temperature: JsonField = JsonMissing.of() @@ -517,9 +543,11 @@ private constructor( internal fun from(openaiModelParams: OpenAIModelParams) = apply { frequencyPenalty = openaiModelParams.frequencyPenalty functionCall = openaiModelParams.functionCall + maxCompletionTokens = openaiModelParams.maxCompletionTokens maxTokens = openaiModelParams.maxTokens n = openaiModelParams.n presencePenalty = openaiModelParams.presencePenalty + reasoningEffort = openaiModelParams.reasoningEffort responseFormat = openaiModelParams.responseFormat stop = openaiModelParams.stop.map { it.toMutableList() } temperature = openaiModelParams.temperature @@ -549,6 +577,15 @@ private constructor( fun functionCall(function: FunctionCall.Function) = functionCall(FunctionCall.ofFunction(function)) + /** The successor to max_tokens */ + fun maxCompletionTokens(maxCompletionTokens: Double) = + maxCompletionTokens(JsonField.of(maxCompletionTokens)) + + /** The successor to max_tokens */ + fun maxCompletionTokens(maxCompletionTokens: JsonField) = apply { + this.maxCompletionTokens = maxCompletionTokens + } + fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } @@ -564,8 +601,18 @@ private constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) + fun reasoningEffort(reasoningEffort: ReasoningEffort) = + reasoningEffort(JsonField.of(reasoningEffort)) + + fun reasoningEffort(reasoningEffort: JsonField) = apply { + this.reasoningEffort = reasoningEffort + } + + fun responseFormat(responseFormat: ResponseFormat?) = + responseFormat(JsonField.ofNullable(responseFormat)) + + fun responseFormat(responseFormat: Optional) = + responseFormat(responseFormat.getOrNull()) fun responseFormat(responseFormat: JsonField) = apply { this.responseFormat = responseFormat @@ -580,9 +627,6 @@ private constructor( fun responseFormat(text: ResponseFormat.Text) = responseFormat(ResponseFormat.ofText(text)) - fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = - responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) - fun stop(stop: List) = stop(JsonField.of(stop)) fun stop(stop: JsonField>) = apply { @@ -648,9 +692,11 @@ private constructor( OpenAIModelParams( frequencyPenalty, functionCall, + maxCompletionTokens, maxTokens, n, presencePenalty, + reasoningEffort, responseFormat, (stop ?: JsonMissing.of()).map { it.toImmutable() }, temperature, @@ -1016,6 +1062,120 @@ private constructor( } } + class ReasoningEffort + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LOW = of("low") + + @JvmField val MEDIUM = of("medium") + + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = ReasoningEffort(JsonField.of(value)) + } + + /** An enum containing [ReasoningEffort]'s known values. */ + enum class Known { + LOW, + MEDIUM, + HIGH, + } + + /** + * An enum containing [ReasoningEffort]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReasoningEffort] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LOW, + MEDIUM, + HIGH, + /** + * An enum member indicating that [ReasoningEffort] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException("Unknown ReasoningEffort: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BraintrustInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReasoningEffort && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + @JsonDeserialize(using = ResponseFormat.Deserializer::class) @JsonSerialize(using = ResponseFormat.Serializer::class) class ResponseFormat @@ -1023,7 +1183,6 @@ private constructor( private val jsonObject: JsonObject? = null, private val jsonSchema: JsonSchema? = null, private val text: Text? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -1033,26 +1192,18 @@ private constructor( fun text(): Optional = Optional.ofNullable(text) - fun nullableVariant(): Optional = - Optional.ofNullable(nullableVariant) - fun isJsonObject(): Boolean = jsonObject != null fun isJsonSchema(): Boolean = jsonSchema != null fun isText(): Boolean = text != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asJsonObject(): JsonObject = jsonObject.getOrThrow("jsonObject") fun asJsonSchema(): JsonSchema = jsonSchema.getOrThrow("jsonSchema") fun asText(): Text = text.getOrThrow("text") - fun asNullableVariant(): NullableVariant = - nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -1060,7 +1211,6 @@ private constructor( jsonObject != null -> visitor.visitJsonObject(jsonObject) jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) text != null -> visitor.visitText(text) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -1085,10 +1235,6 @@ private constructor( override fun visitText(text: Text) { text.validate() } - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -1099,18 +1245,16 @@ private constructor( return true } - return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text) /* spotless:on */ override fun toString(): String = when { jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" text != null -> "ResponseFormat{text=$text}" - nullableVariant != null -> - "ResponseFormat{nullableVariant=$nullableVariant}" _json != null -> "ResponseFormat{_unknown=$_json}" else -> throw IllegalStateException("Invalid ResponseFormat") } @@ -1126,10 +1270,6 @@ private constructor( ResponseFormat(jsonSchema = jsonSchema) @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - ResponseFormat(nullableVariant = nullableVariant) } /** @@ -1144,8 +1284,6 @@ private constructor( fun visitText(text: Text): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [ResponseFormat] to a value of type [T]. * @@ -1179,10 +1317,6 @@ private constructor( ?.let { return ResponseFormat(text = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(nullableVariant = it, _json = json) - } return ResponseFormat(_json = json) } @@ -1199,8 +1333,6 @@ private constructor( value.jsonObject != null -> generator.writeObject(value.jsonObject) value.jsonSchema != null -> generator.writeObject(value.jsonSchema) value.text != null -> generator.writeObject(value.text) - value.nullableVariant != null -> - generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ResponseFormat") } @@ -1644,6 +1776,11 @@ private constructor( fun schema(schema: JsonField) = apply { this.schema = schema } + fun schema(unionMember0: Schema.UnionMember0) = + schema(Schema.ofUnionMember0(unionMember0)) + + fun schema(string: String) = schema(Schema.ofString(string)) + fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) fun strict(strict: Boolean) = strict(strict as Boolean?) @@ -1684,19 +1821,38 @@ private constructor( ) } - @NoAutoDetect + @JsonDeserialize(using = Schema.Deserializer::class) + @JsonSerialize(using = Schema.Serializer::class) class Schema - @JsonCreator private constructor( - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap() + private val unionMember0: UnionMember0? = null, + private val string: String? = null, + private val _json: JsonValue? = null, ) { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun string(): Optional = Optional.ofNullable(string) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isString(): Boolean = string != null + + fun asUnionMember0(): UnionMember0 = + unionMember0.getOrThrow("unionMember0") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + } private var validated: Boolean = false @@ -1705,74 +1861,202 @@ private constructor( return@apply } + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitString(string: String) {} + } + ) validated = true } - fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schema && unionMember0 == other.unionMember0 && string == other.string /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, string) /* spotless:on */ + + override fun toString(): String = + when { + unionMember0 != null -> "Schema{unionMember0=$unionMember0}" + string != null -> "Schema{string=$string}" + _json != null -> "Schema{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Schema") + } companion object { + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + Schema(unionMember0 = unionMember0) + + @JvmStatic fun ofString(string: String) = Schema(string = string) + } + + /** + * An interface that defines how to map each variant of [Schema] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitString(string: String): T + /** - * Returns a mutable builder for constructing an instance of - * [Schema]. + * Maps an unknown variant of [Schema] to a value of type [T]. + * + * An instance of [Schema] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default + * implementation. */ - @JvmStatic fun builder() = Builder() + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Schema: $json") + } } - /** A builder for [Schema]. */ - class Builder internal constructor() { + internal class Deserializer : BaseDeserializer(Schema::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Schema { + val json = JsonValue.fromJsonNode(node) - private var additionalProperties: MutableMap = - mutableMapOf() + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Schema(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Schema(string = it, _json = json) + } - @JvmSynthetic - internal fun from(schema: Schema) = apply { - additionalProperties = - schema.additionalProperties.toMutableMap() + return Schema(_json = json) } + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + internal class Serializer : BaseSerializer(Schema::class) { + + override fun serialize( + value: Schema, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Schema") + } } + } + + @NoAutoDetect + class UnionMember0 + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun toBuilder() = Builder().from(this) + + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) } - fun build(): Schema = Schema(additionalProperties.toImmutable()) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return /* spotless:off */ other is UnionMember0 && additionalProperties == other.additionalProperties /* spotless:on */ } - return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "Schema{additionalProperties=$additionalProperties}" + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { @@ -2118,95 +2402,6 @@ private constructor( override fun toString() = "Text{type=$type, additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NullableVariant]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = - nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = - NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NullableVariant{additionalProperties=$additionalProperties}" - } } @JsonDeserialize(using = ToolChoice.Deserializer::class) @@ -2807,17 +3002,17 @@ private constructor( return true } - return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxCompletionTokens == other.maxCompletionTokens && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && reasoningEffort == other.reasoningEffort && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequencyPenalty, functionCall, maxTokens, n, presencePenalty, responseFormat, stop, temperature, toolChoice, topP, useCache, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(frequencyPenalty, functionCall, maxCompletionTokens, maxTokens, n, presencePenalty, reasoningEffort, responseFormat, stop, temperature, toolChoice, topP, useCache, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxCompletionTokens=$maxCompletionTokens, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, reasoningEffort=$reasoningEffort, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 50735234..7282d348 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -37,6 +37,9 @@ private constructor( /** SpanIframe id */ fun spanIframeId(): String = spanIframeId + /** Textual description of the span iframe */ + fun description(): Optional = body.description() + /** Name of the span iframe */ fun name(): Optional = body.name() @@ -49,6 +52,9 @@ private constructor( /** URL to embed the project viewer in an iframe */ fun url(): Optional = body.url() + /** Textual description of the span iframe */ + fun _description(): JsonField = body._description() + /** Name of the span iframe */ fun _name(): JsonField = body._name() @@ -84,6 +90,9 @@ private constructor( class Body @JsonCreator private constructor( + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -95,6 +104,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** Textual description of the span iframe */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + /** Name of the span iframe */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -108,6 +121,11 @@ private constructor( /** URL to embed the project viewer in an iframe */ fun url(): Optional = Optional.ofNullable(url.getNullable("url")) + /** Textual description of the span iframe */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + /** Name of the span iframe */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -133,6 +151,7 @@ private constructor( return@apply } + description() name() postMessage() url() @@ -150,6 +169,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var description: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var postMessage: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() @@ -157,12 +177,24 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + description = body.description name = body.name postMessage = body.postMessage url = body.url additionalProperties = body.additionalProperties.toMutableMap() } + /** Textual description of the span iframe */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the span iframe */ + fun description(description: Optional) = description(description.getOrNull()) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { + this.description = description + } + /** Name of the span iframe */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -226,7 +258,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Body = Body(name, postMessage, url, additionalProperties.toImmutable()) + fun build(): Body = + Body(description, name, postMessage, url, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -234,17 +267,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, postMessage, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(description, name, postMessage, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" + "Body{description=$description, name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -282,6 +315,15 @@ private constructor( /** SpanIframe id */ fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + /** Textual description of the span iframe */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the span iframe */ + fun description(description: Optional) = description(description.getOrNull()) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { body.description(description) } + /** Name of the span iframe */ fun name(name: String?) = apply { body.name(name) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt index a8bb266f..58a05213 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt @@ -479,19 +479,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = of("experiments") + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUNDS = of("playgrounds") + + @JvmField val PLAYGROUND = of("playground") + @JvmField val DATASETS = of("datasets") + @JvmField val DATASET = of("dataset") + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -499,13 +505,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -519,13 +528,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -540,13 +552,16 @@ private constructor( 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 + PLAYGROUNDS -> Value.PLAYGROUNDS + PLAYGROUND -> Value.PLAYGROUND + DATASETS -> Value.DATASETS DATASET -> Value.DATASET + PROMPTS -> Value.PROMPTS + TOOLS -> Value.TOOLS + SCORERS -> Value.SCORERS + LOGS -> Value.LOGS else -> Value._UNKNOWN } @@ -562,13 +577,16 @@ private constructor( 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 + PLAYGROUNDS -> Known.PLAYGROUNDS + PLAYGROUND -> Known.PLAYGROUND + DATASETS -> Known.DATASETS DATASET -> Known.DATASET + PROMPTS -> Known.PROMPTS + TOOLS -> Known.TOOLS + SCORERS -> Known.SCORERS + LOGS -> Known.LOGS else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt index 0597fc32..7d07ab02 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt @@ -755,19 +755,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = of("experiments") + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUNDS = of("playgrounds") + + @JvmField val PLAYGROUND = of("playground") + @JvmField val DATASETS = of("datasets") + @JvmField val DATASET = of("dataset") + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -775,13 +781,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -795,13 +804,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -816,13 +828,16 @@ private constructor( 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 + PLAYGROUNDS -> Value.PLAYGROUNDS + PLAYGROUND -> Value.PLAYGROUND + DATASETS -> Value.DATASETS DATASET -> Value.DATASET + PROMPTS -> Value.PROMPTS + TOOLS -> Value.TOOLS + SCORERS -> Value.SCORERS + LOGS -> Value.LOGS else -> Value._UNKNOWN } @@ -838,13 +853,16 @@ private constructor( 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 + PLAYGROUNDS -> Known.PLAYGROUNDS + PLAYGROUND -> Known.PLAYGROUND + DATASETS -> Known.DATASETS DATASET -> Known.DATASET + PROMPTS -> Known.PROMPTS + TOOLS -> Known.TOOLS + SCORERS -> Known.SCORERS + LOGS -> Known.LOGS else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } 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 3dd24391..dd2f1d06 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 @@ -637,19 +637,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = of("experiments") + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUNDS = of("playgrounds") + + @JvmField val PLAYGROUND = of("playground") + @JvmField val DATASETS = of("datasets") + @JvmField val DATASET = of("dataset") + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -657,13 +663,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -677,13 +686,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -698,13 +710,16 @@ private constructor( 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 + PLAYGROUNDS -> Value.PLAYGROUNDS + PLAYGROUND -> Value.PLAYGROUND + DATASETS -> Value.DATASETS DATASET -> Value.DATASET + PROMPTS -> Value.PROMPTS + TOOLS -> Value.TOOLS + SCORERS -> Value.SCORERS + LOGS -> Value.LOGS else -> Value._UNKNOWN } @@ -720,13 +735,16 @@ private constructor( 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 + PLAYGROUNDS -> Known.PLAYGROUNDS + PLAYGROUND -> Known.PLAYGROUND + DATASETS -> Known.DATASETS DATASET -> Known.DATASET + PROMPTS -> Known.PROMPTS + TOOLS -> Known.TOOLS + SCORERS -> Known.SCORERS + LOGS -> Known.LOGS else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 731eab40..40ff24c4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -32,6 +32,15 @@ private constructor( @JsonProperty("columnVisibility") @ExcludeMissing private val columnVisibility: JsonField = JsonMissing.of(), + @JsonProperty("grouping") + @ExcludeMissing + private val grouping: JsonField = JsonMissing.of(), + @JsonProperty("layout") + @ExcludeMissing + private val layout: JsonField = JsonMissing.of(), + @JsonProperty("rowHeight") + @ExcludeMissing + private val rowHeight: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -44,6 +53,12 @@ private constructor( fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) + + fun layout(): Optional = Optional.ofNullable(layout.getNullable("layout")) + + fun rowHeight(): Optional = Optional.ofNullable(rowHeight.getNullable("rowHeight")) + @JsonProperty("columnOrder") @ExcludeMissing fun _columnOrder(): JsonField> = columnOrder @@ -56,6 +71,12 @@ private constructor( @ExcludeMissing fun _columnVisibility(): JsonField = columnVisibility + @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping + + @JsonProperty("layout") @ExcludeMissing fun _layout(): JsonField = layout + + @JsonProperty("rowHeight") @ExcludeMissing fun _rowHeight(): JsonField = rowHeight + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -70,6 +91,9 @@ private constructor( columnOrder() columnSizing().ifPresent { it.validate() } columnVisibility().ifPresent { it.validate() } + grouping() + layout() + rowHeight() validated = true } @@ -87,6 +111,9 @@ private constructor( private var columnOrder: JsonField>? = null private var columnSizing: JsonField = JsonMissing.of() private var columnVisibility: JsonField = JsonMissing.of() + private var grouping: JsonField = JsonMissing.of() + private var layout: JsonField = JsonMissing.of() + private var rowHeight: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -94,6 +121,9 @@ private constructor( columnOrder = viewOptions.columnOrder.map { it.toMutableList() } columnSizing = viewOptions.columnSizing columnVisibility = viewOptions.columnVisibility + grouping = viewOptions.grouping + layout = viewOptions.layout + rowHeight = viewOptions.rowHeight additionalProperties = viewOptions.additionalProperties.toMutableMap() } @@ -132,6 +162,24 @@ private constructor( this.columnVisibility = columnVisibility } + fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.getOrNull()) + + fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + + fun layout(layout: String?) = layout(JsonField.ofNullable(layout)) + + fun layout(layout: Optional) = layout(layout.getOrNull()) + + fun layout(layout: JsonField) = apply { this.layout = layout } + + fun rowHeight(rowHeight: String?) = rowHeight(JsonField.ofNullable(rowHeight)) + + fun rowHeight(rowHeight: Optional) = rowHeight(rowHeight.getOrNull()) + + fun rowHeight(rowHeight: JsonField) = apply { this.rowHeight = rowHeight } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -156,6 +204,9 @@ private constructor( (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, columnSizing, columnVisibility, + grouping, + layout, + rowHeight, additionalProperties.toImmutable(), ) } @@ -323,15 +374,15 @@ private constructor( return true } - return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && grouping == other.grouping && layout == other.layout && rowHeight == other.rowHeight && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(columnOrder, columnSizing, columnVisibility, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(columnOrder, columnSizing, columnVisibility, grouping, layout, rowHeight, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" + "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, grouping=$grouping, layout=$layout, rowHeight=$rowHeight, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt index d99f4f94..3c53c17e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt @@ -759,19 +759,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = of("experiments") + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUNDS = of("playgrounds") + + @JvmField val PLAYGROUND = of("playground") + @JvmField val DATASETS = of("datasets") + @JvmField val DATASET = of("dataset") + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -779,13 +785,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -799,13 +808,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -820,13 +832,16 @@ private constructor( 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 + PLAYGROUNDS -> Value.PLAYGROUNDS + PLAYGROUND -> Value.PLAYGROUND + DATASETS -> Value.DATASETS DATASET -> Value.DATASET + PROMPTS -> Value.PROMPTS + TOOLS -> Value.TOOLS + SCORERS -> Value.SCORERS + LOGS -> Value.LOGS else -> Value._UNKNOWN } @@ -842,13 +857,16 @@ private constructor( 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 + PLAYGROUNDS -> Known.PLAYGROUNDS + PLAYGROUND -> Known.PLAYGROUND + DATASETS -> Known.DATASETS DATASET -> Known.DATASET + PROMPTS -> Known.PROMPTS + TOOLS -> Known.TOOLS + SCORERS -> Known.SCORERS + LOGS -> Known.LOGS else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt index 368c4698..525a0dbc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt @@ -737,19 +737,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = of("experiments") + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUNDS = of("playgrounds") + + @JvmField val PLAYGROUND = of("playground") + @JvmField val DATASETS = of("datasets") + @JvmField val DATASET = of("dataset") + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -757,13 +763,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -777,13 +786,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -798,13 +810,16 @@ private constructor( 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 + PLAYGROUNDS -> Value.PLAYGROUNDS + PLAYGROUND -> Value.PLAYGROUND + DATASETS -> Value.DATASETS DATASET -> Value.DATASET + PROMPTS -> Value.PROMPTS + TOOLS -> Value.TOOLS + SCORERS -> Value.SCORERS + LOGS -> Value.LOGS else -> Value._UNKNOWN } @@ -820,13 +835,16 @@ private constructor( 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 + PLAYGROUNDS -> Known.PLAYGROUNDS + PLAYGROUND -> Known.PLAYGROUND + DATASETS -> Known.DATASETS DATASET -> Known.DATASET + PROMPTS -> Known.PROMPTS + TOOLS -> Known.TOOLS + SCORERS -> Known.SCORERS + LOGS -> Known.LOGS else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 5138c220..a361b6f2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -5,8 +5,6 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -69,28 +67,6 @@ interface AclServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ - fun batchUpdate(): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture = batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture = findAndDelete(params, RequestOptions.none()) @@ -164,35 +140,6 @@ interface AclServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclServiceAsync.batchUpdate]. - */ - @MustBeClosed - fun batchUpdate(): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture> = - batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - requestOptions: RequestOptions - ): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclServiceAsync.findAndDelete]. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index e99ec877..00da2121 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -16,8 +16,6 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -63,13 +61,6 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/acl/batch-update - withRawResponse().batchUpdate(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, @@ -204,37 +195,6 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 5d4a4de6..5e571994 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -5,8 +5,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -58,27 +56,6 @@ interface AclService { /** @see [delete] */ fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ - fun batchUpdate(): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AclBatchUpdateResponse - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): AclBatchUpdateResponse = batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): Acl = findAndDelete(params, RequestOptions.none()) @@ -152,32 +129,6 @@ interface AclService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclService.batchUpdate]. - */ - @MustBeClosed - fun batchUpdate(): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): HttpResponseFor = batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclService.findAndDelete]. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index 39e18573..ef37bddc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -16,8 +16,6 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -49,13 +47,6 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).parse() - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): AclBatchUpdateResponse = - // post /v1/acl/batch-update - withRawResponse().batchUpdate(params, requestOptions).parse() - override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, @@ -176,34 +167,6 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index 693b9866..d4b40e30 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -24,6 +24,7 @@ class AISecretTest { ) .previewSecret("preview_secret") .type("type") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() assertThat(aiSecret).isNotNull assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -38,5 +39,6 @@ class AISecretTest { ) assertThat(aiSecret.previewSecret()).contains("preview_secret") assertThat(aiSecret.type()).contains("type") + assertThat(aiSecret.updatedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt deleted file mode 100644 index ce3f43d3..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt +++ /dev/null @@ -1,118 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import kotlin.test.assertNotNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class AclBatchUpdateParamsTest { - - @Test - fun create() { - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - } - - @Test - fun body() { - val params = - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.addAcls()) - .contains( - listOf( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - assertThat(body.removeAcls()) - .contains( - listOf( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = AclBatchUpdateParams.builder().build() - - val body = params._body() - - assertNotNull(body) - } -} 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 index 687f05e1..2226864c 100755 --- 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 @@ -23,17 +23,14 @@ class DatasetEventTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(DatasetEvent.Metadata.builder().model("model").build()) .origin( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .addTag("string") @@ -51,18 +48,15 @@ class DatasetEventTest { assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(datasetEvent.isRoot()).contains(true) assertThat(datasetEvent.metadata()) - .contains( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(DatasetEvent.Metadata.builder().model("model").build()) assertThat(datasetEvent.origin()) .contains( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(datasetEvent.tags().get()).containsExactly("string") 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 9f080dd0..7278beb1 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 @@ -24,9 +24,14 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") @@ -53,9 +58,14 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") @@ -81,9 +91,14 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 5ac72887..869fa93c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -12,7 +12,17 @@ class EvalCreateParamsTest { @Test fun create() { EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -42,6 +52,24 @@ class EvalCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -65,7 +93,17 @@ class EvalCreateParamsTest { fun body() { val params = EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -95,6 +133,26 @@ class EvalCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -119,7 +177,15 @@ class EvalCreateParamsTest { assertThat(body.data()) .isEqualTo( EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() ) ) assertThat(body.projectId()).isEqualTo("project_id") @@ -161,6 +227,29 @@ class EvalCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + assertThat(body.parent()) + .contains( + EvalCreateParams.Parent.ofSpanParentStruct( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + ) assertThat(body.repoInfo()) .contains( RepoInfo.builder() 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 index 3830f18c..f10a67a4 100755 --- 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 @@ -27,16 +27,11 @@ class ExperimentEventTest { .callerLineno(0L) .build() ) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ExperimentEvent.Metadata.builder().model("model").build()) .metrics( ExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -50,11 +45,12 @@ class ExperimentEventTest { .build() ) .origin( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -86,17 +82,12 @@ class ExperimentEventTest { .callerLineno(0L) .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.isRoot()).contains(true) assertThat(experimentEvent.metadata()) - .contains( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(ExperimentEvent.Metadata.builder().model("model").build()) assertThat(experimentEvent.metrics()) .contains( ExperimentEvent.Metrics.builder() @@ -112,11 +103,12 @@ class ExperimentEventTest { ) assertThat(experimentEvent.origin()) .contains( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) 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 9627ff9b..8326f83a 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 @@ -29,15 +29,10 @@ class ExperimentInsertParamsTest { .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( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -50,6 +45,15 @@ class ExperimentInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -88,15 +92,10 @@ class ExperimentInsertParamsTest { .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( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -109,6 +108,15 @@ class ExperimentInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -149,15 +157,10 @@ class ExperimentInsertParamsTest { .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( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -170,6 +173,15 @@ class ExperimentInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( 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 index ad7d703b..29bcfe3b 100755 --- 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 @@ -25,17 +25,14 @@ class FetchDatasetEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(DatasetEvent.Metadata.builder().model("model").build()) .origin( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .addTag("string") @@ -57,17 +54,14 @@ class FetchDatasetEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(DatasetEvent.Metadata.builder().model("model").build()) .origin( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .addTag("string") 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 index 7e95ce35..d8796002 100755 --- 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 @@ -29,16 +29,11 @@ class FetchExperimentEventsResponseTest { .callerLineno(0L) .build() ) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ExperimentEvent.Metadata.builder().model("model").build()) .metrics( ExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -52,11 +47,12 @@ class FetchExperimentEventsResponseTest { .build() ) .origin( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -95,16 +91,11 @@ class FetchExperimentEventsResponseTest { .callerLineno(0L) .build() ) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ExperimentEvent.Metadata.builder().model("model").build()) .metrics( ExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -118,11 +109,12 @@ class FetchExperimentEventsResponseTest { .build() ) .origin( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) 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 index 4c35853e..480a33d8 100755 --- 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 @@ -34,11 +34,7 @@ class FetchProjectLogsEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( ProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -52,11 +48,12 @@ class FetchProjectLogsEventsResponseTest { .build() ) .origin( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -100,11 +97,7 @@ class FetchProjectLogsEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( ProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -118,11 +111,12 @@ class FetchProjectLogsEventsResponseTest { .build() ) .origin( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt index f4114dc7..389d6004 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt @@ -48,9 +48,13 @@ class FunctionCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -154,9 +158,14 @@ class FunctionCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -264,9 +273,13 @@ class FunctionCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index dcfb6ecc..4a9bbd1f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -13,6 +13,7 @@ class FunctionInvokeParamsTest { fun create() { FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -21,6 +22,11 @@ class FunctionInvokeParamsTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -52,6 +58,7 @@ class FunctionInvokeParamsTest { val params = FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -60,6 +67,11 @@ class FunctionInvokeParamsTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -88,6 +100,7 @@ class FunctionInvokeParamsTest { val body = params._body() assertNotNull(body) + assertThat(body._expected()).isEqualTo(JsonValue.from(mapOf())) assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.messages()) .contains( @@ -101,6 +114,12 @@ class FunctionInvokeParamsTest { ) ) ) + assertThat(body.metadata()) + .contains( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) assertThat(body.parent()) .contains( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt index 56eba313..590c73e7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt @@ -48,9 +48,13 @@ class FunctionReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -154,9 +158,14 @@ class FunctionReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -264,9 +273,13 @@ class FunctionReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt index b6570597..2183cad8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt @@ -59,9 +59,14 @@ class FunctionTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -177,9 +182,13 @@ class FunctionTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index 051c89be..cd43ea77 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -33,9 +33,13 @@ class FunctionUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -124,9 +128,14 @@ class FunctionUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -216,9 +225,13 @@ class FunctionUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt index 53366aec..f81a9b5e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -21,9 +21,14 @@ class InsertDatasetEventTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") @@ -42,9 +47,15 @@ class InsertDatasetEventTest { assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertDatasetEvent.metadata()) + .contains(InsertDatasetEvent.Metadata.builder().model("model").build()) + assertThat(insertDatasetEvent.origin()) .contains( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt index e9425570..c067cb4b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt @@ -26,15 +26,10 @@ class InsertExperimentEventTest { .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( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -47,6 +42,15 @@ class InsertExperimentEventTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -77,17 +81,12 @@ class InsertExperimentEventTest { ) assertThat(insertExperimentEvent.created()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent._expected()) .isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent.metadata()) - .contains( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(InsertExperimentEvent.Metadata.builder().model("model").build()) assertThat(insertExperimentEvent.metrics()) .contains( InsertExperimentEvent.Metrics.builder() @@ -101,6 +100,16 @@ class InsertExperimentEventTest { .tokens(0L) .build() ) + assertThat(insertExperimentEvent.origin()) + .contains( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") assertThat(insertExperimentEvent.scores()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt index 3454b8e9..20bcc290 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt @@ -29,11 +29,7 @@ class InsertProjectLogsEventTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -46,6 +42,15 @@ class InsertProjectLogsEventTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -81,11 +86,7 @@ class InsertProjectLogsEventTest { .isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent.metadata()) - .contains( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(InsertProjectLogsEvent.Metadata.builder().model("model").build()) assertThat(insertProjectLogsEvent.metrics()) .contains( InsertProjectLogsEvent.Metrics.builder() @@ -99,6 +100,16 @@ class InsertProjectLogsEventTest { .tokens(0L) .build() ) + assertThat(insertProjectLogsEvent.origin()) + .contains( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") assertThat(insertProjectLogsEvent.scores()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt new file mode 100644 index 00000000..d859fcd0 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.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 ObjectReferenceTest { + + @Test + fun createObjectReference() { + val objectReference = + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + assertThat(objectReference).isNotNull + assertThat(objectReference.id()).isEqualTo("id") + assertThat(objectReference._xactId()).isEqualTo("_xact_id") + assertThat(objectReference.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(objectReference.objectType()).isEqualTo(ObjectReference.ObjectType.EXPERIMENT) + assertThat(objectReference.created()).contains("created") + } +} 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 24369344..c5bb43ae 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 @@ -32,11 +32,7 @@ class ProjectLogInsertParamsTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -49,6 +45,15 @@ class ProjectLogInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -90,11 +95,7 @@ class ProjectLogInsertParamsTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -107,6 +108,15 @@ class ProjectLogInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -150,11 +160,7 @@ class ProjectLogInsertParamsTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -167,6 +173,15 @@ class ProjectLogInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( 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 index d49aac8a..e81a0afb 100755 --- 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 @@ -32,11 +32,7 @@ class ProjectLogsEventTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( ProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -50,11 +46,12 @@ class ProjectLogsEventTest { .build() ) .origin( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -92,11 +89,7 @@ class ProjectLogsEventTest { assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(projectLogsEvent.isRoot()).contains(true) assertThat(projectLogsEvent.metadata()) - .contains( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(ProjectLogsEvent.Metadata.builder().model("model").build()) assertThat(projectLogsEvent.metrics()) .contains( ProjectLogsEvent.Metrics.builder() @@ -112,11 +105,12 @@ class ProjectLogsEventTest { ) assertThat(projectLogsEvent.origin()) .contains( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt index ebd3f975..762e01a3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt @@ -11,7 +11,7 @@ class ProjectScoreConfigTest { fun createProjectScoreConfig() { val projectScoreConfig = ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -28,8 +28,7 @@ class ProjectScoreConfigTest { ) .build() assertThat(projectScoreConfig).isNotNull - assertThat(projectScoreConfig.destination()) - .contains(ProjectScoreConfig.Destination.EXPECTED) + assertThat(projectScoreConfig.destination()).contains("destination") assertThat(projectScoreConfig.multiSelect()).contains(true) assertThat(projectScoreConfig.online()) .contains( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt index f2eb7ba1..ff0c8da7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt @@ -19,7 +19,7 @@ class ProjectScoreCreateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -52,7 +52,7 @@ class ProjectScoreCreateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -87,7 +87,7 @@ class ProjectScoreCreateParamsTest { assertThat(body.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt index 022d016b..1049822d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt @@ -19,7 +19,7 @@ class ProjectScoreReplaceParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -52,7 +52,7 @@ class ProjectScoreReplaceParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -87,7 +87,7 @@ class ProjectScoreReplaceParamsTest { assertThat(body.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt index 888ef861..0e2e0b4b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt @@ -22,7 +22,7 @@ class ProjectScoreTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -58,7 +58,7 @@ class ProjectScoreTest { assertThat(projectScore.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt index 7f153a84..2407e87f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt @@ -17,7 +17,7 @@ class ProjectScoreUpdateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -50,7 +50,7 @@ class ProjectScoreUpdateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -84,7 +84,7 @@ class ProjectScoreUpdateParamsTest { assertThat(body.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt index 0624066d..f5216655 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt @@ -9,8 +9,31 @@ class ProjectSettingsTest { @Test fun createProjectSettings() { - val projectSettings = ProjectSettings.builder().comparisonKey("comparison_key").build() + val projectSettings = + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() assertThat(projectSettings).isNotNull + assertThat(projectSettings.baselineExperimentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(projectSettings.comparisonKey()).contains("comparison_key") + assertThat(projectSettings.spanFieldOrder().get()) + .containsExactly( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 390af485..0a924ec6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -17,7 +17,20 @@ class ProjectTest { .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(project).isNotNull @@ -27,7 +40,20 @@ class ProjectTest { assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(project.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .contains( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 63716ab9..55bd050e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -13,7 +13,20 @@ class ProjectUpdateParamsTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() } @@ -23,7 +36,20 @@ class ProjectUpdateParamsTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() val body = params._body() @@ -31,7 +57,20 @@ class ProjectUpdateParamsTest { assertNotNull(body) assertThat(body.name()).contains("name") assertThat(body.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .contains( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 92e03d0c..80c96334 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -30,9 +30,13 @@ class PromptCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -118,9 +122,14 @@ class PromptCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -205,9 +214,13 @@ class PromptCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index f2acf4d6..66346100 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -22,9 +22,13 @@ class PromptDataTest { PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() @@ -92,9 +96,13 @@ class PromptDataTest { PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index 119a47b3..beaa5bd4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -18,9 +18,11 @@ class PromptOptionsTest { .functionCall( PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort(PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() @@ -52,9 +54,11 @@ class PromptOptionsTest { .functionCall( PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort(PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 18d87eb2..b25b4263 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -30,9 +30,13 @@ class PromptReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -118,9 +122,14 @@ class PromptReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -205,9 +214,13 @@ class PromptReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index c65cd2c6..fed67a6f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -41,9 +41,14 @@ class PromptTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -136,9 +141,13 @@ class PromptTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 7dae6fe3..00490393 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -28,9 +28,13 @@ class PromptUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -115,9 +119,14 @@ class PromptUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -200,9 +209,13 @@ class PromptUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index 57fce4c2..b6f5b3b9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -12,6 +12,7 @@ class SpanIframeUpdateParamsTest { fun create() { SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") @@ -23,6 +24,7 @@ class SpanIframeUpdateParamsTest { val params = SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") @@ -31,6 +33,7 @@ class SpanIframeUpdateParamsTest { val body = params._body() assertNotNull(body) + assertThat(body.description()).contains("description") assertThat(body.name()).contains("name") assertThat(body.postMessage()).contains(true) assertThat(body.url()).contains("url") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt index 1f09c824..3b7432e8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt @@ -31,6 +31,9 @@ class ViewCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -71,6 +74,9 @@ class ViewCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -110,6 +116,9 @@ class ViewCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index 3d6989ba..a4691564 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -23,6 +23,9 @@ class ViewOptionsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() assertThat(viewOptions).isNotNull assertThat(viewOptions.columnOrder().get()).containsExactly("string") @@ -38,5 +41,8 @@ class ViewOptionsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + assertThat(viewOptions.grouping()).contains("grouping") + assertThat(viewOptions.layout()).contains("layout") + assertThat(viewOptions.rowHeight()).contains("rowHeight") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt index 069dcccd..81ed6e41 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt @@ -31,6 +31,9 @@ class ViewReplaceParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -71,6 +74,9 @@ class ViewReplaceParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -110,6 +116,9 @@ class ViewReplaceParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt index fd19dbb6..afd86c23 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt @@ -33,6 +33,9 @@ class ViewTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -71,6 +74,9 @@ class ViewTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt index 67d83174..f5072c25 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt @@ -29,6 +29,9 @@ class ViewUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -69,6 +72,9 @@ class ViewUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -107,6 +113,9 @@ class ViewUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt index 5df9416c..510dfe93 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync -import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -99,51 +98,6 @@ class AclServiceAsyncTest { acl.validate() } - @Test - fun batchUpdate() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclBatchUpdateResponseFuture = - aclServiceAsync.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() - aclBatchUpdateResponse.validate() - } - @Test fun findAndDelete() { val client = diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt index 4e6b2e1f..a0c5552c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams import com.braintrustdata.api.models.FeedbackDatasetItem import com.braintrustdata.api.models.InsertDatasetEvent +import com.braintrustdata.api.models.ObjectReference import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -237,9 +238,14 @@ class DatasetServiceAsyncTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt index 406d7f7b..a8d438bf 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt @@ -25,7 +25,17 @@ class EvalServiceAsyncTest { val summarizeExperimentResponseFuture = evalServiceAsync.create( EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -55,6 +65,26 @@ class EvalServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt index e4ab67f2..ca4c7bc5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackExperimentItem import com.braintrustdata.api.models.InsertExperimentEvent +import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.RepoInfo import com.braintrustdata.api.models.SpanAttributes import java.time.OffsetDateTime @@ -285,14 +286,11 @@ class ExperimentServiceAsyncTest { .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( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertExperimentEvent.Metadata.builder().model("model").build() ) .metrics( InsertExperimentEvent.Metrics.builder() @@ -306,6 +304,15 @@ class ExperimentServiceAsyncTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt index 58578b30..f1a05501 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt @@ -69,9 +69,15 @@ class FunctionServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -193,9 +199,15 @@ class FunctionServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -312,6 +324,7 @@ class FunctionServiceAsyncTest { functionServiceAsync.invoke( FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -320,6 +333,11 @@ class FunctionServiceAsyncTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -401,9 +419,15 @@ class FunctionServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt index efa55642..1aed2310 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt @@ -38,7 +38,7 @@ class ProjectScoreServiceAsyncTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -101,7 +101,7 @@ class ProjectScoreServiceAsyncTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -183,7 +183,7 @@ class ProjectScoreServiceAsyncTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt index 85f07a6a..1d4af2db 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt @@ -67,7 +67,20 @@ class ProjectServiceAsyncTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt index 2535012d..e44cb335 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt @@ -48,9 +48,15 @@ class PromptServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -167,9 +173,15 @@ class PromptServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -304,9 +316,15 @@ class PromptServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt index 8d448a50..e10665eb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt @@ -72,6 +72,7 @@ class SpanIframeServiceAsyncTest { spanIframeServiceAsync.update( SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt index 8a7b3bfb..2a7f254c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt @@ -51,6 +51,9 @@ class ViewServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -124,6 +127,9 @@ class ViewServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -220,6 +226,9 @@ class ViewServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt index fec1f6b8..566ece51 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FeedbackProjectLogsItem import com.braintrustdata.api.models.InsertProjectLogsEvent +import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -139,9 +140,7 @@ class LogServiceAsyncTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertProjectLogsEvent.Metadata.builder().model("model").build() ) .metrics( InsertProjectLogsEvent.Metrics.builder() @@ -155,6 +154,15 @@ class LogServiceAsyncTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt index 499ca976..ba3e2c4d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -95,50 +94,6 @@ class AclServiceTest { acl.validate() } - @Test - fun batchUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val aclBatchUpdateResponse = - aclService.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - aclBatchUpdateResponse.validate() - } - @Test fun findAndDelete() { val client = 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 a9bae5c4..d1b98d7b 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 @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams import com.braintrustdata.api.models.FeedbackDatasetItem import com.braintrustdata.api.models.InsertDatasetEvent +import com.braintrustdata.api.models.ObjectReference import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -229,9 +230,14 @@ class DatasetServiceTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index feaa3f95..e363273c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -25,7 +25,17 @@ class EvalServiceTest { val summarizeExperimentResponse = evalService.create( EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -55,6 +65,26 @@ class EvalServiceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") 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 b4e00567..93c696d6 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 @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackExperimentItem import com.braintrustdata.api.models.InsertExperimentEvent +import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.RepoInfo import com.braintrustdata.api.models.SpanAttributes import java.time.OffsetDateTime @@ -277,14 +278,11 @@ class ExperimentServiceTest { .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( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertExperimentEvent.Metadata.builder().model("model").build() ) .metrics( InsertExperimentEvent.Metrics.builder() @@ -298,6 +296,15 @@ class ExperimentServiceTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt index d5caebf7..805b0d1d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt @@ -69,9 +69,15 @@ class FunctionServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -191,9 +197,15 @@ class FunctionServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -307,6 +319,7 @@ class FunctionServiceTest { functionService.invoke( FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -315,6 +328,11 @@ class FunctionServiceTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -395,9 +413,15 @@ class FunctionServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt index 0f7d4d1c..96b3a100 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt @@ -38,7 +38,7 @@ class ProjectScoreServiceTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -99,7 +99,7 @@ class ProjectScoreServiceTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -178,7 +178,7 @@ class ProjectScoreServiceTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 9b95d382..51fa7715 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -65,7 +65,20 @@ class ProjectServiceTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 68eff58c..4d3cd8e9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -48,9 +48,15 @@ class PromptServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -165,9 +171,15 @@ class PromptServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -299,9 +311,15 @@ class PromptServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index 0f18d989..a7d4d465 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -70,6 +70,7 @@ class SpanIframeServiceTest { spanIframeService.update( SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") 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 888e7466..a47e80d3 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 @@ -51,6 +51,9 @@ class ViewServiceTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -122,6 +125,9 @@ class ViewServiceTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -215,6 +221,9 @@ class ViewServiceTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 fca0f5f6..ac3a13bc 100644 --- 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 @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FeedbackProjectLogsItem import com.braintrustdata.api.models.InsertProjectLogsEvent +import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -136,9 +137,7 @@ class LogServiceTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertProjectLogsEvent.Metadata.builder().model("model").build() ) .metrics( InsertProjectLogsEvent.Metrics.builder() @@ -152,6 +151,15 @@ class LogServiceTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores(