Skip to content

Commit 786edff

Browse files
feat(api): api update
1 parent 739d870 commit 786edff

6 files changed

Lines changed: 179 additions & 3 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 100
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-84a6eb59eaaeafdb657c210d633ff6ea6e067f843ddeeb0758b46a97b4691fc0.yml
3-
openapi_spec_hash: 53270859b477e8697ef7f72d20f895dd
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-a6f7a10efb491bdc12951aa17c12fbab5e3972358b16cba711f1d988f9facb03.yml
3+
openapi_spec_hash: 85cbf183f717d85868696f29dd514651
44
config_hash: d847cdf0b10e3d2ae194df8fed4ae22a

langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private constructor(
4343
private val correction: JsonField<Correction>,
4444
private val createdAt: JsonField<OffsetDateTime>,
4545
private val error: JsonField<Boolean>,
46+
private val extra: JsonField<Extra>,
4647
private val feedbackConfig: JsonField<FeedbackConfig>,
4748
private val feedbackGroupId: JsonField<String>,
4849
private val feedbackSource: JsonField<FeedbackSource>,
@@ -71,6 +72,7 @@ private constructor(
7172
@ExcludeMissing
7273
createdAt: JsonField<OffsetDateTime> = JsonMissing.of(),
7374
@JsonProperty("error") @ExcludeMissing error: JsonField<Boolean> = JsonMissing.of(),
75+
@JsonProperty("extra") @ExcludeMissing extra: JsonField<Extra> = JsonMissing.of(),
7476
@JsonProperty("feedback_config")
7577
@ExcludeMissing
7678
feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(),
@@ -99,6 +101,7 @@ private constructor(
99101
correction,
100102
createdAt,
101103
error,
104+
extra,
102105
feedbackConfig,
103106
feedbackGroupId,
104107
feedbackSource,
@@ -155,6 +158,12 @@ private constructor(
155158
*/
156159
fun error(): Optional<Boolean> = error.getOptional("error")
157160

161+
/**
162+
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
163+
* server responded with an unexpected value).
164+
*/
165+
fun extra(): Optional<Extra> = extra.getOptional("extra")
166+
158167
/**
159168
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
160169
* server responded with an unexpected value).
@@ -273,6 +282,13 @@ private constructor(
273282
*/
274283
@JsonProperty("error") @ExcludeMissing fun _error(): JsonField<Boolean> = error
275284

285+
/**
286+
* Returns the raw JSON value of [extra].
287+
*
288+
* Unlike [extra], this method doesn't throw if the JSON field has an unexpected type.
289+
*/
290+
@JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField<Extra> = extra
291+
276292
/**
277293
* Returns the raw JSON value of [feedbackConfig].
278294
*
@@ -388,6 +404,7 @@ private constructor(
388404
private var correction: JsonField<Correction> = JsonMissing.of()
389405
private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of()
390406
private var error: JsonField<Boolean> = JsonMissing.of()
407+
private var extra: JsonField<Extra> = JsonMissing.of()
391408
private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of()
392409
private var feedbackGroupId: JsonField<String> = JsonMissing.of()
393410
private var feedbackSource: JsonField<FeedbackSource> = JsonMissing.of()
@@ -409,6 +426,7 @@ private constructor(
409426
correction = feedbackCreateSchema.correction
410427
createdAt = feedbackCreateSchema.createdAt
411428
error = feedbackCreateSchema.error
429+
extra = feedbackCreateSchema.extra
412430
feedbackConfig = feedbackCreateSchema.feedbackConfig
413431
feedbackGroupId = feedbackCreateSchema.feedbackGroupId
414432
feedbackSource = feedbackCreateSchema.feedbackSource
@@ -528,6 +546,19 @@ private constructor(
528546
*/
529547
fun error(error: JsonField<Boolean>) = apply { this.error = error }
530548

549+
fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra))
550+
551+
/** Alias for calling [Builder.extra] with `extra.orElse(null)`. */
552+
fun extra(extra: Optional<Extra>) = extra(extra.getOrNull())
553+
554+
/**
555+
* Sets [Builder.extra] to an arbitrary JSON value.
556+
*
557+
* You should usually call [Builder.extra] with a well-typed [Extra] value instead. This
558+
* method is primarily for setting the field to an undocumented or not yet supported value.
559+
*/
560+
fun extra(extra: JsonField<Extra>) = apply { this.extra = extra }
561+
531562
fun feedbackConfig(feedbackConfig: FeedbackConfig?) =
532563
feedbackConfig(JsonField.ofNullable(feedbackConfig))
533564

@@ -748,6 +779,7 @@ private constructor(
748779
correction,
749780
createdAt,
750781
error,
782+
extra,
751783
feedbackConfig,
752784
feedbackGroupId,
753785
feedbackSource,
@@ -776,6 +808,7 @@ private constructor(
776808
correction().ifPresent { it.validate() }
777809
createdAt()
778810
error()
811+
extra().ifPresent { it.validate() }
779812
feedbackConfig().ifPresent { it.validate() }
780813
feedbackGroupId()
781814
feedbackSource().ifPresent { it.validate() }
@@ -811,6 +844,7 @@ private constructor(
811844
(correction.asKnown().getOrNull()?.validity() ?: 0) +
812845
(if (createdAt.asKnown().isPresent) 1 else 0) +
813846
(if (error.asKnown().isPresent) 1 else 0) +
847+
(extra.asKnown().getOrNull()?.validity() ?: 0) +
814848
(feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) +
815849
(if (feedbackGroupId.asKnown().isPresent) 1 else 0) +
816850
(feedbackSource.asKnown().getOrNull()?.validity() ?: 0) +
@@ -1099,6 +1133,105 @@ private constructor(
10991133
}
11001134
}
11011135

1136+
class Extra
1137+
@JsonCreator
1138+
private constructor(
1139+
@com.fasterxml.jackson.annotation.JsonValue
1140+
private val additionalProperties: Map<String, JsonValue>
1141+
) {
1142+
1143+
@JsonAnyGetter
1144+
@ExcludeMissing
1145+
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
1146+
1147+
fun toBuilder() = Builder().from(this)
1148+
1149+
companion object {
1150+
1151+
/** Returns a mutable builder for constructing an instance of [Extra]. */
1152+
@JvmStatic fun builder() = Builder()
1153+
}
1154+
1155+
/** A builder for [Extra]. */
1156+
class Builder internal constructor() {
1157+
1158+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
1159+
1160+
@JvmSynthetic
1161+
internal fun from(extra: Extra) = apply {
1162+
additionalProperties = extra.additionalProperties.toMutableMap()
1163+
}
1164+
1165+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
1166+
this.additionalProperties.clear()
1167+
putAllAdditionalProperties(additionalProperties)
1168+
}
1169+
1170+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
1171+
additionalProperties.put(key, value)
1172+
}
1173+
1174+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
1175+
this.additionalProperties.putAll(additionalProperties)
1176+
}
1177+
1178+
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
1179+
1180+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
1181+
keys.forEach(::removeAdditionalProperty)
1182+
}
1183+
1184+
/**
1185+
* Returns an immutable instance of [Extra].
1186+
*
1187+
* Further updates to this [Builder] will not mutate the returned instance.
1188+
*/
1189+
fun build(): Extra = Extra(additionalProperties.toImmutable())
1190+
}
1191+
1192+
private var validated: Boolean = false
1193+
1194+
fun validate(): Extra = apply {
1195+
if (validated) {
1196+
return@apply
1197+
}
1198+
1199+
validated = true
1200+
}
1201+
1202+
fun isValid(): Boolean =
1203+
try {
1204+
validate()
1205+
true
1206+
} catch (e: LangChainInvalidDataException) {
1207+
false
1208+
}
1209+
1210+
/**
1211+
* Returns a score indicating how many valid values are contained in this object
1212+
* recursively.
1213+
*
1214+
* Used for best match union deserialization.
1215+
*/
1216+
@JvmSynthetic
1217+
internal fun validity(): Int =
1218+
additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() }
1219+
1220+
override fun equals(other: Any?): Boolean {
1221+
if (this === other) {
1222+
return true
1223+
}
1224+
1225+
return other is Extra && additionalProperties == other.additionalProperties
1226+
}
1227+
1228+
private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
1229+
1230+
override fun hashCode(): Int = hashCode
1231+
1232+
override fun toString() = "Extra{additionalProperties=$additionalProperties}"
1233+
}
1234+
11021235
class FeedbackConfig
11031236
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
11041237
private constructor(
@@ -2472,6 +2605,7 @@ private constructor(
24722605
correction == other.correction &&
24732606
createdAt == other.createdAt &&
24742607
error == other.error &&
2608+
extra == other.extra &&
24752609
feedbackConfig == other.feedbackConfig &&
24762610
feedbackGroupId == other.feedbackGroupId &&
24772611
feedbackSource == other.feedbackSource &&
@@ -2494,6 +2628,7 @@ private constructor(
24942628
correction,
24952629
createdAt,
24962630
error,
2631+
extra,
24972632
feedbackConfig,
24982633
feedbackGroupId,
24992634
feedbackSource,
@@ -2511,5 +2646,5 @@ private constructor(
25112646
override fun hashCode(): Int = hashCode
25122647

25132648
override fun toString() =
2514-
"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}"
2649+
"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}"
25152650
}

langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ internal class FeedbackCreateParamsTest {
2525
)
2626
.createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
2727
.error(true)
28+
.extra(
29+
FeedbackCreateSchema.Extra.builder()
30+
.putAdditionalProperty("foo", JsonValue.from("bar"))
31+
.build()
32+
)
2833
.feedbackConfig(
2934
FeedbackCreateSchema.FeedbackConfig.builder()
3035
.type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)
@@ -78,6 +83,11 @@ internal class FeedbackCreateParamsTest {
7883
)
7984
.createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
8085
.error(true)
86+
.extra(
87+
FeedbackCreateSchema.Extra.builder()
88+
.putAdditionalProperty("foo", JsonValue.from("bar"))
89+
.build()
90+
)
8191
.feedbackConfig(
8292
FeedbackCreateSchema.FeedbackConfig.builder()
8393
.type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)
@@ -129,6 +139,11 @@ internal class FeedbackCreateParamsTest {
129139
)
130140
.createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
131141
.error(true)
142+
.extra(
143+
FeedbackCreateSchema.Extra.builder()
144+
.putAdditionalProperty("foo", JsonValue.from("bar"))
145+
.build()
146+
)
132147
.feedbackConfig(
133148
FeedbackCreateSchema.FeedbackConfig.builder()
134149
.type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)

langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ internal class FeedbackCreateSchemaTest {
2626
)
2727
.createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
2828
.error(true)
29+
.extra(
30+
FeedbackCreateSchema.Extra.builder()
31+
.putAdditionalProperty("foo", JsonValue.from("bar"))
32+
.build()
33+
)
2934
.feedbackConfig(
3035
FeedbackCreateSchema.FeedbackConfig.builder()
3136
.type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)
@@ -75,6 +80,12 @@ internal class FeedbackCreateSchemaTest {
7580
assertThat(feedbackCreateSchema.createdAt())
7681
.contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
7782
assertThat(feedbackCreateSchema.error()).contains(true)
83+
assertThat(feedbackCreateSchema.extra())
84+
.contains(
85+
FeedbackCreateSchema.Extra.builder()
86+
.putAdditionalProperty("foo", JsonValue.from("bar"))
87+
.build()
88+
)
7889
assertThat(feedbackCreateSchema.feedbackConfig())
7990
.contains(
8091
FeedbackCreateSchema.FeedbackConfig.builder()
@@ -132,6 +143,11 @@ internal class FeedbackCreateSchemaTest {
132143
)
133144
.createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
134145
.error(true)
146+
.extra(
147+
FeedbackCreateSchema.Extra.builder()
148+
.putAdditionalProperty("foo", JsonValue.from("bar"))
149+
.build()
150+
)
135151
.feedbackConfig(
136152
FeedbackCreateSchema.FeedbackConfig.builder()
137153
.type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)

langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ internal class FeedbackServiceAsyncTest {
4343
)
4444
.createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
4545
.error(true)
46+
.extra(
47+
FeedbackCreateSchema.Extra.builder()
48+
.putAdditionalProperty("foo", JsonValue.from("bar"))
49+
.build()
50+
)
4651
.feedbackConfig(
4752
FeedbackCreateSchema.FeedbackConfig.builder()
4853
.type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)

langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ internal class FeedbackServiceTest {
4343
)
4444
.createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
4545
.error(true)
46+
.extra(
47+
FeedbackCreateSchema.Extra.builder()
48+
.putAdditionalProperty("foo", JsonValue.from("bar"))
49+
.build()
50+
)
4651
.feedbackConfig(
4752
FeedbackCreateSchema.FeedbackConfig.builder()
4853
.type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS)

0 commit comments

Comments
 (0)