mirror of
https://github.com/langchain-ai/langsmith-java.git
synced 2026-08-24 22:01:31 -04:00
feat(api): api update
This commit is contained in:
+136
-1
@@ -43,6 +43,7 @@ private constructor(
|
||||
private val correction: JsonField<Correction>,
|
||||
private val createdAt: JsonField<OffsetDateTime>,
|
||||
private val error: JsonField<Boolean>,
|
||||
private val extra: JsonField<Extra>,
|
||||
private val feedbackConfig: JsonField<FeedbackConfig>,
|
||||
private val feedbackGroupId: JsonField<String>,
|
||||
private val feedbackSource: JsonField<FeedbackSource>,
|
||||
@@ -71,6 +72,7 @@ private constructor(
|
||||
@ExcludeMissing
|
||||
createdAt: JsonField<OffsetDateTime> = JsonMissing.of(),
|
||||
@JsonProperty("error") @ExcludeMissing error: JsonField<Boolean> = JsonMissing.of(),
|
||||
@JsonProperty("extra") @ExcludeMissing extra: JsonField<Extra> = JsonMissing.of(),
|
||||
@JsonProperty("feedback_config")
|
||||
@ExcludeMissing
|
||||
feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(),
|
||||
@@ -99,6 +101,7 @@ private constructor(
|
||||
correction,
|
||||
createdAt,
|
||||
error,
|
||||
extra,
|
||||
feedbackConfig,
|
||||
feedbackGroupId,
|
||||
feedbackSource,
|
||||
@@ -155,6 +158,12 @@ private constructor(
|
||||
*/
|
||||
fun error(): Optional<Boolean> = 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> = 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<Boolean> = 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> = extra
|
||||
|
||||
/**
|
||||
* Returns the raw JSON value of [feedbackConfig].
|
||||
*
|
||||
@@ -388,6 +404,7 @@ private constructor(
|
||||
private var correction: JsonField<Correction> = JsonMissing.of()
|
||||
private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of()
|
||||
private var error: JsonField<Boolean> = JsonMissing.of()
|
||||
private var extra: JsonField<Extra> = JsonMissing.of()
|
||||
private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of()
|
||||
private var feedbackGroupId: JsonField<String> = JsonMissing.of()
|
||||
private var feedbackSource: JsonField<FeedbackSource> = 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<Boolean>) = 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(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<Extra>) = 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<String, JsonValue>
|
||||
) {
|
||||
|
||||
@JsonAnyGetter
|
||||
@ExcludeMissing
|
||||
fun _additionalProperties(): Map<String, JsonValue> = 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<String, JsonValue> = mutableMapOf()
|
||||
|
||||
@JvmSynthetic
|
||||
internal fun from(extra: Extra) = apply {
|
||||
additionalProperties = extra.additionalProperties.toMutableMap()
|
||||
}
|
||||
|
||||
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
|
||||
this.additionalProperties.clear()
|
||||
putAllAdditionalProperties(additionalProperties)
|
||||
}
|
||||
|
||||
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
|
||||
additionalProperties.put(key, value)
|
||||
}
|
||||
|
||||
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
|
||||
this.additionalProperties.putAll(additionalProperties)
|
||||
}
|
||||
|
||||
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
|
||||
|
||||
fun removeAllAdditionalProperties(keys: Set<String>) = 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}"
|
||||
}
|
||||
|
||||
+15
@@ -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)
|
||||
|
||||
+16
@@ -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)
|
||||
|
||||
+5
@@ -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)
|
||||
|
||||
+5
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user