Skip to content

Commit 2708533

Browse files
feat(api): api update
1 parent b28b2e5 commit 2708533

3 files changed

Lines changed: 74 additions & 6 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: 104
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-08fb63f15b46e95cfa398bdec0cd7fee9d24e599dd6139a0bd4f5c4435f17e93.yml
3-
openapi_spec_hash: 9921a6c2c02ea547426f8245aba6f6ea
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-ac64176a3b92a77b219d45128c282b4fa84854ad40163f517564aa6670416b11.yml
3+
openapi_spec_hash: f34bca699cf1e463f47e774d2d4da3a1
44
config_hash: 547a7f805036e8dd5fc37a0e908d0400

langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponse.kt

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ private constructor(
2424
private val commitHash: JsonField<String>,
2525
private val examples: JsonField<List<Example>>,
2626
private val manifest: JsonValue,
27+
private val modelConfig: JsonValue,
28+
private val modelProvider: JsonField<String>,
2729
private val additionalProperties: MutableMap<String, JsonValue>,
2830
) {
2931

@@ -36,7 +38,11 @@ private constructor(
3638
@ExcludeMissing
3739
examples: JsonField<List<Example>> = JsonMissing.of(),
3840
@JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(),
39-
) : this(commitHash, examples, manifest, mutableMapOf())
41+
@JsonProperty("model_config") @ExcludeMissing modelConfig: JsonValue = JsonMissing.of(),
42+
@JsonProperty("model_provider")
43+
@ExcludeMissing
44+
modelProvider: JsonField<String> = JsonMissing.of(),
45+
) : this(commitHash, examples, manifest, modelConfig, modelProvider, mutableMapOf())
4046

4147
/**
4248
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
@@ -58,6 +64,20 @@ private constructor(
5864
*/
5965
@JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest
6066

67+
/**
68+
* This arbitrary value can be deserialized into a custom type using the `convert` method:
69+
* ```java
70+
* MyClass myObject = commitRetrieveResponse.modelConfig().convert(MyClass.class);
71+
* ```
72+
*/
73+
@JsonProperty("model_config") @ExcludeMissing fun _modelConfig(): JsonValue = modelConfig
74+
75+
/**
76+
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
77+
* server responded with an unexpected value).
78+
*/
79+
fun modelProvider(): Optional<String> = modelProvider.getOptional("model_provider")
80+
6181
/**
6282
* Returns the raw JSON value of [commitHash].
6383
*
@@ -72,6 +92,15 @@ private constructor(
7292
*/
7393
@JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField<List<Example>> = examples
7494

