Skip to content

Commit 9ebd84f

Browse files
feat(api): api update
1 parent 88bd850 commit 9ebd84f

3 files changed

Lines changed: 63 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-5621c5d496a015ec01b7acccb92ab7e4267b4f9b88b0e6e3e1f12deadb05a6d5.yml
3-
openapi_spec_hash: 70a0cb92d318c9828dfab1cfc5d35378
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-1d2915c35123d9fafcdec586ab2c2f8d1096f184839389ec0205793c2095da8a.yml
3+
openapi_spec_hash: a0a1d15d368475c444170f3ac18df763
44
config_hash: 4c81a93850b2f9805605749a196ed2df

langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRuns.kt

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class QueryExampleSchemaWithRuns
2424
private constructor(
2525
private val sessionIds: JsonField<List<String>>,
2626
private val comparativeExperimentId: JsonField<String>,
27+
private val exampleIds: JsonField<List<String>>,
2728
private val filters: JsonField<Filters>,
2829
private val limit: JsonField<Long>,
2930
private val offset: JsonField<Long>,
@@ -41,6 +42,9 @@ private constructor(
4142
@JsonProperty("comparative_experiment_id")
4243
@ExcludeMissing
4344
comparativeExperimentId: JsonField<String> = JsonMissing.of(),
45+
@JsonProperty("example_ids")
46+
@ExcludeMissing
47+
exampleIds: JsonField<List<String>> = JsonMissing.of(),
4448
@JsonProperty("filters") @ExcludeMissing filters: JsonField<Filters> = JsonMissing.of(),
4549
@JsonProperty("limit") @ExcludeMissing limit: JsonField<Long> = JsonMissing.of(),
4650
@JsonProperty("offset") @ExcludeMissing offset: JsonField<Long> = JsonMissing.of(),
@@ -52,6 +56,7 @@ private constructor(
5256
) : this(
5357
sessionIds,
5458
comparativeExperimentId,
59+
exampleIds,
5560
filters,
5661
limit,
5762
offset,
@@ -74,6 +79,12 @@ private constructor(
7479
fun comparativeExperimentId(): Optional<String> =
7580
comparativeExperimentId.getOptional("comparative_experiment_id")
7681

82+
/**
83+
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
84+
* server responded with an unexpected value).
85+
*/
86+
fun exampleIds(): Optional<List<String>> = exampleIds.getOptional("example_ids")
87+
7788
/**
7889
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
7990
* server responded with an unexpected value).
@@ -130,6 +141,15 @@ private constructor(
130141
@ExcludeMissing
131142
fun _comparativeExperimentId(): JsonField<String> = comparativeExperimentId
132143

144+
/**
145+
* Returns the raw JSON value of [exampleIds].
146+
*
147+
* Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type.
148+
*/
149+
@JsonProperty("example_ids")
150+
@ExcludeMissing
151+
fun _exampleIds(): JsonField<List<String>> = exampleIds
152+
133153
/**
134154
* Returns the raw JSON value of [filters].
135155
*
@@ -204,6 +224,7 @@ private constructor(
204224

205225
private var sessionIds: JsonField<MutableList<String>>? = null
206226
private var comparativeExperimentId: JsonField<String> = JsonMissing.of()
227+
private var exampleIds: JsonField<MutableList<String>>? = null
207228
private var filters: JsonField<Filters> = JsonMissing.of()
208229
private var limit: JsonField<Long> = JsonMissing.of()
209230
private var offset: JsonField<Long> = JsonMissing.of()
@@ -216,6 +237,7 @@ private constructor(
216237
internal fun from(queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns) = apply {
217238
sessionIds = queryExampleSchemaWithRuns.sessionIds.map { it.toMutableList() }
218239
comparativeExperimentId = queryExampleSchemaWithRuns.comparativeExperimentId
240+
exampleIds = queryExampleSchemaWithRuns.exampleIds.map { it.toMutableList() }
219241
filters = queryExampleSchemaWithRuns.filters
220242
limit = queryExampleSchemaWithRuns.limit
221243
offset = queryExampleSchemaWithRuns.offset
@@ -271,6 +293,34 @@ private constructor(
271293
this.comparativeExperimentId = comparativeExperimentId
272294
}
273295

296+
fun exampleIds(exampleIds: List<String>?) = exampleIds(JsonField.ofNullable(exampleIds))
297+
298+
/** Alias for calling [Builder.exampleIds] with `exampleIds.orElse(null)`. */
299+
fun exampleIds(exampleIds: Optional<List<String>>) = exampleIds(exampleIds.getOrNull())
300+
301+
/**
302+
* Sets [Builder.exampleIds] to an arbitrary JSON value.
303+
*
304+
* You should usually call [Builder.exampleIds] with a well-typed `List<String>` value
305+
* instead. This method is primarily for setting the field to an undocumented or not yet
306+
* supported value.
307+
*/
308+
fun exampleIds(exampleIds: JsonField<List<String>>) = apply {
309+
this.exampleIds = exampleIds.map { it.toMutableList() }
310+
}
311+
312+
/**
313+
* Adds a single [String] to [exampleIds].
314+
*
315+
* @throws IllegalStateException if the field was previously set to a non-list.
316+
*/
317+
fun addExampleId(exampleId: String) = apply {
318+
exampleIds =
319+
(exampleIds ?: JsonField.of(mutableListOf())).also {
320+
checkKnown("exampleIds", it).add(exampleId)
321+
}
322+
}
323+
274324
fun filters(filters: Filters?) = filters(JsonField.ofNullable(filters))
275325

276326
/** Alias for calling [Builder.filters] with `filters.orElse(null)`. */
@@ -377,6 +427,7 @@ private constructor(
377427
QueryExampleSchemaWithRuns(
378428
checkRequired("sessionIds", sessionIds).map { it.toImmutable() },
379429
comparativeExperimentId,
430+
(exampleIds ?: JsonMissing.of()).map { it.toImmutable() },
380431
filters,
381432
limit,
382433
offset,
@@ -396,6 +447,7 @@ private constructor(
396447

397448
sessionIds()
398449
comparativeExperimentId()
450+
exampleIds()
399451
filters().ifPresent { it.validate() }
400452
limit()
401453
offset()
@@ -422,6 +474,7 @@ private constructor(
422474
internal fun validity(): Int =
423475
(sessionIds.asKnown().getOrNull()?.size ?: 0) +
424476
(if (comparativeExperimentId.asKnown().isPresent) 1 else 0) +
477+
(exampleIds.asKnown().getOrNull()?.size ?: 0) +
425478
(filters.asKnown().getOrNull()?.validity() ?: 0) +
426479
(if (limit.asKnown().isPresent) 1 else 0) +
427480
(if (offset.asKnown().isPresent) 1 else 0) +
@@ -536,6 +589,7 @@ private constructor(
536589
return other is QueryExampleSchemaWithRuns &&
537590
sessionIds == other.sessionIds &&
538591
comparativeExperimentId == other.comparativeExperimentId &&
592+
exampleIds == other.exampleIds &&
539593
filters == other.filters &&
540594
limit == other.limit &&
541595
offset == other.offset &&
@@ -549,6 +603,7 @@ private constructor(
549603
Objects.hash(
550604
sessionIds,
551605
comparativeExperimentId,
606+
exampleIds,
552607
filters,
553608
limit,
554609
offset,
@@ -562,5 +617,5 @@ private constructor(
562617
override fun hashCode(): Int = hashCode
563618

564619
override fun toString() =
565-
"QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}"
620+
"QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, exampleIds=$exampleIds, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}"
566621
}

langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRunsTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.langchain.smith.models.datasets.runs
55
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
66
import com.langchain.smith.core.JsonValue
77
import com.langchain.smith.core.jsonMapper
8+
import kotlin.jvm.optionals.getOrNull
89
import org.assertj.core.api.Assertions.assertThat
910
import org.junit.jupiter.api.Test
1011

@@ -16,6 +17,7 @@ internal class QueryExampleSchemaWithRunsTest {
1617
QueryExampleSchemaWithRuns.builder()
1718
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1819
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
20+
.addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1921
.filters(
2022
QueryExampleSchemaWithRuns.Filters.builder()
2123
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
@@ -37,6 +39,8 @@ internal class QueryExampleSchemaWithRunsTest {
3739
.containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
3840
assertThat(queryExampleSchemaWithRuns.comparativeExperimentId())
3941
.contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
42+
assertThat(queryExampleSchemaWithRuns.exampleIds().getOrNull())
43+
.containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
4044
assertThat(queryExampleSchemaWithRuns.filters())
4145
.contains(
4246
QueryExampleSchemaWithRuns.Filters.builder()
@@ -63,6 +67,7 @@ internal class QueryExampleSchemaWithRunsTest {
6367
QueryExampleSchemaWithRuns.builder()
6468
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
6569
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
70+
.addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
6671
.filters(
6772
QueryExampleSchemaWithRuns.Filters.builder()
6873
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))

0 commit comments

Comments
 (0)