diff --git a/.stats.yml b/.stats.yml index 791902e5..0c4379f0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 100 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-68036b7754e99e2e6861a98527cd216b1a2e1254b959668acd96019d5f5932b6.yml -openapi_spec_hash: cdd2746840d2e6a57efbd40c4284b915 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-6967de3ecfa76f0521865fc59ebad7a1fa31c9cc174fd2b88af484da64a4c59b.yml +openapi_spec_hash: 3783aa323fc29bf35e0e271056709c5b config_hash: 6783036145db2324b18a88cfed58abad diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt index 324b2b89..7e0d5fe0 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt @@ -67,7 +67,11 @@ private constructor( */ fun enableReservations(): Optional = body.enableReservations() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -148,6 +152,13 @@ private constructor( */ fun _enableReservations(): JsonField = body._enableReservations() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + /** * Returns the raw JSON value of [numReviewersPerItem]. * @@ -339,7 +350,19 @@ private constructor( body.enableReservations(enableReservations) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } fun numReviewersPerItem(numReviewersPerItem: Long?) = apply { body.numReviewersPerItem(numReviewersPerItem) @@ -633,7 +656,7 @@ private constructor( private val defaultDataset: JsonField, private val description: JsonField, private val enableReservations: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val numReviewersPerItem: JsonField, private val reservationMinutes: JsonField, private val rubricInstructions: JsonField, @@ -659,7 +682,9 @@ private constructor( @JsonProperty("enable_reservations") @ExcludeMissing enableReservations: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("num_reviewers_per_item") @ExcludeMissing numReviewersPerItem: JsonField = JsonMissing.of(), @@ -732,7 +757,11 @@ private constructor( fun enableReservations(): Optional = enableReservations.getOptional("enable_reservations") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -826,6 +855,13 @@ private constructor( @ExcludeMissing fun _enableReservations(): JsonField = enableReservations + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [numReviewersPerItem]. * @@ -917,7 +953,7 @@ private constructor( private var defaultDataset: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var enableReservations: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var numReviewersPerItem: JsonField = JsonMissing.of() private var reservationMinutes: JsonField = JsonMissing.of() private var rubricInstructions: JsonField = JsonMissing.of() @@ -1042,7 +1078,19 @@ private constructor( this.enableReservations = enableReservations } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun numReviewersPerItem(numReviewersPerItem: Long?) = numReviewersPerItem(JsonField.ofNullable(numReviewersPerItem)) @@ -1257,6 +1305,7 @@ private constructor( defaultDataset() description() enableReservations() + metadata().ifPresent { it.validate() } numReviewersPerItem() reservationMinutes() rubricInstructions() @@ -1288,6 +1337,7 @@ private constructor( (if (defaultDataset.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (enableReservations.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (numReviewersPerItem.asKnown().isPresent) 1 else 0) + (if (reservationMinutes.asKnown().isPresent) 1 else 0) + (if (rubricInstructions.asKnown().isPresent) 1 else 0) + @@ -1342,6 +1392,105 @@ private constructor( "Body{name=$name, id=$id, createdAt=$createdAt, defaultDataset=$defaultDataset, description=$description, enableReservations=$enableReservations, metadata=$metadata, numReviewersPerItem=$numReviewersPerItem, reservationMinutes=$reservationMinutes, rubricInstructions=$rubricInstructions, rubricItems=$rubricItems, sessionIds=$sessionIds, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt index 5e35f2e1..7497be2e 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt @@ -12,6 +12,7 @@ import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -32,7 +33,7 @@ private constructor( private val defaultDataset: JsonField, private val description: JsonField, private val enableReservations: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val numReviewersPerItem: JsonField, private val reservationMinutes: JsonField, private val runRuleId: JsonField, @@ -62,7 +63,7 @@ private constructor( @JsonProperty("enable_reservations") @ExcludeMissing enableReservations: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("num_reviewers_per_item") @ExcludeMissing numReviewersPerItem: JsonField = JsonMissing.of(), @@ -152,7 +153,11 @@ private constructor( fun enableReservations(): Optional = enableReservations.getOptional("enable_reservations") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -255,6 +260,13 @@ private constructor( @ExcludeMissing fun _enableReservations(): JsonField = enableReservations + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [numReviewersPerItem]. * @@ -342,7 +354,7 @@ private constructor( private var defaultDataset: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var enableReservations: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var numReviewersPerItem: JsonField = JsonMissing.of() private var reservationMinutes: JsonField = JsonMissing.of() private var runRuleId: JsonField = JsonMissing.of() @@ -497,7 +509,19 @@ private constructor( this.enableReservations = enableReservations } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun numReviewersPerItem(numReviewersPerItem: Long?) = numReviewersPerItem(JsonField.ofNullable(numReviewersPerItem)) @@ -668,6 +692,7 @@ private constructor( defaultDataset() description() enableReservations() + metadata().ifPresent { it.validate() } numReviewersPerItem() reservationMinutes() runRuleId() @@ -700,6 +725,7 @@ private constructor( (if (defaultDataset.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (enableReservations.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (numReviewersPerItem.asKnown().isPresent) 1 else 0) + (if (reservationMinutes.asKnown().isPresent) 1 else 0) + (if (runRuleId.asKnown().isPresent) 1 else 0) + @@ -835,6 +861,105 @@ private constructor( override fun toString() = value.toString() } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponse.kt index c849c71c..d6df24c5 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponse.kt @@ -33,7 +33,7 @@ private constructor( private val defaultDataset: JsonField, private val description: JsonField, private val enableReservations: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val numReviewersPerItem: JsonField, private val reservationMinutes: JsonField, private val rubricInstructions: JsonField, @@ -64,7 +64,7 @@ private constructor( @JsonProperty("enable_reservations") @ExcludeMissing enableReservations: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("num_reviewers_per_item") @ExcludeMissing numReviewersPerItem: JsonField = JsonMissing.of(), @@ -155,7 +155,11 @@ private constructor( fun enableReservations(): Optional = enableReservations.getOptional("enable_reservations") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -265,6 +269,13 @@ private constructor( @ExcludeMissing fun _enableReservations(): JsonField = enableReservations + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [numReviewersPerItem]. * @@ -369,7 +380,7 @@ private constructor( private var defaultDataset: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var enableReservations: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var numReviewersPerItem: JsonField = JsonMissing.of() private var reservationMinutes: JsonField = JsonMissing.of() private var rubricInstructions: JsonField = JsonMissing.of() @@ -514,7 +525,19 @@ private constructor( this.enableReservations = enableReservations } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun numReviewersPerItem(numReviewersPerItem: Long?) = numReviewersPerItem(JsonField.ofNullable(numReviewersPerItem)) @@ -734,6 +757,7 @@ private constructor( defaultDataset() description() enableReservations() + metadata().ifPresent { it.validate() } numReviewersPerItem() reservationMinutes() rubricInstructions() @@ -767,6 +791,7 @@ private constructor( (if (defaultDataset.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (enableReservations.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (numReviewersPerItem.asKnown().isPresent) 1 else 0) + (if (reservationMinutes.asKnown().isPresent) 1 else 0) + (if (rubricInstructions.asKnown().isPresent) 1 else 0) + @@ -904,6 +929,105 @@ private constructor( override fun toString() = value.toString() } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchema.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchema.kt index 290a9dfc..0c2a2498 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchema.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchema.kt @@ -12,6 +12,7 @@ import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -31,7 +32,7 @@ private constructor( private val defaultDataset: JsonField, private val description: JsonField, private val enableReservations: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val numReviewersPerItem: JsonField, private val reservationMinutes: JsonField, private val runRuleId: JsonField, @@ -60,7 +61,7 @@ private constructor( @JsonProperty("enable_reservations") @ExcludeMissing enableReservations: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("num_reviewers_per_item") @ExcludeMissing numReviewersPerItem: JsonField = JsonMissing.of(), @@ -143,7 +144,11 @@ private constructor( fun enableReservations(): Optional = enableReservations.getOptional("enable_reservations") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -239,6 +244,13 @@ private constructor( @ExcludeMissing fun _enableReservations(): JsonField = enableReservations + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [numReviewersPerItem]. * @@ -323,7 +335,7 @@ private constructor( private var defaultDataset: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var enableReservations: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var numReviewersPerItem: JsonField = JsonMissing.of() private var reservationMinutes: JsonField = JsonMissing.of() private var runRuleId: JsonField = JsonMissing.of() @@ -462,7 +474,19 @@ private constructor( this.enableReservations = enableReservations } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun numReviewersPerItem(numReviewersPerItem: Long?) = numReviewersPerItem(JsonField.ofNullable(numReviewersPerItem)) @@ -630,6 +654,7 @@ private constructor( defaultDataset() description() enableReservations() + metadata().ifPresent { it.validate() } numReviewersPerItem() reservationMinutes() runRuleId() @@ -661,6 +686,7 @@ private constructor( (if (defaultDataset.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (enableReservations.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (numReviewersPerItem.asKnown().isPresent) 1 else 0) + (if (reservationMinutes.asKnown().isPresent) 1 else 0) + (if (runRuleId.asKnown().isPresent) 1 else 0) + @@ -796,6 +822,105 @@ private constructor( override fun toString() = value.toString() } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParams.kt index 30838319..51937964 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParams.kt @@ -280,8 +280,8 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } - /** Alias for calling [metadata] with `Metadata.ofJsonValue(jsonValue)`. */ - fun metadata(jsonValue: JsonValue) = apply { body.metadata(jsonValue) } + /** Alias for calling [metadata] with `Metadata.ofUnionMember0(unionMember0)`. */ + fun metadata(unionMember0: Metadata.UnionMember0) = apply { body.metadata(unionMember0) } /** Alias for calling [metadata] with `Metadata.ofMissing(missing)`. */ fun metadata(missing: Missing) = apply { body.metadata(missing) } @@ -856,8 +856,9 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** Alias for calling [metadata] with `Metadata.ofJsonValue(jsonValue)`. */ - fun metadata(jsonValue: JsonValue) = metadata(Metadata.ofJsonValue(jsonValue)) + /** Alias for calling [metadata] with `Metadata.ofUnionMember0(unionMember0)`. */ + fun metadata(unionMember0: Metadata.UnionMember0) = + metadata(Metadata.ofUnionMember0(unionMember0)) /** Alias for calling [metadata] with `Metadata.ofMissing(missing)`. */ fun metadata(missing: Missing) = metadata(Metadata.ofMissing(missing)) @@ -1118,20 +1119,20 @@ private constructor( @JsonSerialize(using = Metadata.Serializer::class) class Metadata private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val missing: Missing? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun missing(): Optional = Optional.ofNullable(missing) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isMissing(): Boolean = missing != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asMissing(): Missing = missing.getOrThrow("missing") @@ -1139,7 +1140,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) missing != null -> visitor.visitMissing(missing) else -> visitor.unknown(_json) } @@ -1153,7 +1154,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitMissing(missing: Missing) { missing.validate() @@ -1181,7 +1184,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitMissing(missing: Missing) = missing.validity() @@ -1194,14 +1198,16 @@ private constructor( return true } - return other is Metadata && jsonValue == other.jsonValue && missing == other.missing + return other is Metadata && + unionMember0 == other.unionMember0 && + missing == other.missing } - override fun hashCode(): Int = Objects.hash(jsonValue, missing) + override fun hashCode(): Int = Objects.hash(unionMember0, missing) override fun toString(): String = when { - jsonValue != null -> "Metadata{jsonValue=$jsonValue}" + unionMember0 != null -> "Metadata{unionMember0=$unionMember0}" missing != null -> "Metadata{missing=$missing}" _json != null -> "Metadata{_unknown=$_json}" else -> throw IllegalStateException("Invalid Metadata") @@ -1209,7 +1215,8 @@ private constructor( companion object { - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Metadata(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Metadata(unionMember0 = unionMember0) @JvmStatic fun ofMissing(missing: Missing) = Metadata(missing = missing) } @@ -1219,7 +1226,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitMissing(missing: Missing): T @@ -1245,19 +1252,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Metadata(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Metadata(missing = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Metadata(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> Metadata(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1276,13 +1283,115 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) value.missing != null -> generator.writeObject(value.missing) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Metadata") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } } @JsonDeserialize(using = NumReviewersPerItem.Deserializer::class) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt index 9f191a47..5f6eb3b2 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt @@ -44,22 +44,22 @@ private constructor( private val effectiveAddedAt: JsonField, private val endTime: JsonField, private val error: JsonField, - private val events: JsonField>, + private val events: JsonField>, private val executionOrder: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val feedbackStats: JsonField, private val firstTokenTime: JsonField, private val inDataset: JsonField, - private val inputs: JsonValue, + private val inputs: JsonField, private val inputsPreview: JsonField, - private val inputsS3Urls: JsonValue, + private val inputsS3Urls: JsonField, private val lastQueuedAt: JsonField, private val lastReviewedTime: JsonField, private val manifestId: JsonField, private val manifestS3Id: JsonField, - private val outputs: JsonValue, + private val outputs: JsonField, private val outputsPreview: JsonField, - private val outputsS3Urls: JsonValue, + private val outputsS3Urls: JsonField, private val parentRunId: JsonField, private val parentRunIds: JsonField>, private val priceModelId: JsonField, @@ -69,8 +69,8 @@ private constructor( private val promptTokens: JsonField, private val referenceDatasetId: JsonField, private val referenceExampleId: JsonField, - private val s3Urls: JsonValue, - private val serialized: JsonValue, + private val s3Urls: JsonField, + private val serialized: JsonField, private val shareToken: JsonField, private val startTime: JsonField, private val tags: JsonField>, @@ -129,13 +129,11 @@ private constructor( @ExcludeMissing endTime: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("events") - @ExcludeMissing - events: JsonField> = JsonMissing.of(), + @JsonProperty("events") @ExcludeMissing events: JsonField> = JsonMissing.of(), @JsonProperty("execution_order") @ExcludeMissing executionOrder: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonField = JsonMissing.of(), @@ -145,11 +143,13 @@ private constructor( @JsonProperty("in_dataset") @ExcludeMissing inDataset: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), @JsonProperty("inputs_preview") @ExcludeMissing inputsPreview: JsonField = JsonMissing.of(), - @JsonProperty("inputs_s3_urls") @ExcludeMissing inputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + inputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("last_queued_at") @ExcludeMissing lastQueuedAt: JsonField = JsonMissing.of(), @@ -162,13 +162,13 @@ private constructor( @JsonProperty("manifest_s3_id") @ExcludeMissing manifestS3Id: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("outputs_preview") @ExcludeMissing outputsPreview: JsonField = JsonMissing.of(), @JsonProperty("outputs_s3_urls") @ExcludeMissing - outputsS3Urls: JsonValue = JsonMissing.of(), + outputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("parent_run_id") @ExcludeMissing parentRunId: JsonField = JsonMissing.of(), @@ -196,8 +196,10 @@ private constructor( @JsonProperty("reference_example_id") @ExcludeMissing referenceExampleId: JsonField = JsonMissing.of(), - @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), - @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonField = JsonMissing.of(), + @JsonProperty("serialized") + @ExcludeMissing + serialized: JsonField = JsonMissing.of(), @JsonProperty("share_token") @ExcludeMissing shareToken: JsonField = JsonMissing.of(), @@ -412,7 +414,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun events(): Optional> = events.getOptional("events") + fun events(): Optional> = events.getOptional("events") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -420,7 +422,11 @@ private constructor( */ fun executionOrder(): Optional = executionOrder.getOptional("execution_order") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -440,7 +446,11 @@ private constructor( */ fun inDataset(): Optional = inDataset.getOptional("in_dataset") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -448,7 +458,11 @@ private constructor( */ fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") - @JsonProperty("inputs_s3_urls") @ExcludeMissing fun _inputsS3Urls(): JsonValue = inputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputsS3Urls(): Optional = inputsS3Urls.getOptional("inputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -475,7 +489,11 @@ private constructor( */ fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -483,7 +501,11 @@ private constructor( */ fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") - @JsonProperty("outputs_s3_urls") @ExcludeMissing fun _outputsS3Urls(): JsonValue = outputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputsS3Urls(): Optional = outputsS3Urls.getOptional("outputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -543,9 +565,17 @@ private constructor( fun referenceExampleId(): Optional = referenceExampleId.getOptional("reference_example_id") - @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun s3Urls(): Optional = s3Urls.getOptional("s3_urls") - @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serialized(): Optional = serialized.getOptional("serialized") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -781,7 +811,7 @@ private constructor( * * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Returns the raw JSON value of [executionOrder]. @@ -792,6 +822,13 @@ private constructor( @ExcludeMissing fun _executionOrder(): JsonField = executionOrder + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [feedbackStats]. * @@ -817,6 +854,13 @@ private constructor( */ @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField = inDataset + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + /** * Returns the raw JSON value of [inputsPreview]. * @@ -826,6 +870,15 @@ private constructor( @ExcludeMissing fun _inputsPreview(): JsonField = inputsPreview + /** + * Returns the raw JSON value of [inputsS3Urls]. + * + * Unlike [inputsS3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + fun _inputsS3Urls(): JsonField = inputsS3Urls + /** * Returns the raw JSON value of [lastQueuedAt]. * @@ -861,6 +914,13 @@ private constructor( @ExcludeMissing fun _manifestS3Id(): JsonField = manifestS3Id + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [outputsPreview]. * @@ -870,6 +930,15 @@ private constructor( @ExcludeMissing fun _outputsPreview(): JsonField = outputsPreview + /** + * Returns the raw JSON value of [outputsS3Urls]. + * + * Unlike [outputsS3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + fun _outputsS3Urls(): JsonField = outputsS3Urls + /** * Returns the raw JSON value of [parentRunId]. * @@ -953,6 +1022,22 @@ private constructor( @ExcludeMissing fun _referenceExampleId(): JsonField = referenceExampleId + /** + * Returns the raw JSON value of [s3Urls]. + * + * Unlike [s3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonField = s3Urls + + /** + * Returns the raw JSON value of [serialized]. + * + * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("serialized") + @ExcludeMissing + fun _serialized(): JsonField = serialized + /** * Returns the raw JSON value of [shareToken]. * @@ -1106,22 +1191,22 @@ private constructor( private var effectiveAddedAt: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() private var error: JsonField = JsonMissing.of() - private var events: JsonField>? = null + private var events: JsonField>? = null private var executionOrder: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var feedbackStats: JsonField = JsonMissing.of() private var firstTokenTime: JsonField = JsonMissing.of() private var inDataset: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() private var inputsPreview: JsonField = JsonMissing.of() - private var inputsS3Urls: JsonValue = JsonMissing.of() + private var inputsS3Urls: JsonField = JsonMissing.of() private var lastQueuedAt: JsonField = JsonMissing.of() private var lastReviewedTime: JsonField = JsonMissing.of() private var manifestId: JsonField = JsonMissing.of() private var manifestS3Id: JsonField = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var outputsPreview: JsonField = JsonMissing.of() - private var outputsS3Urls: JsonValue = JsonMissing.of() + private var outputsS3Urls: JsonField = JsonMissing.of() private var parentRunId: JsonField = JsonMissing.of() private var parentRunIds: JsonField>? = null private var priceModelId: JsonField = JsonMissing.of() @@ -1131,8 +1216,8 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() private var referenceExampleId: JsonField = JsonMissing.of() - private var s3Urls: JsonValue = JsonMissing.of() - private var serialized: JsonValue = JsonMissing.of() + private var s3Urls: JsonField = JsonMissing.of() + private var serialized: JsonField = JsonMissing.of() private var shareToken: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var tags: JsonField>? = null @@ -1501,28 +1586,28 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } - fun events(events: List?) = events(JsonField.ofNullable(events)) + fun events(events: List?) = events(JsonField.ofNullable(events)) /** Alias for calling [Builder.events] with `events.orElse(null)`. */ - fun events(events: Optional>) = events(events.getOrNull()) + fun events(events: Optional>) = events(events.getOrNull()) /** * Sets [Builder.events] to an arbitrary JSON value. * - * You should usually call [Builder.events] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.events] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun events(events: JsonField>) = apply { + fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [events]. + * Adds a single [Event] to [events]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addEvent(event: JsonValue) = apply { + fun addEvent(event: Event) = apply { events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) @@ -1542,7 +1627,18 @@ private constructor( this.executionOrder = executionOrder } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun feedbackStats(feedbackStats: FeedbackStats?) = feedbackStats(JsonField.ofNullable(feedbackStats)) @@ -1601,7 +1697,18 @@ private constructor( */ fun inDataset(inDataset: JsonField) = apply { this.inDataset = inDataset } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) + + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } fun inputsPreview(inputsPreview: String?) = inputsPreview(JsonField.ofNullable(inputsPreview)) @@ -1621,7 +1728,23 @@ private constructor( this.inputsPreview = inputsPreview } - fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + fun inputsS3Urls(inputsS3Urls: InputsS3Urls?) = + inputsS3Urls(JsonField.ofNullable(inputsS3Urls)) + + /** Alias for calling [Builder.inputsS3Urls] with `inputsS3Urls.orElse(null)`. */ + fun inputsS3Urls(inputsS3Urls: Optional) = + inputsS3Urls(inputsS3Urls.getOrNull()) + + /** + * Sets [Builder.inputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsS3Urls] with a well-typed [InputsS3Urls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputsS3Urls(inputsS3Urls: JsonField) = apply { + this.inputsS3Urls = inputsS3Urls + } fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) @@ -1689,7 +1812,18 @@ private constructor( this.manifestS3Id = manifestS3Id } - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun outputsPreview(outputsPreview: String?) = outputsPreview(JsonField.ofNullable(outputsPreview)) @@ -1709,7 +1843,23 @@ private constructor( this.outputsPreview = outputsPreview } - fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { this.outputsS3Urls = outputsS3Urls } + fun outputsS3Urls(outputsS3Urls: OutputsS3Urls?) = + outputsS3Urls(JsonField.ofNullable(outputsS3Urls)) + + /** Alias for calling [Builder.outputsS3Urls] with `outputsS3Urls.orElse(null)`. */ + fun outputsS3Urls(outputsS3Urls: Optional) = + outputsS3Urls(outputsS3Urls.getOrNull()) + + /** + * Sets [Builder.outputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsS3Urls] with a well-typed [OutputsS3Urls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsS3Urls(outputsS3Urls: JsonField) = apply { + this.outputsS3Urls = outputsS3Urls + } fun parentRunId(parentRunId: String?) = parentRunId(JsonField.ofNullable(parentRunId)) @@ -1874,9 +2024,32 @@ private constructor( this.referenceExampleId = referenceExampleId } - fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + fun s3Urls(s3Urls: S3Urls?) = s3Urls(JsonField.ofNullable(s3Urls)) - fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + /** Alias for calling [Builder.s3Urls] with `s3Urls.orElse(null)`. */ + fun s3Urls(s3Urls: Optional) = s3Urls(s3Urls.getOrNull()) + + /** + * Sets [Builder.s3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.s3Urls] with a well-typed [S3Urls] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun s3Urls(s3Urls: JsonField) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: Serialized?) = serialized(JsonField.ofNullable(serialized)) + + /** Alias for calling [Builder.serialized] with `serialized.orElse(null)`. */ + fun serialized(serialized: Optional) = serialized(serialized.getOrNull()) + + /** + * Sets [Builder.serialized] to an arbitrary JSON value. + * + * You should usually call [Builder.serialized] with a well-typed [Serialized] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serialized(serialized: JsonField) = apply { this.serialized = serialized } fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) @@ -2199,17 +2372,22 @@ private constructor( effectiveAddedAt() endTime() error() - events() + events().ifPresent { it.forEach { it.validate() } } executionOrder() + extra().ifPresent { it.validate() } feedbackStats().ifPresent { it.validate() } firstTokenTime() inDataset() + inputs().ifPresent { it.validate() } inputsPreview() + inputsS3Urls().ifPresent { it.validate() } lastQueuedAt() lastReviewedTime() manifestId() manifestS3Id() + outputs().ifPresent { it.validate() } outputsPreview() + outputsS3Urls().ifPresent { it.validate() } parentRunId() parentRunIds() priceModelId() @@ -2219,6 +2397,8 @@ private constructor( promptTokens() referenceDatasetId() referenceExampleId() + s3Urls().ifPresent { it.validate() } + serialized().ifPresent { it.validate() } shareToken() startTime() tags() @@ -2268,17 +2448,22 @@ private constructor( (if (effectiveAddedAt.asKnown().isPresent) 1 else 0) + (if (endTime.asKnown().isPresent) 1 else 0) + (if (error.asKnown().isPresent) 1 else 0) + - (events.asKnown().getOrNull()?.size ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + (if (inDataset.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (inputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + (if (manifestId.asKnown().isPresent) 1 else 0) + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (outputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (parentRunId.asKnown().isPresent) 1 else 0) + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + (if (priceModelId.asKnown().isPresent) 1 else 0) + @@ -2288,6 +2473,8 @@ private constructor( (if (promptTokens.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (s3Urls.asKnown().getOrNull()?.validity() ?: 0) + + (serialized.asKnown().getOrNull()?.validity() ?: 0) + (if (shareToken.asKnown().isPresent) 1 else 0) + (if (startTime.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + @@ -2667,6 +2854,204 @@ private constructor( "CompletionTokenDetails{additionalProperties=$additionalProperties}" } + class Event + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Event]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Event]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(event: Event) = apply { + additionalProperties = event.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) + } + + /** + * Returns an immutable instance of [Event]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Event = Event(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Event = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Event && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Event{additionalProperties=$additionalProperties}" + } + + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + class FeedbackStats @JsonCreator private constructor( @@ -2766,6 +3151,402 @@ private constructor( override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" } + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class InputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsS3Urls: InputsS3Urls) = apply { + additionalProperties = inputsS3Urls.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) + } + + /** + * Returns an immutable instance of [InputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsS3Urls = InputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "InputsS3Urls{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + + class OutputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OutputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsS3Urls: OutputsS3Urls) = apply { + additionalProperties = outputsS3Urls.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) + } + + /** + * Returns an immutable instance of [OutputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsS3Urls = OutputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OutputsS3Urls{additionalProperties=$additionalProperties}" + } + class PromptCostDetails @JsonCreator private constructor( @@ -2964,6 +3745,204 @@ private constructor( override fun toString() = "PromptTokenDetails{additionalProperties=$additionalProperties}" } + class S3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [S3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3Urls: S3Urls) = apply { + additionalProperties = s3Urls.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) + } + + /** + * Returns an immutable instance of [S3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): S3Urls = S3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): S3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "S3Urls{additionalProperties=$additionalProperties}" + } + + class Serialized + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Serialized]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Serialized]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serialized: Serialized) = apply { + additionalProperties = serialized.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) + } + + /** + * Returns an immutable instance of [Serialized]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Serialized = Serialized(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Serialized = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Serialized && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Serialized{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitManifestResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitManifestResponse.kt index 8a7d4669..9a6fe76f 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitManifestResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitManifestResponse.kt @@ -25,7 +25,7 @@ class CommitManifestResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val commitHash: JsonField, - private val manifest: JsonValue, + private val manifest: JsonField, private val examples: JsonField>, private val additionalProperties: MutableMap, ) { @@ -35,7 +35,7 @@ private constructor( @JsonProperty("commit_hash") @ExcludeMissing commitHash: JsonField = JsonMissing.of(), - @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("manifest") @ExcludeMissing manifest: JsonField = JsonMissing.of(), @JsonProperty("examples") @ExcludeMissing examples: JsonField> = JsonMissing.of(), @@ -47,7 +47,11 @@ private constructor( */ fun commitHash(): String = commitHash.getRequired("commit_hash") - @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun manifest(): Manifest = manifest.getRequired("manifest") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -62,6 +66,13 @@ private constructor( */ @JsonProperty("commit_hash") @ExcludeMissing fun _commitHash(): JsonField = commitHash + /** + * Returns the raw JSON value of [manifest]. + * + * Unlike [manifest], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonField = manifest + /** * Returns the raw JSON value of [examples]. * @@ -99,7 +110,7 @@ private constructor( class Builder internal constructor() { private var commitHash: JsonField? = null - private var manifest: JsonValue? = null + private var manifest: JsonField? = null private var examples: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -122,7 +133,16 @@ private constructor( */ fun commitHash(commitHash: JsonField) = apply { this.commitHash = commitHash } - fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + fun manifest(manifest: Manifest) = manifest(JsonField.of(manifest)) + + /** + * Sets [Builder.manifest] to an arbitrary JSON value. + * + * You should usually call [Builder.manifest] with a well-typed [Manifest] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifest(manifest: JsonField) = apply { this.manifest = manifest } fun examples(examples: List?) = examples(JsonField.ofNullable(examples)) @@ -201,6 +221,7 @@ private constructor( } commitHash() + manifest().validate() examples().ifPresent { it.forEach { it.validate() } } validated = true } @@ -221,16 +242,116 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (commitHash.asKnown().isPresent) 1 else 0) + + (manifest.asKnown().getOrNull()?.validity() ?: 0) + (examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Manifest + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Manifest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Manifest]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(manifest: Manifest) = apply { + additionalProperties = manifest.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) + } + + /** + * Returns an immutable instance of [Manifest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Manifest = Manifest(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Manifest = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Manifest && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Manifest{additionalProperties=$additionalProperties}" + } + /** Response model for example runs */ class Example @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val sessionId: JsonField, - private val inputs: JsonValue, - private val outputs: JsonValue, + private val inputs: JsonField, + private val outputs: JsonField, private val startTime: JsonField, private val additionalProperties: MutableMap, ) { @@ -241,8 +362,8 @@ private constructor( @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("start_time") @ExcludeMissing startTime: JsonField = JsonMissing.of(), @@ -260,9 +381,17 @@ private constructor( */ fun sessionId(): String = sessionId.getRequired("session_id") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -284,6 +413,20 @@ private constructor( */ @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [startTime]. * @@ -324,8 +467,8 @@ private constructor( private var id: JsonField? = null private var sessionId: JsonField? = null - private var inputs: JsonValue = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -361,9 +504,33 @@ private constructor( */ fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } + + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) @@ -433,6 +600,8 @@ private constructor( id() sessionId() + inputs().ifPresent { it.validate() } + outputs().ifPresent { it.validate() } startTime() validated = true } @@ -455,8 +624,214 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (sessionId.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (startTime.asKnown().isPresent) 1 else 0) + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitUpdateParams.kt index 8eaa6b85..4f7bfcd2 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitUpdateParams.kt @@ -47,7 +47,11 @@ private constructor( fun repo(): Optional = Optional.ofNullable(repo) - fun _manifest(): JsonValue = body._manifest() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun manifest(): Manifest = body.manifest() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -67,6 +71,13 @@ private constructor( */ fun skipWebhooks(): Optional = body.skipWebhooks() + /** + * Returns the raw JSON value of [manifest]. + * + * Unlike [manifest], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _manifest(): JsonField = body._manifest() + /** * Returns the raw JSON value of [exampleRunIds]. * @@ -149,7 +160,16 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - fun manifest(manifest: JsonValue) = apply { body.manifest(manifest) } + fun manifest(manifest: Manifest) = apply { body.manifest(manifest) } + + /** + * Sets [Builder.manifest] to an arbitrary JSON value. + * + * You should usually call [Builder.manifest] with a well-typed [Manifest] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifest(manifest: JsonField) = apply { body.manifest(manifest) } fun exampleRunIds(exampleRunIds: List?) = apply { body.exampleRunIds(exampleRunIds) @@ -370,7 +390,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val manifest: JsonValue, + private val manifest: JsonField, private val exampleRunIds: JsonField>, private val parentCommit: JsonField, private val skipWebhooks: JsonField, @@ -379,7 +399,9 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("manifest") + @ExcludeMissing + manifest: JsonField = JsonMissing.of(), @JsonProperty("example_run_ids") @ExcludeMissing exampleRunIds: JsonField> = JsonMissing.of(), @@ -391,7 +413,11 @@ private constructor( skipWebhooks: JsonField = JsonMissing.of(), ) : this(manifest, exampleRunIds, parentCommit, skipWebhooks, mutableMapOf()) - @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun manifest(): Manifest = manifest.getRequired("manifest") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -411,6 +437,13 @@ private constructor( */ fun skipWebhooks(): Optional = skipWebhooks.getOptional("skip_webhooks") + /** + * Returns the raw JSON value of [manifest]. + * + * Unlike [manifest], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonField = manifest + /** * Returns the raw JSON value of [exampleRunIds]. * @@ -469,7 +502,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { - private var manifest: JsonValue? = null + private var manifest: JsonField? = null private var exampleRunIds: JsonField>? = null private var parentCommit: JsonField = JsonMissing.of() private var skipWebhooks: JsonField = JsonMissing.of() @@ -484,7 +517,16 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + fun manifest(manifest: Manifest) = manifest(JsonField.of(manifest)) + + /** + * Sets [Builder.manifest] to an arbitrary JSON value. + * + * You should usually call [Builder.manifest] with a well-typed [Manifest] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun manifest(manifest: JsonField) = apply { this.manifest = manifest } fun exampleRunIds(exampleRunIds: List?) = exampleRunIds(JsonField.ofNullable(exampleRunIds)) @@ -602,6 +644,7 @@ private constructor( return@apply } + manifest().validate() exampleRunIds() parentCommit() skipWebhooks().ifPresent { it.validate() } @@ -624,7 +667,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (exampleRunIds.asKnown().getOrNull()?.size ?: 0) + + (manifest.asKnown().getOrNull()?.validity() ?: 0) + + (exampleRunIds.asKnown().getOrNull()?.size ?: 0) + (if (parentCommit.asKnown().isPresent) 1 else 0) + (skipWebhooks.asKnown().getOrNull()?.validity() ?: 0) @@ -651,6 +695,105 @@ private constructor( "Body{manifest=$manifest, exampleRunIds=$exampleRunIds, parentCommit=$parentCommit, skipWebhooks=$skipWebhooks, additionalProperties=$additionalProperties}" } + class Manifest + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Manifest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Manifest]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(manifest: Manifest) = apply { + additionalProperties = manifest.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) + } + + /** + * Returns an immutable instance of [Manifest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Manifest = Manifest(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Manifest = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Manifest && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Manifest{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = SkipWebhooks.Deserializer::class) @JsonSerialize(using = SkipWebhooks.Serializer::class) class SkipWebhooks diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitWithLookups.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitWithLookups.kt index dbca57a9..fb549221 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitWithLookups.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitWithLookups.kt @@ -30,7 +30,7 @@ private constructor( private val commitHash: JsonField, private val createdAt: JsonField, private val exampleRunIds: JsonField>, - private val manifest: JsonValue, + private val manifest: JsonField, private val numDownloads: JsonField, private val numViews: JsonField, private val repoId: JsonField, @@ -53,7 +53,7 @@ private constructor( @JsonProperty("example_run_ids") @ExcludeMissing exampleRunIds: JsonField> = JsonMissing.of(), - @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("manifest") @ExcludeMissing manifest: JsonField = JsonMissing.of(), @JsonProperty("num_downloads") @ExcludeMissing numDownloads: JsonField = JsonMissing.of(), @@ -107,7 +107,11 @@ private constructor( */ fun exampleRunIds(): List = exampleRunIds.getRequired("example_run_ids") - @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun manifest(): Manifest = manifest.getRequired("manifest") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -183,6 +187,13 @@ private constructor( @ExcludeMissing fun _exampleRunIds(): JsonField> = exampleRunIds + /** + * Returns the raw JSON value of [manifest]. + * + * Unlike [manifest], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonField = manifest + /** * Returns the raw JSON value of [numDownloads]. * @@ -279,7 +290,7 @@ private constructor( private var commitHash: JsonField? = null private var createdAt: JsonField? = null private var exampleRunIds: JsonField>? = null - private var manifest: JsonValue? = null + private var manifest: JsonField? = null private var numDownloads: JsonField? = null private var numViews: JsonField? = null private var repoId: JsonField? = null @@ -363,7 +374,16 @@ private constructor( } } - fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + fun manifest(manifest: Manifest) = manifest(JsonField.of(manifest)) + + /** + * Sets [Builder.manifest] to an arbitrary JSON value. + * + * You should usually call [Builder.manifest] with a well-typed [Manifest] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifest(manifest: JsonField) = apply { this.manifest = manifest } fun numDownloads(numDownloads: Long) = numDownloads(JsonField.of(numDownloads)) @@ -519,6 +539,7 @@ private constructor( commitHash() createdAt() exampleRunIds() + manifest().validate() numDownloads() numViews() repoId() @@ -548,6 +569,7 @@ private constructor( (if (commitHash.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (exampleRunIds.asKnown().getOrNull()?.size ?: 0) + + (manifest.asKnown().getOrNull()?.validity() ?: 0) + (if (numDownloads.asKnown().isPresent) 1 else 0) + (if (numViews.asKnown().isPresent) 1 else 0) + (if (repoId.asKnown().isPresent) 1 else 0) + @@ -556,6 +578,105 @@ private constructor( (if (parentCommitHash.asKnown().isPresent) 1 else 0) + (if (parentId.asKnown().isPresent) 1 else 0) + class Manifest + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Manifest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Manifest]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(manifest: Manifest) = apply { + additionalProperties = manifest.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) + } + + /** + * Returns an immutable instance of [Manifest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Manifest = Manifest(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Manifest = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Manifest && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Manifest{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/Dataset.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/Dataset.kt index 2285beaf..d4bede30 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/Dataset.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/Dataset.kt @@ -34,10 +34,10 @@ private constructor( private val dataType: JsonField, private val description: JsonField, private val externallyManaged: JsonField, - private val inputsSchemaDefinition: JsonValue, + private val inputsSchemaDefinition: JsonField, private val lastSessionStartTime: JsonField, - private val metadata: JsonValue, - private val outputsSchemaDefinition: JsonValue, + private val metadata: JsonField, + private val outputsSchemaDefinition: JsonField, private val transformations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -68,14 +68,14 @@ private constructor( externallyManaged: JsonField = JsonMissing.of(), @JsonProperty("inputs_schema_definition") @ExcludeMissing - inputsSchemaDefinition: JsonValue = JsonMissing.of(), + inputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("last_session_start_time") @ExcludeMissing lastSessionStartTime: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("outputs_schema_definition") @ExcludeMissing - outputsSchemaDefinition: JsonValue = JsonMissing.of(), + outputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("transformations") @ExcludeMissing transformations: JsonField> = JsonMissing.of(), @@ -160,9 +160,12 @@ private constructor( */ fun externallyManaged(): Optional = externallyManaged.getOptional("externally_managed") - @JsonProperty("inputs_schema_definition") - @ExcludeMissing - fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional = + inputsSchemaDefinition.getOptional("inputs_schema_definition") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -171,11 +174,18 @@ private constructor( fun lastSessionStartTime(): Optional = lastSessionStartTime.getOptional("last_session_start_time") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("outputs_schema_definition") - @ExcludeMissing - fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional = + outputsSchemaDefinition.getOptional("outputs_schema_definition") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -265,6 +275,16 @@ private constructor( @ExcludeMissing fun _externallyManaged(): JsonField = externallyManaged + /** + * Returns the raw JSON value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonField = inputsSchemaDefinition + /** * Returns the raw JSON value of [lastSessionStartTime]. * @@ -275,6 +295,23 @@ private constructor( @ExcludeMissing fun _lastSessionStartTime(): JsonField = lastSessionStartTime + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonField = outputsSchemaDefinition + /** * Returns the raw JSON value of [transformations]. * @@ -327,10 +364,10 @@ private constructor( private var dataType: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var externallyManaged: JsonField = JsonMissing.of() - private var inputsSchemaDefinition: JsonValue = JsonMissing.of() + private var inputsSchemaDefinition: JsonField = JsonMissing.of() private var lastSessionStartTime: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var outputsSchemaDefinition: JsonField = JsonMissing.of() private var transformations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -485,9 +522,27 @@ private constructor( this.externallyManaged = externallyManaged } - fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { - this.inputsSchemaDefinition = inputsSchemaDefinition - } + fun inputsSchemaDefinition(inputsSchemaDefinition: InputsSchemaDefinition?) = + inputsSchemaDefinition(JsonField.ofNullable(inputsSchemaDefinition)) + + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed + * [InputsSchemaDefinition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonField) = + apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } fun lastSessionStartTime(lastSessionStartTime: OffsetDateTime?) = lastSessionStartTime(JsonField.ofNullable(lastSessionStartTime)) @@ -510,11 +565,41 @@ private constructor( this.lastSessionStartTime = lastSessionStartTime } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { - this.outputsSchemaDefinition = outputsSchemaDefinition - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun outputsSchemaDefinition(outputsSchemaDefinition: OutputsSchemaDefinition?) = + outputsSchemaDefinition(JsonField.ofNullable(outputsSchemaDefinition)) + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: Optional) = + outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed + * [OutputsSchemaDefinition] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonField) = + apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } fun transformations(transformations: List?) = transformations(JsonField.ofNullable(transformations)) @@ -620,7 +705,10 @@ private constructor( dataType().ifPresent { it.validate() } description() externallyManaged() + inputsSchemaDefinition().ifPresent { it.validate() } lastSessionStartTime() + metadata().ifPresent { it.validate() } + outputsSchemaDefinition().ifPresent { it.validate() } transformations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -650,9 +738,319 @@ private constructor( (dataType.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (inputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + (if (lastSessionStartTime.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (outputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class InputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsSchemaDefinition: InputsSchemaDefinition) = apply { + additionalProperties = inputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [InputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsSchemaDefinition = + InputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class OutputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OutputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsSchemaDefinition: OutputsSchemaDefinition) = apply { + additionalProperties = outputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [OutputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsSchemaDefinition = + OutputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponse.kt index 8b055be3..1ab577ca 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponse.kt @@ -3,29 +3,23 @@ package com.langchain.smith.models.datasets import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.langchain.smith.core.ExcludeMissing import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException -import java.util.Collections import java.util.Objects class DatasetCloneResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor(private val additionalProperties: MutableMap) { - - @JsonCreator private constructor() : this(mutableMapOf()) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map +) { @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) @@ -69,8 +63,7 @@ private constructor(private val additionalProperties: MutableMap !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCreateParams.kt index 85fd1ccf..3e82a8a3 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCreateParams.kt @@ -69,11 +69,24 @@ private constructor( */ fun externallyManaged(): Optional = body.externallyManaged() - fun _extra(): JsonValue = body._extra() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = body.extra() - fun _inputsSchemaDefinition(): JsonValue = body._inputsSchemaDefinition() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional = body.inputsSchemaDefinition() - fun _outputsSchemaDefinition(): JsonValue = body._outputsSchemaDefinition() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional = + body.outputsSchemaDefinition() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -124,6 +137,31 @@ private constructor( */ fun _externallyManaged(): JsonField = body._externallyManaged() + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _extra(): JsonField = body._extra() + + /** + * Returns the raw JSON value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _inputsSchemaDefinition(): JsonField = + body._inputsSchemaDefinition() + + /** + * Returns the raw JSON value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _outputsSchemaDefinition(): JsonField = + body._outputsSchemaDefinition() + /** * Returns the raw JSON value of [transformations]. * @@ -269,16 +307,65 @@ private constructor( body.externallyManaged(externallyManaged) } - fun extra(extra: JsonValue) = apply { body.extra(extra) } + fun extra(extra: Extra?) = apply { body.extra(extra) } - fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { body.extra(extra) } + + fun inputsSchemaDefinition(inputsSchemaDefinition: InputsSchemaDefinition?) = apply { body.inputsSchemaDefinition(inputsSchemaDefinition) } - fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed + * [InputsSchemaDefinition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonField) = + apply { + body.inputsSchemaDefinition(inputsSchemaDefinition) + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: OutputsSchemaDefinition?) = apply { body.outputsSchemaDefinition(outputsSchemaDefinition) } + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: Optional) = + outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed + * [OutputsSchemaDefinition] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonField) = + apply { + body.outputsSchemaDefinition(outputsSchemaDefinition) + } + fun transformations(transformations: List?) = apply { body.transformations(transformations) } @@ -460,9 +547,9 @@ private constructor( private val dataType: JsonField, private val description: JsonField, private val externallyManaged: JsonField, - private val extra: JsonValue, - private val inputsSchemaDefinition: JsonValue, - private val outputsSchemaDefinition: JsonValue, + private val extra: JsonField, + private val inputsSchemaDefinition: JsonField, + private val outputsSchemaDefinition: JsonField, private val transformations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -483,13 +570,13 @@ private constructor( @JsonProperty("externally_managed") @ExcludeMissing externallyManaged: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("inputs_schema_definition") @ExcludeMissing - inputsSchemaDefinition: JsonValue = JsonMissing.of(), + inputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("outputs_schema_definition") @ExcludeMissing - outputsSchemaDefinition: JsonValue = JsonMissing.of(), + outputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("transformations") @ExcludeMissing transformations: JsonField> = JsonMissing.of(), @@ -546,15 +633,25 @@ private constructor( fun externallyManaged(): Optional = externallyManaged.getOptional("externally_managed") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") - @JsonProperty("inputs_schema_definition") - @ExcludeMissing - fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional = + inputsSchemaDefinition.getOptional("inputs_schema_definition") - @JsonProperty("outputs_schema_definition") - @ExcludeMissing - fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional = + outputsSchemaDefinition.getOptional("outputs_schema_definition") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -612,6 +709,33 @@ private constructor( @ExcludeMissing fun _externallyManaged(): JsonField = externallyManaged + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + + /** + * Returns the raw JSON value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonField = inputsSchemaDefinition + + /** + * Returns the raw JSON value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonField = outputsSchemaDefinition + /** * Returns the raw JSON value of [transformations]. * @@ -656,9 +780,10 @@ private constructor( private var dataType: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var externallyManaged: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() - private var inputsSchemaDefinition: JsonValue = JsonMissing.of() - private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() + private var inputsSchemaDefinition: JsonField = JsonMissing.of() + private var outputsSchemaDefinition: JsonField = + JsonMissing.of() private var transformations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -771,15 +896,63 @@ private constructor( this.externallyManaged = externallyManaged } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { - this.inputsSchemaDefinition = inputsSchemaDefinition - } + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) - fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { - this.outputsSchemaDefinition = outputsSchemaDefinition - } + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } + + fun inputsSchemaDefinition(inputsSchemaDefinition: InputsSchemaDefinition?) = + inputsSchemaDefinition(JsonField.ofNullable(inputsSchemaDefinition)) + + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed + * [InputsSchemaDefinition] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonField) = + apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: OutputsSchemaDefinition?) = + outputsSchemaDefinition(JsonField.ofNullable(outputsSchemaDefinition)) + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition( + outputsSchemaDefinition: Optional + ) = outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed + * [OutputsSchemaDefinition] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun outputsSchemaDefinition( + outputsSchemaDefinition: JsonField + ) = apply { this.outputsSchemaDefinition = outputsSchemaDefinition } fun transformations(transformations: List?) = transformations(JsonField.ofNullable(transformations)) @@ -871,6 +1044,9 @@ private constructor( dataType().ifPresent { it.validate() } description() externallyManaged() + extra().ifPresent { it.validate() } + inputsSchemaDefinition().ifPresent { it.validate() } + outputsSchemaDefinition().ifPresent { it.validate() } transformations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -897,6 +1073,9 @@ private constructor( (dataType.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (inputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + + (outputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { @@ -940,6 +1119,313 @@ private constructor( "Body{name=$name, id=$id, createdAt=$createdAt, dataType=$dataType, description=$description, externallyManaged=$externallyManaged, extra=$extra, inputsSchemaDefinition=$inputsSchemaDefinition, outputsSchemaDefinition=$outputsSchemaDefinition, transformations=$transformations, additionalProperties=$additionalProperties}" } + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + + class InputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsSchemaDefinition: InputsSchemaDefinition) = apply { + additionalProperties = inputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [InputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsSchemaDefinition = + InputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + + class OutputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OutputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsSchemaDefinition: OutputsSchemaDefinition) = apply { + additionalProperties = outputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [OutputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsSchemaDefinition = + OutputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParams.kt index b7f52745..75c47ece 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParams.kt @@ -238,10 +238,10 @@ private constructor( /** * Alias for calling [inputsSchemaDefinition] with - * `InputsSchemaDefinition.ofJsonValue(jsonValue)`. + * `InputsSchemaDefinition.ofUnionMember0(unionMember0)`. */ - fun inputsSchemaDefinition(jsonValue: JsonValue) = apply { - body.inputsSchemaDefinition(jsonValue) + fun inputsSchemaDefinition(unionMember0: InputsSchemaDefinition.UnionMember0) = apply { + body.inputsSchemaDefinition(unionMember0) } /** @@ -266,8 +266,8 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } - /** Alias for calling [metadata] with `Metadata.ofJsonValue(jsonValue)`. */ - fun metadata(jsonValue: JsonValue) = apply { body.metadata(jsonValue) } + /** Alias for calling [metadata] with `Metadata.ofUnionMember0(unionMember0)`. */ + fun metadata(unionMember0: Metadata.UnionMember0) = apply { body.metadata(unionMember0) } /** Alias for calling [metadata] with `Metadata.ofMissing(missing)`. */ fun metadata(missing: Missing) = apply { body.metadata(missing) } @@ -316,10 +316,10 @@ private constructor( /** * Alias for calling [outputsSchemaDefinition] with - * `OutputsSchemaDefinition.ofJsonValue(jsonValue)`. + * `OutputsSchemaDefinition.ofUnionMember0(unionMember0)`. */ - fun outputsSchemaDefinition(jsonValue: JsonValue) = apply { - body.outputsSchemaDefinition(jsonValue) + fun outputsSchemaDefinition(unionMember0: OutputsSchemaDefinition.UnionMember0) = apply { + body.outputsSchemaDefinition(unionMember0) } /** @@ -764,10 +764,10 @@ private constructor( /** * Alias for calling [inputsSchemaDefinition] with - * `InputsSchemaDefinition.ofJsonValue(jsonValue)`. + * `InputsSchemaDefinition.ofUnionMember0(unionMember0)`. */ - fun inputsSchemaDefinition(jsonValue: JsonValue) = - inputsSchemaDefinition(InputsSchemaDefinition.ofJsonValue(jsonValue)) + fun inputsSchemaDefinition(unionMember0: InputsSchemaDefinition.UnionMember0) = + inputsSchemaDefinition(InputsSchemaDefinition.ofUnionMember0(unionMember0)) /** * Alias for calling [inputsSchemaDefinition] with @@ -790,8 +790,9 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** Alias for calling [metadata] with `Metadata.ofJsonValue(jsonValue)`. */ - fun metadata(jsonValue: JsonValue) = metadata(Metadata.ofJsonValue(jsonValue)) + /** Alias for calling [metadata] with `Metadata.ofUnionMember0(unionMember0)`. */ + fun metadata(unionMember0: Metadata.UnionMember0) = + metadata(Metadata.ofUnionMember0(unionMember0)) /** Alias for calling [metadata] with `Metadata.ofMissing(missing)`. */ fun metadata(missing: Missing) = metadata(Metadata.ofMissing(missing)) @@ -840,10 +841,10 @@ private constructor( /** * Alias for calling [outputsSchemaDefinition] with - * `OutputsSchemaDefinition.ofJsonValue(jsonValue)`. + * `OutputsSchemaDefinition.ofUnionMember0(unionMember0)`. */ - fun outputsSchemaDefinition(jsonValue: JsonValue) = - outputsSchemaDefinition(OutputsSchemaDefinition.ofJsonValue(jsonValue)) + fun outputsSchemaDefinition(unionMember0: OutputsSchemaDefinition.UnionMember0) = + outputsSchemaDefinition(OutputsSchemaDefinition.ofUnionMember0(unionMember0)) /** * Alias for calling [outputsSchemaDefinition] with @@ -1185,20 +1186,20 @@ private constructor( @JsonSerialize(using = InputsSchemaDefinition.Serializer::class) class InputsSchemaDefinition private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val missing: Missing? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun missing(): Optional = Optional.ofNullable(missing) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isMissing(): Boolean = missing != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asMissing(): Missing = missing.getOrThrow("missing") @@ -1206,7 +1207,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) missing != null -> visitor.visitMissing(missing) else -> visitor.unknown(_json) } @@ -1220,7 +1221,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitMissing(missing: Missing) { missing.validate() @@ -1248,7 +1251,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitMissing(missing: Missing) = missing.validity() @@ -1262,15 +1266,15 @@ private constructor( } return other is InputsSchemaDefinition && - jsonValue == other.jsonValue && + unionMember0 == other.unionMember0 && missing == other.missing } - override fun hashCode(): Int = Objects.hash(jsonValue, missing) + override fun hashCode(): Int = Objects.hash(unionMember0, missing) override fun toString(): String = when { - jsonValue != null -> "InputsSchemaDefinition{jsonValue=$jsonValue}" + unionMember0 != null -> "InputsSchemaDefinition{unionMember0=$unionMember0}" missing != null -> "InputsSchemaDefinition{missing=$missing}" _json != null -> "InputsSchemaDefinition{_unknown=$_json}" else -> throw IllegalStateException("Invalid InputsSchemaDefinition") @@ -1279,7 +1283,8 @@ private constructor( companion object { @JvmStatic - fun ofJsonValue(jsonValue: JsonValue) = InputsSchemaDefinition(jsonValue = jsonValue) + fun ofUnionMember0(unionMember0: UnionMember0) = + InputsSchemaDefinition(unionMember0 = unionMember0) @JvmStatic fun ofMissing(missing: Missing) = InputsSchemaDefinition(missing = missing) } @@ -1290,7 +1295,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitMissing(missing: Missing): T @@ -1317,19 +1322,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + InputsSchemaDefinition(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { InputsSchemaDefinition(missing = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - InputsSchemaDefinition(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> InputsSchemaDefinition(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1349,33 +1354,135 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) value.missing != null -> generator.writeObject(value.missing) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid InputsSchemaDefinition") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } } @JsonDeserialize(using = Metadata.Deserializer::class) @JsonSerialize(using = Metadata.Serializer::class) class Metadata private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val missing: Missing? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun missing(): Optional = Optional.ofNullable(missing) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isMissing(): Boolean = missing != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asMissing(): Missing = missing.getOrThrow("missing") @@ -1383,7 +1490,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) missing != null -> visitor.visitMissing(missing) else -> visitor.unknown(_json) } @@ -1397,7 +1504,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitMissing(missing: Missing) { missing.validate() @@ -1425,7 +1534,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitMissing(missing: Missing) = missing.validity() @@ -1438,14 +1548,16 @@ private constructor( return true } - return other is Metadata && jsonValue == other.jsonValue && missing == other.missing + return other is Metadata && + unionMember0 == other.unionMember0 && + missing == other.missing } - override fun hashCode(): Int = Objects.hash(jsonValue, missing) + override fun hashCode(): Int = Objects.hash(unionMember0, missing) override fun toString(): String = when { - jsonValue != null -> "Metadata{jsonValue=$jsonValue}" + unionMember0 != null -> "Metadata{unionMember0=$unionMember0}" missing != null -> "Metadata{missing=$missing}" _json != null -> "Metadata{_unknown=$_json}" else -> throw IllegalStateException("Invalid Metadata") @@ -1453,7 +1565,8 @@ private constructor( companion object { - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Metadata(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Metadata(unionMember0 = unionMember0) @JvmStatic fun ofMissing(missing: Missing) = Metadata(missing = missing) } @@ -1463,7 +1576,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitMissing(missing: Missing): T @@ -1489,19 +1602,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Metadata(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Metadata(missing = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Metadata(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> Metadata(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1520,13 +1633,115 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) value.missing != null -> generator.writeObject(value.missing) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Metadata") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } } @JsonDeserialize(using = Name.Deserializer::class) @@ -1701,20 +1916,20 @@ private constructor( @JsonSerialize(using = OutputsSchemaDefinition.Serializer::class) class OutputsSchemaDefinition private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val missing: Missing? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun missing(): Optional = Optional.ofNullable(missing) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isMissing(): Boolean = missing != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asMissing(): Missing = missing.getOrThrow("missing") @@ -1722,7 +1937,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) missing != null -> visitor.visitMissing(missing) else -> visitor.unknown(_json) } @@ -1736,7 +1951,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitMissing(missing: Missing) { missing.validate() @@ -1764,7 +1981,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitMissing(missing: Missing) = missing.validity() @@ -1778,15 +1996,15 @@ private constructor( } return other is OutputsSchemaDefinition && - jsonValue == other.jsonValue && + unionMember0 == other.unionMember0 && missing == other.missing } - override fun hashCode(): Int = Objects.hash(jsonValue, missing) + override fun hashCode(): Int = Objects.hash(unionMember0, missing) override fun toString(): String = when { - jsonValue != null -> "OutputsSchemaDefinition{jsonValue=$jsonValue}" + unionMember0 != null -> "OutputsSchemaDefinition{unionMember0=$unionMember0}" missing != null -> "OutputsSchemaDefinition{missing=$missing}" _json != null -> "OutputsSchemaDefinition{_unknown=$_json}" else -> throw IllegalStateException("Invalid OutputsSchemaDefinition") @@ -1795,7 +2013,8 @@ private constructor( companion object { @JvmStatic - fun ofJsonValue(jsonValue: JsonValue) = OutputsSchemaDefinition(jsonValue = jsonValue) + fun ofUnionMember0(unionMember0: UnionMember0) = + OutputsSchemaDefinition(unionMember0 = unionMember0) @JvmStatic fun ofMissing(missing: Missing) = OutputsSchemaDefinition(missing = missing) } @@ -1806,7 +2025,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitMissing(missing: Missing): T @@ -1833,19 +2052,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OutputsSchemaDefinition(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { OutputsSchemaDefinition(missing = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - OutputsSchemaDefinition(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from boolean). 0 -> OutputsSchemaDefinition(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1865,13 +2084,115 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) value.missing != null -> generator.writeObject(value.missing) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid OutputsSchemaDefinition") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } } class PatchExamples diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponse.kt index 39f4edd8..a3ba7e73 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponse.kt @@ -30,8 +30,8 @@ private constructor( private val dataType: JsonField, private val description: JsonField, private val externallyManaged: JsonField, - private val inputsSchemaDefinition: JsonValue, - private val outputsSchemaDefinition: JsonValue, + private val inputsSchemaDefinition: JsonField, + private val outputsSchemaDefinition: JsonField, private val transformations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -53,10 +53,10 @@ private constructor( externallyManaged: JsonField = JsonMissing.of(), @JsonProperty("inputs_schema_definition") @ExcludeMissing - inputsSchemaDefinition: JsonValue = JsonMissing.of(), + inputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("outputs_schema_definition") @ExcludeMissing - outputsSchemaDefinition: JsonValue = JsonMissing.of(), + outputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("transformations") @ExcludeMissing transformations: JsonField> = JsonMissing.of(), @@ -118,13 +118,19 @@ private constructor( */ fun externallyManaged(): Optional = externallyManaged.getOptional("externally_managed") - @JsonProperty("inputs_schema_definition") - @ExcludeMissing - fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional = + inputsSchemaDefinition.getOptional("inputs_schema_definition") - @JsonProperty("outputs_schema_definition") - @ExcludeMissing - fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional = + outputsSchemaDefinition.getOptional("outputs_schema_definition") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -187,6 +193,26 @@ private constructor( @ExcludeMissing fun _externallyManaged(): JsonField = externallyManaged + /** + * Returns the raw JSON value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonField = inputsSchemaDefinition + + /** + * Returns the raw JSON value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonField = outputsSchemaDefinition + /** * Returns the raw JSON value of [transformations]. * @@ -233,8 +259,8 @@ private constructor( private var dataType: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var externallyManaged: JsonField = JsonMissing.of() - private var inputsSchemaDefinition: JsonValue = JsonMissing.of() - private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var inputsSchemaDefinition: JsonField = JsonMissing.of() + private var outputsSchemaDefinition: JsonField = JsonMissing.of() private var transformations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -349,13 +375,49 @@ private constructor( this.externallyManaged = externallyManaged } - fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { - this.inputsSchemaDefinition = inputsSchemaDefinition - } + fun inputsSchemaDefinition(inputsSchemaDefinition: InputsSchemaDefinition?) = + inputsSchemaDefinition(JsonField.ofNullable(inputsSchemaDefinition)) - fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { - this.outputsSchemaDefinition = outputsSchemaDefinition - } + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed + * [InputsSchemaDefinition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonField) = + apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: OutputsSchemaDefinition?) = + outputsSchemaDefinition(JsonField.ofNullable(outputsSchemaDefinition)) + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: Optional) = + outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed + * [OutputsSchemaDefinition] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonField) = + apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } fun transformations(transformations: List?) = transformations(JsonField.ofNullable(transformations)) @@ -450,6 +512,8 @@ private constructor( dataType().ifPresent { it.validate() } description() externallyManaged() + inputsSchemaDefinition().ifPresent { it.validate() } + outputsSchemaDefinition().ifPresent { it.validate() } transformations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -476,8 +540,218 @@ private constructor( (dataType.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (inputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + + (outputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class InputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsSchemaDefinition: InputsSchemaDefinition) = apply { + additionalProperties = inputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [InputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsSchemaDefinition = + InputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + + class OutputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OutputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsSchemaDefinition: OutputsSchemaDefinition) = apply { + additionalProperties = outputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [OutputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsSchemaDefinition = + OutputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchema.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchema.kt index 8939e28f..ddb1ef67 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchema.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchema.kt @@ -46,7 +46,7 @@ private constructor( private val comparativeExperimentId: JsonField, private val correction: JsonField, private val createdAt: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val feedbackConfig: JsonField, private val feedbackGroupId: JsonField, private val feedbackSource: JsonField, @@ -70,7 +70,7 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_config") @ExcludeMissing feedbackConfig: JsonField = JsonMissing.of(), @@ -139,7 +139,11 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -228,6 +232,13 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [feedbackConfig]. * @@ -312,7 +323,7 @@ private constructor( private var comparativeExperimentId: JsonField = JsonMissing.of() private var correction: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var feedbackConfig: JsonField = JsonMissing.of() private var feedbackGroupId: JsonField = JsonMissing.of() private var feedbackSource: JsonField = JsonMissing.of() @@ -407,8 +418,9 @@ private constructor( */ fun correction(correction: JsonField) = apply { this.correction = correction } - /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ - fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + /** Alias for calling [correction] with `Correction.ofUnionMember0(unionMember0)`. */ + fun correction(unionMember0: Correction.UnionMember0) = + correction(Correction.ofUnionMember0(unionMember0)) /** Alias for calling [correction] with `Correction.ofString(string)`. */ fun correction(string: String) = correction(Correction.ofString(string)) @@ -424,7 +436,18 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun feedbackConfig(feedbackConfig: FeedbackConfig?) = feedbackConfig(JsonField.ofNullable(feedbackConfig)) @@ -549,8 +572,8 @@ private constructor( /** Alias for calling [value] with `Value.ofString(string)`. */ fun value(string: String) = value(Value.ofString(string)) - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) + /** Alias for calling [value] with `Value.ofUnionMember3(unionMember3)`. */ + fun value(unionMember3: Value.UnionMember3) = value(Value.ofUnionMember3(unionMember3)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -615,6 +638,7 @@ private constructor( comparativeExperimentId() correction().ifPresent { it.validate() } createdAt() + extra().ifPresent { it.validate() } feedbackConfig().ifPresent { it.validate() } feedbackGroupId() feedbackSource().ifPresent { it.validate() } @@ -645,6 +669,7 @@ private constructor( (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + (correction.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (feedbackGroupId.asKnown().isPresent) 1 else 0) + (feedbackSource.asKnown().getOrNull()?.validity() ?: 0) + @@ -656,20 +681,20 @@ private constructor( @JsonSerialize(using = Correction.Serializer::class) class Correction private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun string(): Optional = Optional.ofNullable(string) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isString(): Boolean = string != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asString(): String = string.getOrThrow("string") @@ -677,7 +702,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -691,7 +716,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitString(string: String) {} } @@ -717,7 +744,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitString(string: String) = 1 @@ -730,14 +758,16 @@ private constructor( return true } - return other is Correction && jsonValue == other.jsonValue && string == other.string + return other is Correction && + unionMember0 == other.unionMember0 && + string == other.string } - override fun hashCode(): Int = Objects.hash(jsonValue, string) + override fun hashCode(): Int = Objects.hash(unionMember0, string) override fun toString(): String = when { - jsonValue != null -> "Correction{jsonValue=$jsonValue}" + unionMember0 != null -> "Correction{unionMember0=$unionMember0}" string != null -> "Correction{string=$string}" _json != null -> "Correction{_unknown=$_json}" else -> throw IllegalStateException("Invalid Correction") @@ -745,7 +775,8 @@ private constructor( companion object { - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Correction(unionMember0 = unionMember0) @JvmStatic fun ofString(string: String) = Correction(string = string) } @@ -755,7 +786,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitString(string: String): T @@ -781,19 +812,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Correction(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Correction(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Correction(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Correction(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -812,13 +843,214 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + 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 Correction") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" } class FeedbackConfig @@ -1869,7 +2101,7 @@ private constructor( private val number: Double? = null, private val bool: Boolean? = null, private val string: String? = null, - private val json: JsonValue? = null, + private val unionMember3: UnionMember3? = null, private val _json: JsonValue? = null, ) { @@ -1879,7 +2111,7 @@ private constructor( fun string(): Optional = Optional.ofNullable(string) - fun json(): Optional = Optional.ofNullable(json) + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) fun isNumber(): Boolean = number != null @@ -1887,7 +2119,7 @@ private constructor( fun isString(): Boolean = string != null - fun isJson(): Boolean = json != null + fun isUnionMember3(): Boolean = unionMember3 != null fun asNumber(): Double = number.getOrThrow("number") @@ -1895,7 +2127,7 @@ private constructor( fun asString(): String = string.getOrThrow("string") - fun asJson(): JsonValue = json.getOrThrow("json") + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") fun _json(): Optional = Optional.ofNullable(_json) @@ -1904,7 +2136,7 @@ private constructor( number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) string != null -> visitor.visitString(string) - json != null -> visitor.visitJson(json) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) else -> visitor.unknown(_json) } @@ -1923,7 +2155,9 @@ private constructor( override fun visitString(string: String) {} - override fun visitJson(json: JsonValue) {} + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } } ) validated = true @@ -1953,7 +2187,8 @@ private constructor( override fun visitString(string: String) = 1 - override fun visitJson(json: JsonValue) = 1 + override fun visitUnionMember3(unionMember3: UnionMember3) = + unionMember3.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1968,17 +2203,17 @@ private constructor( number == other.number && bool == other.bool && string == other.string && - json == other.json + unionMember3 == other.unionMember3 } - override fun hashCode(): Int = Objects.hash(number, bool, string, json) + override fun hashCode(): Int = Objects.hash(number, bool, string, unionMember3) override fun toString(): String = when { number != null -> "Value{number=$number}" bool != null -> "Value{bool=$bool}" string != null -> "Value{string=$string}" - json != null -> "Value{json=$json}" + unionMember3 != null -> "Value{unionMember3=$unionMember3}" _json != null -> "Value{_unknown=$_json}" else -> throw IllegalStateException("Invalid Value") } @@ -1991,7 +2226,8 @@ private constructor( @JvmStatic fun ofString(string: String) = Value(string = string) - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = Value(unionMember3 = unionMember3) } /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ @@ -2003,7 +2239,7 @@ private constructor( fun visitString(string: String): T - fun visitJson(json: JsonValue): T + fun visitUnionMember3(unionMember3: UnionMember3): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -2027,6 +2263,9 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(unionMember3 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Value(number = it, _json = json) }, @@ -2036,16 +2275,13 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Value(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Value(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -2067,12 +2303,114 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) value.string != null -> generator.writeObject(value.string) - value.json != null -> generator.writeObject(value.json) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Value") } } } + + class UnionMember3 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + additionalProperties = unionMember3.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) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = UnionMember3(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParams.kt index 92506b16..8a2e1e21 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParams.kt @@ -55,7 +55,11 @@ private constructor( */ fun description(): Optional = body.description() - fun _extra(): JsonValue = body._extra() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = body.extra() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -103,6 +107,13 @@ private constructor( */ fun _description(): JsonField = body._description() + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _extra(): JsonField = body._extra() + /** * Returns the raw JSON value of [modifiedAt]. * @@ -231,7 +242,18 @@ private constructor( */ fun description(description: JsonField) = apply { body.description(description) } - fun extra(extra: JsonValue) = apply { body.extra(extra) } + fun extra(extra: Extra?) = apply { body.extra(extra) } + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { body.extra(extra) } fun modifiedAt(modifiedAt: OffsetDateTime) = apply { body.modifiedAt(modifiedAt) } @@ -431,7 +453,7 @@ private constructor( private val id: JsonField, private val createdAt: JsonField, private val description: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val modifiedAt: JsonField, private val name: JsonField, private val referenceDatasetId: JsonField, @@ -450,7 +472,7 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("modified_at") @ExcludeMissing modifiedAt: JsonField = JsonMissing.of(), @@ -494,7 +516,11 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -550,6 +576,13 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [modifiedAt]. * @@ -608,7 +641,7 @@ private constructor( private var id: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var modifiedAt: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() @@ -693,7 +726,19 @@ private constructor( this.description = description } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) @@ -799,6 +844,7 @@ private constructor( id() createdAt() description() + extra().ifPresent { it.validate() } modifiedAt() name() referenceDatasetId() @@ -825,6 +871,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (if (modifiedAt.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) @@ -866,6 +913,105 @@ private constructor( "Body{experimentIds=$experimentIds, id=$id, createdAt=$createdAt, description=$description, extra=$extra, modifiedAt=$modifiedAt, name=$name, referenceDatasetId=$referenceDatasetId, additionalProperties=$additionalProperties}" } + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponse.kt index c2b11b7c..9b334a09 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponse.kt @@ -11,6 +11,7 @@ import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -28,7 +29,7 @@ private constructor( private val referenceDatasetId: JsonField, private val tenantId: JsonField, private val description: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val name: JsonField, private val additionalProperties: MutableMap, ) { @@ -49,7 +50,7 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), ) : this( id, @@ -99,7 +100,11 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -156,6 +161,13 @@ private constructor( */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [name]. * @@ -201,7 +213,7 @@ private constructor( private var referenceDatasetId: JsonField? = null private var tenantId: JsonField? = null private var description: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -290,7 +302,18 @@ private constructor( */ fun description(description: JsonField) = apply { this.description = description } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -367,6 +390,7 @@ private constructor( referenceDatasetId() tenantId() description() + extra().ifPresent { it.validate() } name() validated = true } @@ -392,8 +416,108 @@ private constructor( (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (tenantId.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponse.kt index aea0477e..a52a3230 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponse.kt @@ -31,8 +31,8 @@ private constructor( private val referenceDatasetId: JsonField, private val tenantId: JsonField, private val description: JsonField, - private val extra: JsonValue, - private val feedbackStats: JsonValue, + private val extra: JsonField, + private val feedbackStats: JsonField, private val name: JsonField, private val additionalProperties: MutableMap, ) { @@ -56,8 +56,10 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), - @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), ) : this( id, @@ -116,9 +118,17 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") - @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -184,6 +194,22 @@ private constructor( */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + /** * Returns the raw JSON value of [name]. * @@ -231,8 +257,8 @@ private constructor( private var referenceDatasetId: JsonField? = null private var tenantId: JsonField? = null private var description: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() - private var feedbackStats: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -349,9 +375,36 @@ private constructor( */ fun description(description: JsonField) = apply { this.description = description } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { + this.feedbackStats = feedbackStats + } fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -432,6 +485,8 @@ private constructor( referenceDatasetId() tenantId() description() + extra().ifPresent { it.validate() } + feedbackStats().ifPresent { it.validate() } name() validated = true } @@ -458,8 +513,208 @@ private constructor( (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (tenantId.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.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) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt index 43584ac0..1395f7fd 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt @@ -236,7 +236,7 @@ private constructor( private val completionTokens: JsonField, private val count: JsonField, private val errorRate: JsonField, - private val feedbackStats: JsonValue, + private val feedbackStats: JsonField, private val latencyP50: JsonField, private val latencyP99: JsonField, private val maxStartTime: JsonField, @@ -275,7 +275,7 @@ private constructor( errorRate: JsonField = JsonMissing.of(), @JsonProperty("feedback_stats") @ExcludeMissing - feedbackStats: JsonValue = JsonMissing.of(), + feedbackStats: JsonField = JsonMissing.of(), @JsonProperty("latency_p50") @ExcludeMissing latencyP50: JsonField = JsonMissing.of(), @@ -376,9 +376,11 @@ private constructor( */ fun errorRate(): Optional = errorRate.getOptional("error_rate") - @JsonProperty("feedback_stats") - @ExcludeMissing - fun _feedbackStats(): JsonValue = feedbackStats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -504,6 +506,16 @@ private constructor( */ @JsonProperty("error_rate") @ExcludeMissing fun _errorRate(): JsonField = errorRate + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + /** * Returns the raw JSON value of [latencyP50]. * @@ -618,7 +630,7 @@ private constructor( private var completionTokens: JsonField = JsonMissing.of() private var count: JsonField = JsonMissing.of() private var errorRate: JsonField = JsonMissing.of() - private var feedbackStats: JsonValue = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() private var latencyP50: JsonField = JsonMissing.of() private var latencyP99: JsonField = JsonMissing.of() private var maxStartTime: JsonField = JsonMissing.of() @@ -831,7 +843,21 @@ private constructor( */ fun errorRate(errorRate: JsonField) = apply { this.errorRate = errorRate } - fun feedbackStats(feedbackStats: JsonValue) = apply { + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { this.feedbackStats = feedbackStats } @@ -1060,6 +1086,7 @@ private constructor( completionTokens() count() errorRate() + feedbackStats().ifPresent { it.validate() } latencyP50() latencyP99() maxStartTime() @@ -1096,6 +1123,7 @@ private constructor( (if (completionTokens.asKnown().isPresent) 1 else 0) + (if (count.asKnown().isPresent) 1 else 0) + (if (errorRate.asKnown().isPresent) 1 else 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (latencyP50.asKnown().isPresent) 1 else 0) + (if (latencyP99.asKnown().isPresent) 1 else 0) + (if (maxStartTime.asKnown().isPresent) 1 else 0) + @@ -1296,8 +1324,8 @@ private constructor( private val endTime: JsonField, private val errorRate: JsonField, private val exampleCount: JsonField, - private val extra: JsonValue, - private val feedbackStats: JsonValue, + private val extra: JsonField, + private val feedbackStats: JsonField, private val firstTokenP50: JsonField, private val firstTokenP99: JsonField, private val lastRunStartTime: JsonField, @@ -1311,8 +1339,8 @@ private constructor( private val promptTokens: JsonField, private val referenceDatasetId: JsonField, private val runCount: JsonField, - private val runFacets: JsonField>, - private val sessionFeedbackStats: JsonValue, + private val runFacets: JsonField>, + private val sessionFeedbackStats: JsonField, private val startTime: JsonField, private val streamingRate: JsonField, private val testRunNumber: JsonField, @@ -1352,10 +1380,10 @@ private constructor( @JsonProperty("example_count") @ExcludeMissing exampleCount: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_stats") @ExcludeMissing - feedbackStats: JsonValue = JsonMissing.of(), + feedbackStats: JsonField = JsonMissing.of(), @JsonProperty("first_token_p50") @ExcludeMissing firstTokenP50: JsonField = JsonMissing.of(), @@ -1395,10 +1423,10 @@ private constructor( runCount: JsonField = JsonMissing.of(), @JsonProperty("run_facets") @ExcludeMissing - runFacets: JsonField> = JsonMissing.of(), + runFacets: JsonField> = JsonMissing.of(), @JsonProperty("session_feedback_stats") @ExcludeMissing - sessionFeedbackStats: JsonValue = JsonMissing.of(), + sessionFeedbackStats: JsonField = JsonMissing.of(), @JsonProperty("start_time") @ExcludeMissing startTime: JsonField = JsonMissing.of(), @@ -1519,11 +1547,18 @@ private constructor( */ fun exampleCount(): Optional = exampleCount.getOptional("example_count") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") - @JsonProperty("feedback_stats") - @ExcludeMissing - fun _feedbackStats(): JsonValue = feedbackStats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackStats(): Optional = + feedbackStats.getOptional("feedback_stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. @@ -1612,11 +1647,14 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun runFacets(): Optional> = runFacets.getOptional("run_facets") + fun runFacets(): Optional> = runFacets.getOptional("run_facets") - @JsonProperty("session_feedback_stats") - @ExcludeMissing - fun _sessionFeedbackStats(): JsonValue = sessionFeedbackStats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionFeedbackStats(): Optional = + sessionFeedbackStats.getOptional("session_feedback_stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. @@ -1745,6 +1783,23 @@ private constructor( @ExcludeMissing fun _exampleCount(): JsonField = exampleCount + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + /** * Returns the raw JSON value of [firstTokenP50]. * @@ -1878,7 +1933,17 @@ private constructor( */ @JsonProperty("run_facets") @ExcludeMissing - fun _runFacets(): JsonField> = runFacets + fun _runFacets(): JsonField> = runFacets + + /** + * Returns the raw JSON value of [sessionFeedbackStats]. + * + * Unlike [sessionFeedbackStats], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("session_feedback_stats") + @ExcludeMissing + fun _sessionFeedbackStats(): JsonField = sessionFeedbackStats /** * Returns the raw JSON value of [startTime]. @@ -1980,8 +2045,8 @@ private constructor( private var endTime: JsonField = JsonMissing.of() private var errorRate: JsonField = JsonMissing.of() private var exampleCount: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() - private var feedbackStats: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() private var firstTokenP50: JsonField = JsonMissing.of() private var firstTokenP99: JsonField = JsonMissing.of() private var lastRunStartTime: JsonField = JsonMissing.of() @@ -1995,8 +2060,8 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() private var runCount: JsonField = JsonMissing.of() - private var runFacets: JsonField>? = null - private var sessionFeedbackStats: JsonValue = JsonMissing.of() + private var runFacets: JsonField>? = null + private var sessionFeedbackStats: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var streamingRate: JsonField = JsonMissing.of() private var testRunNumber: JsonField = JsonMissing.of() @@ -2224,9 +2289,35 @@ private constructor( this.exampleCount = exampleCount } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - fun feedbackStats(feedbackStats: JsonValue) = apply { + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { this.feedbackStats = feedbackStats } @@ -2498,39 +2589,57 @@ private constructor( */ fun runCount(runCount: JsonField) = apply { this.runCount = runCount } - fun runFacets(runFacets: List?) = + fun runFacets(runFacets: List?) = runFacets(JsonField.ofNullable(runFacets)) /** Alias for calling [Builder.runFacets] with `runFacets.orElse(null)`. */ - fun runFacets(runFacets: Optional>) = + fun runFacets(runFacets: Optional>) = runFacets(runFacets.getOrNull()) /** * Sets [Builder.runFacets] to an arbitrary JSON value. * - * You should usually call [Builder.runFacets] with a well-typed `List` + * You should usually call [Builder.runFacets] with a well-typed `List` * value instead. This method is primarily for setting the field to an undocumented * or not yet supported value. */ - fun runFacets(runFacets: JsonField>) = apply { + fun runFacets(runFacets: JsonField>) = apply { this.runFacets = runFacets.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [runFacets]. + * Adds a single [RunFacet] to [runFacets]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addRunFacet(runFacet: JsonValue) = apply { + fun addRunFacet(runFacet: RunFacet) = apply { runFacets = (runFacets ?: JsonField.of(mutableListOf())).also { checkKnown("runFacets", it).add(runFacet) } } - fun sessionFeedbackStats(sessionFeedbackStats: JsonValue) = apply { - this.sessionFeedbackStats = sessionFeedbackStats - } + fun sessionFeedbackStats(sessionFeedbackStats: SessionFeedbackStats?) = + sessionFeedbackStats(JsonField.ofNullable(sessionFeedbackStats)) + + /** + * Alias for calling [Builder.sessionFeedbackStats] with + * `sessionFeedbackStats.orElse(null)`. + */ + fun sessionFeedbackStats(sessionFeedbackStats: Optional) = + sessionFeedbackStats(sessionFeedbackStats.getOrNull()) + + /** + * Sets [Builder.sessionFeedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionFeedbackStats] with a well-typed + * [SessionFeedbackStats] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun sessionFeedbackStats(sessionFeedbackStats: JsonField) = + apply { + this.sessionFeedbackStats = sessionFeedbackStats + } fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) @@ -2740,6 +2849,8 @@ private constructor( endTime() errorRate() exampleCount() + extra().ifPresent { it.validate() } + feedbackStats().ifPresent { it.validate() } firstTokenP50() firstTokenP99() lastRunStartTime() @@ -2753,7 +2864,8 @@ private constructor( promptTokens() referenceDatasetId() runCount() - runFacets() + runFacets().ifPresent { it.forEach { it.validate() } } + sessionFeedbackStats().ifPresent { it.validate() } startTime() streamingRate() testRunNumber() @@ -2789,6 +2901,8 @@ private constructor( (if (endTime.asKnown().isPresent) 1 else 0) + (if (errorRate.asKnown().isPresent) 1 else 0) + (if (exampleCount.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (firstTokenP50.asKnown().isPresent) 1 else 0) + (if (firstTokenP99.asKnown().isPresent) 1 else 0) + (if (lastRunStartTime.asKnown().isPresent) 1 else 0) + @@ -2802,7 +2916,8 @@ private constructor( (if (promptTokens.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (runCount.asKnown().isPresent) 1 else 0) + - (runFacets.asKnown().getOrNull()?.size ?: 0) + + (runFacets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (sessionFeedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (startTime.asKnown().isPresent) 1 else 0) + (if (streamingRate.asKnown().isPresent) 1 else 0) + (if (testRunNumber.asKnown().isPresent) 1 else 0) + @@ -2810,6 +2925,433 @@ private constructor( (if (totalTokens.asKnown().isPresent) 1 else 0) + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackStats]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.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) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class RunFacet + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunFacet]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunFacet]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runFacet: RunFacet) = apply { + additionalProperties = runFacet.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) + } + + /** + * Returns an immutable instance of [RunFacet]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunFacet = RunFacet(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunFacet = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunFacet && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunFacet{additionalProperties=$additionalProperties}" + } + + class SessionFeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SessionFeedbackStats]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionFeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionFeedbackStats: SessionFeedbackStats) = apply { + additionalProperties = + sessionFeedbackStats.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) + } + + /** + * Returns an immutable instance of [SessionFeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionFeedbackStats = + SessionFeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SessionFeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionFeedbackStats && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SessionFeedbackStats{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3028,6 +3570,108 @@ private constructor( "Session{id=$id, filter=$filter, tenantId=$tenantId, completionCost=$completionCost, completionTokens=$completionTokens, defaultDatasetId=$defaultDatasetId, description=$description, endTime=$endTime, errorRate=$errorRate, exampleCount=$exampleCount, extra=$extra, feedbackStats=$feedbackStats, firstTokenP50=$firstTokenP50, firstTokenP99=$firstTokenP99, lastRunStartTime=$lastRunStartTime, lastRunStartTimeLive=$lastRunStartTimeLive, latencyP50=$latencyP50, latencyP99=$latencyP99, maxStartTime=$maxStartTime, minStartTime=$minStartTime, name=$name, promptCost=$promptCost, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, runCount=$runCount, runFacets=$runFacets, sessionFeedbackStats=$sessionFeedbackStats, startTime=$startTime, streamingRate=$streamingRate, testRunNumber=$testRunNumber, totalCost=$totalCost, totalTokens=$totalTokens, traceTier=$traceTier, additionalProperties=$additionalProperties}" } + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.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) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt index 2cbf5216..946f1251 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt @@ -82,7 +82,11 @@ private constructor( */ fun evaluatorRules(): Optional> = body.evaluatorRules() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -207,6 +211,13 @@ private constructor( */ fun _evaluatorRules(): JsonField> = body._evaluatorRules() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + /** * Returns the raw JSON value of [owner]. * @@ -477,7 +488,19 @@ private constructor( */ fun addEvaluatorRule(evaluatorRule: String) = apply { body.addEvaluatorRule(evaluatorRule) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } fun owner(owner: String?) = apply { body.owner(owner) } @@ -826,7 +849,7 @@ private constructor( private val commit: JsonField, private val datasetSplits: JsonField>, private val evaluatorRules: JsonField>, - private val metadata: JsonValue, + private val metadata: JsonField, private val owner: JsonField, private val parallelToolCalls: JsonField, private val repetitions: JsonField, @@ -864,7 +887,9 @@ private constructor( @JsonProperty("evaluator_rules") @ExcludeMissing evaluatorRules: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("owner") @ExcludeMissing owner: JsonField = JsonMissing.of(), @JsonProperty("parallel_tool_calls") @ExcludeMissing @@ -969,7 +994,11 @@ private constructor( */ fun evaluatorRules(): Optional> = evaluatorRules.getOptional("evaluator_rules") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1105,6 +1134,13 @@ private constructor( @ExcludeMissing fun _evaluatorRules(): JsonField> = evaluatorRules + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [owner]. * @@ -1241,7 +1277,7 @@ private constructor( private var commit: JsonField = JsonMissing.of() private var datasetSplits: JsonField>? = null private var evaluatorRules: JsonField>? = null - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var owner: JsonField = JsonMissing.of() private var parallelToolCalls: JsonField = JsonMissing.of() private var repetitions: JsonField = JsonMissing.of() @@ -1425,7 +1461,19 @@ private constructor( } } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun owner(owner: String?) = owner(JsonField.ofNullable(owner)) @@ -1701,6 +1749,7 @@ private constructor( commit() datasetSplits() evaluatorRules() + metadata().ifPresent { it.validate() } owner() parallelToolCalls() repetitions() @@ -1739,6 +1788,7 @@ private constructor( (if (commit.asKnown().isPresent) 1 else 0) + (datasetSplits.asKnown().getOrNull()?.size ?: 0) + (evaluatorRules.asKnown().getOrNull()?.size ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (owner.asKnown().isPresent) 1 else 0) + (if (parallelToolCalls.asKnown().isPresent) 1 else 0) + (if (repetitions.asKnown().isPresent) 1 else 0) + @@ -1913,6 +1963,105 @@ private constructor( override fun toString() = "Secrets{additionalProperties=$additionalProperties}" } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt index 5624c8f0..79b20dc5 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt @@ -76,7 +76,11 @@ private constructor( */ fun evaluatorRules(): Optional> = body.evaluatorRules() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -194,6 +198,13 @@ private constructor( */ fun _evaluatorRules(): JsonField> = body._evaluatorRules() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + /** * Returns the raw JSON value of [owner]. * @@ -444,7 +455,19 @@ private constructor( */ fun addEvaluatorRule(evaluatorRule: String) = apply { body.addEvaluatorRule(evaluatorRule) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } fun owner(owner: String?) = apply { body.owner(owner) } @@ -792,7 +815,7 @@ private constructor( private val commit: JsonField, private val datasetSplits: JsonField>, private val evaluatorRules: JsonField>, - private val metadata: JsonValue, + private val metadata: JsonField, private val owner: JsonField, private val parallelToolCalls: JsonField, private val repetitions: JsonField, @@ -827,7 +850,9 @@ private constructor( @JsonProperty("evaluator_rules") @ExcludeMissing evaluatorRules: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("owner") @ExcludeMissing owner: JsonField = JsonMissing.of(), @JsonProperty("parallel_tool_calls") @ExcludeMissing @@ -925,7 +950,11 @@ private constructor( */ fun evaluatorRules(): Optional> = evaluatorRules.getOptional("evaluator_rules") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1054,6 +1083,13 @@ private constructor( @ExcludeMissing fun _evaluatorRules(): JsonField> = evaluatorRules + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [owner]. * @@ -1189,7 +1225,7 @@ private constructor( private var commit: JsonField = JsonMissing.of() private var datasetSplits: JsonField>? = null private var evaluatorRules: JsonField>? = null - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var owner: JsonField = JsonMissing.of() private var parallelToolCalls: JsonField = JsonMissing.of() private var repetitions: JsonField = JsonMissing.of() @@ -1351,7 +1387,19 @@ private constructor( } } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun owner(owner: String?) = owner(JsonField.ofNullable(owner)) @@ -1625,6 +1673,7 @@ private constructor( commit() datasetSplits() evaluatorRules() + metadata().ifPresent { it.validate() } owner() parallelToolCalls() repetitions() @@ -1662,6 +1711,7 @@ private constructor( (if (commit.asKnown().isPresent) 1 else 0) + (datasetSplits.asKnown().getOrNull()?.size ?: 0) + (evaluatorRules.asKnown().getOrNull()?.size ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (owner.asKnown().isPresent) 1 else 0) + (if (parallelToolCalls.asKnown().isPresent) 1 else 0) + (if (repetitions.asKnown().isPresent) 1 else 0) + @@ -1834,6 +1884,105 @@ private constructor( override fun toString() = "Secrets{additionalProperties=$additionalProperties}" } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfig.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfig.kt index d133c8fb..175ed8fd 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfig.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfig.kt @@ -34,9 +34,9 @@ class RunnableConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val callbacks: JsonField, - private val configurable: JsonValue, + private val configurable: JsonField, private val maxConcurrency: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val recursionLimit: JsonField, private val runId: JsonField, private val runName: JsonField, @@ -49,11 +49,13 @@ private constructor( @JsonProperty("callbacks") @ExcludeMissing callbacks: JsonField = JsonMissing.of(), - @JsonProperty("configurable") @ExcludeMissing configurable: JsonValue = JsonMissing.of(), + @JsonProperty("configurable") + @ExcludeMissing + configurable: JsonField = JsonMissing.of(), @JsonProperty("max_concurrency") @ExcludeMissing maxConcurrency: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("recursion_limit") @ExcludeMissing recursionLimit: JsonField = JsonMissing.of(), @@ -78,7 +80,11 @@ private constructor( */ fun callbacks(): Optional = callbacks.getOptional("callbacks") - @JsonProperty("configurable") @ExcludeMissing fun _configurable(): JsonValue = configurable + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configurable(): Optional = configurable.getOptional("configurable") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -86,7 +92,11 @@ private constructor( */ fun maxConcurrency(): Optional = maxConcurrency.getOptional("max_concurrency") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -119,6 +129,15 @@ private constructor( */ @JsonProperty("callbacks") @ExcludeMissing fun _callbacks(): JsonField = callbacks + /** + * Returns the raw JSON value of [configurable]. + * + * Unlike [configurable], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configurable") + @ExcludeMissing + fun _configurable(): JsonField = configurable + /** * Returns the raw JSON value of [maxConcurrency]. * @@ -128,6 +147,13 @@ private constructor( @ExcludeMissing fun _maxConcurrency(): JsonField = maxConcurrency + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [recursionLimit]. * @@ -180,9 +206,9 @@ private constructor( class Builder internal constructor() { private var callbacks: JsonField = JsonMissing.of() - private var configurable: JsonValue = JsonMissing.of() + private var configurable: JsonField = JsonMissing.of() private var maxConcurrency: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var recursionLimit: JsonField = JsonMissing.of() private var runId: JsonField = JsonMissing.of() private var runName: JsonField = JsonMissing.of() @@ -223,7 +249,18 @@ private constructor( /** Alias for calling [callbacks] with `Callbacks.ofJsonValue(jsonValue)`. */ fun callbacks(jsonValue: JsonValue) = callbacks(Callbacks.ofJsonValue(jsonValue)) - fun configurable(configurable: JsonValue) = apply { this.configurable = configurable } + fun configurable(configurable: Configurable) = configurable(JsonField.of(configurable)) + + /** + * Sets [Builder.configurable] to an arbitrary JSON value. + * + * You should usually call [Builder.configurable] with a well-typed [Configurable] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurable(configurable: JsonField) = apply { + this.configurable = configurable + } fun maxConcurrency(maxConcurrency: Long?) = maxConcurrency(JsonField.ofNullable(maxConcurrency)) @@ -250,7 +287,16 @@ private constructor( this.maxConcurrency = maxConcurrency } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun recursionLimit(recursionLimit: Long) = recursionLimit(JsonField.of(recursionLimit)) @@ -356,7 +402,9 @@ private constructor( } callbacks().ifPresent { it.validate() } + configurable().ifPresent { it.validate() } maxConcurrency() + metadata().ifPresent { it.validate() } recursionLimit() runId() runName() @@ -380,7 +428,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (callbacks.asKnown().getOrNull()?.validity() ?: 0) + + (configurable.asKnown().getOrNull()?.validity() ?: 0) + (if (maxConcurrency.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (recursionLimit.asKnown().isPresent) 1 else 0) + (if (runId.asKnown().isPresent) 1 else 0) + (if (runName.asKnown().isPresent) 1 else 0) + @@ -559,6 +609,204 @@ private constructor( } } + class Configurable + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Configurable]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Configurable]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(configurable: Configurable) = apply { + additionalProperties = configurable.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) + } + + /** + * Returns an immutable instance of [Configurable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Configurable = Configurable(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Configurable = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Configurable && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Configurable{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRuns.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRuns.kt index a91383fd..eccca0c0 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRuns.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRuns.kt @@ -27,14 +27,14 @@ class ExampleWithRuns private constructor( private val id: JsonField, private val datasetId: JsonField, - private val inputs: JsonValue, + private val inputs: JsonField, private val name: JsonField, private val runs: JsonField>, - private val attachmentUrls: JsonValue, + private val attachmentUrls: JsonField, private val createdAt: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val modifiedAt: JsonField, - private val outputs: JsonValue, + private val outputs: JsonField, private val sourceRunId: JsonField, private val additionalProperties: MutableMap, ) { @@ -43,20 +43,20 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("runs") @ExcludeMissing runs: JsonField> = JsonMissing.of(), @JsonProperty("attachment_urls") @ExcludeMissing - attachmentUrls: JsonValue = JsonMissing.of(), + attachmentUrls: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("modified_at") @ExcludeMissing modifiedAt: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("source_run_id") @ExcludeMissing sourceRunId: JsonField = JsonMissing.of(), @@ -87,7 +87,11 @@ private constructor( */ fun datasetId(): String = datasetId.getRequired("dataset_id") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputs(): Inputs = inputs.getRequired("inputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -101,9 +105,11 @@ private constructor( */ fun runs(): List = runs.getRequired("runs") - @JsonProperty("attachment_urls") - @ExcludeMissing - fun _attachmentUrls(): JsonValue = attachmentUrls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attachmentUrls(): Optional = attachmentUrls.getOptional("attachment_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -111,7 +117,11 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -119,7 +129,11 @@ private constructor( */ fun modifiedAt(): Optional = modifiedAt.getOptional("modified_at") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -141,6 +155,13 @@ private constructor( */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + /** * Returns the raw JSON value of [name]. * @@ -155,6 +176,15 @@ private constructor( */ @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField> = runs + /** + * Returns the raw JSON value of [attachmentUrls]. + * + * Unlike [attachmentUrls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attachment_urls") + @ExcludeMissing + fun _attachmentUrls(): JsonField = attachmentUrls + /** * Returns the raw JSON value of [createdAt]. * @@ -164,6 +194,13 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [modifiedAt]. * @@ -173,6 +210,13 @@ private constructor( @ExcludeMissing fun _modifiedAt(): JsonField = modifiedAt + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [sourceRunId]. * @@ -216,14 +260,14 @@ private constructor( private var id: JsonField? = null private var datasetId: JsonField? = null - private var inputs: JsonValue? = null + private var inputs: JsonField? = null private var name: JsonField? = null private var runs: JsonField>? = null - private var attachmentUrls: JsonValue = JsonMissing.of() + private var attachmentUrls: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var modifiedAt: JsonField = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var sourceRunId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -264,7 +308,15 @@ private constructor( */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs) = inputs(JsonField.of(inputs)) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } fun name(name: String) = name(JsonField.of(name)) @@ -295,7 +347,21 @@ private constructor( runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } } - fun attachmentUrls(attachmentUrls: JsonValue) = apply { + fun attachmentUrls(attachmentUrls: AttachmentUrls?) = + attachmentUrls(JsonField.ofNullable(attachmentUrls)) + + /** Alias for calling [Builder.attachmentUrls] with `attachmentUrls.orElse(null)`. */ + fun attachmentUrls(attachmentUrls: Optional) = + attachmentUrls(attachmentUrls.getOrNull()) + + /** + * Sets [Builder.attachmentUrls] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentUrls] with a well-typed [AttachmentUrls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attachmentUrls(attachmentUrls: JsonField) = apply { this.attachmentUrls = attachmentUrls } @@ -310,7 +376,19 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) @@ -328,7 +406,18 @@ private constructor( this.modifiedAt = modifiedAt } - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) @@ -405,10 +494,14 @@ private constructor( id() datasetId() + inputs().validate() name() runs().forEach { it.validate() } + attachmentUrls().ifPresent { it.validate() } createdAt() + metadata().ifPresent { it.validate() } modifiedAt() + outputs().ifPresent { it.validate() } sourceRunId() validated = true } @@ -430,12 +523,115 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (datasetId.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (attachmentUrls.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (sourceRunId.asKnown().isPresent) 1 else 0) + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + /** Run schema. */ class Run @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -456,21 +652,21 @@ private constructor( private val directChildRunIds: JsonField>, private val endTime: JsonField, private val error: JsonField, - private val events: JsonField>, + private val events: JsonField>, private val executionOrder: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val feedbackStats: JsonField, private val firstTokenTime: JsonField, private val inDataset: JsonField, - private val inputs: JsonValue, + private val inputs: JsonField, private val inputsPreview: JsonField, - private val inputsS3Urls: JsonValue, + private val inputsS3Urls: JsonField, private val lastQueuedAt: JsonField, private val manifestId: JsonField, private val manifestS3Id: JsonField, - private val outputs: JsonValue, + private val outputs: JsonField, private val outputsPreview: JsonField, - private val outputsS3Urls: JsonValue, + private val outputsS3Urls: JsonField, private val parentRunId: JsonField, private val parentRunIds: JsonField>, private val priceModelId: JsonField, @@ -480,8 +676,8 @@ private constructor( private val promptTokens: JsonField, private val referenceDatasetId: JsonField, private val referenceExampleId: JsonField, - private val s3Urls: JsonValue, - private val serialized: JsonValue, + private val s3Urls: JsonField, + private val serialized: JsonField, private val shareToken: JsonField, private val startTime: JsonField, private val tags: JsonField>, @@ -537,11 +733,11 @@ private constructor( @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), @JsonProperty("events") @ExcludeMissing - events: JsonField> = JsonMissing.of(), + events: JsonField> = JsonMissing.of(), @JsonProperty("execution_order") @ExcludeMissing executionOrder: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonField = JsonMissing.of(), @@ -551,13 +747,13 @@ private constructor( @JsonProperty("in_dataset") @ExcludeMissing inDataset: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), @JsonProperty("inputs_preview") @ExcludeMissing inputsPreview: JsonField = JsonMissing.of(), @JsonProperty("inputs_s3_urls") @ExcludeMissing - inputsS3Urls: JsonValue = JsonMissing.of(), + inputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("last_queued_at") @ExcludeMissing lastQueuedAt: JsonField = JsonMissing.of(), @@ -567,13 +763,13 @@ private constructor( @JsonProperty("manifest_s3_id") @ExcludeMissing manifestS3Id: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("outputs_preview") @ExcludeMissing outputsPreview: JsonField = JsonMissing.of(), @JsonProperty("outputs_s3_urls") @ExcludeMissing - outputsS3Urls: JsonValue = JsonMissing.of(), + outputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("parent_run_id") @ExcludeMissing parentRunId: JsonField = JsonMissing.of(), @@ -601,8 +797,10 @@ private constructor( @JsonProperty("reference_example_id") @ExcludeMissing referenceExampleId: JsonField = JsonMissing.of(), - @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), - @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonField = JsonMissing.of(), + @JsonProperty("serialized") + @ExcludeMissing + serialized: JsonField = JsonMissing.of(), @JsonProperty("share_token") @ExcludeMissing shareToken: JsonField = JsonMissing.of(), @@ -800,7 +998,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun events(): Optional> = events.getOptional("events") + fun events(): Optional> = events.getOptional("events") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -808,7 +1006,11 @@ private constructor( */ fun executionOrder(): Optional = executionOrder.getOptional("execution_order") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -829,7 +1031,11 @@ private constructor( */ fun inDataset(): Optional = inDataset.getOptional("in_dataset") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -837,9 +1043,11 @@ private constructor( */ fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") - @JsonProperty("inputs_s3_urls") - @ExcludeMissing - fun _inputsS3Urls(): JsonValue = inputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsS3Urls(): Optional = inputsS3Urls.getOptional("inputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -859,7 +1067,11 @@ private constructor( */ fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -867,9 +1079,11 @@ private constructor( */ fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") - @JsonProperty("outputs_s3_urls") - @ExcludeMissing - fun _outputsS3Urls(): JsonValue = outputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsS3Urls(): Optional = outputsS3Urls.getOptional("outputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -929,9 +1143,17 @@ private constructor( fun referenceExampleId(): Optional = referenceExampleId.getOptional("reference_example_id") - @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun s3Urls(): Optional = s3Urls.getOptional("s3_urls") - @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun serialized(): Optional = serialized.getOptional("serialized") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1146,7 +1368,7 @@ private constructor( * * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Returns the raw JSON value of [executionOrder]. @@ -1158,6 +1380,13 @@ private constructor( @ExcludeMissing fun _executionOrder(): JsonField = executionOrder + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [feedbackStats]. * @@ -1185,6 +1414,13 @@ private constructor( */ @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField = inDataset + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + /** * Returns the raw JSON value of [inputsPreview]. * @@ -1195,6 +1431,16 @@ private constructor( @ExcludeMissing fun _inputsPreview(): JsonField = inputsPreview + /** + * Returns the raw JSON value of [inputsS3Urls]. + * + * Unlike [inputsS3Urls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + fun _inputsS3Urls(): JsonField = inputsS3Urls + /** * Returns the raw JSON value of [lastQueuedAt]. * @@ -1224,6 +1470,13 @@ private constructor( @ExcludeMissing fun _manifestS3Id(): JsonField = manifestS3Id + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [outputsPreview]. * @@ -1234,6 +1487,16 @@ private constructor( @ExcludeMissing fun _outputsPreview(): JsonField = outputsPreview + /** + * Returns the raw JSON value of [outputsS3Urls]. + * + * Unlike [outputsS3Urls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + fun _outputsS3Urls(): JsonField = outputsS3Urls + /** * Returns the raw JSON value of [parentRunId]. * @@ -1322,6 +1585,22 @@ private constructor( @ExcludeMissing fun _referenceExampleId(): JsonField = referenceExampleId + /** + * Returns the raw JSON value of [s3Urls]. + * + * Unlike [s3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonField = s3Urls + + /** + * Returns the raw JSON value of [serialized]. + * + * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("serialized") + @ExcludeMissing + fun _serialized(): JsonField = serialized + /** * Returns the raw JSON value of [shareToken]. * @@ -1477,21 +1756,21 @@ private constructor( private var directChildRunIds: JsonField>? = null private var endTime: JsonField = JsonMissing.of() private var error: JsonField = JsonMissing.of() - private var events: JsonField>? = null + private var events: JsonField>? = null private var executionOrder: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var feedbackStats: JsonField = JsonMissing.of() private var firstTokenTime: JsonField = JsonMissing.of() private var inDataset: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() private var inputsPreview: JsonField = JsonMissing.of() - private var inputsS3Urls: JsonValue = JsonMissing.of() + private var inputsS3Urls: JsonField = JsonMissing.of() private var lastQueuedAt: JsonField = JsonMissing.of() private var manifestId: JsonField = JsonMissing.of() private var manifestS3Id: JsonField = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var outputsPreview: JsonField = JsonMissing.of() - private var outputsS3Urls: JsonValue = JsonMissing.of() + private var outputsS3Urls: JsonField = JsonMissing.of() private var parentRunId: JsonField = JsonMissing.of() private var parentRunIds: JsonField>? = null private var priceModelId: JsonField = JsonMissing.of() @@ -1501,8 +1780,8 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() private var referenceExampleId: JsonField = JsonMissing.of() - private var s3Urls: JsonValue = JsonMissing.of() - private var serialized: JsonValue = JsonMissing.of() + private var s3Urls: JsonField = JsonMissing.of() + private var serialized: JsonField = JsonMissing.of() private var shareToken: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var tags: JsonField>? = null @@ -1833,28 +2112,28 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } - fun events(events: List?) = events(JsonField.ofNullable(events)) + fun events(events: List?) = events(JsonField.ofNullable(events)) /** Alias for calling [Builder.events] with `events.orElse(null)`. */ - fun events(events: Optional>) = events(events.getOrNull()) + fun events(events: Optional>) = events(events.getOrNull()) /** * Sets [Builder.events] to an arbitrary JSON value. * - * You should usually call [Builder.events] with a well-typed `List` value + * You should usually call [Builder.events] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun events(events: JsonField>) = apply { + fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [events]. + * Adds a single [Event] to [events]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addEvent(event: JsonValue) = apply { + fun addEvent(event: Event) = apply { events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) @@ -1874,7 +2153,19 @@ private constructor( this.executionOrder = executionOrder } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun feedbackStats(feedbackStats: FeedbackStats?) = feedbackStats(JsonField.ofNullable(feedbackStats)) @@ -1933,7 +2224,19 @@ private constructor( */ fun inDataset(inDataset: JsonField) = apply { this.inDataset = inDataset } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) + + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } fun inputsPreview(inputsPreview: String?) = inputsPreview(JsonField.ofNullable(inputsPreview)) @@ -1953,7 +2256,23 @@ private constructor( this.inputsPreview = inputsPreview } - fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + fun inputsS3Urls(inputsS3Urls: InputsS3Urls?) = + inputsS3Urls(JsonField.ofNullable(inputsS3Urls)) + + /** Alias for calling [Builder.inputsS3Urls] with `inputsS3Urls.orElse(null)`. */ + fun inputsS3Urls(inputsS3Urls: Optional) = + inputsS3Urls(inputsS3Urls.getOrNull()) + + /** + * Sets [Builder.inputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsS3Urls] with a well-typed [InputsS3Urls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputsS3Urls(inputsS3Urls: JsonField) = apply { + this.inputsS3Urls = inputsS3Urls + } fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) @@ -2005,7 +2324,19 @@ private constructor( this.manifestS3Id = manifestS3Id } - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun outputsPreview(outputsPreview: String?) = outputsPreview(JsonField.ofNullable(outputsPreview)) @@ -2025,7 +2356,21 @@ private constructor( this.outputsPreview = outputsPreview } - fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { + fun outputsS3Urls(outputsS3Urls: OutputsS3Urls?) = + outputsS3Urls(JsonField.ofNullable(outputsS3Urls)) + + /** Alias for calling [Builder.outputsS3Urls] with `outputsS3Urls.orElse(null)`. */ + fun outputsS3Urls(outputsS3Urls: Optional) = + outputsS3Urls(outputsS3Urls.getOrNull()) + + /** + * Sets [Builder.outputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsS3Urls] with a well-typed [OutputsS3Urls] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputsS3Urls(outputsS3Urls: JsonField) = apply { this.outputsS3Urls = outputsS3Urls } @@ -2203,9 +2548,35 @@ private constructor( this.referenceExampleId = referenceExampleId } - fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + fun s3Urls(s3Urls: S3Urls?) = s3Urls(JsonField.ofNullable(s3Urls)) - fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + /** Alias for calling [Builder.s3Urls] with `s3Urls.orElse(null)`. */ + fun s3Urls(s3Urls: Optional) = s3Urls(s3Urls.getOrNull()) + + /** + * Sets [Builder.s3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.s3Urls] with a well-typed [S3Urls] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun s3Urls(s3Urls: JsonField) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: Serialized?) = serialized(JsonField.ofNullable(serialized)) + + /** Alias for calling [Builder.serialized] with `serialized.orElse(null)`. */ + fun serialized(serialized: Optional) = serialized(serialized.getOrNull()) + + /** + * Sets [Builder.serialized] to an arbitrary JSON value. + * + * You should usually call [Builder.serialized] with a well-typed [Serialized] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serialized(serialized: JsonField) = apply { + this.serialized = serialized + } fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) @@ -2529,16 +2900,21 @@ private constructor( directChildRunIds() endTime() error() - events() + events().ifPresent { it.forEach { it.validate() } } executionOrder() + extra().ifPresent { it.validate() } feedbackStats().ifPresent { it.validate() } firstTokenTime() inDataset() + inputs().ifPresent { it.validate() } inputsPreview() + inputsS3Urls().ifPresent { it.validate() } lastQueuedAt() manifestId() manifestS3Id() + outputs().ifPresent { it.validate() } outputsPreview() + outputsS3Urls().ifPresent { it.validate() } parentRunId() parentRunIds() priceModelId() @@ -2548,6 +2924,8 @@ private constructor( promptTokens() referenceDatasetId() referenceExampleId() + s3Urls().ifPresent { it.validate() } + serialized().ifPresent { it.validate() } shareToken() startTime() tags() @@ -2595,16 +2973,21 @@ private constructor( (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + (if (endTime.asKnown().isPresent) 1 else 0) + (if (error.asKnown().isPresent) 1 else 0) + - (events.asKnown().getOrNull()?.size ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + (if (inDataset.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (inputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + (if (manifestId.asKnown().isPresent) 1 else 0) + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (outputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (parentRunId.asKnown().isPresent) 1 else 0) + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + (if (priceModelId.asKnown().isPresent) 1 else 0) + @@ -2614,6 +2997,8 @@ private constructor( (if (promptTokens.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (s3Urls.asKnown().getOrNull()?.validity() ?: 0) + + (serialized.asKnown().getOrNull()?.validity() ?: 0) + (if (shareToken.asKnown().isPresent) 1 else 0) + (if (startTime.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + @@ -3005,6 +3390,210 @@ private constructor( "CompletionTokenDetails{additionalProperties=$additionalProperties}" } + class Event + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Event]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Event]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(event: Event) = apply { + additionalProperties = event.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) + } + + /** + * Returns an immutable instance of [Event]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Event = Event(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Event = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Event && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Event{additionalProperties=$additionalProperties}" + } + + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + class FeedbackStats @JsonCreator private constructor( @@ -3107,6 +3696,414 @@ private constructor( override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" } + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class InputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsS3Urls: InputsS3Urls) = apply { + additionalProperties = inputsS3Urls.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) + } + + /** + * Returns an immutable instance of [InputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsS3Urls = InputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "InputsS3Urls{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + + class OutputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OutputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsS3Urls: OutputsS3Urls) = apply { + additionalProperties = outputsS3Urls.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) + } + + /** + * Returns an immutable instance of [OutputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsS3Urls = OutputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OutputsS3Urls{additionalProperties=$additionalProperties}" + } + class PromptCostDetails @JsonCreator private constructor( @@ -3321,6 +4318,210 @@ private constructor( "PromptTokenDetails{additionalProperties=$additionalProperties}" } + class S3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [S3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3Urls: S3Urls) = apply { + additionalProperties = s3Urls.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) + } + + /** + * Returns an immutable instance of [S3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): S3Urls = S3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): S3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "S3Urls{additionalProperties=$additionalProperties}" + } + + class Serialized + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Serialized]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Serialized]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serialized: Serialized) = apply { + additionalProperties = serialized.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) + } + + /** + * Returns an immutable instance of [Serialized]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Serialized = Serialized(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Serialized = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Serialized && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Serialized{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3581,6 +4782,303 @@ private constructor( "Run{id=$id, appPath=$appPath, dottedOrder=$dottedOrder, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inDataset=$inDataset, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, lastQueuedAt=$lastQueuedAt, manifestId=$manifestId, manifestS3Id=$manifestS3Id, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, shareToken=$shareToken, startTime=$startTime, tags=$tags, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceFirstReceivedAt=$traceFirstReceivedAt, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, traceTier=$traceTier, traceUpgrade=$traceUpgrade, ttlSeconds=$ttlSeconds, additionalProperties=$additionalProperties}" } + class AttachmentUrls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AttachmentUrls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentUrls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentUrls: AttachmentUrls) = apply { + additionalProperties = attachmentUrls.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) + } + + /** + * Returns an immutable instance of [AttachmentUrls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AttachmentUrls = AttachmentUrls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AttachmentUrls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentUrls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AttachmentUrls{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt index 2c44d0cc..c6b90e50 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt @@ -33,14 +33,14 @@ class ExampleWithRunsCh private constructor( private val id: JsonField, private val datasetId: JsonField, - private val inputs: JsonValue, + private val inputs: JsonField, private val name: JsonField, private val runs: JsonField>, - private val attachmentUrls: JsonValue, + private val attachmentUrls: JsonField, private val createdAt: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val modifiedAt: JsonField, - private val outputs: JsonValue, + private val outputs: JsonField, private val sourceRunId: JsonField, private val additionalProperties: MutableMap, ) { @@ -49,20 +49,20 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("runs") @ExcludeMissing runs: JsonField> = JsonMissing.of(), @JsonProperty("attachment_urls") @ExcludeMissing - attachmentUrls: JsonValue = JsonMissing.of(), + attachmentUrls: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("modified_at") @ExcludeMissing modifiedAt: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("source_run_id") @ExcludeMissing sourceRunId: JsonField = JsonMissing.of(), @@ -93,7 +93,11 @@ private constructor( */ fun datasetId(): String = datasetId.getRequired("dataset_id") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputs(): Inputs = inputs.getRequired("inputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -107,9 +111,11 @@ private constructor( */ fun runs(): List = runs.getRequired("runs") - @JsonProperty("attachment_urls") - @ExcludeMissing - fun _attachmentUrls(): JsonValue = attachmentUrls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attachmentUrls(): Optional = attachmentUrls.getOptional("attachment_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -117,7 +123,11 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -125,7 +135,11 @@ private constructor( */ fun modifiedAt(): Optional = modifiedAt.getOptional("modified_at") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -147,6 +161,13 @@ private constructor( */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + /** * Returns the raw JSON value of [name]. * @@ -161,6 +182,15 @@ private constructor( */ @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField> = runs + /** + * Returns the raw JSON value of [attachmentUrls]. + * + * Unlike [attachmentUrls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attachment_urls") + @ExcludeMissing + fun _attachmentUrls(): JsonField = attachmentUrls + /** * Returns the raw JSON value of [createdAt]. * @@ -170,6 +200,13 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [modifiedAt]. * @@ -179,6 +216,13 @@ private constructor( @ExcludeMissing fun _modifiedAt(): JsonField = modifiedAt + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [sourceRunId]. * @@ -222,14 +266,14 @@ private constructor( private var id: JsonField? = null private var datasetId: JsonField? = null - private var inputs: JsonValue? = null + private var inputs: JsonField? = null private var name: JsonField? = null private var runs: JsonField>? = null - private var attachmentUrls: JsonValue = JsonMissing.of() + private var attachmentUrls: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var modifiedAt: JsonField = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var sourceRunId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -270,7 +314,15 @@ private constructor( */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs) = inputs(JsonField.of(inputs)) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } fun name(name: String) = name(JsonField.of(name)) @@ -301,7 +353,21 @@ private constructor( runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } } - fun attachmentUrls(attachmentUrls: JsonValue) = apply { + fun attachmentUrls(attachmentUrls: AttachmentUrls?) = + attachmentUrls(JsonField.ofNullable(attachmentUrls)) + + /** Alias for calling [Builder.attachmentUrls] with `attachmentUrls.orElse(null)`. */ + fun attachmentUrls(attachmentUrls: Optional) = + attachmentUrls(attachmentUrls.getOrNull()) + + /** + * Sets [Builder.attachmentUrls] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentUrls] with a well-typed [AttachmentUrls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attachmentUrls(attachmentUrls: JsonField) = apply { this.attachmentUrls = attachmentUrls } @@ -316,7 +382,19 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) @@ -334,7 +412,18 @@ private constructor( this.modifiedAt = modifiedAt } - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) @@ -411,10 +500,14 @@ private constructor( id() datasetId() + inputs().validate() name() runs().forEach { it.validate() } + attachmentUrls().ifPresent { it.validate() } createdAt() + metadata().ifPresent { it.validate() } modifiedAt() + outputs().ifPresent { it.validate() } sourceRunId() validated = true } @@ -436,12 +529,115 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (datasetId.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (attachmentUrls.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (sourceRunId.asKnown().isPresent) 1 else 0) + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + /** Run schema for comparison view. */ class Run @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -458,24 +654,24 @@ private constructor( private val dottedOrder: JsonField, private val endTime: JsonField, private val error: JsonField, - private val events: JsonField>, + private val events: JsonField>, private val executionOrder: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val feedbackStats: JsonField, - private val inputs: JsonValue, + private val inputs: JsonField, private val inputsPreview: JsonField, - private val inputsS3Urls: JsonValue, + private val inputsS3Urls: JsonField, private val manifestId: JsonField, private val manifestS3Id: JsonField, - private val outputs: JsonValue, + private val outputs: JsonField, private val outputsPreview: JsonField, - private val outputsS3Urls: JsonValue, + private val outputsS3Urls: JsonField, private val parentRunId: JsonField, private val promptCost: JsonField, private val promptTokens: JsonField, private val referenceExampleId: JsonField, - private val s3Urls: JsonValue, - private val serialized: JsonValue, + private val s3Urls: JsonField, + private val serialized: JsonField, private val startTime: JsonField, private val tags: JsonField>, private val totalCost: JsonField, @@ -513,34 +709,34 @@ private constructor( @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), @JsonProperty("events") @ExcludeMissing - events: JsonField> = JsonMissing.of(), + events: JsonField> = JsonMissing.of(), @JsonProperty("execution_order") @ExcludeMissing executionOrder: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), @JsonProperty("inputs_preview") @ExcludeMissing inputsPreview: JsonField = JsonMissing.of(), @JsonProperty("inputs_s3_urls") @ExcludeMissing - inputsS3Urls: JsonValue = JsonMissing.of(), + inputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("manifest_id") @ExcludeMissing manifestId: JsonField = JsonMissing.of(), @JsonProperty("manifest_s3_id") @ExcludeMissing manifestS3Id: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("outputs_preview") @ExcludeMissing outputsPreview: JsonField = JsonMissing.of(), @JsonProperty("outputs_s3_urls") @ExcludeMissing - outputsS3Urls: JsonValue = JsonMissing.of(), + outputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("parent_run_id") @ExcludeMissing parentRunId: JsonField = JsonMissing.of(), @@ -553,8 +749,10 @@ private constructor( @JsonProperty("reference_example_id") @ExcludeMissing referenceExampleId: JsonField = JsonMissing.of(), - @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), - @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonField = JsonMissing.of(), + @JsonProperty("serialized") + @ExcludeMissing + serialized: JsonField = JsonMissing.of(), @JsonProperty("start_time") @ExcludeMissing startTime: JsonField = JsonMissing.of(), @@ -689,7 +887,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun events(): Optional> = events.getOptional("events") + fun events(): Optional> = events.getOptional("events") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -697,7 +895,11 @@ private constructor( */ fun executionOrder(): Optional = executionOrder.getOptional("execution_order") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -705,7 +907,11 @@ private constructor( */ fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -713,9 +919,11 @@ private constructor( */ fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") - @JsonProperty("inputs_s3_urls") - @ExcludeMissing - fun _inputsS3Urls(): JsonValue = inputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsS3Urls(): Optional = inputsS3Urls.getOptional("inputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -729,7 +937,11 @@ private constructor( */ fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -737,9 +949,11 @@ private constructor( */ fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") - @JsonProperty("outputs_s3_urls") - @ExcludeMissing - fun _outputsS3Urls(): JsonValue = outputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsS3Urls(): Optional = outputsS3Urls.getOptional("outputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -766,9 +980,17 @@ private constructor( fun referenceExampleId(): Optional = referenceExampleId.getOptional("reference_example_id") - @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun s3Urls(): Optional = s3Urls.getOptional("s3_urls") - @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun serialized(): Optional = serialized.getOptional("serialized") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -907,7 +1129,7 @@ private constructor( * * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Returns the raw JSON value of [executionOrder]. @@ -919,6 +1141,13 @@ private constructor( @ExcludeMissing fun _executionOrder(): JsonField = executionOrder + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [feedbackStats]. * @@ -929,6 +1158,13 @@ private constructor( @ExcludeMissing fun _feedbackStats(): JsonField = feedbackStats + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + /** * Returns the raw JSON value of [inputsPreview]. * @@ -939,6 +1175,16 @@ private constructor( @ExcludeMissing fun _inputsPreview(): JsonField = inputsPreview + /** + * Returns the raw JSON value of [inputsS3Urls]. + * + * Unlike [inputsS3Urls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + fun _inputsS3Urls(): JsonField = inputsS3Urls + /** * Returns the raw JSON value of [manifestId]. * @@ -958,6 +1204,13 @@ private constructor( @ExcludeMissing fun _manifestS3Id(): JsonField = manifestS3Id + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [outputsPreview]. * @@ -968,6 +1221,16 @@ private constructor( @ExcludeMissing fun _outputsPreview(): JsonField = outputsPreview + /** + * Returns the raw JSON value of [outputsS3Urls]. + * + * Unlike [outputsS3Urls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + fun _outputsS3Urls(): JsonField = outputsS3Urls + /** * Returns the raw JSON value of [parentRunId]. * @@ -1006,6 +1269,22 @@ private constructor( @ExcludeMissing fun _referenceExampleId(): JsonField = referenceExampleId + /** + * Returns the raw JSON value of [s3Urls]. + * + * Unlike [s3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonField = s3Urls + + /** + * Returns the raw JSON value of [serialized]. + * + * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("serialized") + @ExcludeMissing + fun _serialized(): JsonField = serialized + /** * Returns the raw JSON value of [startTime]. * @@ -1103,24 +1382,24 @@ private constructor( private var dottedOrder: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() private var error: JsonField = JsonMissing.of() - private var events: JsonField>? = null + private var events: JsonField>? = null private var executionOrder: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var feedbackStats: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() private var inputsPreview: JsonField = JsonMissing.of() - private var inputsS3Urls: JsonValue = JsonMissing.of() + private var inputsS3Urls: JsonField = JsonMissing.of() private var manifestId: JsonField = JsonMissing.of() private var manifestS3Id: JsonField = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var outputsPreview: JsonField = JsonMissing.of() - private var outputsS3Urls: JsonValue = JsonMissing.of() + private var outputsS3Urls: JsonField = JsonMissing.of() private var parentRunId: JsonField = JsonMissing.of() private var promptCost: JsonField = JsonMissing.of() private var promptTokens: JsonField = JsonMissing.of() private var referenceExampleId: JsonField = JsonMissing.of() - private var s3Urls: JsonValue = JsonMissing.of() - private var serialized: JsonValue = JsonMissing.of() + private var s3Urls: JsonField = JsonMissing.of() + private var serialized: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var totalCost: JsonField = JsonMissing.of() @@ -1341,28 +1620,28 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } - fun events(events: List?) = events(JsonField.ofNullable(events)) + fun events(events: List?) = events(JsonField.ofNullable(events)) /** Alias for calling [Builder.events] with `events.orElse(null)`. */ - fun events(events: Optional>) = events(events.getOrNull()) + fun events(events: Optional>) = events(events.getOrNull()) /** * Sets [Builder.events] to an arbitrary JSON value. * - * You should usually call [Builder.events] with a well-typed `List` value + * You should usually call [Builder.events] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun events(events: JsonField>) = apply { + fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [events]. + * Adds a single [Event] to [events]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addEvent(event: JsonValue) = apply { + fun addEvent(event: Event) = apply { events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) @@ -1382,7 +1661,19 @@ private constructor( this.executionOrder = executionOrder } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun feedbackStats(feedbackStats: FeedbackStats?) = feedbackStats(JsonField.ofNullable(feedbackStats)) @@ -1402,7 +1693,19 @@ private constructor( this.feedbackStats = feedbackStats } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) + + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } fun inputsPreview(inputsPreview: String?) = inputsPreview(JsonField.ofNullable(inputsPreview)) @@ -1422,7 +1725,23 @@ private constructor( this.inputsPreview = inputsPreview } - fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + fun inputsS3Urls(inputsS3Urls: InputsS3Urls?) = + inputsS3Urls(JsonField.ofNullable(inputsS3Urls)) + + /** Alias for calling [Builder.inputsS3Urls] with `inputsS3Urls.orElse(null)`. */ + fun inputsS3Urls(inputsS3Urls: Optional) = + inputsS3Urls(inputsS3Urls.getOrNull()) + + /** + * Sets [Builder.inputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsS3Urls] with a well-typed [InputsS3Urls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputsS3Urls(inputsS3Urls: JsonField) = apply { + this.inputsS3Urls = inputsS3Urls + } fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) @@ -1456,7 +1775,19 @@ private constructor( this.manifestS3Id = manifestS3Id } - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun outputsPreview(outputsPreview: String?) = outputsPreview(JsonField.ofNullable(outputsPreview)) @@ -1476,7 +1807,21 @@ private constructor( this.outputsPreview = outputsPreview } - fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { + fun outputsS3Urls(outputsS3Urls: OutputsS3Urls?) = + outputsS3Urls(JsonField.ofNullable(outputsS3Urls)) + + /** Alias for calling [Builder.outputsS3Urls] with `outputsS3Urls.orElse(null)`. */ + fun outputsS3Urls(outputsS3Urls: Optional) = + outputsS3Urls(outputsS3Urls.getOrNull()) + + /** + * Sets [Builder.outputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsS3Urls] with a well-typed [OutputsS3Urls] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputsS3Urls(outputsS3Urls: JsonField) = apply { this.outputsS3Urls = outputsS3Urls } @@ -1554,9 +1899,35 @@ private constructor( this.referenceExampleId = referenceExampleId } - fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + fun s3Urls(s3Urls: S3Urls?) = s3Urls(JsonField.ofNullable(s3Urls)) - fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + /** Alias for calling [Builder.s3Urls] with `s3Urls.orElse(null)`. */ + fun s3Urls(s3Urls: Optional) = s3Urls(s3Urls.getOrNull()) + + /** + * Sets [Builder.s3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.s3Urls] with a well-typed [S3Urls] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun s3Urls(s3Urls: JsonField) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: Serialized?) = serialized(JsonField.ofNullable(serialized)) + + /** Alias for calling [Builder.serialized] with `serialized.orElse(null)`. */ + fun serialized(serialized: Optional) = serialized(serialized.getOrNull()) + + /** + * Sets [Builder.serialized] to an arbitrary JSON value. + * + * You should usually call [Builder.serialized] with a well-typed [Serialized] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serialized(serialized: JsonField) = apply { + this.serialized = serialized + } fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) @@ -1769,17 +2140,24 @@ private constructor( dottedOrder() endTime() error() - events() + events().ifPresent { it.forEach { it.validate() } } executionOrder() + extra().ifPresent { it.validate() } feedbackStats().ifPresent { it.validate() } + inputs().ifPresent { it.validate() } inputsPreview() + inputsS3Urls().ifPresent { it.validate() } manifestId() manifestS3Id() + outputs().ifPresent { it.validate() } outputsPreview() + outputsS3Urls().ifPresent { it.validate() } parentRunId() promptCost() promptTokens() referenceExampleId() + s3Urls().ifPresent { it.validate() } + serialized().ifPresent { it.validate() } startTime() tags() totalCost() @@ -1817,17 +2195,24 @@ private constructor( (if (dottedOrder.asKnown().isPresent) 1 else 0) + (if (endTime.asKnown().isPresent) 1 else 0) + (if (error.asKnown().isPresent) 1 else 0) + - (events.asKnown().getOrNull()?.size ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (inputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (manifestId.asKnown().isPresent) 1 else 0) + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (outputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (parentRunId.asKnown().isPresent) 1 else 0) + (if (promptCost.asKnown().isPresent) 1 else 0) + (if (promptTokens.asKnown().isPresent) 1 else 0) + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (s3Urls.asKnown().getOrNull()?.validity() ?: 0) + + (serialized.asKnown().getOrNull()?.validity() ?: 0) + (if (startTime.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (totalCost.asKnown().isPresent) 1 else 0) + @@ -1996,6 +2381,210 @@ private constructor( override fun toString() = value.toString() } + class Event + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Event]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Event]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(event: Event) = apply { + additionalProperties = event.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) + } + + /** + * Returns an immutable instance of [Event]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Event = Event(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Event = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Event && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Event{additionalProperties=$additionalProperties}" + } + + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + class FeedbackStats @JsonCreator private constructor( @@ -2098,6 +2687,618 @@ private constructor( override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" } + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class InputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsS3Urls: InputsS3Urls) = apply { + additionalProperties = inputsS3Urls.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) + } + + /** + * Returns an immutable instance of [InputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsS3Urls = InputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "InputsS3Urls{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + + class OutputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OutputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsS3Urls: OutputsS3Urls) = apply { + additionalProperties = outputsS3Urls.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) + } + + /** + * Returns an immutable instance of [OutputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsS3Urls = OutputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OutputsS3Urls{additionalProperties=$additionalProperties}" + } + + class S3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [S3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3Urls: S3Urls) = apply { + additionalProperties = s3Urls.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) + } + + /** + * Returns an immutable instance of [S3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): S3Urls = S3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): S3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "S3Urls{additionalProperties=$additionalProperties}" + } + + class Serialized + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Serialized]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Serialized]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serialized: Serialized) = apply { + additionalProperties = serialized.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) + } + + /** + * Returns an immutable instance of [Serialized]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Serialized = Serialized(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Serialized = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Serialized && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Serialized{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2191,6 +3392,303 @@ private constructor( "Run{id=$id, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, appPath=$appPath, completionCost=$completionCost, completionTokens=$completionTokens, dottedOrder=$dottedOrder, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, manifestId=$manifestId, manifestS3Id=$manifestS3Id, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, promptCost=$promptCost, promptTokens=$promptTokens, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, startTime=$startTime, tags=$tags, totalCost=$totalCost, totalTokens=$totalTokens, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, additionalProperties=$additionalProperties}" } + class AttachmentUrls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AttachmentUrls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentUrls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentUrls: AttachmentUrls) = apply { + additionalProperties = attachmentUrls.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) + } + + /** + * Returns an immutable instance of [AttachmentUrls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AttachmentUrls = AttachmentUrls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AttachmentUrls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentUrls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AttachmentUrls{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/Example.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/Example.kt index 4af984e9..90627d59 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/Example.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/Example.kt @@ -11,6 +11,7 @@ import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -24,13 +25,13 @@ class Example private constructor( private val id: JsonField, private val datasetId: JsonField, - private val inputs: JsonValue, + private val inputs: JsonField, private val name: JsonField, - private val attachmentUrls: JsonValue, + private val attachmentUrls: JsonField, private val createdAt: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val modifiedAt: JsonField, - private val outputs: JsonValue, + private val outputs: JsonField, private val sourceRunId: JsonField, private val additionalProperties: MutableMap, ) { @@ -39,19 +40,19 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("attachment_urls") @ExcludeMissing - attachmentUrls: JsonValue = JsonMissing.of(), + attachmentUrls: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("modified_at") @ExcludeMissing modifiedAt: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("source_run_id") @ExcludeMissing sourceRunId: JsonField = JsonMissing.of(), @@ -81,7 +82,11 @@ private constructor( */ fun datasetId(): String = datasetId.getRequired("dataset_id") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputs(): Inputs = inputs.getRequired("inputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -89,9 +94,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("attachment_urls") - @ExcludeMissing - fun _attachmentUrls(): JsonValue = attachmentUrls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attachmentUrls(): Optional = attachmentUrls.getOptional("attachment_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -99,7 +106,11 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -107,7 +118,11 @@ private constructor( */ fun modifiedAt(): Optional = modifiedAt.getOptional("modified_at") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -129,6 +144,13 @@ private constructor( */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + /** * Returns the raw JSON value of [name]. * @@ -136,6 +158,15 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [attachmentUrls]. + * + * Unlike [attachmentUrls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attachment_urls") + @ExcludeMissing + fun _attachmentUrls(): JsonField = attachmentUrls + /** * Returns the raw JSON value of [createdAt]. * @@ -145,6 +176,13 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [modifiedAt]. * @@ -154,6 +192,13 @@ private constructor( @ExcludeMissing fun _modifiedAt(): JsonField = modifiedAt + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [sourceRunId]. * @@ -196,13 +241,13 @@ private constructor( private var id: JsonField? = null private var datasetId: JsonField? = null - private var inputs: JsonValue? = null + private var inputs: JsonField? = null private var name: JsonField? = null - private var attachmentUrls: JsonValue = JsonMissing.of() + private var attachmentUrls: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var modifiedAt: JsonField = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var sourceRunId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -242,7 +287,15 @@ private constructor( */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs) = inputs(JsonField.of(inputs)) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } fun name(name: String) = name(JsonField.of(name)) @@ -254,7 +307,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun attachmentUrls(attachmentUrls: JsonValue) = apply { + fun attachmentUrls(attachmentUrls: AttachmentUrls?) = + attachmentUrls(JsonField.ofNullable(attachmentUrls)) + + /** Alias for calling [Builder.attachmentUrls] with `attachmentUrls.orElse(null)`. */ + fun attachmentUrls(attachmentUrls: Optional) = + attachmentUrls(attachmentUrls.getOrNull()) + + /** + * Sets [Builder.attachmentUrls] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentUrls] with a well-typed [AttachmentUrls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attachmentUrls(attachmentUrls: JsonField) = apply { this.attachmentUrls = attachmentUrls } @@ -269,7 +336,19 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) @@ -287,7 +366,18 @@ private constructor( this.modifiedAt = modifiedAt } - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) @@ -362,9 +452,13 @@ private constructor( id() datasetId() + inputs().validate() name() + attachmentUrls().ifPresent { it.validate() } createdAt() + metadata().ifPresent { it.validate() } modifiedAt() + outputs().ifPresent { it.validate() } sourceRunId() validated = true } @@ -386,11 +480,411 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (datasetId.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + + (attachmentUrls.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (sourceRunId.asKnown().isPresent) 1 else 0) + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class AttachmentUrls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AttachmentUrls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentUrls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentUrls: AttachmentUrls) = apply { + additionalProperties = attachmentUrls.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) + } + + /** + * Returns an immutable instance of [AttachmentUrls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AttachmentUrls = AttachmentUrls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AttachmentUrls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentUrls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AttachmentUrls{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleCreateParams.kt index adc7c147..ed5e0e9a 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleCreateParams.kt @@ -59,11 +59,23 @@ private constructor( */ fun createdAt(): Optional = body.createdAt() - fun _inputs(): JsonValue = body._inputs() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputs(): Optional = body.inputs() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() - fun _outputs(): JsonValue = body._outputs() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = body.outputs() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -118,6 +130,27 @@ private constructor( */ fun _createdAt(): JsonField = body._createdAt() + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _inputs(): JsonField = body._inputs() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _outputs(): JsonField = body._outputs() + /** * Returns the raw JSON value of [sourceRunId]. * @@ -241,11 +274,45 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { body.createdAt(createdAt) } - fun inputs(inputs: JsonValue) = apply { body.inputs(inputs) } + fun inputs(inputs: Inputs?) = apply { body.inputs(inputs) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - fun outputs(outputs: JsonValue) = apply { body.outputs(outputs) } + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { body.inputs(inputs) } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun outputs(outputs: Outputs?) = apply { body.outputs(outputs) } + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { body.outputs(outputs) } fun sourceRunId(sourceRunId: String?) = apply { body.sourceRunId(sourceRunId) } @@ -483,9 +550,9 @@ private constructor( private val datasetId: JsonField, private val id: JsonField, private val createdAt: JsonField, - private val inputs: JsonValue, - private val metadata: JsonValue, - private val outputs: JsonValue, + private val inputs: JsonField, + private val metadata: JsonField, + private val outputs: JsonField, private val sourceRunId: JsonField, private val split: JsonField, private val useLegacyMessageFormat: JsonField, @@ -503,9 +570,11 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("source_run_id") @ExcludeMissing sourceRunId: JsonField = JsonMissing.of(), @@ -552,11 +621,23 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -613,6 +694,27 @@ private constructor( */ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [sourceRunId]. * @@ -690,9 +792,9 @@ private constructor( private var datasetId: JsonField? = null private var id: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var sourceRunId: JsonField = JsonMissing.of() private var split: JsonField = JsonMissing.of() private var useLegacyMessageFormat: JsonField = JsonMissing.of() @@ -752,11 +854,47 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) @@ -907,6 +1045,9 @@ private constructor( datasetId() id() createdAt() + inputs().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + outputs().ifPresent { it.validate() } sourceRunId() split().ifPresent { it.validate() } useLegacyMessageFormat() @@ -934,6 +1075,9 @@ private constructor( (if (datasetId.asKnown().isPresent) 1 else 0) + (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (sourceRunId.asKnown().isPresent) 1 else 0) + (split.asKnown().getOrNull()?.validity() ?: 0) + (if (useLegacyMessageFormat.asKnown().isPresent) 1 else 0) + @@ -983,6 +1127,303 @@ private constructor( "Body{datasetId=$datasetId, id=$id, createdAt=$createdAt, inputs=$inputs, metadata=$metadata, outputs=$outputs, sourceRunId=$sourceRunId, split=$split, useLegacyMessageFormat=$useLegacyMessageFormat, useSourceRunAttachments=$useSourceRunAttachments, useSourceRunIo=$useSourceRunIo, additionalProperties=$additionalProperties}" } + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = Split.Deserializer::class) @JsonSerialize(using = Split.Serializer::class) class Split diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleUpdateParams.kt index dd30e84c..513dd5ea 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleUpdateParams.kt @@ -54,11 +54,23 @@ private constructor( */ fun datasetId(): Optional = body.datasetId() - fun _inputs(): JsonValue = body._inputs() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputs(): Optional = body.inputs() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() - fun _outputs(): JsonValue = body._outputs() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = body.outputs() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -87,6 +99,27 @@ private constructor( */ fun _datasetId(): JsonField = body._datasetId() + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _inputs(): JsonField = body._inputs() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _outputs(): JsonField = body._outputs() + /** * Returns the raw JSON value of [overwrite]. * @@ -190,11 +223,45 @@ private constructor( */ fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } - fun inputs(inputs: JsonValue) = apply { body.inputs(inputs) } + fun inputs(inputs: Inputs?) = apply { body.inputs(inputs) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - fun outputs(outputs: JsonValue) = apply { body.outputs(outputs) } + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { body.inputs(inputs) } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun outputs(outputs: Outputs?) = apply { body.outputs(outputs) } + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { body.outputs(outputs) } fun overwrite(overwrite: Boolean) = apply { body.overwrite(overwrite) } @@ -375,9 +442,9 @@ private constructor( private constructor( private val attachmentsOperations: JsonField, private val datasetId: JsonField, - private val inputs: JsonValue, - private val metadata: JsonValue, - private val outputs: JsonValue, + private val inputs: JsonField, + private val metadata: JsonField, + private val outputs: JsonField, private val overwrite: JsonField, private val split: JsonField, private val additionalProperties: MutableMap, @@ -391,9 +458,11 @@ private constructor( @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("overwrite") @ExcludeMissing overwrite: JsonField = JsonMissing.of(), @@ -422,11 +491,23 @@ private constructor( */ fun datasetId(): Optional = datasetId.getOptional("dataset_id") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -457,6 +538,27 @@ private constructor( */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [overwrite]. * @@ -494,9 +596,9 @@ private constructor( private var attachmentsOperations: JsonField = JsonMissing.of() private var datasetId: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var overwrite: JsonField = JsonMissing.of() private var split: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -549,11 +651,47 @@ private constructor( */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun overwrite(overwrite: Boolean) = overwrite(JsonField.of(overwrite)) @@ -632,6 +770,9 @@ private constructor( attachmentsOperations().ifPresent { it.validate() } datasetId() + inputs().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + outputs().ifPresent { it.validate() } overwrite() split().ifPresent { it.validate() } validated = true @@ -655,6 +796,9 @@ private constructor( internal fun validity(): Int = (attachmentsOperations.asKnown().getOrNull()?.validity() ?: 0) + (if (datasetId.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (overwrite.asKnown().isPresent) 1 else 0) + (split.asKnown().getOrNull()?.validity() ?: 0) @@ -693,6 +837,303 @@ private constructor( "Body{attachmentsOperations=$attachmentsOperations, datasetId=$datasetId, inputs=$inputs, metadata=$metadata, outputs=$outputs, overwrite=$overwrite, split=$split, additionalProperties=$additionalProperties}" } + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = Split.Deserializer::class) @JsonSerialize(using = Split.Serializer::class) class Split diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParams.kt index 1bc80265..3a6fb8c8 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParams.kt @@ -222,9 +222,9 @@ private constructor( private val datasetId: JsonField, private val id: JsonField, private val createdAt: JsonField, - private val inputs: JsonValue, - private val metadata: JsonValue, - private val outputs: JsonValue, + private val inputs: JsonField, + private val metadata: JsonField, + private val outputs: JsonField, private val sourceRunId: JsonField, private val split: JsonField, private val useLegacyMessageFormat: JsonField, @@ -242,9 +242,11 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("source_run_id") @ExcludeMissing sourceRunId: JsonField = JsonMissing.of(), @@ -291,11 +293,23 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -352,6 +366,27 @@ private constructor( */ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [sourceRunId]. * @@ -429,9 +464,9 @@ private constructor( private var datasetId: JsonField? = null private var id: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var sourceRunId: JsonField = JsonMissing.of() private var split: JsonField = JsonMissing.of() private var useLegacyMessageFormat: JsonField = JsonMissing.of() @@ -494,11 +529,47 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) @@ -649,6 +720,9 @@ private constructor( datasetId() id() createdAt() + inputs().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + outputs().ifPresent { it.validate() } sourceRunId() split().ifPresent { it.validate() } useLegacyMessageFormat() @@ -676,12 +750,321 @@ private constructor( (if (datasetId.asKnown().isPresent) 1 else 0) + (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (sourceRunId.asKnown().isPresent) 1 else 0) + (split.asKnown().getOrNull()?.validity() ?: 0) + (if (useLegacyMessageFormat.asKnown().isPresent) 1 else 0) + (useSourceRunAttachments.asKnown().getOrNull()?.size ?: 0) + (if (useSourceRunIo.asKnown().isPresent) 1 else 0) + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = Split.Deserializer::class) @JsonSerialize(using = Split.Serializer::class) class Split diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParams.kt index 95904af9..a188a8d1 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParams.kt @@ -223,9 +223,9 @@ private constructor( private val id: JsonField, private val attachmentsOperations: JsonField, private val datasetId: JsonField, - private val inputs: JsonValue, - private val metadata: JsonValue, - private val outputs: JsonValue, + private val inputs: JsonField, + private val metadata: JsonField, + private val outputs: JsonField, private val overwrite: JsonField, private val split: JsonField, private val additionalProperties: MutableMap, @@ -240,9 +240,11 @@ private constructor( @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("overwrite") @ExcludeMissing overwrite: JsonField = JsonMissing.of(), @@ -278,11 +280,23 @@ private constructor( */ fun datasetId(): Optional = datasetId.getOptional("dataset_id") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -320,6 +334,27 @@ private constructor( */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [overwrite]. * @@ -365,9 +400,9 @@ private constructor( private var id: JsonField? = null private var attachmentsOperations: JsonField = JsonMissing.of() private var datasetId: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var overwrite: JsonField = JsonMissing.of() private var split: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -432,11 +467,47 @@ private constructor( */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun overwrite(overwrite: Boolean) = overwrite(JsonField.of(overwrite)) @@ -524,6 +595,9 @@ private constructor( id() attachmentsOperations().ifPresent { it.validate() } datasetId() + inputs().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + outputs().ifPresent { it.validate() } overwrite() split().ifPresent { it.validate() } validated = true @@ -548,9 +622,318 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (attachmentsOperations.asKnown().getOrNull()?.validity() ?: 0) + (if (datasetId.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (overwrite.asKnown().isPresent) 1 else 0) + (split.asKnown().getOrNull()?.validity() ?: 0) + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = Split.Deserializer::class) @JsonSerialize(using = Split.Serializer::class) class Split diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResult.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResult.kt index d6c73150..c3c18e48 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResult.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResult.kt @@ -36,9 +36,9 @@ private constructor( private val id: JsonField, private val createdAt: JsonField, private val datasetId: JsonField, - private val inputs: JsonValue, - private val metadata: JsonValue, - private val outputs: JsonValue, + private val inputs: JsonField, + private val metadata: JsonField, + private val outputs: JsonField, private val overwrite: JsonField, private val sourceRunId: JsonField, private val split: JsonField, @@ -53,9 +53,9 @@ private constructor( @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("overwrite") @ExcludeMissing overwrite: JsonField = JsonMissing.of(), @JsonProperty("source_run_id") @ExcludeMissing @@ -96,11 +96,23 @@ private constructor( */ fun datasetId(): Optional = datasetId.getOptional("dataset_id") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -149,6 +161,27 @@ private constructor( */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [overwrite]. * @@ -205,9 +238,9 @@ private constructor( private var id: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var datasetId: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var overwrite: JsonField = JsonMissing.of() private var sourceRunId: JsonField = JsonMissing.of() private var split: JsonField = JsonMissing.of() @@ -270,11 +303,45 @@ private constructor( */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun overwrite(overwrite: Boolean) = overwrite(JsonField.of(overwrite)) @@ -383,6 +450,9 @@ private constructor( id() createdAt() datasetId() + inputs().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + outputs().ifPresent { it.validate() } overwrite() sourceRunId() split().ifPresent { it.validate() } @@ -408,11 +478,311 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (datasetId.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (overwrite.asKnown().isPresent) 1 else 0) + (if (sourceRunId.asKnown().isPresent) 1 else 0) + (split.asKnown().getOrNull()?.validity() ?: 0) + (if (useSourceRunIo.asKnown().isPresent) 1 else 0) + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(using = Split.Deserializer::class) @JsonSerialize(using = Split.Serializer::class) class Split diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSource.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSource.kt index 1c032e2e..00f29353 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSource.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSource.kt @@ -11,6 +11,7 @@ import com.langchain.smith.core.ExcludeMissing import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Collections import java.util.Objects @@ -21,18 +22,22 @@ import kotlin.jvm.optionals.getOrNull class ApiFeedbackSource @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val metadata: JsonValue, + private val metadata: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this(metadata, type, mutableMapOf()) - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -40,6 +45,13 @@ private constructor( */ fun type(): Optional = type.getOptional("type") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [type]. * @@ -68,7 +80,7 @@ private constructor( /** A builder for [ApiFeedbackSource]. */ class Builder internal constructor() { - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -79,7 +91,19 @@ private constructor( additionalProperties = apiFeedbackSource.additionalProperties.toMutableMap() } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun type(type: Type) = type(JsonField.of(type)) @@ -126,6 +150,7 @@ private constructor( return@apply } + metadata().ifPresent { it.validate() } type().ifPresent { it.validate() } validated = true } @@ -143,7 +168,109 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AppFeedbackSource.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AppFeedbackSource.kt index efc6faa4..8118ca06 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AppFeedbackSource.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AppFeedbackSource.kt @@ -11,6 +11,7 @@ import com.langchain.smith.core.ExcludeMissing import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Collections import java.util.Objects @@ -21,18 +22,22 @@ import kotlin.jvm.optionals.getOrNull class AppFeedbackSource @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val metadata: JsonValue, + private val metadata: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this(metadata, type, mutableMapOf()) - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -40,6 +45,13 @@ private constructor( */ fun type(): Optional = type.getOptional("type") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [type]. * @@ -68,7 +80,7 @@ private constructor( /** A builder for [AppFeedbackSource]. */ class Builder internal constructor() { - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -79,7 +91,19 @@ private constructor( additionalProperties = appFeedbackSource.additionalProperties.toMutableMap() } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun type(type: Type) = type(JsonField.of(type)) @@ -126,6 +150,7 @@ private constructor( return@apply } + metadata().ifPresent { it.validate() } type().ifPresent { it.validate() } validated = true } @@ -143,7 +168,109 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSource.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSource.kt index c77a2f1d..32fe7d77 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSource.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSource.kt @@ -11,6 +11,7 @@ import com.langchain.smith.core.ExcludeMissing import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Collections import java.util.Objects @@ -21,18 +22,22 @@ import kotlin.jvm.optionals.getOrNull class AutoEvalFeedbackSource @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val metadata: JsonValue, + private val metadata: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this(metadata, type, mutableMapOf()) - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -40,6 +45,13 @@ private constructor( */ fun type(): Optional = type.getOptional("type") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [type]. * @@ -68,7 +80,7 @@ private constructor( /** A builder for [AutoEvalFeedbackSource]. */ class Builder internal constructor() { - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -79,7 +91,19 @@ private constructor( additionalProperties = autoEvalFeedbackSource.additionalProperties.toMutableMap() } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun type(type: Type) = type(JsonField.of(type)) @@ -126,6 +150,7 @@ private constructor( return@apply } + metadata().ifPresent { it.validate() } type().ifPresent { it.validate() } validated = true } @@ -143,7 +168,109 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt index b568098a..44434060 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt @@ -468,8 +468,9 @@ private constructor( */ fun correction(correction: JsonField) = apply { this.correction = correction } - /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ - fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + /** Alias for calling [correction] with `Correction.ofUnionMember0(unionMember0)`. */ + fun correction(unionMember0: Correction.UnionMember0) = + correction(Correction.ofUnionMember0(unionMember0)) /** Alias for calling [correction] with `Correction.ofString(string)`. */ fun correction(string: String) = correction(Correction.ofString(string)) @@ -668,8 +669,8 @@ private constructor( /** Alias for calling [value] with `Value.ofString(string)`. */ fun value(string: String) = value(Value.ofString(string)) - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) + /** Alias for calling [value] with `Value.ofUnionMember3(unionMember3)`. */ + fun value(unionMember3: Value.UnionMember3) = value(Value.ofUnionMember3(unionMember3)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -786,20 +787,20 @@ private constructor( @JsonSerialize(using = Correction.Serializer::class) class Correction private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun string(): Optional = Optional.ofNullable(string) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isString(): Boolean = string != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asString(): String = string.getOrThrow("string") @@ -807,7 +808,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -821,7 +822,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitString(string: String) {} } @@ -847,7 +850,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitString(string: String) = 1 @@ -860,14 +864,16 @@ private constructor( return true } - return other is Correction && jsonValue == other.jsonValue && string == other.string + return other is Correction && + unionMember0 == other.unionMember0 && + string == other.string } - override fun hashCode(): Int = Objects.hash(jsonValue, string) + override fun hashCode(): Int = Objects.hash(unionMember0, string) override fun toString(): String = when { - jsonValue != null -> "Correction{jsonValue=$jsonValue}" + unionMember0 != null -> "Correction{unionMember0=$unionMember0}" string != null -> "Correction{string=$string}" _json != null -> "Correction{_unknown=$_json}" else -> throw IllegalStateException("Invalid Correction") @@ -875,7 +881,8 @@ private constructor( companion object { - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Correction(unionMember0 = unionMember0) @JvmStatic fun ofString(string: String) = Correction(string = string) } @@ -885,7 +892,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitString(string: String): T @@ -911,19 +918,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Correction(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Correction(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Correction(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Correction(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -942,13 +949,115 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + 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 Correction") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } } class FeedbackConfig @@ -1999,7 +2108,7 @@ private constructor( private val number: Double? = null, private val bool: Boolean? = null, private val string: String? = null, - private val json: JsonValue? = null, + private val unionMember3: UnionMember3? = null, private val _json: JsonValue? = null, ) { @@ -2009,7 +2118,7 @@ private constructor( fun string(): Optional = Optional.ofNullable(string) - fun json(): Optional = Optional.ofNullable(json) + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) fun isNumber(): Boolean = number != null @@ -2017,7 +2126,7 @@ private constructor( fun isString(): Boolean = string != null - fun isJson(): Boolean = json != null + fun isUnionMember3(): Boolean = unionMember3 != null fun asNumber(): Double = number.getOrThrow("number") @@ -2025,7 +2134,7 @@ private constructor( fun asString(): String = string.getOrThrow("string") - fun asJson(): JsonValue = json.getOrThrow("json") + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") fun _json(): Optional = Optional.ofNullable(_json) @@ -2034,7 +2143,7 @@ private constructor( number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) string != null -> visitor.visitString(string) - json != null -> visitor.visitJson(json) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) else -> visitor.unknown(_json) } @@ -2053,7 +2162,9 @@ private constructor( override fun visitString(string: String) {} - override fun visitJson(json: JsonValue) {} + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } } ) validated = true @@ -2083,7 +2194,8 @@ private constructor( override fun visitString(string: String) = 1 - override fun visitJson(json: JsonValue) = 1 + override fun visitUnionMember3(unionMember3: UnionMember3) = + unionMember3.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2098,17 +2210,17 @@ private constructor( number == other.number && bool == other.bool && string == other.string && - json == other.json + unionMember3 == other.unionMember3 } - override fun hashCode(): Int = Objects.hash(number, bool, string, json) + override fun hashCode(): Int = Objects.hash(number, bool, string, unionMember3) override fun toString(): String = when { number != null -> "Value{number=$number}" bool != null -> "Value{bool=$bool}" string != null -> "Value{string=$string}" - json != null -> "Value{json=$json}" + unionMember3 != null -> "Value{unionMember3=$unionMember3}" _json != null -> "Value{_unknown=$_json}" else -> throw IllegalStateException("Invalid Value") } @@ -2121,7 +2233,8 @@ private constructor( @JvmStatic fun ofString(string: String) = Value(string = string) - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = Value(unionMember3 = unionMember3) } /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ @@ -2133,7 +2246,7 @@ private constructor( fun visitString(string: String): T - fun visitJson(json: JsonValue): T + fun visitUnionMember3(unionMember3: UnionMember3): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -2157,6 +2270,9 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(unionMember3 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Value(number = it, _json = json) }, @@ -2166,16 +2282,13 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Value(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Value(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -2197,12 +2310,114 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) value.string != null -> generator.writeObject(value.string) - value.json != null -> generator.writeObject(value.json) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Value") } } } + + class UnionMember3 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + additionalProperties = unionMember3.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) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = UnionMember3(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackSchema.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackSchema.kt index 075c9801..9bde14b5 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackSchema.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackSchema.kt @@ -22,6 +22,7 @@ import com.langchain.smith.core.JsonValue import com.langchain.smith.core.allMaxBy import com.langchain.smith.core.checkRequired import com.langchain.smith.core.getOrThrow +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -39,7 +40,7 @@ private constructor( private val comparativeExperimentId: JsonField, private val correction: JsonField, private val createdAt: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val feedbackGroupId: JsonField, private val feedbackSource: JsonField, private val feedbackThreadId: JsonField, @@ -67,7 +68,7 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_group_id") @ExcludeMissing feedbackGroupId: JsonField = JsonMissing.of(), @@ -146,7 +147,11 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -259,6 +264,13 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [feedbackGroupId]. * @@ -375,7 +387,7 @@ private constructor( private var comparativeExperimentId: JsonField = JsonMissing.of() private var correction: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var feedbackGroupId: JsonField = JsonMissing.of() private var feedbackSource: JsonField = JsonMissing.of() private var feedbackThreadId: JsonField = JsonMissing.of() @@ -478,8 +490,9 @@ private constructor( */ fun correction(correction: JsonField) = apply { this.correction = correction } - /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ - fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + /** Alias for calling [correction] with `Correction.ofUnionMember0(unionMember0)`. */ + fun correction(unionMember0: Correction.UnionMember0) = + correction(Correction.ofUnionMember0(unionMember0)) /** Alias for calling [correction] with `Correction.ofString(string)`. */ fun correction(string: String) = correction(Correction.ofString(string)) @@ -495,7 +508,18 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun feedbackGroupId(feedbackGroupId: String?) = feedbackGroupId(JsonField.ofNullable(feedbackGroupId)) @@ -660,8 +684,8 @@ private constructor( /** Alias for calling [value] with `Value.ofString(string)`. */ fun value(string: String) = value(Value.ofString(string)) - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) + /** Alias for calling [value] with `Value.ofUnionMember3(unionMember3)`. */ + fun value(unionMember3: Value.UnionMember3) = value(Value.ofUnionMember3(unionMember3)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -731,6 +755,7 @@ private constructor( comparativeExperimentId() correction().ifPresent { it.validate() } createdAt() + extra().ifPresent { it.validate() } feedbackGroupId() feedbackSource().ifPresent { it.validate() } feedbackThreadId() @@ -765,6 +790,7 @@ private constructor( (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + (correction.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (if (feedbackGroupId.asKnown().isPresent) 1 else 0) + (feedbackSource.asKnown().getOrNull()?.validity() ?: 0) + (if (feedbackThreadId.asKnown().isPresent) 1 else 0) + @@ -780,20 +806,20 @@ private constructor( @JsonSerialize(using = Correction.Serializer::class) class Correction private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun string(): Optional = Optional.ofNullable(string) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isString(): Boolean = string != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asString(): String = string.getOrThrow("string") @@ -801,7 +827,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -815,7 +841,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitString(string: String) {} } @@ -841,7 +869,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitString(string: String) = 1 @@ -854,14 +883,16 @@ private constructor( return true } - return other is Correction && jsonValue == other.jsonValue && string == other.string + return other is Correction && + unionMember0 == other.unionMember0 && + string == other.string } - override fun hashCode(): Int = Objects.hash(jsonValue, string) + override fun hashCode(): Int = Objects.hash(unionMember0, string) override fun toString(): String = when { - jsonValue != null -> "Correction{jsonValue=$jsonValue}" + unionMember0 != null -> "Correction{unionMember0=$unionMember0}" string != null -> "Correction{string=$string}" _json != null -> "Correction{_unknown=$_json}" else -> throw IllegalStateException("Invalid Correction") @@ -869,7 +900,8 @@ private constructor( companion object { - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Correction(unionMember0 = unionMember0) @JvmStatic fun ofString(string: String) = Correction(string = string) } @@ -879,7 +911,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitString(string: String): T @@ -905,19 +937,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Correction(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Correction(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Correction(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Correction(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -936,13 +968,214 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + 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 Correction") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" } /** The feedback source loaded from the database. */ @@ -950,7 +1183,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val lsUserId: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val type: JsonField, private val userId: JsonField, private val userName: JsonField, @@ -962,7 +1195,9 @@ private constructor( @JsonProperty("ls_user_id") @ExcludeMissing lsUserId: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), @JsonProperty("user_name") @@ -976,7 +1211,11 @@ private constructor( */ fun lsUserId(): Optional = lsUserId.getOptional("ls_user_id") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1003,6 +1242,13 @@ private constructor( */ @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField = lsUserId + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [type]. * @@ -1046,7 +1292,7 @@ private constructor( class Builder internal constructor() { private var lsUserId: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() private var userName: JsonField = JsonMissing.of() @@ -1076,7 +1322,19 @@ private constructor( */ fun lsUserId(lsUserId: JsonField) = apply { this.lsUserId = lsUserId } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun type(type: String?) = type(JsonField.ofNullable(type)) @@ -1163,6 +1421,7 @@ private constructor( } lsUserId() + metadata().ifPresent { it.validate() } type() userId() userName() @@ -1186,10 +1445,113 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (lsUserId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (type.asKnown().isPresent) 1 else 0) + (if (userId.asKnown().isPresent) 1 else 0) + (if (userName.asKnown().isPresent) 1 else 0) + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1388,7 +1750,7 @@ private constructor( private val number: Double? = null, private val bool: Boolean? = null, private val string: String? = null, - private val json: JsonValue? = null, + private val unionMember3: UnionMember3? = null, private val _json: JsonValue? = null, ) { @@ -1398,7 +1760,7 @@ private constructor( fun string(): Optional = Optional.ofNullable(string) - fun json(): Optional = Optional.ofNullable(json) + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) fun isNumber(): Boolean = number != null @@ -1406,7 +1768,7 @@ private constructor( fun isString(): Boolean = string != null - fun isJson(): Boolean = json != null + fun isUnionMember3(): Boolean = unionMember3 != null fun asNumber(): Double = number.getOrThrow("number") @@ -1414,7 +1776,7 @@ private constructor( fun asString(): String = string.getOrThrow("string") - fun asJson(): JsonValue = json.getOrThrow("json") + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") fun _json(): Optional = Optional.ofNullable(_json) @@ -1423,7 +1785,7 @@ private constructor( number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) string != null -> visitor.visitString(string) - json != null -> visitor.visitJson(json) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) else -> visitor.unknown(_json) } @@ -1442,7 +1804,9 @@ private constructor( override fun visitString(string: String) {} - override fun visitJson(json: JsonValue) {} + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } } ) validated = true @@ -1472,7 +1836,8 @@ private constructor( override fun visitString(string: String) = 1 - override fun visitJson(json: JsonValue) = 1 + override fun visitUnionMember3(unionMember3: UnionMember3) = + unionMember3.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1487,17 +1852,17 @@ private constructor( number == other.number && bool == other.bool && string == other.string && - json == other.json + unionMember3 == other.unionMember3 } - override fun hashCode(): Int = Objects.hash(number, bool, string, json) + override fun hashCode(): Int = Objects.hash(number, bool, string, unionMember3) override fun toString(): String = when { number != null -> "Value{number=$number}" bool != null -> "Value{bool=$bool}" string != null -> "Value{string=$string}" - json != null -> "Value{json=$json}" + unionMember3 != null -> "Value{unionMember3=$unionMember3}" _json != null -> "Value{_unknown=$_json}" else -> throw IllegalStateException("Invalid Value") } @@ -1510,7 +1875,8 @@ private constructor( @JvmStatic fun ofString(string: String) = Value(string = string) - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = Value(unionMember3 = unionMember3) } /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ @@ -1522,7 +1888,7 @@ private constructor( fun visitString(string: String): T - fun visitJson(json: JsonValue): T + fun visitUnionMember3(unionMember3: UnionMember3): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -1546,6 +1912,9 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(unionMember3 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Value(number = it, _json = json) }, @@ -1555,16 +1924,13 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Value(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Value(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1586,12 +1952,114 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) value.string != null -> generator.writeObject(value.string) - value.json != null -> generator.writeObject(value.json) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Value") } } } + + class UnionMember3 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + additionalProperties = unionMember3.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) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = UnionMember3(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParams.kt index 42fa5a34..b603c633 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParams.kt @@ -190,8 +190,10 @@ private constructor( */ fun correction(correction: JsonField) = apply { body.correction(correction) } - /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ - fun correction(jsonValue: JsonValue) = apply { body.correction(jsonValue) } + /** Alias for calling [correction] with `Correction.ofUnionMember0(unionMember0)`. */ + fun correction(unionMember0: Correction.UnionMember0) = apply { + body.correction(unionMember0) + } /** Alias for calling [correction] with `Correction.ofString(string)`. */ fun correction(string: String) = apply { body.correction(string) } @@ -256,8 +258,8 @@ private constructor( /** Alias for calling [value] with `Value.ofString(string)`. */ fun value(string: String) = apply { body.value(string) } - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = apply { body.value(json) } + /** Alias for calling [value] with `Value.ofUnionMember3(unionMember3)`. */ + fun value(unionMember3: Value.UnionMember3) = apply { body.value(unionMember3) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -566,8 +568,9 @@ private constructor( this.correction = correction } - /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ - fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + /** Alias for calling [correction] with `Correction.ofUnionMember0(unionMember0)`. */ + fun correction(unionMember0: Correction.UnionMember0) = + correction(Correction.ofUnionMember0(unionMember0)) /** Alias for calling [correction] with `Correction.ofString(string)`. */ fun correction(string: String) = correction(Correction.ofString(string)) @@ -633,8 +636,8 @@ private constructor( /** Alias for calling [value] with `Value.ofString(string)`. */ fun value(string: String) = value(Value.ofString(string)) - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) + /** Alias for calling [value] with `Value.ofUnionMember3(unionMember3)`. */ + fun value(unionMember3: Value.UnionMember3) = value(Value.ofUnionMember3(unionMember3)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -736,20 +739,20 @@ private constructor( @JsonSerialize(using = Correction.Serializer::class) class Correction private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun string(): Optional = Optional.ofNullable(string) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isString(): Boolean = string != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asString(): String = string.getOrThrow("string") @@ -757,7 +760,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -771,7 +774,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitString(string: String) {} } @@ -797,7 +802,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitString(string: String) = 1 @@ -810,14 +816,16 @@ private constructor( return true } - return other is Correction && jsonValue == other.jsonValue && string == other.string + return other is Correction && + unionMember0 == other.unionMember0 && + string == other.string } - override fun hashCode(): Int = Objects.hash(jsonValue, string) + override fun hashCode(): Int = Objects.hash(unionMember0, string) override fun toString(): String = when { - jsonValue != null -> "Correction{jsonValue=$jsonValue}" + unionMember0 != null -> "Correction{unionMember0=$unionMember0}" string != null -> "Correction{string=$string}" _json != null -> "Correction{_unknown=$_json}" else -> throw IllegalStateException("Invalid Correction") @@ -825,7 +833,8 @@ private constructor( companion object { - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Correction(unionMember0 = unionMember0) @JvmStatic fun ofString(string: String) = Correction(string = string) } @@ -835,7 +844,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitString(string: String): T @@ -861,19 +870,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Correction(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Correction(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Correction(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Correction(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -892,13 +901,115 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + 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 Correction") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } } class FeedbackConfig @@ -1709,7 +1820,7 @@ private constructor( private val number: Double? = null, private val bool: Boolean? = null, private val string: String? = null, - private val json: JsonValue? = null, + private val unionMember3: UnionMember3? = null, private val _json: JsonValue? = null, ) { @@ -1719,7 +1830,7 @@ private constructor( fun string(): Optional = Optional.ofNullable(string) - fun json(): Optional = Optional.ofNullable(json) + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) fun isNumber(): Boolean = number != null @@ -1727,7 +1838,7 @@ private constructor( fun isString(): Boolean = string != null - fun isJson(): Boolean = json != null + fun isUnionMember3(): Boolean = unionMember3 != null fun asNumber(): Double = number.getOrThrow("number") @@ -1735,7 +1846,7 @@ private constructor( fun asString(): String = string.getOrThrow("string") - fun asJson(): JsonValue = json.getOrThrow("json") + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") fun _json(): Optional = Optional.ofNullable(_json) @@ -1744,7 +1855,7 @@ private constructor( number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) string != null -> visitor.visitString(string) - json != null -> visitor.visitJson(json) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) else -> visitor.unknown(_json) } @@ -1763,7 +1874,9 @@ private constructor( override fun visitString(string: String) {} - override fun visitJson(json: JsonValue) {} + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } } ) validated = true @@ -1793,7 +1906,8 @@ private constructor( override fun visitString(string: String) = 1 - override fun visitJson(json: JsonValue) = 1 + override fun visitUnionMember3(unionMember3: UnionMember3) = + unionMember3.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1808,17 +1922,17 @@ private constructor( number == other.number && bool == other.bool && string == other.string && - json == other.json + unionMember3 == other.unionMember3 } - override fun hashCode(): Int = Objects.hash(number, bool, string, json) + override fun hashCode(): Int = Objects.hash(number, bool, string, unionMember3) override fun toString(): String = when { number != null -> "Value{number=$number}" bool != null -> "Value{bool=$bool}" string != null -> "Value{string=$string}" - json != null -> "Value{json=$json}" + unionMember3 != null -> "Value{unionMember3=$unionMember3}" _json != null -> "Value{_unknown=$_json}" else -> throw IllegalStateException("Invalid Value") } @@ -1831,7 +1945,8 @@ private constructor( @JvmStatic fun ofString(string: String) = Value(string = string) - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = Value(unionMember3 = unionMember3) } /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ @@ -1843,7 +1958,7 @@ private constructor( fun visitString(string: String): T - fun visitJson(json: JsonValue): T + fun visitUnionMember3(unionMember3: UnionMember3): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -1867,6 +1982,9 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(unionMember3 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Value(number = it, _json = json) }, @@ -1876,16 +1994,13 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Value(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Value(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1907,12 +2022,114 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) value.string != null -> generator.writeObject(value.string) - value.json != null -> generator.writeObject(value.json) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Value") } } } + + class UnionMember3 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + additionalProperties = unionMember3.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) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = UnionMember3(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSource.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSource.kt index c28f0809..d2c10e7f 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSource.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSource.kt @@ -11,6 +11,7 @@ import com.langchain.smith.core.ExcludeMissing import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Collections import java.util.Objects @@ -21,18 +22,22 @@ import kotlin.jvm.optionals.getOrNull class ModelFeedbackSource @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val metadata: JsonValue, + private val metadata: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this(metadata, type, mutableMapOf()) - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -40,6 +45,13 @@ private constructor( */ fun type(): Optional = type.getOptional("type") + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [type]. * @@ -68,7 +80,7 @@ private constructor( /** A builder for [ModelFeedbackSource]. */ class Builder internal constructor() { - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -79,7 +91,19 @@ private constructor( additionalProperties = modelFeedbackSource.additionalProperties.toMutableMap() } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun type(type: Type) = type(JsonField.of(type)) @@ -126,6 +150,7 @@ private constructor( return@apply } + metadata().ifPresent { it.validate() } type().ifPresent { it.validate() } validated = true } @@ -143,7 +168,109 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParams.kt index 17360cb8..f2e3225f 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParams.kt @@ -24,6 +24,7 @@ import com.langchain.smith.core.allMaxBy import com.langchain.smith.core.getOrThrow import com.langchain.smith.core.http.Headers import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Collections import java.util.Objects @@ -53,7 +54,11 @@ private constructor( */ fun correction(): Optional = body.correction() - fun _metadata(): JsonValue = body._metadata() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = body.metadata() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -81,6 +86,13 @@ private constructor( */ fun _correction(): JsonField = body._correction() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField = body._metadata() + /** * Returns the raw JSON value of [score]. * @@ -175,13 +187,27 @@ private constructor( */ fun correction(correction: JsonField) = apply { body.correction(correction) } - /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ - fun correction(jsonValue: JsonValue) = apply { body.correction(jsonValue) } + /** Alias for calling [correction] with `Correction.ofUnionMember0(unionMember0)`. */ + fun correction(unionMember0: Correction.UnionMember0) = apply { + body.correction(unionMember0) + } /** Alias for calling [correction] with `Correction.ofString(string)`. */ fun correction(string: String) = apply { body.correction(string) } - fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } fun score(score: Score?) = apply { body.score(score) } @@ -373,7 +399,7 @@ private constructor( private constructor( private val comment: JsonField, private val correction: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val score: JsonField, private val value: JsonField, private val additionalProperties: MutableMap, @@ -385,7 +411,9 @@ private constructor( @JsonProperty("correction") @ExcludeMissing correction: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("score") @ExcludeMissing score: JsonField = JsonMissing.of(), @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), ) : this(comment, correction, metadata, score, value, mutableMapOf()) @@ -402,7 +430,11 @@ private constructor( */ fun correction(): Optional = correction.getOptional("correction") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -432,6 +464,13 @@ private constructor( @ExcludeMissing fun _correction(): JsonField = correction + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [score]. * @@ -469,7 +508,7 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var correction: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var score: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -514,13 +553,26 @@ private constructor( this.correction = correction } - /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ - fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + /** Alias for calling [correction] with `Correction.ofUnionMember0(unionMember0)`. */ + fun correction(unionMember0: Correction.UnionMember0) = + correction(Correction.ofUnionMember0(unionMember0)) /** Alias for calling [correction] with `Correction.ofString(string)`. */ fun correction(string: String) = correction(Correction.ofString(string)) - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun score(score: Score?) = score(JsonField.ofNullable(score)) @@ -609,6 +661,7 @@ private constructor( comment() correction().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } score().ifPresent { it.validate() } value().ifPresent { it.validate() } validated = true @@ -632,6 +685,7 @@ private constructor( internal fun validity(): Int = (if (comment.asKnown().isPresent) 1 else 0) + (correction.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (score.asKnown().getOrNull()?.validity() ?: 0) + (value.asKnown().getOrNull()?.validity() ?: 0) @@ -663,20 +717,20 @@ private constructor( @JsonSerialize(using = Correction.Serializer::class) class Correction private constructor( - private val jsonValue: JsonValue? = null, + private val unionMember0: UnionMember0? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun jsonValue(): Optional = Optional.ofNullable(jsonValue) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun string(): Optional = Optional.ofNullable(string) - fun isJsonValue(): Boolean = jsonValue != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isString(): Boolean = string != null - fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asString(): String = string.getOrThrow("string") @@ -684,7 +738,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - jsonValue != null -> visitor.visitJsonValue(jsonValue) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -698,7 +752,9 @@ private constructor( accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } override fun visitString(string: String) {} } @@ -724,7 +780,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonValue(jsonValue: JsonValue) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() override fun visitString(string: String) = 1 @@ -737,14 +794,16 @@ private constructor( return true } - return other is Correction && jsonValue == other.jsonValue && string == other.string + return other is Correction && + unionMember0 == other.unionMember0 && + string == other.string } - override fun hashCode(): Int = Objects.hash(jsonValue, string) + override fun hashCode(): Int = Objects.hash(unionMember0, string) override fun toString(): String = when { - jsonValue != null -> "Correction{jsonValue=$jsonValue}" + unionMember0 != null -> "Correction{unionMember0=$unionMember0}" string != null -> "Correction{string=$string}" _json != null -> "Correction{_unknown=$_json}" else -> throw IllegalStateException("Invalid Correction") @@ -752,7 +811,8 @@ private constructor( companion object { - @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Correction(unionMember0 = unionMember0) @JvmStatic fun ofString(string: String) = Correction(string = string) } @@ -762,7 +822,7 @@ private constructor( */ interface Visitor { - fun visitJsonValue(jsonValue: JsonValue): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitString(string: String): T @@ -788,19 +848,19 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Correction(unionMember0 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Correction(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Correction(jsonValue = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants. + // all the possible variants (e.g. deserializing from array). 0 -> Correction(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -819,13 +879,214 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonValue != null -> generator.writeObject(value.jsonValue) + 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 Correction") } } } + + class UnionMember0 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = UnionMember0(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember0{additionalProperties=$additionalProperties}" + } + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @JsonDeserialize(using = Score.Deserializer::class) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponse.kt index ab84c522..03660503 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponse.kt @@ -30,8 +30,8 @@ private constructor( private val experimentsInfo: JsonField>, private val modifiedAt: JsonField, private val description: JsonField, - private val extra: JsonValue, - private val feedbackStats: JsonValue, + private val extra: JsonField, + private val feedbackStats: JsonField, private val name: JsonField, private val additionalProperties: MutableMap, ) { @@ -51,8 +51,10 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), - @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), ) : this( id, @@ -97,9 +99,17 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") - @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -148,6 +158,22 @@ private constructor( */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + /** * Returns the raw JSON value of [name]. * @@ -192,8 +218,8 @@ private constructor( private var experimentsInfo: JsonField>? = null private var modifiedAt: JsonField? = null private var description: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() - private var feedbackStats: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -286,9 +312,36 @@ private constructor( */ fun description(description: JsonField) = apply { this.description = description } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { + this.feedbackStats = feedbackStats + } fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -363,6 +416,8 @@ private constructor( experimentsInfo().forEach { it.validate() } modifiedAt() description() + extra().ifPresent { it.validate() } + feedbackStats().ifPresent { it.validate() } name() validated = true } @@ -387,8 +442,208 @@ private constructor( (experimentsInfo.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (modifiedAt.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.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) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponse.kt index 705d770f..51b47dda 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponse.kt @@ -38,8 +38,8 @@ private constructor( private val dataType: JsonField, private val description: JsonField, private val externallyManaged: JsonField, - private val inputsSchemaDefinition: JsonValue, - private val outputsSchemaDefinition: JsonValue, + private val inputsSchemaDefinition: JsonField, + private val outputsSchemaDefinition: JsonField, private val transformations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -63,10 +63,10 @@ private constructor( externallyManaged: JsonField = JsonMissing.of(), @JsonProperty("inputs_schema_definition") @ExcludeMissing - inputsSchemaDefinition: JsonValue = JsonMissing.of(), + inputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("outputs_schema_definition") @ExcludeMissing - outputsSchemaDefinition: JsonValue = JsonMissing.of(), + outputsSchemaDefinition: JsonField = JsonMissing.of(), @JsonProperty("transformations") @ExcludeMissing transformations: JsonField> = JsonMissing.of(), @@ -128,13 +128,19 @@ private constructor( */ fun externallyManaged(): Optional = externallyManaged.getOptional("externally_managed") - @JsonProperty("inputs_schema_definition") - @ExcludeMissing - fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional = + inputsSchemaDefinition.getOptional("inputs_schema_definition") - @JsonProperty("outputs_schema_definition") - @ExcludeMissing - fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional = + outputsSchemaDefinition.getOptional("outputs_schema_definition") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -199,6 +205,26 @@ private constructor( @ExcludeMissing fun _externallyManaged(): JsonField = externallyManaged + /** + * Returns the raw JSON value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonField = inputsSchemaDefinition + + /** + * Returns the raw JSON value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonField = outputsSchemaDefinition + /** * Returns the raw JSON value of [transformations]. * @@ -245,8 +271,8 @@ private constructor( private var dataType: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var externallyManaged: JsonField = JsonMissing.of() - private var inputsSchemaDefinition: JsonValue = JsonMissing.of() - private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var inputsSchemaDefinition: JsonField = JsonMissing.of() + private var outputsSchemaDefinition: JsonField = JsonMissing.of() private var transformations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -362,13 +388,49 @@ private constructor( this.externallyManaged = externallyManaged } - fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { - this.inputsSchemaDefinition = inputsSchemaDefinition - } + fun inputsSchemaDefinition(inputsSchemaDefinition: InputsSchemaDefinition?) = + inputsSchemaDefinition(JsonField.ofNullable(inputsSchemaDefinition)) - fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { - this.outputsSchemaDefinition = outputsSchemaDefinition - } + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed + * [InputsSchemaDefinition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonField) = + apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: OutputsSchemaDefinition?) = + outputsSchemaDefinition(JsonField.ofNullable(outputsSchemaDefinition)) + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: Optional) = + outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed + * [OutputsSchemaDefinition] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonField) = + apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } fun transformations(transformations: List?) = transformations(JsonField.ofNullable(transformations)) @@ -463,6 +525,8 @@ private constructor( dataType().ifPresent { it.validate() } description() externallyManaged() + inputsSchemaDefinition().ifPresent { it.validate() } + outputsSchemaDefinition().ifPresent { it.validate() } transformations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -489,8 +553,218 @@ private constructor( (dataType.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (inputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + + (outputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class InputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsSchemaDefinition: InputsSchemaDefinition) = apply { + additionalProperties = inputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [InputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsSchemaDefinition = + InputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + + class OutputsSchemaDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OutputsSchemaDefinition]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsSchemaDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsSchemaDefinition: OutputsSchemaDefinition) = apply { + additionalProperties = outputsSchemaDefinition.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) + } + + /** + * Returns an immutable instance of [OutputsSchemaDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsSchemaDefinition = + OutputsSchemaDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsSchemaDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputsSchemaDefinition{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/DemoConfig.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/DemoConfig.kt index 6ae2cbd6..e36e8c0d 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/DemoConfig.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/DemoConfig.kt @@ -22,9 +22,9 @@ import kotlin.jvm.optionals.getOrNull class DemoConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val examples: JsonField>, + private val examples: JsonField>, private val messageIndex: JsonField, - private val metaprompt: JsonValue, + private val metaprompt: JsonField, private val overallFeedback: JsonField, private val additionalProperties: MutableMap, ) { @@ -33,11 +33,13 @@ private constructor( private constructor( @JsonProperty("examples") @ExcludeMissing - examples: JsonField> = JsonMissing.of(), + examples: JsonField> = JsonMissing.of(), @JsonProperty("message_index") @ExcludeMissing messageIndex: JsonField = JsonMissing.of(), - @JsonProperty("metaprompt") @ExcludeMissing metaprompt: JsonValue = JsonMissing.of(), + @JsonProperty("metaprompt") + @ExcludeMissing + metaprompt: JsonField = JsonMissing.of(), @JsonProperty("overall_feedback") @ExcludeMissing overallFeedback: JsonField = JsonMissing.of(), @@ -47,7 +49,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun examples(): List = examples.getRequired("examples") + fun examples(): List = examples.getRequired("examples") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -55,7 +57,11 @@ private constructor( */ fun messageIndex(): Long = messageIndex.getRequired("message_index") - @JsonProperty("metaprompt") @ExcludeMissing fun _metaprompt(): JsonValue = metaprompt + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metaprompt(): Metaprompt = metaprompt.getRequired("metaprompt") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -68,7 +74,7 @@ private constructor( * * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField> = examples + @JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField> = examples /** * Returns the raw JSON value of [messageIndex]. @@ -79,6 +85,15 @@ private constructor( @ExcludeMissing fun _messageIndex(): JsonField = messageIndex + /** + * Returns the raw JSON value of [metaprompt]. + * + * Unlike [metaprompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metaprompt") + @ExcludeMissing + fun _metaprompt(): JsonField = metaprompt + /** * Returns the raw JSON value of [overallFeedback]. * @@ -119,9 +134,9 @@ private constructor( /** A builder for [DemoConfig]. */ class Builder internal constructor() { - private var examples: JsonField>? = null + private var examples: JsonField>? = null private var messageIndex: JsonField? = null - private var metaprompt: JsonValue? = null + private var metaprompt: JsonField? = null private var overallFeedback: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -134,25 +149,25 @@ private constructor( additionalProperties = demoConfig.additionalProperties.toMutableMap() } - fun examples(examples: List) = examples(JsonField.of(examples)) + fun examples(examples: List) = examples(JsonField.of(examples)) /** * Sets [Builder.examples] to an arbitrary JSON value. * - * You should usually call [Builder.examples] with a well-typed `List` value + * You should usually call [Builder.examples] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun examples(examples: JsonField>) = apply { + fun examples(examples: JsonField>) = apply { this.examples = examples.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [examples]. + * Adds a single [Example] to [examples]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExample(example: JsonValue) = apply { + fun addExample(example: Example) = apply { examples = (examples ?: JsonField.of(mutableListOf())).also { checkKnown("examples", it).add(example) @@ -170,7 +185,16 @@ private constructor( */ fun messageIndex(messageIndex: JsonField) = apply { this.messageIndex = messageIndex } - fun metaprompt(metaprompt: JsonValue) = apply { this.metaprompt = metaprompt } + fun metaprompt(metaprompt: Metaprompt) = metaprompt(JsonField.of(metaprompt)) + + /** + * Sets [Builder.metaprompt] to an arbitrary JSON value. + * + * You should usually call [Builder.metaprompt] with a well-typed [Metaprompt] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metaprompt(metaprompt: JsonField) = apply { this.metaprompt = metaprompt } fun overallFeedback(overallFeedback: String?) = overallFeedback(JsonField.ofNullable(overallFeedback)) @@ -241,8 +265,9 @@ private constructor( return@apply } - examples() + examples().forEach { it.validate() } messageIndex() + metaprompt().validate() overallFeedback() validated = true } @@ -262,10 +287,209 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (examples.asKnown().getOrNull()?.size ?: 0) + + (examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (messageIndex.asKnown().isPresent) 1 else 0) + + (metaprompt.asKnown().getOrNull()?.validity() ?: 0) + (if (overallFeedback.asKnown().isPresent) 1 else 0) + class Example + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Example]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Example]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(example: Example) = apply { + additionalProperties = example.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) + } + + /** + * Returns an immutable instance of [Example]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Example = Example(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Example = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Example && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Example{additionalProperties=$additionalProperties}" + } + + class Metaprompt + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metaprompt]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metaprompt]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metaprompt: Metaprompt) = apply { + additionalProperties = metaprompt.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) + } + + /** + * Returns an immutable instance of [Metaprompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metaprompt = Metaprompt(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metaprompt = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metaprompt && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metaprompt{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt index 28d46491..0110cb23 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt @@ -399,21 +399,21 @@ private constructor( private val directChildRunIds: JsonField>, private val endTime: JsonField, private val error: JsonField, - private val events: JsonField>, + private val events: JsonField>, private val executionOrder: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val feedbackStats: JsonField, private val firstTokenTime: JsonField, private val inDataset: JsonField, - private val inputs: JsonValue, + private val inputs: JsonField, private val inputsPreview: JsonField, - private val inputsS3Urls: JsonValue, + private val inputsS3Urls: JsonField, private val lastQueuedAt: JsonField, private val manifestId: JsonField, private val manifestS3Id: JsonField, - private val outputs: JsonValue, + private val outputs: JsonField, private val outputsPreview: JsonField, - private val outputsS3Urls: JsonValue, + private val outputsS3Urls: JsonField, private val parentRunId: JsonField, private val parentRunIds: JsonField>, private val priceModelId: JsonField, @@ -423,8 +423,8 @@ private constructor( private val promptTokens: JsonField, private val referenceDatasetId: JsonField, private val referenceExampleId: JsonField, - private val s3Urls: JsonValue, - private val serialized: JsonValue, + private val s3Urls: JsonField, + private val serialized: JsonField, private val shareToken: JsonField, private val startTime: JsonField, private val tags: JsonField>, @@ -480,11 +480,11 @@ private constructor( @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), @JsonProperty("events") @ExcludeMissing - events: JsonField> = JsonMissing.of(), + events: JsonField> = JsonMissing.of(), @JsonProperty("execution_order") @ExcludeMissing executionOrder: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonField = JsonMissing.of(), @@ -494,13 +494,13 @@ private constructor( @JsonProperty("in_dataset") @ExcludeMissing inDataset: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), @JsonProperty("inputs_preview") @ExcludeMissing inputsPreview: JsonField = JsonMissing.of(), @JsonProperty("inputs_s3_urls") @ExcludeMissing - inputsS3Urls: JsonValue = JsonMissing.of(), + inputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("last_queued_at") @ExcludeMissing lastQueuedAt: JsonField = JsonMissing.of(), @@ -510,13 +510,13 @@ private constructor( @JsonProperty("manifest_s3_id") @ExcludeMissing manifestS3Id: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), @JsonProperty("outputs_preview") @ExcludeMissing outputsPreview: JsonField = JsonMissing.of(), @JsonProperty("outputs_s3_urls") @ExcludeMissing - outputsS3Urls: JsonValue = JsonMissing.of(), + outputsS3Urls: JsonField = JsonMissing.of(), @JsonProperty("parent_run_id") @ExcludeMissing parentRunId: JsonField = JsonMissing.of(), @@ -544,8 +544,10 @@ private constructor( @JsonProperty("reference_example_id") @ExcludeMissing referenceExampleId: JsonField = JsonMissing.of(), - @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), - @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonField = JsonMissing.of(), + @JsonProperty("serialized") + @ExcludeMissing + serialized: JsonField = JsonMissing.of(), @JsonProperty("share_token") @ExcludeMissing shareToken: JsonField = JsonMissing.of(), @@ -743,7 +745,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun events(): Optional> = events.getOptional("events") + fun events(): Optional> = events.getOptional("events") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -751,7 +753,11 @@ private constructor( */ fun executionOrder(): Optional = executionOrder.getOptional("execution_order") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -772,7 +778,11 @@ private constructor( */ fun inDataset(): Optional = inDataset.getOptional("in_dataset") - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -780,9 +790,11 @@ private constructor( */ fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") - @JsonProperty("inputs_s3_urls") - @ExcludeMissing - fun _inputsS3Urls(): JsonValue = inputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsS3Urls(): Optional = inputsS3Urls.getOptional("inputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -802,7 +814,11 @@ private constructor( */ fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -810,9 +826,11 @@ private constructor( */ fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") - @JsonProperty("outputs_s3_urls") - @ExcludeMissing - fun _outputsS3Urls(): JsonValue = outputsS3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsS3Urls(): Optional = outputsS3Urls.getOptional("outputs_s3_urls") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -872,9 +890,17 @@ private constructor( fun referenceExampleId(): Optional = referenceExampleId.getOptional("reference_example_id") - @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun s3Urls(): Optional = s3Urls.getOptional("s3_urls") - @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun serialized(): Optional = serialized.getOptional("serialized") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1089,7 +1115,7 @@ private constructor( * * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Returns the raw JSON value of [executionOrder]. @@ -1101,6 +1127,13 @@ private constructor( @ExcludeMissing fun _executionOrder(): JsonField = executionOrder + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [feedbackStats]. * @@ -1128,6 +1161,13 @@ private constructor( */ @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField = inDataset + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + /** * Returns the raw JSON value of [inputsPreview]. * @@ -1138,6 +1178,16 @@ private constructor( @ExcludeMissing fun _inputsPreview(): JsonField = inputsPreview + /** + * Returns the raw JSON value of [inputsS3Urls]. + * + * Unlike [inputsS3Urls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + fun _inputsS3Urls(): JsonField = inputsS3Urls + /** * Returns the raw JSON value of [lastQueuedAt]. * @@ -1167,6 +1217,13 @@ private constructor( @ExcludeMissing fun _manifestS3Id(): JsonField = manifestS3Id + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + /** * Returns the raw JSON value of [outputsPreview]. * @@ -1177,6 +1234,16 @@ private constructor( @ExcludeMissing fun _outputsPreview(): JsonField = outputsPreview + /** + * Returns the raw JSON value of [outputsS3Urls]. + * + * Unlike [outputsS3Urls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + fun _outputsS3Urls(): JsonField = outputsS3Urls + /** * Returns the raw JSON value of [parentRunId]. * @@ -1265,6 +1332,22 @@ private constructor( @ExcludeMissing fun _referenceExampleId(): JsonField = referenceExampleId + /** + * Returns the raw JSON value of [s3Urls]. + * + * Unlike [s3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonField = s3Urls + + /** + * Returns the raw JSON value of [serialized]. + * + * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("serialized") + @ExcludeMissing + fun _serialized(): JsonField = serialized + /** * Returns the raw JSON value of [shareToken]. * @@ -1420,21 +1503,21 @@ private constructor( private var directChildRunIds: JsonField>? = null private var endTime: JsonField = JsonMissing.of() private var error: JsonField = JsonMissing.of() - private var events: JsonField>? = null + private var events: JsonField>? = null private var executionOrder: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var feedbackStats: JsonField = JsonMissing.of() private var firstTokenTime: JsonField = JsonMissing.of() private var inDataset: JsonField = JsonMissing.of() - private var inputs: JsonValue = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() private var inputsPreview: JsonField = JsonMissing.of() - private var inputsS3Urls: JsonValue = JsonMissing.of() + private var inputsS3Urls: JsonField = JsonMissing.of() private var lastQueuedAt: JsonField = JsonMissing.of() private var manifestId: JsonField = JsonMissing.of() private var manifestS3Id: JsonField = JsonMissing.of() - private var outputs: JsonValue = JsonMissing.of() + private var outputs: JsonField = JsonMissing.of() private var outputsPreview: JsonField = JsonMissing.of() - private var outputsS3Urls: JsonValue = JsonMissing.of() + private var outputsS3Urls: JsonField = JsonMissing.of() private var parentRunId: JsonField = JsonMissing.of() private var parentRunIds: JsonField>? = null private var priceModelId: JsonField = JsonMissing.of() @@ -1444,8 +1527,8 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() private var referenceExampleId: JsonField = JsonMissing.of() - private var s3Urls: JsonValue = JsonMissing.of() - private var serialized: JsonValue = JsonMissing.of() + private var s3Urls: JsonField = JsonMissing.of() + private var serialized: JsonField = JsonMissing.of() private var shareToken: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var tags: JsonField>? = null @@ -1776,28 +1859,28 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } - fun events(events: List?) = events(JsonField.ofNullable(events)) + fun events(events: List?) = events(JsonField.ofNullable(events)) /** Alias for calling [Builder.events] with `events.orElse(null)`. */ - fun events(events: Optional>) = events(events.getOrNull()) + fun events(events: Optional>) = events(events.getOrNull()) /** * Sets [Builder.events] to an arbitrary JSON value. * - * You should usually call [Builder.events] with a well-typed `List` value + * You should usually call [Builder.events] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun events(events: JsonField>) = apply { + fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [events]. + * Adds a single [Event] to [events]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addEvent(event: JsonValue) = apply { + fun addEvent(event: Event) = apply { events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) @@ -1817,7 +1900,19 @@ private constructor( this.executionOrder = executionOrder } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun feedbackStats(feedbackStats: FeedbackStats?) = feedbackStats(JsonField.ofNullable(feedbackStats)) @@ -1876,7 +1971,19 @@ private constructor( */ fun inDataset(inDataset: JsonField) = apply { this.inDataset = inDataset } - fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) + + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } fun inputsPreview(inputsPreview: String?) = inputsPreview(JsonField.ofNullable(inputsPreview)) @@ -1896,7 +2003,23 @@ private constructor( this.inputsPreview = inputsPreview } - fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + fun inputsS3Urls(inputsS3Urls: InputsS3Urls?) = + inputsS3Urls(JsonField.ofNullable(inputsS3Urls)) + + /** Alias for calling [Builder.inputsS3Urls] with `inputsS3Urls.orElse(null)`. */ + fun inputsS3Urls(inputsS3Urls: Optional) = + inputsS3Urls(inputsS3Urls.getOrNull()) + + /** + * Sets [Builder.inputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsS3Urls] with a well-typed [InputsS3Urls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputsS3Urls(inputsS3Urls: JsonField) = apply { + this.inputsS3Urls = inputsS3Urls + } fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) @@ -1948,7 +2071,19 @@ private constructor( this.manifestS3Id = manifestS3Id } - fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } fun outputsPreview(outputsPreview: String?) = outputsPreview(JsonField.ofNullable(outputsPreview)) @@ -1968,7 +2103,21 @@ private constructor( this.outputsPreview = outputsPreview } - fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { + fun outputsS3Urls(outputsS3Urls: OutputsS3Urls?) = + outputsS3Urls(JsonField.ofNullable(outputsS3Urls)) + + /** Alias for calling [Builder.outputsS3Urls] with `outputsS3Urls.orElse(null)`. */ + fun outputsS3Urls(outputsS3Urls: Optional) = + outputsS3Urls(outputsS3Urls.getOrNull()) + + /** + * Sets [Builder.outputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsS3Urls] with a well-typed [OutputsS3Urls] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputsS3Urls(outputsS3Urls: JsonField) = apply { this.outputsS3Urls = outputsS3Urls } @@ -2146,9 +2295,35 @@ private constructor( this.referenceExampleId = referenceExampleId } - fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + fun s3Urls(s3Urls: S3Urls?) = s3Urls(JsonField.ofNullable(s3Urls)) - fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + /** Alias for calling [Builder.s3Urls] with `s3Urls.orElse(null)`. */ + fun s3Urls(s3Urls: Optional) = s3Urls(s3Urls.getOrNull()) + + /** + * Sets [Builder.s3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.s3Urls] with a well-typed [S3Urls] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun s3Urls(s3Urls: JsonField) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: Serialized?) = serialized(JsonField.ofNullable(serialized)) + + /** Alias for calling [Builder.serialized] with `serialized.orElse(null)`. */ + fun serialized(serialized: Optional) = serialized(serialized.getOrNull()) + + /** + * Sets [Builder.serialized] to an arbitrary JSON value. + * + * You should usually call [Builder.serialized] with a well-typed [Serialized] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serialized(serialized: JsonField) = apply { + this.serialized = serialized + } fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) @@ -2472,16 +2647,21 @@ private constructor( directChildRunIds() endTime() error() - events() + events().ifPresent { it.forEach { it.validate() } } executionOrder() + extra().ifPresent { it.validate() } feedbackStats().ifPresent { it.validate() } firstTokenTime() inDataset() + inputs().ifPresent { it.validate() } inputsPreview() + inputsS3Urls().ifPresent { it.validate() } lastQueuedAt() manifestId() manifestS3Id() + outputs().ifPresent { it.validate() } outputsPreview() + outputsS3Urls().ifPresent { it.validate() } parentRunId() parentRunIds() priceModelId() @@ -2491,6 +2671,8 @@ private constructor( promptTokens() referenceDatasetId() referenceExampleId() + s3Urls().ifPresent { it.validate() } + serialized().ifPresent { it.validate() } shareToken() startTime() tags() @@ -2538,16 +2720,21 @@ private constructor( (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + (if (endTime.asKnown().isPresent) 1 else 0) + (if (error.asKnown().isPresent) 1 else 0) + - (events.asKnown().getOrNull()?.size ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + (if (inDataset.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (inputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + (if (manifestId.asKnown().isPresent) 1 else 0) + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (outputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + (if (parentRunId.asKnown().isPresent) 1 else 0) + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + (if (priceModelId.asKnown().isPresent) 1 else 0) + @@ -2557,6 +2744,8 @@ private constructor( (if (promptTokens.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (s3Urls.asKnown().getOrNull()?.validity() ?: 0) + + (serialized.asKnown().getOrNull()?.validity() ?: 0) + (if (shareToken.asKnown().isPresent) 1 else 0) + (if (startTime.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + @@ -2948,6 +3137,210 @@ private constructor( "CompletionTokenDetails{additionalProperties=$additionalProperties}" } + class Event + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Event]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Event]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(event: Event) = apply { + additionalProperties = event.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) + } + + /** + * Returns an immutable instance of [Event]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Event = Event(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Event = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Event && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Event{additionalProperties=$additionalProperties}" + } + + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + class FeedbackStats @JsonCreator private constructor( @@ -3050,6 +3443,414 @@ private constructor( override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" } + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class InputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsS3Urls: InputsS3Urls) = apply { + additionalProperties = inputsS3Urls.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) + } + + /** + * Returns an immutable instance of [InputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsS3Urls = InputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "InputsS3Urls{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + + class OutputsS3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OutputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsS3Urls: OutputsS3Urls) = apply { + additionalProperties = outputsS3Urls.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) + } + + /** + * Returns an immutable instance of [OutputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsS3Urls = OutputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsS3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OutputsS3Urls{additionalProperties=$additionalProperties}" + } + class PromptCostDetails @JsonCreator private constructor( @@ -3264,6 +4065,210 @@ private constructor( "PromptTokenDetails{additionalProperties=$additionalProperties}" } + class S3Urls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [S3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3Urls: S3Urls) = apply { + additionalProperties = s3Urls.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) + } + + /** + * Returns an immutable instance of [S3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): S3Urls = S3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): S3Urls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "S3Urls{additionalProperties=$additionalProperties}" + } + + class Serialized + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Serialized]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Serialized]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serialized: Serialized) = apply { + additionalProperties = serialized.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) + } + + /** + * Returns an immutable instance of [Serialized]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Serialized = Serialized(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Serialized = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Serialized && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Serialized{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/CustomChartsSection.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/CustomChartsSection.kt index 891a40c3..e8111895 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/CustomChartsSection.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/CustomChartsSection.kt @@ -424,7 +424,7 @@ private constructor( private val title: JsonField, private val commonFilters: JsonField, private val description: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -446,7 +446,9 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), ) : this( id, chartType, @@ -510,7 +512,11 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * Returns the raw JSON value of [id]. @@ -575,6 +581,13 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -616,7 +629,7 @@ private constructor( private var title: JsonField? = null private var commonFilters: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -762,7 +775,19 @@ private constructor( this.description = description } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -830,6 +855,7 @@ private constructor( title() commonFilters().ifPresent { it.validate() } description() + metadata().ifPresent { it.validate() } validated = true } @@ -856,7 +882,8 @@ private constructor( (series.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (title.asKnown().isPresent) 1 else 0) + (commonFilters.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Enum for custom chart types. */ class ChartType @JsonCreator private constructor(private val value: JsonField) : @@ -1156,8 +1183,9 @@ private constructor( /** Alias for calling [value] with `Value.ofNumber(number)`. */ fun value(number: Double) = value(Value.ofNumber(number)) - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) + /** Alias for calling [value] with `Value.ofUnionMember1(unionMember1)`. */ + fun value(unionMember1: Value.UnionMember1) = + value(Value.ofUnionMember1(unionMember1)) fun group(group: String?) = group(JsonField.ofNullable(group)) @@ -1259,28 +1287,28 @@ private constructor( class Value private constructor( private val number: Double? = null, - private val json: JsonValue? = null, + private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { fun number(): Optional = Optional.ofNullable(number) - fun json(): Optional = Optional.ofNullable(json) + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) fun isNumber(): Boolean = number != null - fun isJson(): Boolean = json != null + fun isUnionMember1(): Boolean = unionMember1 != null fun asNumber(): Double = number.getOrThrow("number") - fun asJson(): JsonValue = json.getOrThrow("json") + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) - json != null -> visitor.visitJson(json) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) else -> visitor.unknown(_json) } @@ -1295,7 +1323,9 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) {} - override fun visitJson(json: JsonValue) {} + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } } ) validated = true @@ -1321,7 +1351,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitJson(json: JsonValue) = 1 + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1332,15 +1363,17 @@ private constructor( return true } - return other is Value && number == other.number && json == other.json + return other is Value && + number == other.number && + unionMember1 == other.unionMember1 } - override fun hashCode(): Int = Objects.hash(number, json) + override fun hashCode(): Int = Objects.hash(number, unionMember1) override fun toString(): String = when { number != null -> "Value{number=$number}" - json != null -> "Value{json=$json}" + unionMember1 != null -> "Value{unionMember1=$unionMember1}" _json != null -> "Value{_unknown=$_json}" else -> throw IllegalStateException("Invalid Value") } @@ -1349,7 +1382,9 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Value(number = number) - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + Value(unionMember1 = unionMember1) } /** @@ -1360,7 +1395,7 @@ private constructor( fun visitNumber(number: Double): T - fun visitJson(json: JsonValue): T + fun visitUnionMember1(unionMember1: UnionMember1): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -1384,19 +1419,20 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(unionMember1 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Value(number = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely - // incompatible with all the possible variants. + // incompatible with all the possible variants (e.g. deserializing from + // boolean). 0 -> Value(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -1416,12 +1452,121 @@ private constructor( ) { when { value.number != null -> generator.writeObject(value.number) - value.json != null -> generator.writeObject(value.json) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Value") } } } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember1]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.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) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { @@ -3533,6 +3678,108 @@ private constructor( "CommonFilters{filter=$filter, session=$session, traceFilter=$traceFilter, treeFilter=$treeFilter, additionalProperties=$additionalProperties}" } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3878,7 +4125,7 @@ private constructor( private val title: JsonField, private val commonFilters: JsonField, private val description: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -3902,7 +4149,9 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), ) : this( id, chartType, @@ -3973,7 +4222,11 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * Returns the raw JSON value of [id]. @@ -4040,6 +4293,16 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4081,7 +4344,7 @@ private constructor( private var title: JsonField? = null private var commonFilters: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4231,7 +4494,19 @@ private constructor( this.description = description } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4302,6 +4577,7 @@ private constructor( title() commonFilters().ifPresent { it.validate() } description() + metadata().ifPresent { it.validate() } validated = true } @@ -4328,7 +4604,8 @@ private constructor( (series.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (title.asKnown().isPresent) 1 else 0) + (commonFilters.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Enum for custom chart types. */ class ChartType @JsonCreator private constructor(private val value: JsonField) : @@ -4636,8 +4913,9 @@ private constructor( /** Alias for calling [value] with `Value.ofNumber(number)`. */ fun value(number: Double) = value(Value.ofNumber(number)) - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) + /** Alias for calling [value] with `Value.ofUnionMember1(unionMember1)`. */ + fun value(unionMember1: Value.UnionMember1) = + value(Value.ofUnionMember1(unionMember1)) fun group(group: String?) = group(JsonField.ofNullable(group)) @@ -4739,28 +5017,28 @@ private constructor( class Value private constructor( private val number: Double? = null, - private val json: JsonValue? = null, + private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { fun number(): Optional = Optional.ofNullable(number) - fun json(): Optional = Optional.ofNullable(json) + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) fun isNumber(): Boolean = number != null - fun isJson(): Boolean = json != null + fun isUnionMember1(): Boolean = unionMember1 != null fun asNumber(): Double = number.getOrThrow("number") - fun asJson(): JsonValue = json.getOrThrow("json") + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) - json != null -> visitor.visitJson(json) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) else -> visitor.unknown(_json) } @@ -4775,7 +5053,9 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) {} - override fun visitJson(json: JsonValue) {} + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } } ) validated = true @@ -4801,7 +5081,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitJson(json: JsonValue) = 1 + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() override fun unknown(json: JsonValue?) = 0 } @@ -4812,15 +5093,17 @@ private constructor( return true } - return other is Value && number == other.number && json == other.json + return other is Value && + number == other.number && + unionMember1 == other.unionMember1 } - override fun hashCode(): Int = Objects.hash(number, json) + override fun hashCode(): Int = Objects.hash(number, unionMember1) override fun toString(): String = when { number != null -> "Value{number=$number}" - json != null -> "Value{json=$json}" + unionMember1 != null -> "Value{unionMember1=$unionMember1}" _json != null -> "Value{_unknown=$_json}" else -> throw IllegalStateException("Invalid Value") } @@ -4829,7 +5112,9 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Value(number = number) - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + Value(unionMember1 = unionMember1) } /** @@ -4840,7 +5125,7 @@ private constructor( fun visitNumber(number: Double): T - fun visitJson(json: JsonValue): T + fun visitUnionMember1(unionMember1: UnionMember1): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -4864,19 +5149,20 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(unionMember1 = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Value(number = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely - // incompatible with all the possible variants. + // incompatible with all the possible variants (e.g. deserializing + // from boolean). 0 -> Value(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then @@ -4897,12 +5183,126 @@ private constructor( ) { when { value.number != null -> generator.writeObject(value.number) - value.json != null -> generator.writeObject(value.json) + value.unionMember1 != null -> + generator.writeObject(value.unionMember1) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Value") } } } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember1]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = + unionMember1.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) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): UnionMember1 = + UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { @@ -7054,6 +7454,110 @@ private constructor( "CommonFilters{filter=$filter, session=$session, traceFilter=$traceFilter, treeFilter=$treeFilter, additionalProperties=$additionalProperties}" } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionCreateParams.kt index b1b341f8..d56e2b4e 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionCreateParams.kt @@ -14,6 +14,7 @@ import com.langchain.smith.core.JsonValue import com.langchain.smith.core.Params import com.langchain.smith.core.http.Headers import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -56,7 +57,11 @@ private constructor( */ fun endTime(): Optional = body.endTime() - fun _extra(): JsonValue = body._extra() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = body.extra() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -111,6 +116,13 @@ private constructor( */ fun _endTime(): JsonField = body._endTime() + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _extra(): JsonField = body._extra() + /** * Returns the raw JSON value of [name]. * @@ -260,7 +272,18 @@ private constructor( */ fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } - fun extra(extra: JsonValue) = apply { body.extra(extra) } + fun extra(extra: Extra?) = apply { body.extra(extra) } + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { body.extra(extra) } fun name(name: String) = apply { body.name(name) } @@ -469,7 +492,7 @@ private constructor( private val defaultDatasetId: JsonField, private val description: JsonField, private val endTime: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val name: JsonField, private val referenceDatasetId: JsonField, private val startTime: JsonField, @@ -489,7 +512,7 @@ private constructor( @JsonProperty("end_time") @ExcludeMissing endTime: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("reference_dataset_id") @ExcludeMissing @@ -538,7 +561,11 @@ private constructor( */ fun endTime(): Optional = endTime.getOptional("end_time") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -600,6 +627,13 @@ private constructor( @ExcludeMissing fun _endTime(): JsonField = endTime + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [name]. * @@ -660,7 +694,7 @@ private constructor( private var defaultDatasetId: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() @@ -745,7 +779,19 @@ private constructor( */ fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun name(name: String) = name(JsonField.of(name)) @@ -856,6 +902,7 @@ private constructor( defaultDatasetId() description() endTime() + extra().ifPresent { it.validate() } name() referenceDatasetId() startTime() @@ -883,6 +930,7 @@ private constructor( (if (defaultDatasetId.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (endTime.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (startTime.asKnown().isPresent) 1 else 0) + @@ -927,6 +975,105 @@ private constructor( "Body{id=$id, defaultDatasetId=$defaultDatasetId, description=$description, endTime=$endTime, extra=$extra, name=$name, referenceDatasetId=$referenceDatasetId, startTime=$startTime, traceTier=$traceTier, additionalProperties=$additionalProperties}" } + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionUpdateParams.kt index 3a334b6f..fd01e8ba 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/SessionUpdateParams.kt @@ -14,6 +14,7 @@ import com.langchain.smith.core.JsonValue import com.langchain.smith.core.Params import com.langchain.smith.core.http.Headers import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -50,7 +51,11 @@ private constructor( */ fun endTime(): Optional = body.endTime() - fun _extra(): JsonValue = body._extra() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = body.extra() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -86,6 +91,13 @@ private constructor( */ fun _endTime(): JsonField = body._endTime() + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _extra(): JsonField = body._extra() + /** * Returns the raw JSON value of [name]. * @@ -200,7 +212,18 @@ private constructor( */ fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } - fun extra(extra: JsonValue) = apply { body.extra(extra) } + fun extra(extra: Extra?) = apply { body.extra(extra) } + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { body.extra(extra) } fun name(name: String?) = apply { body.name(name) } @@ -379,7 +402,7 @@ private constructor( private val defaultDatasetId: JsonField, private val description: JsonField, private val endTime: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val name: JsonField, private val traceTier: JsonField, private val additionalProperties: MutableMap, @@ -396,7 +419,7 @@ private constructor( @JsonProperty("end_time") @ExcludeMissing endTime: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("trace_tier") @ExcludeMissing @@ -422,7 +445,11 @@ private constructor( */ fun endTime(): Optional = endTime.getOptional("end_time") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -464,6 +491,13 @@ private constructor( @ExcludeMissing fun _endTime(): JsonField = endTime + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [name]. * @@ -504,7 +538,7 @@ private constructor( private var defaultDatasetId: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var traceTier: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -570,7 +604,19 @@ private constructor( */ fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -646,6 +692,7 @@ private constructor( defaultDatasetId() description() endTime() + extra().ifPresent { it.validate() } name() traceTier().ifPresent { it.validate() } validated = true @@ -670,6 +717,7 @@ private constructor( (if (defaultDatasetId.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (endTime.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (traceTier.asKnown().getOrNull()?.validity() ?: 0) @@ -706,6 +754,105 @@ private constructor( "Body{defaultDatasetId=$defaultDatasetId, description=$description, endTime=$endTime, extra=$extra, name=$name, traceTier=$traceTier, additionalProperties=$additionalProperties}" } + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSession.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSession.kt index e0c1f8b6..7c0ce495 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSession.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSession.kt @@ -33,8 +33,8 @@ private constructor( private val description: JsonField, private val endTime: JsonField, private val errorRate: JsonField, - private val extra: JsonValue, - private val feedbackStats: JsonValue, + private val extra: JsonField, + private val feedbackStats: JsonField, private val firstTokenP50: JsonField, private val firstTokenP99: JsonField, private val lastRunStartTime: JsonField, @@ -46,8 +46,8 @@ private constructor( private val promptTokens: JsonField, private val referenceDatasetId: JsonField, private val runCount: JsonField, - private val runFacets: JsonField>, - private val sessionFeedbackStats: JsonValue, + private val runFacets: JsonField>, + private val sessionFeedbackStats: JsonField, private val startTime: JsonField, private val streamingRate: JsonField, private val testRunNumber: JsonField, @@ -77,8 +77,10 @@ private constructor( @ExcludeMissing endTime: JsonField = JsonMissing.of(), @JsonProperty("error_rate") @ExcludeMissing errorRate: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), - @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField = JsonMissing.of(), @JsonProperty("first_token_p50") @ExcludeMissing firstTokenP50: JsonField = JsonMissing.of(), @@ -110,10 +112,10 @@ private constructor( @JsonProperty("run_count") @ExcludeMissing runCount: JsonField = JsonMissing.of(), @JsonProperty("run_facets") @ExcludeMissing - runFacets: JsonField> = JsonMissing.of(), + runFacets: JsonField> = JsonMissing.of(), @JsonProperty("session_feedback_stats") @ExcludeMissing - sessionFeedbackStats: JsonValue = JsonMissing.of(), + sessionFeedbackStats: JsonField = JsonMissing.of(), @JsonProperty("start_time") @ExcludeMissing startTime: JsonField = JsonMissing.of(), @@ -211,9 +213,17 @@ private constructor( */ fun errorRate(): Optional = errorRate.getOptional("error_rate") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") - @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -288,11 +298,14 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun runFacets(): Optional> = runFacets.getOptional("run_facets") + fun runFacets(): Optional> = runFacets.getOptional("run_facets") - @JsonProperty("session_feedback_stats") - @ExcludeMissing - fun _sessionFeedbackStats(): JsonValue = sessionFeedbackStats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sessionFeedbackStats(): Optional = + sessionFeedbackStats.getOptional("session_feedback_stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -394,6 +407,22 @@ private constructor( */ @JsonProperty("error_rate") @ExcludeMissing fun _errorRate(): JsonField = errorRate + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + /** * Returns the raw JSON value of [firstTokenP50]. * @@ -493,7 +522,17 @@ private constructor( */ @JsonProperty("run_facets") @ExcludeMissing - fun _runFacets(): JsonField> = runFacets + fun _runFacets(): JsonField> = runFacets + + /** + * Returns the raw JSON value of [sessionFeedbackStats]. + * + * Unlike [sessionFeedbackStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("session_feedback_stats") + @ExcludeMissing + fun _sessionFeedbackStats(): JsonField = sessionFeedbackStats /** * Returns the raw JSON value of [startTime]. @@ -580,8 +619,8 @@ private constructor( private var description: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() private var errorRate: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() - private var feedbackStats: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() private var firstTokenP50: JsonField = JsonMissing.of() private var firstTokenP99: JsonField = JsonMissing.of() private var lastRunStartTime: JsonField = JsonMissing.of() @@ -593,8 +632,8 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() private var runCount: JsonField = JsonMissing.of() - private var runFacets: JsonField>? = null - private var sessionFeedbackStats: JsonValue = JsonMissing.of() + private var runFacets: JsonField>? = null + private var sessionFeedbackStats: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var streamingRate: JsonField = JsonMissing.of() private var testRunNumber: JsonField = JsonMissing.of() @@ -767,9 +806,36 @@ private constructor( */ fun errorRate(errorRate: JsonField) = apply { this.errorRate = errorRate } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { + this.feedbackStats = feedbackStats + } fun firstTokenP50(firstTokenP50: Double?) = firstTokenP50(JsonField.ofNullable(firstTokenP50)) @@ -987,35 +1053,52 @@ private constructor( */ fun runCount(runCount: JsonField) = apply { this.runCount = runCount } - fun runFacets(runFacets: List?) = runFacets(JsonField.ofNullable(runFacets)) + fun runFacets(runFacets: List?) = runFacets(JsonField.ofNullable(runFacets)) /** Alias for calling [Builder.runFacets] with `runFacets.orElse(null)`. */ - fun runFacets(runFacets: Optional>) = runFacets(runFacets.getOrNull()) + fun runFacets(runFacets: Optional>) = runFacets(runFacets.getOrNull()) /** * Sets [Builder.runFacets] to an arbitrary JSON value. * - * You should usually call [Builder.runFacets] with a well-typed `List` value + * You should usually call [Builder.runFacets] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun runFacets(runFacets: JsonField>) = apply { + fun runFacets(runFacets: JsonField>) = apply { this.runFacets = runFacets.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [runFacets]. + * Adds a single [RunFacet] to [runFacets]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addRunFacet(runFacet: JsonValue) = apply { + fun addRunFacet(runFacet: RunFacet) = apply { runFacets = (runFacets ?: JsonField.of(mutableListOf())).also { checkKnown("runFacets", it).add(runFacet) } } - fun sessionFeedbackStats(sessionFeedbackStats: JsonValue) = apply { + fun sessionFeedbackStats(sessionFeedbackStats: SessionFeedbackStats?) = + sessionFeedbackStats(JsonField.ofNullable(sessionFeedbackStats)) + + /** + * Alias for calling [Builder.sessionFeedbackStats] with + * `sessionFeedbackStats.orElse(null)`. + */ + fun sessionFeedbackStats(sessionFeedbackStats: Optional) = + sessionFeedbackStats(sessionFeedbackStats.getOrNull()) + + /** + * Sets [Builder.sessionFeedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionFeedbackStats] with a well-typed + * [SessionFeedbackStats] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun sessionFeedbackStats(sessionFeedbackStats: JsonField) = apply { this.sessionFeedbackStats = sessionFeedbackStats } @@ -1209,6 +1292,8 @@ private constructor( description() endTime() errorRate() + extra().ifPresent { it.validate() } + feedbackStats().ifPresent { it.validate() } firstTokenP50() firstTokenP99() lastRunStartTime() @@ -1220,7 +1305,8 @@ private constructor( promptTokens() referenceDatasetId() runCount() - runFacets() + runFacets().ifPresent { it.forEach { it.validate() } } + sessionFeedbackStats().ifPresent { it.validate() } startTime() streamingRate() testRunNumber() @@ -1253,6 +1339,8 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endTime.asKnown().isPresent) 1 else 0) + (if (errorRate.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (firstTokenP50.asKnown().isPresent) 1 else 0) + (if (firstTokenP99.asKnown().isPresent) 1 else 0) + (if (lastRunStartTime.asKnown().isPresent) 1 else 0) + @@ -1264,7 +1352,8 @@ private constructor( (if (promptTokens.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (runCount.asKnown().isPresent) 1 else 0) + - (runFacets.asKnown().getOrNull()?.size ?: 0) + + (runFacets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (sessionFeedbackStats.asKnown().getOrNull()?.validity() ?: 0) + (if (startTime.asKnown().isPresent) 1 else 0) + (if (streamingRate.asKnown().isPresent) 1 else 0) + (if (testRunNumber.asKnown().isPresent) 1 else 0) + @@ -1272,6 +1361,404 @@ private constructor( (if (totalTokens.asKnown().isPresent) 1 else 0) + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.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) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class RunFacet + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunFacet]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunFacet]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runFacet: RunFacet) = apply { + additionalProperties = runFacet.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) + } + + /** + * Returns an immutable instance of [RunFacet]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunFacet = RunFacet(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunFacet = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunFacet && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunFacet{additionalProperties=$additionalProperties}" + } + + class SessionFeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SessionFeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionFeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionFeedbackStats: SessionFeedbackStats) = apply { + additionalProperties = sessionFeedbackStats.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) + } + + /** + * Returns an immutable instance of [SessionFeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionFeedbackStats = + SessionFeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SessionFeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionFeedbackStats && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SessionFeedbackStats{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFields.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFields.kt index 9dc91353..5a920453 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFields.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFields.kt @@ -12,6 +12,7 @@ import com.langchain.smith.core.JsonField import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -28,7 +29,7 @@ private constructor( private val defaultDatasetId: JsonField, private val description: JsonField, private val endTime: JsonField, - private val extra: JsonValue, + private val extra: JsonField, private val lastRunStartTimeLive: JsonField, private val name: JsonField, private val referenceDatasetId: JsonField, @@ -50,7 +51,7 @@ private constructor( @JsonProperty("end_time") @ExcludeMissing endTime: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("last_run_start_time_live") @ExcludeMissing lastRunStartTimeLive: JsonField = JsonMissing.of(), @@ -109,7 +110,11 @@ private constructor( */ fun endTime(): Optional = endTime.getOptional("end_time") - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -181,6 +186,13 @@ private constructor( */ @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField = endTime + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + /** * Returns the raw JSON value of [lastRunStartTimeLive]. * @@ -259,7 +271,7 @@ private constructor( private var defaultDatasetId: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() - private var extra: JsonValue = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() private var lastRunStartTimeLive: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var referenceDatasetId: JsonField = JsonMissing.of() @@ -351,7 +363,18 @@ private constructor( */ fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - fun extra(extra: JsonValue) = apply { this.extra = extra } + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } fun lastRunStartTimeLive(lastRunStartTimeLive: OffsetDateTime?) = lastRunStartTimeLive(JsonField.ofNullable(lastRunStartTimeLive)) @@ -490,6 +513,7 @@ private constructor( defaultDatasetId() description() endTime() + extra().ifPresent { it.validate() } lastRunStartTimeLive() name() referenceDatasetId() @@ -518,12 +542,112 @@ private constructor( (if (defaultDatasetId.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (endTime.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + (if (lastRunStartTimeLive.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + (if (startTime.asKnown().isPresent) 1 else 0) + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + class TraceTier @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt index 70aa8b43..b75e6945 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt @@ -24,7 +24,7 @@ import kotlin.jvm.optionals.getOrNull class CreateRunClusteringJobRequest @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val attributeSchemas: JsonValue, + private val attributeSchemas: JsonField, private val endTime: JsonField, private val filter: JsonField, private val hierarchy: JsonField>, @@ -44,7 +44,7 @@ private constructor( private constructor( @JsonProperty("attribute_schemas") @ExcludeMissing - attributeSchemas: JsonValue = JsonMissing.of(), + attributeSchemas: JsonField = JsonMissing.of(), @JsonProperty("end_time") @ExcludeMissing endTime: JsonField = JsonMissing.of(), @@ -90,9 +90,12 @@ private constructor( mutableMapOf(), ) - @JsonProperty("attribute_schemas") - @ExcludeMissing - fun _attributeSchemas(): JsonValue = attributeSchemas + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attributeSchemas(): Optional = + attributeSchemas.getOptional("attribute_schemas") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -167,6 +170,16 @@ private constructor( fun validateModelSecrets(): Optional = validateModelSecrets.getOptional("validate_model_secrets") + /** + * Returns the raw JSON value of [attributeSchemas]. + * + * Unlike [attributeSchemas], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attribute_schemas") + @ExcludeMissing + fun _attributeSchemas(): JsonField = attributeSchemas + /** * Returns the raw JSON value of [endTime]. * @@ -286,7 +299,7 @@ private constructor( /** A builder for [CreateRunClusteringJobRequest]. */ class Builder internal constructor() { - private var attributeSchemas: JsonValue = JsonMissing.of() + private var attributeSchemas: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var hierarchy: JsonField>? = null @@ -319,7 +332,21 @@ private constructor( additionalProperties = createRunClusteringJobRequest.additionalProperties.toMutableMap() } - fun attributeSchemas(attributeSchemas: JsonValue) = apply { + fun attributeSchemas(attributeSchemas: AttributeSchemas?) = + attributeSchemas(JsonField.ofNullable(attributeSchemas)) + + /** Alias for calling [Builder.attributeSchemas] with `attributeSchemas.orElse(null)`. */ + fun attributeSchemas(attributeSchemas: Optional) = + attributeSchemas(attributeSchemas.getOrNull()) + + /** + * Sets [Builder.attributeSchemas] to an arbitrary JSON value. + * + * You should usually call [Builder.attributeSchemas] with a well-typed [AttributeSchemas] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attributeSchemas(attributeSchemas: JsonField) = apply { this.attributeSchemas = attributeSchemas } @@ -567,6 +594,7 @@ private constructor( return@apply } + attributeSchemas().ifPresent { it.validate() } endTime() filter() hierarchy() @@ -597,7 +625,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (endTime.asKnown().isPresent) 1 else 0) + + (attributeSchemas.asKnown().getOrNull()?.validity() ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + (hierarchy.asKnown().getOrNull()?.size ?: 0) + (if (lastNHours.asKnown().isPresent) 1 else 0) + @@ -610,6 +639,105 @@ private constructor( (userContext.asKnown().getOrNull()?.validity() ?: 0) + (if (validateModelSecrets.asKnown().isPresent) 1 else 0) + class AttributeSchemas + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AttributeSchemas]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttributeSchemas]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributeSchemas: AttributeSchemas) = apply { + additionalProperties = attributeSchemas.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) + } + + /** + * Returns an immutable instance of [AttributeSchemas]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AttributeSchemas = AttributeSchemas(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AttributeSchemas = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttributeSchemas && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AttributeSchemas{additionalProperties=$additionalProperties}" + } + class Model @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt index 5ac4f3df..72aca854 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt @@ -30,7 +30,7 @@ private constructor( private val status: JsonField, private val endTime: JsonField, private val error: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val shape: JsonField, private val startTime: JsonField, private val additionalProperties: MutableMap, @@ -48,7 +48,7 @@ private constructor( @ExcludeMissing endTime: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("shape") @ExcludeMissing shape: JsonField = JsonMissing.of(), @JsonProperty("start_time") @ExcludeMissing @@ -91,7 +91,11 @@ private constructor( */ fun error(): Optional = error.getOptional("error") - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -147,6 +151,13 @@ private constructor( */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [shape]. * @@ -200,7 +211,7 @@ private constructor( private var status: JsonField? = null private var endTime: JsonField = JsonMissing.of() private var error: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var shape: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -301,7 +312,19 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun shape(shape: Shape?) = shape(JsonField.ofNullable(shape)) @@ -392,6 +415,7 @@ private constructor( status() endTime() error() + metadata().ifPresent { it.validate() } shape().ifPresent { it.validate() } startTime() validated = true @@ -418,6 +442,7 @@ private constructor( (if (status.asKnown().isPresent) 1 else 0) + (if (endTime.asKnown().isPresent) 1 else 0) + (if (error.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (shape.asKnown().getOrNull()?.validity() ?: 0) + (if (startTime.asKnown().isPresent) 1 else 0) @@ -430,7 +455,7 @@ private constructor( private val level: JsonField, private val name: JsonField, private val numRuns: JsonField, - private val stats: JsonValue, + private val stats: JsonField, private val parentId: JsonField, private val parentName: JsonField, private val additionalProperties: MutableMap, @@ -445,7 +470,7 @@ private constructor( @JsonProperty("level") @ExcludeMissing level: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("num_runs") @ExcludeMissing numRuns: JsonField = JsonMissing.of(), - @JsonProperty("stats") @ExcludeMissing stats: JsonValue = JsonMissing.of(), + @JsonProperty("stats") @ExcludeMissing stats: JsonField = JsonMissing.of(), @JsonProperty("parent_id") @ExcludeMissing parentId: JsonField = JsonMissing.of(), @@ -484,7 +509,11 @@ private constructor( */ fun numRuns(): Long = numRuns.getRequired("num_runs") - @JsonProperty("stats") @ExcludeMissing fun _stats(): JsonValue = stats + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun stats(): Optional = stats.getOptional("stats") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -535,6 +564,13 @@ private constructor( */ @JsonProperty("num_runs") @ExcludeMissing fun _numRuns(): JsonField = numRuns + /** + * Returns the raw JSON value of [stats]. + * + * Unlike [stats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stats") @ExcludeMissing fun _stats(): JsonField = stats + /** * Returns the raw JSON value of [parentId]. * @@ -589,7 +625,7 @@ private constructor( private var level: JsonField? = null private var name: JsonField? = null private var numRuns: JsonField? = null - private var stats: JsonValue? = null + private var stats: JsonField? = null private var parentId: JsonField = JsonMissing.of() private var parentName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -664,7 +700,19 @@ private constructor( */ fun numRuns(numRuns: JsonField) = apply { this.numRuns = numRuns } - fun stats(stats: JsonValue) = apply { this.stats = stats } + fun stats(stats: Stats?) = stats(JsonField.ofNullable(stats)) + + /** Alias for calling [Builder.stats] with `stats.orElse(null)`. */ + fun stats(stats: Optional) = stats(stats.getOrNull()) + + /** + * Sets [Builder.stats] to an arbitrary JSON value. + * + * You should usually call [Builder.stats] with a well-typed [Stats] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun stats(stats: JsonField) = apply { this.stats = stats } fun parentId(parentId: String?) = parentId(JsonField.ofNullable(parentId)) @@ -756,6 +804,7 @@ private constructor( level() name() numRuns() + stats().ifPresent { it.validate() } parentId() parentName() validated = true @@ -782,9 +831,112 @@ private constructor( (if (level.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (numRuns.asKnown().isPresent) 1 else 0) + + (stats.asKnown().getOrNull()?.validity() ?: 0) + (if (parentId.asKnown().isPresent) 1 else 0) + (if (parentName.asKnown().isPresent) 1 else 0) + class Stats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Stats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Stats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stats: Stats) = apply { + additionalProperties = stats.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) + } + + /** + * Returns an immutable instance of [Stats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Stats = Stats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Stats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Stats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Stats{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -822,6 +974,105 @@ private constructor( "Cluster{id=$id, description=$description, level=$level, name=$name, numRuns=$numRuns, stats=$stats, parentId=$parentId, parentName=$parentName, additionalProperties=$additionalProperties}" } + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + 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) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Shape @JsonCreator private constructor( diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponse.kt index e4e9fda9..85116ccc 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponse.kt @@ -23,14 +23,14 @@ class InsightRetrieveRunsResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val offset: JsonField, - private val runs: JsonField>, + private val runs: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), - @JsonProperty("runs") @ExcludeMissing runs: JsonField> = JsonMissing.of(), + @JsonProperty("runs") @ExcludeMissing runs: JsonField> = JsonMissing.of(), ) : this(offset, runs, mutableMapOf()) /** @@ -43,7 +43,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun runs(): List = runs.getRequired("runs") + fun runs(): List = runs.getRequired("runs") /** * Returns the raw JSON value of [offset]. @@ -57,7 +57,7 @@ private constructor( * * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField> = runs + @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField> = runs @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -89,7 +89,7 @@ private constructor( class Builder internal constructor() { private var offset: JsonField? = null - private var runs: JsonField>? = null + private var runs: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -119,25 +119,22 @@ private constructor( */ fun offset(offset: JsonField) = apply { this.offset = offset } - fun runs(runs: List) = runs(JsonField.of(runs)) + fun runs(runs: List) = runs(JsonField.of(runs)) /** * Sets [Builder.runs] to an arbitrary JSON value. * - * You should usually call [Builder.runs] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.runs] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun runs(runs: JsonField>) = apply { - this.runs = runs.map { it.toMutableList() } - } + fun runs(runs: JsonField>) = apply { this.runs = runs.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [runs]. + * Adds a single [Run] to [runs]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addRun(run: JsonValue) = apply { + fun addRun(run: Run) = apply { runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } } @@ -189,7 +186,7 @@ private constructor( } offset() - runs() + runs().forEach { it.validate() } validated = true } @@ -208,7 +205,107 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (offset.asKnown().isPresent) 1 else 0) + (runs.asKnown().getOrNull()?.size ?: 0) + (if (offset.asKnown().isPresent) 1 else 0) + + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Run + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Run]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Run]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(run: Run) = apply { + additionalProperties = run.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) + } + + /** + * Returns an immutable instance of [Run]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Run = Run(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Run = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Run && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Run{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt index 2f930b37..ac5d0546 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt @@ -19,7 +19,11 @@ internal class AnnotationQueueAnnotationQueuesParamsTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueAnnotationQueuesParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .rubricInstructions("rubric_instructions") @@ -54,7 +58,11 @@ internal class AnnotationQueueAnnotationQueuesParamsTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueAnnotationQueuesParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .rubricInstructions("rubric_instructions") @@ -86,7 +94,12 @@ internal class AnnotationQueueAnnotationQueuesParamsTest { assertThat(body.defaultDataset()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.description()).contains("description") assertThat(body.enableReservations()).contains(true) - assertThat(body._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.metadata()) + .contains( + AnnotationQueueAnnotationQueuesParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.numReviewersPerItem()).contains(0L) assertThat(body.reservationMinutes()).contains(0L) assertThat(body.rubricInstructions()).contains("rubric_instructions") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt index eeae611b..8e813178 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt @@ -24,7 +24,11 @@ internal class AnnotationQueueRetrieveAnnotationQueuesResponseTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueRetrieveAnnotationQueuesResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -48,8 +52,12 @@ internal class AnnotationQueueRetrieveAnnotationQueuesResponseTest { .contains("description") assertThat(annotationQueueRetrieveAnnotationQueuesResponse.enableReservations()) .contains(true) - assertThat(annotationQueueRetrieveAnnotationQueuesResponse._metadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.metadata()) + .contains( + AnnotationQueueRetrieveAnnotationQueuesResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(annotationQueueRetrieveAnnotationQueuesResponse.numReviewersPerItem()) .contains(0L) assertThat(annotationQueueRetrieveAnnotationQueuesResponse.reservationMinutes()) @@ -76,7 +84,11 @@ internal class AnnotationQueueRetrieveAnnotationQueuesResponseTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueRetrieveAnnotationQueuesResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponseTest.kt index a7ec625c..8accd06c 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveResponseTest.kt @@ -24,7 +24,11 @@ internal class AnnotationQueueRetrieveResponseTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .rubricInstructions("rubric_instructions") @@ -62,8 +66,12 @@ internal class AnnotationQueueRetrieveResponseTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(annotationQueueRetrieveResponse.description()).contains("description") assertThat(annotationQueueRetrieveResponse.enableReservations()).contains(true) - assertThat(annotationQueueRetrieveResponse._metadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(annotationQueueRetrieveResponse.metadata()) + .contains( + AnnotationQueueRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(annotationQueueRetrieveResponse.numReviewersPerItem()).contains(0L) assertThat(annotationQueueRetrieveResponse.reservationMinutes()).contains(0L) assertThat(annotationQueueRetrieveResponse.rubricInstructions()) @@ -106,7 +114,11 @@ internal class AnnotationQueueRetrieveResponseTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .rubricInstructions("rubric_instructions") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchemaTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchemaTest.kt index 2002bf37..c5b42d51 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchemaTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueSchemaTest.kt @@ -23,7 +23,11 @@ internal class AnnotationQueueSchemaTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueSchema.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -43,8 +47,12 @@ internal class AnnotationQueueSchemaTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(annotationQueueSchema.description()).contains("description") assertThat(annotationQueueSchema.enableReservations()).contains(true) - assertThat(annotationQueueSchema._metadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(annotationQueueSchema.metadata()) + .contains( + AnnotationQueueSchema.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(annotationQueueSchema.numReviewersPerItem()).contains(0L) assertThat(annotationQueueSchema.reservationMinutes()).contains(0L) assertThat(annotationQueueSchema.runRuleId()) @@ -68,7 +76,11 @@ internal class AnnotationQueueSchemaTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueSchema.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParamsTest.kt index db0cea69..3db0e0a3 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueUpdateParamsTest.kt @@ -16,7 +16,11 @@ internal class AnnotationQueueUpdateParamsTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .numReviewersPerItem(0L) .reservationMinutes(0L) @@ -60,7 +64,11 @@ internal class AnnotationQueueUpdateParamsTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .numReviewersPerItem(0L) .reservationMinutes(0L) @@ -90,8 +98,10 @@ internal class AnnotationQueueUpdateParamsTest { assertThat(body.enableReservations()).contains(true) assertThat(body.metadata()) .contains( - AnnotationQueueUpdateParams.Metadata.ofJsonValue( - JsonValue.from(mapOf()) + AnnotationQueueUpdateParams.Metadata.ofUnionMember0( + AnnotationQueueUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() ) ) assertThat(body.name()).contains("name") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt index c14acbd9..b54b2650 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt @@ -43,26 +43,50 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .effectiveAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + RunSchemaWithAnnotationQueueInfo.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + RunSchemaWithAnnotationQueueInfo.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( RunSchemaWithAnnotationQueueInfo.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + RunSchemaWithAnnotationQueueInfo.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + RunSchemaWithAnnotationQueueInfo.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + RunSchemaWithAnnotationQueueInfo.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + RunSchemaWithAnnotationQueueInfo.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -80,8 +104,16 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + RunSchemaWithAnnotationQueueInfo.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + RunSchemaWithAnnotationQueueInfo.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -136,24 +168,40 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(runSchemaWithAnnotationQueueInfo.error()).contains("error") assertThat(runSchemaWithAnnotationQueueInfo.events().getOrNull()) - .containsExactly(JsonValue.from(mapOf())) + .containsExactly( + RunSchemaWithAnnotationQueueInfo.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runSchemaWithAnnotationQueueInfo.executionOrder()).contains(1L) - assertThat(runSchemaWithAnnotationQueueInfo._extra()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(runSchemaWithAnnotationQueueInfo.extra()) + .contains( + RunSchemaWithAnnotationQueueInfo.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runSchemaWithAnnotationQueueInfo.feedbackStats()) .contains( RunSchemaWithAnnotationQueueInfo.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) assertThat(runSchemaWithAnnotationQueueInfo.firstTokenTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(runSchemaWithAnnotationQueueInfo.inDataset()).contains(true) - assertThat(runSchemaWithAnnotationQueueInfo._inputs()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(runSchemaWithAnnotationQueueInfo.inputs()) + .contains( + RunSchemaWithAnnotationQueueInfo.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runSchemaWithAnnotationQueueInfo.inputsPreview()).contains("inputs_preview") - assertThat(runSchemaWithAnnotationQueueInfo._inputsS3Urls()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(runSchemaWithAnnotationQueueInfo.inputsS3Urls()) + .contains( + RunSchemaWithAnnotationQueueInfo.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runSchemaWithAnnotationQueueInfo.lastQueuedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(runSchemaWithAnnotationQueueInfo.lastReviewedTime()) @@ -162,11 +210,19 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(runSchemaWithAnnotationQueueInfo.manifestS3Id()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(runSchemaWithAnnotationQueueInfo._outputs()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(runSchemaWithAnnotationQueueInfo.outputs()) + .contains( + RunSchemaWithAnnotationQueueInfo.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runSchemaWithAnnotationQueueInfo.outputsPreview()).contains("outputs_preview") - assertThat(runSchemaWithAnnotationQueueInfo._outputsS3Urls()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(runSchemaWithAnnotationQueueInfo.outputsS3Urls()) + .contains( + RunSchemaWithAnnotationQueueInfo.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runSchemaWithAnnotationQueueInfo.parentRunId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(runSchemaWithAnnotationQueueInfo.parentRunIds().getOrNull()) @@ -191,10 +247,18 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(runSchemaWithAnnotationQueueInfo.referenceExampleId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(runSchemaWithAnnotationQueueInfo._s3Urls()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(runSchemaWithAnnotationQueueInfo._serialized()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(runSchemaWithAnnotationQueueInfo.s3Urls()) + .contains( + RunSchemaWithAnnotationQueueInfo.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchemaWithAnnotationQueueInfo.serialized()) + .contains( + RunSchemaWithAnnotationQueueInfo.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runSchemaWithAnnotationQueueInfo.shareToken()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(runSchemaWithAnnotationQueueInfo.startTime()) @@ -247,26 +311,50 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .effectiveAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + RunSchemaWithAnnotationQueueInfo.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + RunSchemaWithAnnotationQueueInfo.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( RunSchemaWithAnnotationQueueInfo.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + RunSchemaWithAnnotationQueueInfo.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + RunSchemaWithAnnotationQueueInfo.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + RunSchemaWithAnnotationQueueInfo.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + RunSchemaWithAnnotationQueueInfo.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -284,8 +372,16 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + RunSchemaWithAnnotationQueueInfo.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + RunSchemaWithAnnotationQueueInfo.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListPageResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListPageResponseTest.kt index 0fab2344..076a82a4 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListPageResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListPageResponseTest.kt @@ -21,7 +21,11 @@ internal class CommitListPageResponseTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -41,7 +45,11 @@ internal class CommitListPageResponseTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -65,7 +73,11 @@ internal class CommitListPageResponseTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitManifestResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitManifestResponseTest.kt index 89bc5822..b008a5ac 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitManifestResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitManifestResponseTest.kt @@ -17,28 +17,52 @@ internal class CommitManifestResponseTest { val commitManifestResponse = CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .build() assertThat(commitManifestResponse.commitHash()).isEqualTo("commit_hash") - assertThat(commitManifestResponse._manifest()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(commitManifestResponse.manifest()) + .isEqualTo( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(commitManifestResponse.examples().getOrNull()) .containsExactly( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -50,13 +74,25 @@ internal class CommitManifestResponseTest { val commitManifestResponse = CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateParamsTest.kt index d1047d41..7875da73 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateParamsTest.kt @@ -14,7 +14,11 @@ internal class CommitUpdateParamsTest { CommitUpdateParams.builder() .owner("owner") .repo("repo") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .parentCommit("parent_commit") .skipWebhooks(true) @@ -27,7 +31,11 @@ internal class CommitUpdateParamsTest { CommitUpdateParams.builder() .owner("owner") .repo("repo") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(params._pathParam(0)).isEqualTo("owner") @@ -42,7 +50,11 @@ internal class CommitUpdateParamsTest { CommitUpdateParams.builder() .owner("owner") .repo("repo") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .parentCommit("parent_commit") .skipWebhooks(true) @@ -50,7 +62,12 @@ internal class CommitUpdateParamsTest { val body = params._body() - assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.manifest()) + .isEqualTo( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.exampleRunIds().getOrNull()) .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.parentCommit()).contains("parent_commit") @@ -63,11 +80,20 @@ internal class CommitUpdateParamsTest { CommitUpdateParams.builder() .owner("owner") .repo("repo") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val body = params._body() - assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.manifest()) + .isEqualTo( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateResponseTest.kt index 1ab6e0a7..70ea39e5 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitUpdateResponseTest.kt @@ -21,7 +21,11 @@ internal class CommitUpdateResponseTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -40,7 +44,11 @@ internal class CommitUpdateResponseTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -63,7 +71,11 @@ internal class CommitUpdateResponseTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitWithLookupsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitWithLookupsTest.kt index 49beeab6..03b8fac6 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitWithLookupsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitWithLookupsTest.kt @@ -19,7 +19,11 @@ internal class CommitWithLookupsTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -35,7 +39,12 @@ internal class CommitWithLookupsTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(commitWithLookups.exampleRunIds()) .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(commitWithLookups._manifest()).isEqualTo(JsonValue.from(mapOf())) + assertThat(commitWithLookups.manifest()) + .isEqualTo( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(commitWithLookups.numDownloads()).isEqualTo(0L) assertThat(commitWithLookups.numViews()).isEqualTo(0L) assertThat(commitWithLookups.repoId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -55,7 +64,11 @@ internal class CommitWithLookupsTest { .commitHash("commit_hash") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitWithLookups.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numDownloads(0L) .numViews(0L) .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponseTest.kt index 3138a344..b3199a85 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneResponseTest.kt @@ -3,6 +3,7 @@ package com.langchain.smith.models.datasets import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.JsonValue import com.langchain.smith.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,13 +12,19 @@ internal class DatasetCloneResponseTest { @Test fun create() { - val datasetCloneResponse = DatasetCloneResponse.builder().build() + val datasetCloneResponse = + DatasetCloneResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val datasetCloneResponse = DatasetCloneResponse.builder().build() + val datasetCloneResponse = + DatasetCloneResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() val roundtrippedDatasetCloneResponse = jsonMapper.readValue( diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCreateParamsTest.kt index 420f5773..c7f0082d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCreateParamsTest.kt @@ -19,9 +19,21 @@ internal class DatasetCreateParamsTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .extra(JsonValue.from(mapOf())) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .extra( + DatasetCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputsSchemaDefinition( + DatasetCreateParams.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetCreateParams.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") @@ -43,9 +55,21 @@ internal class DatasetCreateParamsTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .extra(JsonValue.from(mapOf())) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .extra( + DatasetCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputsSchemaDefinition( + DatasetCreateParams.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetCreateParams.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") @@ -64,9 +88,24 @@ internal class DatasetCreateParamsTest { assertThat(body.dataType()).contains(DataType.KV) assertThat(body.description()).contains("description") assertThat(body.externallyManaged()).contains(true) - assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body._inputsSchemaDefinition()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body._outputsSchemaDefinition()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.extra()) + .contains( + DatasetCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.inputsSchemaDefinition()) + .contains( + DatasetCreateParams.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.outputsSchemaDefinition()) + .contains( + DatasetCreateParams.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.transformations().getOrNull()) .containsExactly( DatasetTransformation.builder() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetTest.kt index e4fed6ca..8a6bb827 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetTest.kt @@ -26,10 +26,22 @@ internal class DatasetTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .inputsSchemaDefinition(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + Dataset.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastSessionStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .metadata( + Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + Dataset.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") @@ -50,13 +62,26 @@ internal class DatasetTest { assertThat(dataset.dataType()).contains(DataType.KV) assertThat(dataset.description()).contains("description") assertThat(dataset.externallyManaged()).contains(true) - assertThat(dataset._inputsSchemaDefinition()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(dataset.inputsSchemaDefinition()) + .contains( + Dataset.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(dataset.lastSessionStartTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset._metadata()).isEqualTo(JsonValue.from(mapOf())) - assertThat(dataset._outputsSchemaDefinition()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(dataset.metadata()) + .contains( + Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(dataset.outputsSchemaDefinition()) + .contains( + Dataset.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(dataset.transformations().getOrNull()) .containsExactly( DatasetTransformation.builder() @@ -83,10 +108,22 @@ internal class DatasetTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .inputsSchemaDefinition(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + Dataset.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastSessionStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .metadata( + Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + Dataset.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParamsTest.kt index 9d48885e..f763af18 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateParamsTest.kt @@ -13,10 +13,22 @@ internal class DatasetUpdateParamsTest { DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("string") - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetUpdateParams.InputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + DatasetUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("string") - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .outputsSchemaDefinition( + DatasetUpdateParams.OutputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .patchExamples( DatasetUpdateParams.PatchExamples.builder() .putAdditionalProperty( @@ -29,9 +41,9 @@ internal class DatasetUpdateParamsTest { "retain" to listOf("string"), ), "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - "inputs" to mapOf(), - "metadata" to mapOf(), - "outputs" to mapOf(), + "inputs" to mapOf("foo" to "bar"), + "metadata" to mapOf("foo" to "bar"), + "outputs" to mapOf("foo" to "bar"), "overwrite" to true, "split" to listOf("string"), ) @@ -68,10 +80,22 @@ internal class DatasetUpdateParamsTest { DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("string") - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetUpdateParams.InputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + DatasetUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("string") - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .outputsSchemaDefinition( + DatasetUpdateParams.OutputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .patchExamples( DatasetUpdateParams.PatchExamples.builder() .putAdditionalProperty( @@ -84,9 +108,9 @@ internal class DatasetUpdateParamsTest { "retain" to listOf("string"), ), "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - "inputs" to mapOf(), - "metadata" to mapOf(), - "outputs" to mapOf(), + "inputs" to mapOf("foo" to "bar"), + "metadata" to mapOf("foo" to "bar"), + "outputs" to mapOf("foo" to "bar"), "overwrite" to true, "split" to listOf("string"), ) @@ -111,19 +135,27 @@ internal class DatasetUpdateParamsTest { assertThat(body.description()).contains(DatasetUpdateParams.Description.ofString("string")) assertThat(body.inputsSchemaDefinition()) .contains( - DatasetUpdateParams.InputsSchemaDefinition.ofJsonValue( - JsonValue.from(mapOf()) + DatasetUpdateParams.InputsSchemaDefinition.ofUnionMember0( + DatasetUpdateParams.InputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() ) ) assertThat(body.metadata()) .contains( - DatasetUpdateParams.Metadata.ofJsonValue(JsonValue.from(mapOf())) + DatasetUpdateParams.Metadata.ofUnionMember0( + DatasetUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) ) assertThat(body.name()).contains(DatasetUpdateParams.Name.ofString("string")) assertThat(body.outputsSchemaDefinition()) .contains( - DatasetUpdateParams.OutputsSchemaDefinition.ofJsonValue( - JsonValue.from(mapOf()) + DatasetUpdateParams.OutputsSchemaDefinition.ofUnionMember0( + DatasetUpdateParams.OutputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() ) ) assertThat(body.patchExamples()) @@ -139,9 +171,9 @@ internal class DatasetUpdateParamsTest { "retain" to listOf("string"), ), "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - "inputs" to mapOf(), - "metadata" to mapOf(), - "outputs" to mapOf(), + "inputs" to mapOf("foo" to "bar"), + "metadata" to mapOf("foo" to "bar"), + "outputs" to mapOf("foo" to "bar"), "overwrite" to true, "split" to listOf("string"), ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponseTest.kt index 238bbe09..3187bc19 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUpdateResponseTest.kt @@ -23,8 +23,16 @@ internal class DatasetUpdateResponseTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetUpdateResponse.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetUpdateResponse.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") @@ -44,10 +52,18 @@ internal class DatasetUpdateResponseTest { assertThat(datasetUpdateResponse.dataType()).contains(DataType.KV) assertThat(datasetUpdateResponse.description()).contains("description") assertThat(datasetUpdateResponse.externallyManaged()).contains(true) - assertThat(datasetUpdateResponse._inputsSchemaDefinition()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetUpdateResponse._outputsSchemaDefinition()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetUpdateResponse.inputsSchemaDefinition()) + .contains( + DatasetUpdateResponse.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(datasetUpdateResponse.outputsSchemaDefinition()) + .contains( + DatasetUpdateResponse.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(datasetUpdateResponse.transformations().getOrNull()) .containsExactly( DatasetTransformation.builder() @@ -71,8 +87,16 @@ internal class DatasetUpdateResponseTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetUpdateResponse.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetUpdateResponse.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchemaTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchemaTest.kt index 5f199947..29a902e3 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchemaTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/FeedbackCreateCoreSchemaTest.kt @@ -20,9 +20,17 @@ internal class FeedbackCreateCoreSchemaTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateCoreSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + FeedbackCreateCoreSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateCoreSchema.FeedbackConfig.builder() .type(FeedbackCreateCoreSchema.FeedbackConfig.Type.CONTINUOUS) @@ -39,7 +47,11 @@ internal class FeedbackCreateCoreSchemaTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -55,14 +67,20 @@ internal class FeedbackCreateCoreSchemaTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(feedbackCreateCoreSchema.correction()) .contains( - FeedbackCreateCoreSchema.Correction.ofJsonValue( - JsonValue.from(mapOf()) + FeedbackCreateCoreSchema.Correction.ofUnionMember0( + FeedbackCreateCoreSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() ) ) assertThat(feedbackCreateCoreSchema.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(feedbackCreateCoreSchema._extra()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackCreateCoreSchema.extra()) + .contains( + FeedbackCreateCoreSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(feedbackCreateCoreSchema.feedbackConfig()) .contains( FeedbackCreateCoreSchema.FeedbackConfig.builder() @@ -83,7 +101,11 @@ internal class FeedbackCreateCoreSchemaTest { .contains( FeedbackCreateCoreSchema.FeedbackSource.ofApp( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -105,9 +127,17 @@ internal class FeedbackCreateCoreSchemaTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateCoreSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + FeedbackCreateCoreSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateCoreSchema.FeedbackConfig.builder() .type(FeedbackCreateCoreSchema.FeedbackConfig.Type.CONTINUOUS) @@ -124,7 +154,11 @@ internal class FeedbackCreateCoreSchemaTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParamsTest.kt index 8d2bfe27..a3b016e8 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateParamsTest.kt @@ -16,7 +16,11 @@ internal class ComparativeCreateParamsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .extra(JsonValue.from(mapOf())) + .extra( + ComparativeCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -31,7 +35,11 @@ internal class ComparativeCreateParamsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .extra(JsonValue.from(mapOf())) + .extra( + ComparativeCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -43,7 +51,12 @@ internal class ComparativeCreateParamsTest { assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.description()).contains("description") - assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.extra()) + .contains( + ComparativeCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.modifiedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.name()).contains("name") assertThat(body.referenceDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponseTest.kt index 4785aeea..389fa726 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeCreateResponseTest.kt @@ -21,7 +21,11 @@ internal class ComparativeCreateResponseTest { .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .extra(JsonValue.from(mapOf())) + .extra( + ComparativeCreateResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() @@ -35,8 +39,12 @@ internal class ComparativeCreateResponseTest { assertThat(comparativeCreateResponse.tenantId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(comparativeCreateResponse.description()).contains("description") - assertThat(comparativeCreateResponse._extra()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(comparativeCreateResponse.extra()) + .contains( + ComparativeCreateResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(comparativeCreateResponse.name()).contains("name") } @@ -51,7 +59,11 @@ internal class ComparativeCreateResponseTest { .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .extra(JsonValue.from(mapOf())) + .extra( + ComparativeCreateResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponseTest.kt index 7a111509..fc337f5f 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponseTest.kt @@ -27,8 +27,16 @@ internal class ComparativeListResponseTest { .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + ComparativeListResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + ComparativeListResponse.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() @@ -49,9 +57,18 @@ internal class ComparativeListResponseTest { assertThat(comparativeListResponse.tenantId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(comparativeListResponse.description()).contains("description") - assertThat(comparativeListResponse._extra()).isEqualTo(JsonValue.from(mapOf())) - assertThat(comparativeListResponse._feedbackStats()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(comparativeListResponse.extra()) + .contains( + ComparativeListResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(comparativeListResponse.feedbackStats()) + .contains( + ComparativeListResponse.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(comparativeListResponse.name()).contains("name") } @@ -72,8 +89,16 @@ internal class ComparativeListResponseTest { .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + ComparativeListResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + ComparativeListResponse.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt index 11fdd17a..68678544 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt @@ -23,7 +23,11 @@ internal class GroupRunsResponseTest { ExampleWithRunsCh.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRunsCh.Run.builder() @@ -39,31 +43,63 @@ internal class GroupRunsResponseTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRunsCh.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -76,11 +112,23 @@ internal class GroupRunsResponseTest { ) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -98,8 +146,16 @@ internal class GroupRunsResponseTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorRate(0.0) .exampleCount(0L) - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + GroupRunsResponse.Group.Session.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + GroupRunsResponse.Group.Session.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .firstTokenP50(0.0) .firstTokenP99(0.0) .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -115,8 +171,16 @@ internal class GroupRunsResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runCount(0L) - .addRunFacet(JsonValue.from(mapOf())) - .sessionFeedbackStats(JsonValue.from(mapOf())) + .addRunFacet( + GroupRunsResponse.Group.Session.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionFeedbackStats( + GroupRunsResponse.Group.Session.SessionFeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .streamingRate(0.0) .testRunNumber(0L) @@ -129,7 +193,11 @@ internal class GroupRunsResponseTest { .completionTokens(0L) .count(0L) .errorRate(0.0) - .feedbackStats(JsonValue.from(mapOf())) + .feedbackStats( + GroupRunsResponse.Group.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .latencyP50(0.0) .latencyP99(0.0) .maxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -150,7 +218,11 @@ internal class GroupRunsResponseTest { ExampleWithRunsCh.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRunsCh.Run.builder() @@ -166,31 +238,63 @@ internal class GroupRunsResponseTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRunsCh.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -203,11 +307,23 @@ internal class GroupRunsResponseTest { ) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -225,8 +341,16 @@ internal class GroupRunsResponseTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorRate(0.0) .exampleCount(0L) - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + GroupRunsResponse.Group.Session.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + GroupRunsResponse.Group.Session.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .firstTokenP50(0.0) .firstTokenP99(0.0) .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -240,8 +364,16 @@ internal class GroupRunsResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runCount(0L) - .addRunFacet(JsonValue.from(mapOf())) - .sessionFeedbackStats(JsonValue.from(mapOf())) + .addRunFacet( + GroupRunsResponse.Group.Session.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionFeedbackStats( + GroupRunsResponse.Group.Session.SessionFeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .streamingRate(0.0) .testRunNumber(0L) @@ -254,7 +386,11 @@ internal class GroupRunsResponseTest { .completionTokens(0L) .count(0L) .errorRate(0.0) - .feedbackStats(JsonValue.from(mapOf())) + .feedbackStats( + GroupRunsResponse.Group.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .latencyP50(0.0) .latencyP99(0.0) .maxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -279,7 +415,11 @@ internal class GroupRunsResponseTest { ExampleWithRunsCh.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRunsCh.Run.builder() @@ -295,31 +435,63 @@ internal class GroupRunsResponseTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRunsCh.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -332,11 +504,23 @@ internal class GroupRunsResponseTest { ) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -354,8 +538,16 @@ internal class GroupRunsResponseTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorRate(0.0) .exampleCount(0L) - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + GroupRunsResponse.Group.Session.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + GroupRunsResponse.Group.Session.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .firstTokenP50(0.0) .firstTokenP99(0.0) .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -371,8 +563,16 @@ internal class GroupRunsResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runCount(0L) - .addRunFacet(JsonValue.from(mapOf())) - .sessionFeedbackStats(JsonValue.from(mapOf())) + .addRunFacet( + GroupRunsResponse.Group.Session.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionFeedbackStats( + GroupRunsResponse.Group.Session.SessionFeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .streamingRate(0.0) .testRunNumber(0L) @@ -385,7 +585,11 @@ internal class GroupRunsResponseTest { .completionTokens(0L) .count(0L) .errorRate(0.0) - .feedbackStats(JsonValue.from(mapOf())) + .feedbackStats( + GroupRunsResponse.Group.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .latencyP50(0.0) .latencyP99(0.0) .maxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt index 5ebdabe5..3725c4af 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt @@ -17,9 +17,17 @@ internal class PlaygroundExperimentBatchParamsTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -36,7 +44,11 @@ internal class PlaygroundExperimentBatchParamsTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentBatchParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) @@ -60,9 +72,17 @@ internal class PlaygroundExperimentBatchParamsTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -79,7 +99,11 @@ internal class PlaygroundExperimentBatchParamsTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentBatchParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) @@ -101,9 +125,17 @@ internal class PlaygroundExperimentBatchParamsTest { .isEqualTo( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -122,7 +154,12 @@ internal class PlaygroundExperimentBatchParamsTest { assertThat(body.datasetSplits().getOrNull()).containsExactly("string") assertThat(body.evaluatorRules().getOrNull()) .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.metadata()) + .contains( + PlaygroundExperimentBatchParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.owner()).contains("owner") assertThat(body.parallelToolCalls()).contains(true) assertThat(body.repetitions()).contains(1L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt index abc2dbcb..91c5b871 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt @@ -17,9 +17,17 @@ internal class PlaygroundExperimentStreamParamsTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -35,7 +43,11 @@ internal class PlaygroundExperimentStreamParamsTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentStreamParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) @@ -59,9 +71,17 @@ internal class PlaygroundExperimentStreamParamsTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -77,7 +97,11 @@ internal class PlaygroundExperimentStreamParamsTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentStreamParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) @@ -99,9 +123,17 @@ internal class PlaygroundExperimentStreamParamsTest { .isEqualTo( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -119,7 +151,12 @@ internal class PlaygroundExperimentStreamParamsTest { assertThat(body.datasetSplits().getOrNull()).containsExactly("string") assertThat(body.evaluatorRules().getOrNull()) .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.metadata()) + .contains( + PlaygroundExperimentStreamParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.owner()).contains("owner") assertThat(body.parallelToolCalls()).contains(true) assertThat(body.repetitions()).contains(1L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfigTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfigTest.kt index fc20ab49..9729b6a7 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfigTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/playgroundexperiment/RunnableConfigTest.kt @@ -16,9 +16,17 @@ internal class RunnableConfigTest { val runnableConfig = RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -29,9 +37,19 @@ internal class RunnableConfigTest { .contains( RunnableConfig.Callbacks.ofJsonValues(listOf(JsonValue.from(mapOf()))) ) - assertThat(runnableConfig._configurable()).isEqualTo(JsonValue.from(mapOf())) + assertThat(runnableConfig.configurable()) + .contains( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runnableConfig.maxConcurrency()).contains(0L) - assertThat(runnableConfig._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(runnableConfig.metadata()) + .contains( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(runnableConfig.recursionLimit()).contains(0L) assertThat(runnableConfig.runId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(runnableConfig.runName()).contains("run_name") @@ -44,9 +62,17 @@ internal class RunnableConfigTest { val runnableConfig = RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt index f4bedb17..548409d8 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt @@ -17,7 +17,11 @@ internal class ExampleWithRunsChTest { ExampleWithRunsCh.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRunsCh.Run.builder() @@ -33,28 +37,60 @@ internal class ExampleWithRunsChTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) - .executionOrder(1L) - .extra(JsonValue.from(mapOf())) - .feedbackStats( - ExampleWithRunsCh.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .executionOrder(1L) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) + .build() + ) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .inputs(JsonValue.from(mapOf())) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -63,17 +99,34 @@ internal class ExampleWithRunsChTest { .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(exampleWithRunsCh.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(exampleWithRunsCh.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(exampleWithRunsCh._inputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRunsCh.inputs()) + .isEqualTo( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRunsCh.name()).isEqualTo("name") assertThat(exampleWithRunsCh.runs()) .containsExactly( @@ -90,28 +143,60 @@ internal class ExampleWithRunsChTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) - .executionOrder(1L) - .extra(JsonValue.from(mapOf())) - .feedbackStats( - ExampleWithRunsCh.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .executionOrder(1L) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) + .build() + ) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .inputs(JsonValue.from(mapOf())) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -120,14 +205,28 @@ internal class ExampleWithRunsChTest { .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(exampleWithRunsCh._attachmentUrls()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRunsCh.attachmentUrls()) + .contains( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRunsCh.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(exampleWithRunsCh._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRunsCh.metadata()) + .contains( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRunsCh.modifiedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(exampleWithRunsCh._outputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRunsCh.outputs()) + .contains( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRunsCh.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @@ -138,7 +237,11 @@ internal class ExampleWithRunsChTest { ExampleWithRunsCh.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRunsCh.Run.builder() @@ -154,28 +257,60 @@ internal class ExampleWithRunsChTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) - .executionOrder(1L) - .extra(JsonValue.from(mapOf())) - .feedbackStats( - ExampleWithRunsCh.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .executionOrder(1L) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) + .build() + ) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .inputs(JsonValue.from(mapOf())) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -184,11 +319,23 @@ internal class ExampleWithRunsChTest { .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsTest.kt index 3b9d1b45..12495616 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsTest.kt @@ -17,7 +17,11 @@ internal class ExampleWithRunsTest { ExampleWithRuns.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRuns.Run.builder() @@ -45,25 +49,49 @@ internal class ExampleWithRunsTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRuns.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRuns.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRuns.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRuns.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -81,8 +109,16 @@ internal class ExampleWithRunsTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRuns.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRuns.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -97,17 +133,34 @@ internal class ExampleWithRunsTest { .ttlSeconds(0L) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRuns.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRuns.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(exampleWithRuns.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(exampleWithRuns.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(exampleWithRuns._inputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRuns.inputs()) + .isEqualTo( + ExampleWithRuns.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRuns.name()).isEqualTo("name") assertThat(exampleWithRuns.runs()) .containsExactly( @@ -136,25 +189,49 @@ internal class ExampleWithRunsTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRuns.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRuns.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRuns.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRuns.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -172,8 +249,16 @@ internal class ExampleWithRunsTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRuns.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRuns.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -188,14 +273,28 @@ internal class ExampleWithRunsTest { .ttlSeconds(0L) .build() ) - assertThat(exampleWithRuns._attachmentUrls()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRuns.attachmentUrls()) + .contains( + ExampleWithRuns.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRuns.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(exampleWithRuns._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRuns.metadata()) + .contains( + ExampleWithRuns.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRuns.modifiedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(exampleWithRuns._outputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleWithRuns.outputs()) + .contains( + ExampleWithRuns.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleWithRuns.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @@ -206,7 +305,11 @@ internal class ExampleWithRunsTest { ExampleWithRuns.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRuns.Run.builder() @@ -234,25 +337,49 @@ internal class ExampleWithRunsTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRuns.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRuns.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRuns.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRuns.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -270,8 +397,16 @@ internal class ExampleWithRunsTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRuns.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRuns.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -286,11 +421,23 @@ internal class ExampleWithRunsTest { .ttlSeconds(0L) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRuns.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRuns.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponseTest.kt index 13302abd..a9a67356 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponseTest.kt @@ -22,7 +22,11 @@ internal class RunCreateResponseTest { ExampleWithRuns.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRuns.Run.builder() @@ -50,28 +54,52 @@ internal class RunCreateResponseTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRuns.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRuns.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRuns.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRuns.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRuns.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -89,8 +117,16 @@ internal class RunCreateResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRuns.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRuns.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -105,11 +141,23 @@ internal class RunCreateResponseTest { .ttlSeconds(0L) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRuns.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRuns.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -129,7 +177,11 @@ internal class RunCreateResponseTest { ExampleWithRuns.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRuns.Run.builder() @@ -157,28 +209,52 @@ internal class RunCreateResponseTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRuns.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRuns.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRuns.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRuns.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRuns.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -196,8 +272,16 @@ internal class RunCreateResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRuns.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRuns.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -214,11 +298,23 @@ internal class RunCreateResponseTest { .ttlSeconds(0L) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRuns.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRuns.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -240,7 +336,11 @@ internal class RunCreateResponseTest { ExampleWithRunsCh.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRunsCh.Run.builder() @@ -256,31 +356,63 @@ internal class RunCreateResponseTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRunsCh.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -289,11 +421,23 @@ internal class RunCreateResponseTest { .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -313,7 +457,11 @@ internal class RunCreateResponseTest { ExampleWithRunsCh.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRunsCh.Run.builder() @@ -329,31 +477,63 @@ internal class RunCreateResponseTest { .dottedOrder("dotted_order") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRunsCh.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRunsCh.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRunsCh.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRunsCh.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRunsCh.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRunsCh.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptTokens(0L) .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRunsCh.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRunsCh.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") .totalCost("total_cost") @@ -362,11 +542,23 @@ internal class RunCreateResponseTest { .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRunsCh.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRunsCh.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRunsCh.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleCreateParamsTest.kt index 9cf3a3aa..83b7b67d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleCreateParamsTest.kt @@ -15,9 +15,21 @@ internal class ExampleCreateParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleCreateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleCreateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -33,9 +45,21 @@ internal class ExampleCreateParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleCreateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleCreateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -48,9 +72,24 @@ internal class ExampleCreateParamsTest { assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.createdAt()).contains("created_at") - assertThat(body._inputs()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body._metadata()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body._outputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.inputs()) + .contains( + ExampleCreateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.metadata()) + .contains( + ExampleCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.outputs()) + .contains( + ExampleCreateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.split()).contains(ExampleCreateParams.Split.ofStrings(listOf("string"))) assertThat(body.useLegacyMessageFormat()).contains(true) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleTest.kt index 6ccda590..67c735b3 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleTest.kt @@ -17,25 +17,59 @@ internal class ExampleTest { Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + Example.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + Example.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(example.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(example.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(example._inputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(example.inputs()) + .isEqualTo( + Example.Inputs.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) assertThat(example.name()).isEqualTo("name") - assertThat(example._attachmentUrls()).isEqualTo(JsonValue.from(mapOf())) + assertThat(example.attachmentUrls()) + .contains( + Example.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(example.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(example._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(example.metadata()) + .contains( + Example.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(example.modifiedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(example._outputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(example.outputs()) + .contains( + Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(example.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @@ -46,13 +80,29 @@ internal class ExampleTest { Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + Example.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + Example.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUpdateParamsTest.kt index 76953626..d9873594 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUpdateParamsTest.kt @@ -23,9 +23,21 @@ internal class ExampleUpdateParamsTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleUpdateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleUpdateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() @@ -57,9 +69,21 @@ internal class ExampleUpdateParamsTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleUpdateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleUpdateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() @@ -78,9 +102,24 @@ internal class ExampleUpdateParamsTest { .build() ) assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body._inputs()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body._metadata()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body._outputs()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.inputs()) + .contains( + ExampleUpdateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.metadata()) + .contains( + ExampleUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.outputs()) + .contains( + ExampleUpdateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.overwrite()).contains(true) assertThat(body.split()).contains(ExampleUpdateParams.Split.ofStrings(listOf("string"))) } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParamsTest.kt index 58fb0f57..83d3e5a5 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkCreateParamsTest.kt @@ -16,9 +16,21 @@ internal class BulkCreateParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkCreateParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkCreateParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkCreateParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -38,9 +50,21 @@ internal class BulkCreateParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkCreateParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkCreateParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkCreateParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -58,9 +82,21 @@ internal class BulkCreateParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkCreateParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkCreateParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkCreateParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParamsTest.kt index da8a61d3..c6b24348 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/bulk/BulkPatchAllParamsTest.kt @@ -26,9 +26,21 @@ internal class BulkPatchAllParamsTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkPatchAllParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkPatchAllParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkPatchAllParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() @@ -54,9 +66,21 @@ internal class BulkPatchAllParamsTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkPatchAllParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkPatchAllParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkPatchAllParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() @@ -80,9 +104,21 @@ internal class BulkPatchAllParamsTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkPatchAllParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkPatchAllParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkPatchAllParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResultTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResultTest.kt index ba662407..40107316 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResultTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/validate/ExampleValidationResultTest.kt @@ -18,9 +18,21 @@ internal class ExampleValidationResultTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleValidationResult.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleValidationResult.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleValidationResult.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) @@ -32,12 +44,24 @@ internal class ExampleValidationResultTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(exampleValidationResult.datasetId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(exampleValidationResult._inputs()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(exampleValidationResult._metadata()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(exampleValidationResult._outputs()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(exampleValidationResult.inputs()) + .contains( + ExampleValidationResult.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(exampleValidationResult.metadata()) + .contains( + ExampleValidationResult.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(exampleValidationResult.outputs()) + .contains( + ExampleValidationResult.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(exampleValidationResult.overwrite()).contains(true) assertThat(exampleValidationResult.sourceRunId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -54,9 +78,21 @@ internal class ExampleValidationResultTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleValidationResult.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleValidationResult.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleValidationResult.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSourceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSourceTest.kt index bdaf1e10..15155ca7 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSourceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ApiFeedbackSourceTest.kt @@ -14,11 +14,20 @@ internal class ApiFeedbackSourceTest { fun create() { val apiFeedbackSource = ApiFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + ApiFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(ApiFeedbackSource.Type.API) .build() - assertThat(apiFeedbackSource._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(apiFeedbackSource.metadata()) + .contains( + ApiFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(apiFeedbackSource.type()).contains(ApiFeedbackSource.Type.API) } @@ -27,7 +36,11 @@ internal class ApiFeedbackSourceTest { val jsonMapper = jsonMapper() val apiFeedbackSource = ApiFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + ApiFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(ApiFeedbackSource.Type.API) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AppFeedbackSourceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AppFeedbackSourceTest.kt index d514bbe0..f308d9d1 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AppFeedbackSourceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AppFeedbackSourceTest.kt @@ -14,11 +14,20 @@ internal class AppFeedbackSourceTest { fun create() { val appFeedbackSource = AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() - assertThat(appFeedbackSource._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(appFeedbackSource.metadata()) + .contains( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(appFeedbackSource.type()).contains(AppFeedbackSource.Type.APP) } @@ -27,7 +36,11 @@ internal class AppFeedbackSourceTest { val jsonMapper = jsonMapper() val appFeedbackSource = AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSourceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSourceTest.kt index 299957ee..970c9608 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSourceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/AutoEvalFeedbackSourceTest.kt @@ -14,12 +14,20 @@ internal class AutoEvalFeedbackSourceTest { fun create() { val autoEvalFeedbackSource = AutoEvalFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AutoEvalFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AutoEvalFeedbackSource.Type.AUTO_EVAL) .build() - assertThat(autoEvalFeedbackSource._metadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(autoEvalFeedbackSource.metadata()) + .contains( + AutoEvalFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(autoEvalFeedbackSource.type()).contains(AutoEvalFeedbackSource.Type.AUTO_EVAL) } @@ -28,7 +36,11 @@ internal class AutoEvalFeedbackSourceTest { val jsonMapper = jsonMapper() val autoEvalFeedbackSource = AutoEvalFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AutoEvalFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AutoEvalFeedbackSource.Type.AUTO_EVAL) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt index c751a34f..32d187d9 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt @@ -18,7 +18,11 @@ internal class FeedbackCreateParamsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .feedbackConfig( @@ -37,7 +41,11 @@ internal class FeedbackCreateParamsTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -62,7 +70,11 @@ internal class FeedbackCreateParamsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .feedbackConfig( @@ -81,7 +93,11 @@ internal class FeedbackCreateParamsTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -104,7 +120,11 @@ internal class FeedbackCreateParamsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .feedbackConfig( @@ -123,7 +143,11 @@ internal class FeedbackCreateParamsTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt index d9f5f8b6..dd8593f1 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt @@ -19,7 +19,11 @@ internal class FeedbackCreateSchemaTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .feedbackConfig( @@ -38,7 +42,11 @@ internal class FeedbackCreateSchemaTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -57,7 +65,11 @@ internal class FeedbackCreateSchemaTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(feedbackCreateSchema.correction()) .contains( - FeedbackCreateSchema.Correction.ofJsonValue(JsonValue.from(mapOf())) + FeedbackCreateSchema.Correction.ofUnionMember0( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) ) assertThat(feedbackCreateSchema.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -82,7 +94,11 @@ internal class FeedbackCreateSchemaTest { .contains( FeedbackCreateSchema.FeedbackSource.ofApp( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -106,7 +122,11 @@ internal class FeedbackCreateSchemaTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .feedbackConfig( @@ -125,7 +145,11 @@ internal class FeedbackCreateSchemaTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackSchemaTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackSchemaTest.kt index a1e70355..1d06d52a 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackSchemaTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackSchemaTest.kt @@ -19,14 +19,26 @@ internal class FeedbackSchemaTest { .key("key") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + FeedbackSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( FeedbackSchema.FeedbackSource.builder() .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + FeedbackSchema.FeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type("type") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userName("user_name") @@ -48,17 +60,32 @@ internal class FeedbackSchemaTest { assertThat(feedbackSchema.comparativeExperimentId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(feedbackSchema.correction()) - .contains(FeedbackSchema.Correction.ofJsonValue(JsonValue.from(mapOf()))) + .contains( + FeedbackSchema.Correction.ofUnionMember0( + FeedbackSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + ) assertThat(feedbackSchema.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(feedbackSchema._extra()).isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackSchema.extra()) + .contains( + FeedbackSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(feedbackSchema.feedbackGroupId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(feedbackSchema.feedbackSource()) .contains( FeedbackSchema.FeedbackSource.builder() .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + FeedbackSchema.FeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type("type") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userName("user_name") @@ -85,14 +112,26 @@ internal class FeedbackSchemaTest { .key("key") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + FeedbackSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( FeedbackSchema.FeedbackSource.builder() .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + FeedbackSchema.FeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type("type") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userName("user_name") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParamsTest.kt index 37a0c84f..03fc894d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackUpdateParamsTest.kt @@ -13,7 +13,11 @@ internal class FeedbackUpdateParamsTest { FeedbackUpdateParams.builder() .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackUpdateParams.FeedbackConfig.builder() .type(FeedbackUpdateParams.FeedbackConfig.Type.CONTINUOUS) @@ -50,7 +54,11 @@ internal class FeedbackUpdateParamsTest { FeedbackUpdateParams.builder() .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackUpdateParams.FeedbackConfig.builder() .type(FeedbackUpdateParams.FeedbackConfig.Type.CONTINUOUS) @@ -73,7 +81,11 @@ internal class FeedbackUpdateParamsTest { assertThat(body.comment()).contains("comment") assertThat(body.correction()) .contains( - FeedbackUpdateParams.Correction.ofJsonValue(JsonValue.from(mapOf())) + FeedbackUpdateParams.Correction.ofUnionMember0( + FeedbackUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) ) assertThat(body.feedbackConfig()) .contains( diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSourceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSourceTest.kt index e730f3fc..4b8810e5 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSourceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/ModelFeedbackSourceTest.kt @@ -14,11 +14,20 @@ internal class ModelFeedbackSourceTest { fun create() { val modelFeedbackSource = ModelFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + ModelFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(ModelFeedbackSource.Type.MODEL) .build() - assertThat(modelFeedbackSource._metadata()).isEqualTo(JsonValue.from(mapOf())) + assertThat(modelFeedbackSource.metadata()) + .contains( + ModelFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(modelFeedbackSource.type()).contains(ModelFeedbackSource.Type.MODEL) } @@ -27,7 +36,11 @@ internal class ModelFeedbackSourceTest { val jsonMapper = jsonMapper() val modelFeedbackSource = ModelFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + ModelFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(ModelFeedbackSource.Type.MODEL) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParamsTest.kt index e108757f..c91c20ec 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/tokens/TokenUpdateParamsTest.kt @@ -13,8 +13,16 @@ internal class TokenUpdateParamsTest { TokenUpdateParams.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .correction( + TokenUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + TokenUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .score(0.0) .value(0.0) .build() @@ -36,8 +44,16 @@ internal class TokenUpdateParamsTest { TokenUpdateParams.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .correction( + TokenUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + TokenUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .score(0.0) .value(0.0) .build() @@ -47,9 +63,18 @@ internal class TokenUpdateParamsTest { assertThat(body.comment()).contains("comment") assertThat(body.correction()) .contains( - TokenUpdateParams.Correction.ofJsonValue(JsonValue.from(mapOf())) + TokenUpdateParams.Correction.ofUnionMember0( + TokenUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + ) + assertThat(body.metadata()) + .contains( + TokenUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() ) - assertThat(body._metadata()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.score()).contains(TokenUpdateParams.Score.ofNumber(0.0)) assertThat(body.value()).contains(TokenUpdateParams.Value.ofNumber(0.0)) } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponseTest.kt index 5318ed6d..5edf68e4 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListComparativeResponseTest.kt @@ -26,8 +26,16 @@ internal class DatasetListComparativeResponseTest { ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + DatasetListComparativeResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + DatasetListComparativeResponse.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() @@ -45,10 +53,18 @@ internal class DatasetListComparativeResponseTest { assertThat(datasetListComparativeResponse.modifiedAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(datasetListComparativeResponse.description()).contains("description") - assertThat(datasetListComparativeResponse._extra()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetListComparativeResponse._feedbackStats()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetListComparativeResponse.extra()) + .contains( + DatasetListComparativeResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(datasetListComparativeResponse.feedbackStats()) + .contains( + DatasetListComparativeResponse.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(datasetListComparativeResponse.name()).contains("name") } @@ -67,8 +83,16 @@ internal class DatasetListComparativeResponseTest { ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + DatasetListComparativeResponse.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + DatasetListComparativeResponse.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponseTest.kt index e16873fe..d9a4469f 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/public_/datasets/DatasetListResponseTest.kt @@ -25,8 +25,16 @@ internal class DatasetListResponseTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetListResponse.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetListResponse.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") @@ -45,10 +53,18 @@ internal class DatasetListResponseTest { assertThat(datasetListResponse.dataType()).contains(DataType.KV) assertThat(datasetListResponse.description()).contains("description") assertThat(datasetListResponse.externallyManaged()).contains(true) - assertThat(datasetListResponse._inputsSchemaDefinition()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetListResponse._outputsSchemaDefinition()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetListResponse.inputsSchemaDefinition()) + .contains( + DatasetListResponse.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(datasetListResponse.outputsSchemaDefinition()) + .contains( + DatasetListResponse.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(datasetListResponse.transformations().getOrNull()) .containsExactly( DatasetTransformation.builder() @@ -72,8 +88,16 @@ internal class DatasetListResponseTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetListResponse.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetListResponse.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt index 994113fe..cc964ad5 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt @@ -37,13 +37,25 @@ internal class CreateRepoResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -81,13 +93,25 @@ internal class CreateRepoResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -129,13 +153,25 @@ internal class CreateRepoResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/DemoConfigTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/DemoConfigTest.kt index d1885f7d..4bbb5602 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/DemoConfigTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/DemoConfigTest.kt @@ -14,15 +14,33 @@ internal class DemoConfigTest { fun create() { val demoConfig = DemoConfig.builder() - .addExample(JsonValue.from(mapOf())) + .addExample( + DemoConfig.Example.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .messageIndex(0L) - .metaprompt(JsonValue.from(mapOf())) + .metaprompt( + DemoConfig.Metaprompt.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overallFeedback("overall_feedback") .build() - assertThat(demoConfig.examples()).containsExactly(JsonValue.from(mapOf())) + assertThat(demoConfig.examples()) + .containsExactly( + DemoConfig.Example.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(demoConfig.messageIndex()).isEqualTo(0L) - assertThat(demoConfig._metaprompt()).isEqualTo(JsonValue.from(mapOf())) + assertThat(demoConfig.metaprompt()) + .isEqualTo( + DemoConfig.Metaprompt.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(demoConfig.overallFeedback()).contains("overall_feedback") } @@ -31,9 +49,17 @@ internal class DemoConfigTest { val jsonMapper = jsonMapper() val demoConfig = DemoConfig.builder() - .addExample(JsonValue.from(mapOf())) + .addExample( + DemoConfig.Example.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .messageIndex(0L) - .metaprompt(JsonValue.from(mapOf())) + .metaprompt( + DemoConfig.Metaprompt.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overallFeedback("overall_feedback") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt index bcee9dfc..b2516a58 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt @@ -37,13 +37,25 @@ internal class GetRepoResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -81,13 +93,25 @@ internal class GetRepoResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -129,13 +153,25 @@ internal class GetRepoResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt index 16b0138e..be2054a9 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt @@ -37,13 +37,25 @@ internal class RepoListPageResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -82,13 +94,25 @@ internal class RepoListPageResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -131,13 +155,25 @@ internal class RepoListPageResponseTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt index 12dbd39f..5353ee77 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt @@ -35,13 +35,25 @@ internal class RepoWithLookupsTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -77,13 +89,25 @@ internal class RepoWithLookupsTest { .contains( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -123,13 +147,25 @@ internal class RepoWithLookupsTest { .latestCommitManifest( CommitManifestResponse.builder() .commitHash("commit_hash") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitManifestResponse.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExample( CommitManifestResponse.Example.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + CommitManifestResponse.Example.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + CommitManifestResponse.Example.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt index fe9c6b76..5e567074 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt @@ -46,25 +46,49 @@ internal class RunQueryResponseTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + RunQueryResponse.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + RunQueryResponse.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( RunQueryResponse.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + RunQueryResponse.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + RunQueryResponse.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + RunQueryResponse.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + RunQueryResponse.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -82,8 +106,16 @@ internal class RunQueryResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + RunQueryResponse.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + RunQueryResponse.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -139,25 +171,49 @@ internal class RunQueryResponseTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + RunQueryResponse.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + RunQueryResponse.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( RunQueryResponse.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + RunQueryResponse.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + RunQueryResponse.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + RunQueryResponse.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + RunQueryResponse.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -175,8 +231,16 @@ internal class RunQueryResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + RunQueryResponse.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + RunQueryResponse.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -236,25 +300,49 @@ internal class RunQueryResponseTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + RunQueryResponse.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + RunQueryResponse.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( RunQueryResponse.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf())) + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + RunQueryResponse.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + RunQueryResponse.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + RunQueryResponse.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + RunQueryResponse.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -272,8 +360,16 @@ internal class RunQueryResponseTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + RunQueryResponse.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + RunQueryResponse.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/CustomChartsSectionTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/CustomChartsSectionTest.kt index b7b8c3f5..357059ae 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/CustomChartsSectionTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/CustomChartsSectionTest.kt @@ -72,7 +72,11 @@ internal class CustomChartsSectionTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .title("title") @@ -150,7 +154,11 @@ internal class CustomChartsSectionTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.SubSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .index(0L) @@ -215,7 +223,11 @@ internal class CustomChartsSectionTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(customChartsSection.title()).isEqualTo("title") @@ -290,7 +302,11 @@ internal class CustomChartsSectionTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.SubSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .index(0L) @@ -361,7 +377,11 @@ internal class CustomChartsSectionTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .title("title") @@ -439,7 +459,11 @@ internal class CustomChartsSectionTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.SubSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .index(0L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionCreateParamsTest.kt index e21cab33..1fb30892 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionCreateParamsTest.kt @@ -18,7 +18,11 @@ internal class SessionCreateParamsTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -35,7 +39,11 @@ internal class SessionCreateParamsTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -65,7 +73,11 @@ internal class SessionCreateParamsTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -78,7 +90,12 @@ internal class SessionCreateParamsTest { assertThat(body.defaultDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.description()).contains("description") assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.extra()) + .contains( + SessionCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.name()).contains("name") assertThat(body.referenceDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionUpdateParamsTest.kt index 1634ecbb..baed4d10 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/SessionUpdateParamsTest.kt @@ -16,7 +16,11 @@ internal class SessionUpdateParamsTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionUpdateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .traceTier(SessionUpdateParams.TraceTier.LONGLIVED) .build() @@ -40,7 +44,11 @@ internal class SessionUpdateParamsTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionUpdateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .traceTier(SessionUpdateParams.TraceTier.LONGLIVED) .build() @@ -50,7 +58,12 @@ internal class SessionUpdateParamsTest { assertThat(body.defaultDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.description()).contains("description") assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.extra()) + .contains( + SessionUpdateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.name()).contains("name") assertThat(body.traceTier()).contains(SessionUpdateParams.TraceTier.LONGLIVED) } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionTest.kt index 21108d1f..c7b7cd7d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionTest.kt @@ -24,8 +24,16 @@ internal class TracerSessionTest { .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorRate(0.0) - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + TracerSession.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + TracerSession.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .firstTokenP50(0.0) .firstTokenP99(0.0) .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -37,8 +45,16 @@ internal class TracerSessionTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runCount(0L) - .addRunFacet(JsonValue.from(mapOf())) - .sessionFeedbackStats(JsonValue.from(mapOf())) + .addRunFacet( + TracerSession.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionFeedbackStats( + TracerSession.SessionFeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .streamingRate(0.0) .testRunNumber(0L) @@ -57,8 +73,18 @@ internal class TracerSessionTest { assertThat(tracerSession.endTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(tracerSession.errorRate()).contains(0.0) - assertThat(tracerSession._extra()).isEqualTo(JsonValue.from(mapOf())) - assertThat(tracerSession._feedbackStats()).isEqualTo(JsonValue.from(mapOf())) + assertThat(tracerSession.extra()) + .contains( + TracerSession.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(tracerSession.feedbackStats()) + .contains( + TracerSession.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(tracerSession.firstTokenP50()).contains(0.0) assertThat(tracerSession.firstTokenP99()).contains(0.0) assertThat(tracerSession.lastRunStartTime()) @@ -74,9 +100,17 @@ internal class TracerSessionTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(tracerSession.runCount()).contains(0L) assertThat(tracerSession.runFacets().getOrNull()) - .containsExactly(JsonValue.from(mapOf())) - assertThat(tracerSession._sessionFeedbackStats()) - .isEqualTo(JsonValue.from(mapOf())) + .containsExactly( + TracerSession.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(tracerSession.sessionFeedbackStats()) + .contains( + TracerSession.SessionFeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(tracerSession.startTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(tracerSession.streamingRate()).contains(0.0) @@ -99,8 +133,16 @@ internal class TracerSessionTest { .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .errorRate(0.0) - .extra(JsonValue.from(mapOf())) - .feedbackStats(JsonValue.from(mapOf())) + .extra( + TracerSession.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + TracerSession.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .firstTokenP50(0.0) .firstTokenP99(0.0) .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -112,8 +154,16 @@ internal class TracerSessionTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runCount(0L) - .addRunFacet(JsonValue.from(mapOf())) - .sessionFeedbackStats(JsonValue.from(mapOf())) + .addRunFacet( + TracerSession.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionFeedbackStats( + TracerSession.SessionFeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .streamingRate(0.0) .testRunNumber(0L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFieldsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFieldsTest.kt index 59fc9f2c..543e5440 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFieldsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/TracerSessionWithoutVirtualFieldsTest.kt @@ -20,7 +20,11 @@ internal class TracerSessionWithoutVirtualFieldsTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + TracerSessionWithoutVirtualFields.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -37,8 +41,12 @@ internal class TracerSessionWithoutVirtualFieldsTest { assertThat(tracerSessionWithoutVirtualFields.description()).contains("description") assertThat(tracerSessionWithoutVirtualFields.endTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(tracerSessionWithoutVirtualFields._extra()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(tracerSessionWithoutVirtualFields.extra()) + .contains( + TracerSessionWithoutVirtualFields.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(tracerSessionWithoutVirtualFields.lastRunStartTimeLive()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(tracerSessionWithoutVirtualFields.name()).contains("name") @@ -60,7 +68,11 @@ internal class TracerSessionWithoutVirtualFieldsTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + TracerSessionWithoutVirtualFields.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt index 5c89d03a..a62ab7c2 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt @@ -16,7 +16,11 @@ internal class CreateRunClusteringJobRequestTest { fun create() { val createRunClusteringJobRequest = CreateRunClusteringJobRequest.builder() - .attributeSchemas(JsonValue.from(mapOf())) + .attributeSchemas( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) @@ -39,8 +43,12 @@ internal class CreateRunClusteringJobRequestTest { .validateModelSecrets(true) .build() - assertThat(createRunClusteringJobRequest._attributeSchemas()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(createRunClusteringJobRequest.attributeSchemas()) + .contains( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(createRunClusteringJobRequest.endTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(createRunClusteringJobRequest.filter()).contains("filter") @@ -73,7 +81,11 @@ internal class CreateRunClusteringJobRequestTest { val jsonMapper = jsonMapper() val createRunClusteringJobRequest = CreateRunClusteringJobRequest.builder() - .attributeSchemas(JsonValue.from(mapOf())) + .attributeSchemas( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt index acabb16b..c8ca7c4d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt @@ -15,7 +15,11 @@ internal class InsightCreateParamsTest { .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createRunClusteringJobRequest( CreateRunClusteringJobRequest.builder() - .attributeSchemas(JsonValue.from(mapOf())) + .attributeSchemas( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) @@ -61,7 +65,11 @@ internal class InsightCreateParamsTest { .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createRunClusteringJobRequest( CreateRunClusteringJobRequest.builder() - .attributeSchemas(JsonValue.from(mapOf())) + .attributeSchemas( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) @@ -91,7 +99,11 @@ internal class InsightCreateParamsTest { assertThat(body) .isEqualTo( CreateRunClusteringJobRequest.builder() - .attributeSchemas(JsonValue.from(mapOf())) + .attributeSchemas( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt index 1a83b2eb..73b88cd8 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt @@ -23,7 +23,11 @@ internal class InsightRetrieveJobResponseTest { .level(0L) .name("name") .numRuns(0L) - .stats(JsonValue.from(mapOf())) + .stats( + InsightRetrieveJobResponse.Cluster.Stats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .parentName("parent_name") .build() @@ -32,7 +36,11 @@ internal class InsightRetrieveJobResponseTest { .status("status") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .metadata(JsonValue.from(mapOf())) + .metadata( + InsightRetrieveJobResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shape( InsightRetrieveJobResponse.Shape.builder() .putAdditionalProperty("foo", JsonValue.from(0)) @@ -51,7 +59,11 @@ internal class InsightRetrieveJobResponseTest { .level(0L) .name("name") .numRuns(0L) - .stats(JsonValue.from(mapOf())) + .stats( + InsightRetrieveJobResponse.Cluster.Stats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .parentName("parent_name") .build() @@ -61,8 +73,12 @@ internal class InsightRetrieveJobResponseTest { assertThat(insightRetrieveJobResponse.endTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(insightRetrieveJobResponse.error()).contains("error") - assertThat(insightRetrieveJobResponse._metadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(insightRetrieveJobResponse.metadata()) + .contains( + InsightRetrieveJobResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(insightRetrieveJobResponse.shape()) .contains( InsightRetrieveJobResponse.Shape.builder() @@ -86,7 +102,11 @@ internal class InsightRetrieveJobResponseTest { .level(0L) .name("name") .numRuns(0L) - .stats(JsonValue.from(mapOf())) + .stats( + InsightRetrieveJobResponse.Cluster.Stats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .parentName("parent_name") .build() @@ -95,7 +115,11 @@ internal class InsightRetrieveJobResponseTest { .status("status") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .metadata(JsonValue.from(mapOf())) + .metadata( + InsightRetrieveJobResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shape( InsightRetrieveJobResponse.Shape.builder() .putAdditionalProperty("foo", JsonValue.from(0)) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponseTest.kt index e9048200..f02447cf 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveRunsResponseTest.kt @@ -15,12 +15,20 @@ internal class InsightRetrieveRunsResponseTest { val insightRetrieveRunsResponse = InsightRetrieveRunsResponse.builder() .offset(0L) - .addRun(JsonValue.from(mapOf())) + .addRun( + InsightRetrieveRunsResponse.Run.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(insightRetrieveRunsResponse.offset()).contains(0L) assertThat(insightRetrieveRunsResponse.runs()) - .containsExactly(JsonValue.from(mapOf())) + .containsExactly( + InsightRetrieveRunsResponse.Run.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -29,7 +37,11 @@ internal class InsightRetrieveRunsResponseTest { val insightRetrieveRunsResponse = InsightRetrieveRunsResponse.builder() .offset(0L) - .addRun(JsonValue.from(mapOf())) + .addRun( + InsightRetrieveRunsResponse.Run.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedInsightRetrieveRunsResponse = diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt index 456d22ba..6af0e725 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt @@ -59,7 +59,11 @@ internal class AnnotationQueueServiceAsyncTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .numReviewersPerItem(0L) .reservationMinutes(0L) @@ -127,7 +131,11 @@ internal class AnnotationQueueServiceAsyncTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueAnnotationQueuesParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .rubricInstructions("rubric_instructions") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/CommitServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/CommitServiceAsyncTest.kt index 2fd5cb79..2f840be2 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/CommitServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/CommitServiceAsyncTest.kt @@ -60,7 +60,11 @@ internal class CommitServiceAsyncTest { CommitUpdateParams.builder() .owner("owner") .repo("repo") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .parentCommit("parent_commit") .skipWebhooks(true) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt index 2b0e2fc7..84b73237 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt @@ -46,9 +46,21 @@ internal class DatasetServiceAsyncTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .extra(JsonValue.from(mapOf())) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .extra( + DatasetCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputsSchemaDefinition( + DatasetCreateParams.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetCreateParams.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") @@ -99,10 +111,22 @@ internal class DatasetServiceAsyncTest { DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("string") - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetUpdateParams.InputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + DatasetUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("string") - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .outputsSchemaDefinition( + DatasetUpdateParams.OutputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .patchExamples( DatasetUpdateParams.PatchExamples.builder() .putAdditionalProperty( @@ -115,9 +139,9 @@ internal class DatasetServiceAsyncTest { "retain" to listOf("string"), ), "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - "inputs" to mapOf(), - "metadata" to mapOf(), - "outputs" to mapOf(), + "inputs" to mapOf("foo" to "bar"), + "metadata" to mapOf("foo" to "bar"), + "outputs" to mapOf("foo" to "bar"), "overwrite" to true, "split" to listOf("string"), ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt index a00fe282..7ca08bd3 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt @@ -38,9 +38,21 @@ internal class ExampleServiceAsyncTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleCreateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleCreateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -104,9 +116,21 @@ internal class ExampleServiceAsyncTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleUpdateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleUpdateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt index 03d113da..4ac31db6 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt @@ -36,7 +36,11 @@ internal class FeedbackServiceAsyncTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .feedbackConfig( @@ -55,7 +59,11 @@ internal class FeedbackServiceAsyncTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -113,7 +121,11 @@ internal class FeedbackServiceAsyncTest { FeedbackUpdateParams.builder() .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackUpdateParams.FeedbackConfig.builder() .type(FeedbackUpdateParams.FeedbackConfig.Type.CONTINUOUS) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/SessionServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/SessionServiceAsyncTest.kt index 0db652ca..bd35df26 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/SessionServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/SessionServiceAsyncTest.kt @@ -40,7 +40,11 @@ internal class SessionServiceAsyncTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -97,7 +101,11 @@ internal class SessionServiceAsyncTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionUpdateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .traceTier(SessionUpdateParams.TraceTier.LONGLIVED) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt index e9381b0b..b68dc509 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt @@ -33,7 +33,11 @@ internal class ComparativeServiceAsyncTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .extra(JsonValue.from(mapOf())) + .extra( + ComparativeCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/PlaygroundExperimentServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/PlaygroundExperimentServiceAsyncTest.kt index 813f2ae5..8bb16601 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/PlaygroundExperimentServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/PlaygroundExperimentServiceAsyncTest.kt @@ -36,9 +36,17 @@ internal class PlaygroundExperimentServiceAsyncTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -55,7 +63,11 @@ internal class PlaygroundExperimentServiceAsyncTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentBatchParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) @@ -94,9 +106,17 @@ internal class PlaygroundExperimentServiceAsyncTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -112,7 +132,11 @@ internal class PlaygroundExperimentServiceAsyncTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentStreamParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/examples/BulkServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/examples/BulkServiceAsyncTest.kt index 1c1b1bc7..2405aad1 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/examples/BulkServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/examples/BulkServiceAsyncTest.kt @@ -35,9 +35,21 @@ internal class BulkServiceAsyncTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkCreateParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkCreateParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkCreateParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -81,9 +93,21 @@ internal class BulkServiceAsyncTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkPatchAllParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkPatchAllParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkPatchAllParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/feedback/TokenServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/feedback/TokenServiceAsyncTest.kt index 7ba2d0b1..8bf0c685 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/feedback/TokenServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/feedback/TokenServiceAsyncTest.kt @@ -112,8 +112,16 @@ internal class TokenServiceAsyncTest { TokenUpdateParams.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .correction( + TokenUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + TokenUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .score(0.0) .value(0.0) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt index 20876793..1606c3a4 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt @@ -37,7 +37,11 @@ internal class InsightServiceAsyncTest { .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createRunClusteringJobRequest( CreateRunClusteringJobRequest.builder() - .attributeSchemas(JsonValue.from(mapOf())) + .attributeSchemas( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt index a31228d1..5043678f 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt @@ -58,7 +58,11 @@ internal class AnnotationQueueServiceTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .numReviewersPerItem(0L) .reservationMinutes(0L) @@ -123,7 +127,11 @@ internal class AnnotationQueueServiceTest { .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .enableReservations(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + AnnotationQueueAnnotationQueuesParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .numReviewersPerItem(0L) .reservationMinutes(0L) .rubricInstructions("rubric_instructions") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/CommitServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/CommitServiceTest.kt index bfcb2e2d..ba89c026 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/CommitServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/CommitServiceTest.kt @@ -59,7 +59,11 @@ internal class CommitServiceTest { CommitUpdateParams.builder() .owner("owner") .repo("repo") - .manifest(JsonValue.from(mapOf())) + .manifest( + CommitUpdateParams.Manifest.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .parentCommit("parent_commit") .skipWebhooks(true) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt index e1db00bd..447da44f 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt @@ -46,9 +46,21 @@ internal class DatasetServiceTest { .dataType(DataType.KV) .description("description") .externallyManaged(true) - .extra(JsonValue.from(mapOf())) - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .extra( + DatasetCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputsSchemaDefinition( + DatasetCreateParams.InputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsSchemaDefinition( + DatasetCreateParams.OutputsSchemaDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .addTransformation( DatasetTransformation.builder() .addPath("string") @@ -97,10 +109,22 @@ internal class DatasetServiceTest { DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("string") - .inputsSchemaDefinition(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .inputsSchemaDefinition( + DatasetUpdateParams.InputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + DatasetUpdateParams.Metadata.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("string") - .outputsSchemaDefinition(JsonValue.from(mapOf())) + .outputsSchemaDefinition( + DatasetUpdateParams.OutputsSchemaDefinition.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .patchExamples( DatasetUpdateParams.PatchExamples.builder() .putAdditionalProperty( @@ -113,9 +137,9 @@ internal class DatasetServiceTest { "retain" to listOf("string"), ), "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - "inputs" to mapOf(), - "metadata" to mapOf(), - "outputs" to mapOf(), + "inputs" to mapOf("foo" to "bar"), + "metadata" to mapOf("foo" to "bar"), + "outputs" to mapOf("foo" to "bar"), "overwrite" to true, "split" to listOf("string"), ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt index 5d3de0f4..1dfa05d1 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt @@ -38,9 +38,21 @@ internal class ExampleServiceTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleCreateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleCreateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -102,9 +114,21 @@ internal class ExampleServiceTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + ExampleUpdateParams.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + ExampleUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + ExampleUpdateParams.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt index 37b41fc2..df46004c 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt @@ -36,7 +36,11 @@ internal class FeedbackServiceTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackCreateSchema.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .feedbackConfig( @@ -55,7 +59,11 @@ internal class FeedbackServiceTest { .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedbackSource( AppFeedbackSource.builder() - .metadata(JsonValue.from(mapOf())) + .metadata( + AppFeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .type(AppFeedbackSource.Type.APP) .build() ) @@ -111,7 +119,11 @@ internal class FeedbackServiceTest { FeedbackUpdateParams.builder() .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) + .correction( + FeedbackUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackUpdateParams.FeedbackConfig.builder() .type(FeedbackUpdateParams.FeedbackConfig.Type.CONTINUOUS) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/SessionServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/SessionServiceTest.kt index afd138bd..92b9e5a0 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/SessionServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/SessionServiceTest.kt @@ -40,7 +40,11 @@ internal class SessionServiceTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -95,7 +99,11 @@ internal class SessionServiceTest { .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra(JsonValue.from(mapOf())) + .extra( + SessionUpdateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .traceTier(SessionUpdateParams.TraceTier.LONGLIVED) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt index 8681c923..d2364321 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt @@ -33,7 +33,11 @@ internal class ComparativeServiceTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .extra(JsonValue.from(mapOf())) + .extra( + ComparativeCreateParams.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/PlaygroundExperimentServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/PlaygroundExperimentServiceTest.kt index 5ddad0de..8949a0f0 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/PlaygroundExperimentServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/PlaygroundExperimentServiceTest.kt @@ -36,9 +36,17 @@ internal class PlaygroundExperimentServiceTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -55,7 +63,11 @@ internal class PlaygroundExperimentServiceTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentBatchParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) @@ -93,9 +105,17 @@ internal class PlaygroundExperimentServiceTest { .options( RunnableConfig.builder() .callbacksOfJsonValues(listOf(JsonValue.from(mapOf()))) - .configurable(JsonValue.from(mapOf())) + .configurable( + RunnableConfig.Configurable.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .maxConcurrency(0L) - .metadata(JsonValue.from(mapOf())) + .metadata( + RunnableConfig.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .recursionLimit(0L) .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runName("run_name") @@ -111,7 +131,11 @@ internal class PlaygroundExperimentServiceTest { .commit("commit") .addDatasetSplit("string") .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(JsonValue.from(mapOf())) + .metadata( + PlaygroundExperimentStreamParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .owner("owner") .parallelToolCalls(true) .repetitions(1L) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/examples/BulkServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/examples/BulkServiceTest.kt index cd41d000..850bc18b 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/examples/BulkServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/examples/BulkServiceTest.kt @@ -35,9 +35,21 @@ internal class BulkServiceTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createdAt("created_at") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkCreateParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkCreateParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkCreateParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .splitOfStrings(listOf("string")) .useLegacyMessageFormat(true) @@ -80,9 +92,21 @@ internal class BulkServiceTest { .build() ) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) - .outputs(JsonValue.from(mapOf())) + .inputs( + BulkPatchAllParams.Body.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + BulkPatchAllParams.Body.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + BulkPatchAllParams.Body.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .overwrite(true) .splitOfStrings(listOf("string")) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/feedback/TokenServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/feedback/TokenServiceTest.kt index ac384fce..5de29056 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/feedback/TokenServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/feedback/TokenServiceTest.kt @@ -110,8 +110,16 @@ internal class TokenServiceTest { TokenUpdateParams.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .correction(JsonValue.from(mapOf())) - .metadata(JsonValue.from(mapOf())) + .correction( + TokenUpdateParams.Correction.UnionMember0.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metadata( + TokenUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .score(0.0) .value(0.0) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt index dec7fe02..d7a5426d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt @@ -37,7 +37,11 @@ internal class InsightServiceTest { .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .createRunClusteringJobRequest( CreateRunClusteringJobRequest.builder() - .attributeSchemas(JsonValue.from(mapOf())) + .attributeSchemas( + CreateRunClusteringJobRequest.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) diff --git a/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt b/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt index 651f026e..a9b6b5f2 100644 --- a/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt +++ b/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt @@ -130,7 +130,11 @@ internal class ProGuardCompatibilityTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .title("title") @@ -208,7 +212,11 @@ internal class ProGuardCompatibilityTest { .build() ) .description("description") - .metadata(JsonValue.from(mapOf())) + .metadata( + CustomChartsSection.SubSection.Chart.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .index(0L) @@ -236,7 +244,11 @@ internal class ProGuardCompatibilityTest { ExampleWithRuns.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .addRun( ExampleWithRuns.Run.builder() @@ -264,28 +276,52 @@ internal class ProGuardCompatibilityTest { .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + ExampleWithRuns.Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .executionOrder(1L) - .extra(JsonValue.from(mapOf())) + .extra( + ExampleWithRuns.Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackStats( ExampleWithRuns.Run.FeedbackStats.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf()), + JsonValue.from(mapOf("foo" to "bar")), ) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) - .inputs(JsonValue.from(mapOf())) + .inputs( + ExampleWithRuns.Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .inputsPreview("inputs_preview") - .inputsS3Urls(JsonValue.from(mapOf())) + .inputsS3Urls( + ExampleWithRuns.Run.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .outputsPreview("outputs_preview") - .outputsS3Urls(JsonValue.from(mapOf())) + .outputsS3Urls( + ExampleWithRuns.Run.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -303,8 +339,16 @@ internal class ProGuardCompatibilityTest { .promptTokens(0L) .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls(JsonValue.from(mapOf())) - .serialized(JsonValue.from(mapOf())) + .s3Urls( + ExampleWithRuns.Run.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + ExampleWithRuns.Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addTag("string") @@ -321,11 +365,23 @@ internal class ProGuardCompatibilityTest { .ttlSeconds(0L) .build() ) - .attachmentUrls(JsonValue.from(mapOf())) + .attachmentUrls( + ExampleWithRuns.AttachmentUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(JsonValue.from(mapOf())) + .metadata( + ExampleWithRuns.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs(JsonValue.from(mapOf())) + .outputs( + ExampleWithRuns.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() )