95+
/**
96+
* Returns the raw JSON value of [modelProvider].
97+
*
98+
* Unlike [modelProvider], this method doesn't throw if the JSON field has an unexpected type.
99+
*/
100+
@JsonProperty("model_provider")
101+
@ExcludeMissing
102+
fun _modelProvider(): JsonField<String> = modelProvider
103+
75104
@JsonAnySetter
76105
private fun putAdditionalProperty(key: String, value: JsonValue) {
77106
additionalProperties.put(key, value)
@@ -96,13 +125,17 @@ private constructor(
96125
private var commitHash: JsonField<String> = JsonMissing.of()
97126
private var examples: JsonField<MutableList<Example>>? = null
98127
private var manifest: JsonValue = JsonMissing.of()
128+
private var modelConfig: JsonValue = JsonMissing.of()
129+
private var modelProvider: JsonField<String> = JsonMissing.of()
99130
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
100131

101132
@JvmSynthetic
102133
internal fun from(commitRetrieveResponse: CommitRetrieveResponse) = apply {
103134
commitHash = commitRetrieveResponse.commitHash
104135
examples = commitRetrieveResponse.examples.map { it.toMutableList() }
105136
manifest = commitRetrieveResponse.manifest
137+
modelConfig = commitRetrieveResponse.modelConfig
138+
modelProvider = commitRetrieveResponse.modelProvider
106139
additionalProperties = commitRetrieveResponse.additionalProperties.toMutableMap()
107140
}
108141

@@ -144,6 +177,21 @@ private constructor(
144177

145178
fun manifest(manifest: JsonValue) = apply { this.manifest = manifest }
146179

180+
fun modelConfig(modelConfig: JsonValue) = apply { this.modelConfig = modelConfig }
181+
182+
fun modelProvider(modelProvider: String) = modelProvider(JsonField.of(modelProvider))
183+
184+
/**
185+
* Sets [Builder.modelProvider] to an arbitrary JSON value.
186+
*
187+
* You should usually call [Builder.modelProvider] with a well-typed [String] value instead.
188+
* This method is primarily for setting the field to an undocumented or not yet supported
189+
* value.
190+
*/
191+
fun modelProvider(modelProvider: JsonField<String>) = apply {
192+
this.modelProvider = modelProvider
193+
}
194+
147195
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
148196
this.additionalProperties.clear()
149197
putAllAdditionalProperties(additionalProperties)
@@ -173,6 +221,8 @@ private constructor(
173221
commitHash,
174222
(examples ?: JsonMissing.of()).map { it.toImmutable() },
175223
manifest,
224+
modelConfig,
225+
modelProvider,
176226
additionalProperties.toMutableMap(),
177227
)
178228
}
@@ -186,6 +236,7 @@ private constructor(
186236

187237
commitHash()
188238
examples().ifPresent { it.forEach { it.validate() } }
239+
modelProvider()
189240
validated = true
190241
}
191242

@@ -205,7 +256,8 @@ private constructor(
205256
@JvmSynthetic
206257
internal fun validity(): Int =
207258
(if (commitHash.asKnown().isPresent) 1 else 0) +
208-
(examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
259+
(examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
260+
(if (modelProvider.asKnown().isPresent) 1 else 0)
209261

210262
class Example
211263
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
@@ -462,15 +514,24 @@ private constructor(
462514
commitHash == other.commitHash &&
463515
examples == other.examples &&
464516
manifest == other.manifest &&
517+
modelConfig == other.modelConfig &&
518+
modelProvider == other.modelProvider &&
465519
additionalProperties == other.additionalProperties
466520
}
467521

468522
private val hashCode: Int by lazy {
469-
Objects.hash(commitHash, examples, manifest, additionalProperties)
523+
Objects.hash(
524+
commitHash,
525+
examples,
526+
manifest,
527+
modelConfig,
528+
modelProvider,
529+
additionalProperties,
530+
)
470531
}
471532

472533
override fun hashCode(): Int = hashCode
473534

474535
override fun toString() =
475-
"CommitRetrieveResponse{commitHash=$commitHash, examples=$examples, manifest=$manifest, additionalProperties=$additionalProperties}"
536+
"CommitRetrieveResponse{commitHash=$commitHash, examples=$examples, manifest=$manifest, modelConfig=$modelConfig, modelProvider=$modelProvider, additionalProperties=$additionalProperties}"
476537
}

langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponseTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ internal class CommitRetrieveResponseTest {
2626
.build()
2727
)
2828
.manifest(JsonValue.from(mapOf<String, Any>()))
29+
.modelConfig(JsonValue.from(mapOf<String, Any>()))
30+
.modelProvider("model_provider")
2931
.build()
3032

3133
assertThat(commitRetrieveResponse.commitHash()).contains("commit_hash")
@@ -41,6 +43,9 @@ internal class CommitRetrieveResponseTest {
4143
)
4244
assertThat(commitRetrieveResponse._manifest())
4345
.isEqualTo(JsonValue.from(mapOf<String, Any>()))
46+
assertThat(commitRetrieveResponse._modelConfig())
47+
.isEqualTo(JsonValue.from(mapOf<String, Any>()))
48+
assertThat(commitRetrieveResponse.modelProvider()).contains("model_provider")
4449
}
4550

4651
@Test
@@ -59,6 +64,8 @@ internal class CommitRetrieveResponseTest {
5964
.build()
6065
)
6166
.manifest(JsonValue.from(mapOf<String, Any>()))
67+
.modelConfig(JsonValue.from(mapOf<String, Any>()))
68+
.modelProvider("model_provider")
6269
.build()
6370

6471
val roundtrippedCommitRetrieveResponse =

0 commit comments

Comments
 (0)