Skip to content

Commit 0758583

Browse files
feat(api): api update
1 parent 1310303 commit 0758583

3 files changed

Lines changed: 170 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: 123
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-fc708889f2ce8249b99dfb6fa91228ac901a33c6417dbc750baacdc04e8818e9.yml
3-
openapi_spec_hash: a3cc8b3280d8a6eb453b699af0c62d58
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-dd6a4e95f079864b89a9e96814f2f0644eec6a3f3717308d4f57c441c39bebb2.yml
3+
openapi_spec_hash: a1bc5d5e3cf4a613299acc63d6b6c5f5
44
config_hash: 0147e25a53ffe0e5055ad212e0c985ba

langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoListParams.kt

Lines changed: 165 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ private constructor(
2424
private val offset: Long?,
2525
private val query: String?,
2626
private val repoType: RepoType?,
27+
private val repoTypes: List<RepoType>?,
2728
private val sortDirection: SortDirection?,
2829
private val sortField: SortField?,
2930
private val tagValueId: List<String>?,
@@ -51,6 +52,8 @@ private constructor(
5152

5253
fun repoType(): Optional<RepoType> = Optional.ofNullable(repoType)
5354

55+
fun repoTypes(): Optional<List<RepoType>> = Optional.ofNullable(repoTypes)
56+
5457
fun sortDirection(): Optional<SortDirection> = Optional.ofNullable(sortDirection)
5558

5659
fun sortField(): Optional<SortField> = Optional.ofNullable(sortField)
@@ -95,6 +98,7 @@ private constructor(
9598
private var offset: Long? = null
9699
private var query: String? = null
97100
private var repoType: RepoType? = null
101+
private var repoTypes: MutableList<RepoType>? = null
98102
private var sortDirection: SortDirection? = null
99103
private var sortField: SortField? = null
100104
private var tagValueId: MutableList<String>? = null
@@ -116,6 +120,7 @@ private constructor(
116120
offset = repoListParams.offset
117121
query = repoListParams.query
118122
repoType = repoListParams.repoType
123+
repoTypes = repoListParams.repoTypes?.toMutableList()
119124
sortDirection = repoListParams.sortDirection
120125
sortField = repoListParams.sortField
121126
tagValueId = repoListParams.tagValueId?.toMutableList()
@@ -185,6 +190,22 @@ private constructor(
185190
/** Alias for calling [Builder.repoType] with `repoType.orElse(null)`. */
186191
fun repoType(repoType: Optional<RepoType>) = repoType(repoType.getOrNull())
187192

193+
fun repoTypes(repoTypes: List<RepoType>?) = apply {
194+
this.repoTypes = repoTypes?.toMutableList()
195+
}
196+
197+
/** Alias for calling [Builder.repoTypes] with `repoTypes.orElse(null)`. */
198+
fun repoTypes(repoTypes: Optional<List<RepoType>>) = repoTypes(repoTypes.getOrNull())
199+
200+
/**
201+
* Adds a single [RepoType] to [repoTypes].
202+
*
203+
* @throws IllegalStateException if the field was previously set to a non-list.
204+
*/
205+
fun addRepoType(repoType: RepoType) = apply {
206+
repoTypes = (repoTypes ?: mutableListOf()).apply { add(repoType) }
207+
}
208+
188209
fun sortDirection(sortDirection: SortDirection?) = apply {
189210
this.sortDirection = sortDirection
190211
}
@@ -384,6 +405,7 @@ private constructor(
384405
offset,
385406
query,
386407
repoType,
408+
repoTypes?.toImmutable(),
387409
sortDirection,
388410
sortField,
389411
tagValueId?.toImmutable(),
@@ -410,6 +432,7 @@ private constructor(
410432
offset?.let { put("offset", it.toString()) }
411433
query?.let { put("query", it) }
412434
repoType?.let { put("repo_type", it.toString()) }
435+
repoTypes?.let { put("repo_types", it.joinToString(",") { it.toString() }) }
413436
sortDirection?.let { put("sort_direction", it.toString()) }
414437
sortField?.let { put("sort_field", it.toString()) }
415438
tagValueId?.let { put("tag_value_id", it.joinToString(",")) }
@@ -824,6 +847,145 @@ private constructor(
824847
override fun toString() = value.toString()
825848
}
826849

850+
class RepoType @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
851+
852+
/**
853+
* Returns this class instance's raw value.
854+
*
855+
* This is usually only useful if this instance was deserialized from data that doesn't
856+
* match any known member, and you want to know that value. For example, if the SDK is on an
857+
* older version than the API, then the API may respond with new members that the SDK is
858+
* unaware of.
859+
*/
860+
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
861+
862+
companion object {
863+
864+
@JvmField val PROMPT = of("prompt")
865+
866+
@JvmField val FILE = of("file")
867+
868+
@JvmField val AGENT = of("agent")
869+
870+
@JvmField val SKILL = of("skill")
871+
872+
@JvmStatic fun of(value: String) = RepoType(JsonField.of(value))
873+
}
874+
875+
/** An enum containing [RepoType]'s known values. */
876+
enum class Known {
877+
PROMPT,
878+
FILE,
879+
AGENT,
880+
SKILL,
881+
}
882+
883+
/**
884+
* An enum containing [RepoType]'s known values, as well as an [_UNKNOWN] member.
885+
*
886+
* An instance of [RepoType] can contain an unknown value in a couple of cases:
887+
* - It was deserialized from data that doesn't match any known member. For example, if the
888+
* SDK is on an older version than the API, then the API may respond with new members that
889+
* the SDK is unaware of.
890+
* - It was constructed with an arbitrary value using the [of] method.
891+
*/
892+
enum class Value {
893+
PROMPT,
894+
FILE,
895+
AGENT,
896+
SKILL,
897+
/** An enum member indicating that [RepoType] was instantiated with an unknown value. */
898+
_UNKNOWN,
899+
}
900+
901+
/**
902+
* Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
903+
* if the class was instantiated with an unknown value.
904+
*
905+
* Use the [known] method instead if you're certain the value is always known or if you want
906+
* to throw for the unknown case.
907+
*/
908+
fun value(): Value =
909+
when (this) {
910+
PROMPT -> Value.PROMPT
911+
FILE -> Value.FILE
912+
AGENT -> Value.AGENT
913+
SKILL -> Value.SKILL
914+
else -> Value._UNKNOWN
915+
}
916+
917+
/**
918+
* Returns an enum member corresponding to this class instance's value.
919+
*
920+
* Use the [value] method instead if you're uncertain the value is always known and don't
921+
* want to throw for the unknown case.
922+
*
923+
* @throws LangChainInvalidDataException if this class instance's value is a not a known
924+
* member.
925+
*/
926+
fun known(): Known =
927+
when (this) {
928+
PROMPT -> Known.PROMPT
929+
FILE -> Known.FILE
930+
AGENT -> Known.AGENT
931+
SKILL -> Known.SKILL
932+
else -> throw LangChainInvalidDataException("Unknown RepoType: $value")
933+
}
934+
935+
/**
936+
* Returns this class instance's primitive wire representation.
937+
*
938+
* This differs from the [toString] method because that method is primarily for debugging
939+
* and generally doesn't throw.
940+
*
941+
* @throws LangChainInvalidDataException if this class instance's value does not have the
942+
* expected primitive type.
943+
*/
944+
fun asString(): String =
945+
_value().asString().orElseThrow {
946+
LangChainInvalidDataException("Value is not a String")
947+
}
948+
949+
private var validated: Boolean = false
950+
951+
fun validate(): RepoType = apply {
952+
if (validated) {
953+
return@apply
954+
}
955+
956+
known()
957+
validated = true
958+
}
959+
960+
fun isValid(): Boolean =
961+
try {
962+
validate()
963+
true
964+
} catch (e: LangChainInvalidDataException) {
965+
false
966+
}
967+
968+
/**
969+
* Returns a score indicating how many valid values are contained in this object
970+
* recursively.
971+
*
972+
* Used for best match union deserialization.
973+
*/
974+
@JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
975+
976+
override fun equals(other: Any?): Boolean {
977+
if (this === other) {
978+
return true
979+
}
980+
981+
return other is RepoType && value == other.value
982+
}
983+
984+
override fun hashCode() = value.hashCode()
985+
986+
override fun toString() = value.toString()
987+
}
988+
827989
class SortDirection @JsonCreator private constructor(private val value: JsonField<String>) :
828990
Enum {
829991

@@ -1115,6 +1277,7 @@ private constructor(
11151277
offset == other.offset &&
11161278
query == other.query &&
11171279
repoType == other.repoType &&
1280+
repoTypes == other.repoTypes &&
11181281
sortDirection == other.sortDirection &&
11191282
sortField == other.sortField &&
11201283
tagValueId == other.tagValueId &&
@@ -1137,6 +1300,7 @@ private constructor(
11371300
offset,
11381301
query,
11391302
repoType,
1303+
repoTypes,
11401304
sortDirection,
11411305
sortField,
11421306
tagValueId,
@@ -1151,5 +1315,5 @@ private constructor(
11511315
)
11521316

11531317
override fun toString() =
1154-
"RepoListParams{hasCommits=$hasCommits, isArchived=$isArchived, isPublic=$isPublic, limit=$limit, offset=$offset, query=$query, repoType=$repoType, sortDirection=$sortDirection, sortField=$sortField, tagValueId=$tagValueId, tags=$tags, tenantHandle=$tenantHandle, tenantId=$tenantId, upstreamRepoHandle=$upstreamRepoHandle, upstreamRepoOwner=$upstreamRepoOwner, withLatestManifest=$withLatestManifest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
1318+
"RepoListParams{hasCommits=$hasCommits, isArchived=$isArchived, isPublic=$isPublic, limit=$limit, offset=$offset, query=$query, repoType=$repoType, repoTypes=$repoTypes, sortDirection=$sortDirection, sortField=$sortField, tagValueId=$tagValueId, tags=$tags, tenantHandle=$tenantHandle, tenantId=$tenantId, upstreamRepoHandle=$upstreamRepoHandle, upstreamRepoOwner=$upstreamRepoOwner, withLatestManifest=$withLatestManifest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
11551319
}

langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListParamsTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal class RepoListParamsTest {
1818
.offset(0L)
1919
.query("query")
2020
.repoType(RepoListParams.RepoType.PROMPT)
21+
.addRepoType(RepoListParams.RepoType.PROMPT)
2122
.sortDirection(RepoListParams.SortDirection.ASC)
2223
.sortField(RepoListParams.SortField.NUM_LIKES)
2324
.addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
@@ -41,6 +42,7 @@ internal class RepoListParamsTest {
4142
.offset(0L)
4243
.query("query")
4344
.repoType(RepoListParams.RepoType.PROMPT)
45+
.addRepoType(RepoListParams.RepoType.PROMPT)
4446
.sortDirection(RepoListParams.SortDirection.ASC)
4547
.sortField(RepoListParams.SortField.NUM_LIKES)
4648
.addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
@@ -64,6 +66,7 @@ internal class RepoListParamsTest {
6466
.put("offset", "0")
6567
.put("query", "query")
6668
.put("repo_type", "prompt")
69+
.put("repo_types", listOf("prompt").joinToString(","))
6770
.put("sort_direction", "asc")
6871
.put("sort_field", "num_likes")
6972
.put(

0 commit comments

Comments
 (0)