diff --git a/.stats.yml b/.stats.yml index abc2633a..d6e85aad 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-84a6eb59eaaeafdb657c210d633ff6ea6e067f843ddeeb0758b46a97b4691fc0.yml -openapi_spec_hash: 53270859b477e8697ef7f72d20f895dd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-a6f7a10efb491bdc12951aa17c12fbab5e3972358b16cba711f1d988f9facb03.yml +openapi_spec_hash: 85cbf183f717d85868696f29dd514651 config_hash: d847cdf0b10e3d2ae194df8fed4ae22a 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 ac287b54..fc9fe4d5 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 @@ -43,6 +43,7 @@ private constructor( private val correction: JsonField, private val createdAt: JsonField, private val error: JsonField, + private val extra: JsonField, private val feedbackConfig: JsonField, private val feedbackGroupId: JsonField, private val feedbackSource: JsonField, @@ -71,6 +72,7 @@ private constructor( @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_config") @ExcludeMissing feedbackConfig: JsonField = JsonMissing.of(), @@ -99,6 +101,7 @@ private constructor( correction, createdAt, error, + extra, feedbackConfig, feedbackGroupId, feedbackSource, @@ -155,6 +158,12 @@ private constructor( */ fun error(): Optional = error.getOptional("error") + /** + * @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 * server responded with an unexpected value). @@ -273,6 +282,13 @@ private constructor( */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + /** + * 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]. * @@ -388,6 +404,7 @@ private constructor( private var correction: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var error: JsonField = 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() @@ -409,6 +426,7 @@ private constructor( correction = feedbackCreateSchema.correction createdAt = feedbackCreateSchema.createdAt error = feedbackCreateSchema.error + extra = feedbackCreateSchema.extra feedbackConfig = feedbackCreateSchema.feedbackConfig feedbackGroupId = feedbackCreateSchema.feedbackGroupId feedbackSource = feedbackCreateSchema.feedbackSource @@ -528,6 +546,19 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } + 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)) @@ -748,6 +779,7 @@ private constructor( correction, createdAt, error, + extra, feedbackConfig, feedbackGroupId, feedbackSource, @@ -776,6 +808,7 @@ private constructor( correction().ifPresent { it.validate() } createdAt() error() + extra().ifPresent { it.validate() } feedbackConfig().ifPresent { it.validate() } feedbackGroupId() feedbackSource().ifPresent { it.validate() } @@ -811,6 +844,7 @@ private constructor( (correction.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (error.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) + @@ -1099,6 +1133,105 @@ private constructor( } } + 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 @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -2472,6 +2605,7 @@ private constructor( correction == other.correction && createdAt == other.createdAt && error == other.error && + extra == other.extra && feedbackConfig == other.feedbackConfig && feedbackGroupId == other.feedbackGroupId && feedbackSource == other.feedbackSource && @@ -2494,6 +2628,7 @@ private constructor( correction, createdAt, error, + extra, feedbackConfig, feedbackGroupId, feedbackSource, @@ -2511,5 +2646,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FeedbackCreateSchema{key=$key, id=$id, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, error=$error, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, startTime=$startTime, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}" + "FeedbackCreateSchema{key=$key, id=$id, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, error=$error, extra=$extra, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, startTime=$startTime, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}" } 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 45d8f906..8d5eb3ad 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 @@ -25,6 +25,11 @@ internal class FeedbackCreateParamsTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) + .extra( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) @@ -78,6 +83,11 @@ internal class FeedbackCreateParamsTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) + .extra( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) @@ -129,6 +139,11 @@ internal class FeedbackCreateParamsTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) + .extra( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) 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 53d2815d..e99461ee 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 @@ -26,6 +26,11 @@ internal class FeedbackCreateSchemaTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) + .extra( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) @@ -75,6 +80,12 @@ internal class FeedbackCreateSchemaTest { assertThat(feedbackCreateSchema.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(feedbackCreateSchema.error()).contains(true) + assertThat(feedbackCreateSchema.extra()) + .contains( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(feedbackCreateSchema.feedbackConfig()) .contains( FeedbackCreateSchema.FeedbackConfig.builder() @@ -132,6 +143,11 @@ internal class FeedbackCreateSchemaTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) + .extra( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) 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 8fba0317..f04b8032 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 @@ -43,6 +43,11 @@ internal class FeedbackServiceAsyncTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) + .extra( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) 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 19cdb23f..597d211d 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 @@ -43,6 +43,11 @@ internal class FeedbackServiceTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) + .extra( + FeedbackCreateSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)