Skip to content

Commit 5561ef0

Browse files
chore(api): minor updates
1 parent b344828 commit 5561ef0

12 files changed

Lines changed: 124 additions & 144 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ import kotlin.jvm.optionals.getOrNull
2525
*/
2626
class CommitCreateParams
2727
private constructor(
28-
private val owner: JsonValue,
29-
private val repo: JsonValue?,
28+
private val owner: String,
29+
private val repo: String?,
3030
private val body: Body,
3131
private val additionalHeaders: Headers,
3232
private val additionalQueryParams: QueryParams,
3333
) : Params {
3434

35-
fun owner(): JsonValue = owner
35+
fun owner(): String = owner
3636

37-
fun repo(): Optional<JsonValue> = Optional.ofNullable(repo)
37+
fun repo(): Optional<String> = Optional.ofNullable(repo)
3838

3939
/**
4040
* This arbitrary value can be deserialized into a custom type using the `convert` method:
@@ -94,8 +94,8 @@ private constructor(
9494
/** A builder for [CommitCreateParams]. */
9595
class Builder internal constructor() {
9696

97-
private var owner: JsonValue? = null
98-
private var repo: JsonValue? = null
97+
private var owner: String? = null
98+
private var repo: String? = null
9999
private var body: Body.Builder = Body.builder()
100100
private var additionalHeaders: Headers.Builder = Headers.builder()
101101
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@@ -109,12 +109,12 @@ private constructor(
109109
additionalQueryParams = commitCreateParams.additionalQueryParams.toBuilder()
110110
}
111111

112-
fun owner(owner: JsonValue) = apply { this.owner = owner }
112+
fun owner(owner: String) = apply { this.owner = owner }
113113

114-
fun repo(repo: JsonValue?) = apply { this.repo = repo }
114+
fun repo(repo: String?) = apply { this.repo = repo }
115115

116116
/** Alias for calling [Builder.repo] with `repo.orElse(null)`. */
117-
fun repo(repo: Optional<JsonValue>) = repo(repo.getOrNull())
117+
fun repo(repo: Optional<String>) = repo(repo.getOrNull())
118118

119119
/**
120120
* Sets the entire request body.
@@ -291,8 +291,8 @@ private constructor(
291291

292292
fun _pathParam(index: Int): String =
293293
when (index) {
294-
0 -> owner.toString()
295-
1 -> repo?.toString() ?: ""
294+
0 -> owner
295+
1 -> repo ?: ""
296296
else -> ""
297297
}
298298

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
package com.langchain.smith.models.commits
44

5-
import com.langchain.smith.core.JsonValue
65
import com.langchain.smith.core.Params
76
import com.langchain.smith.core.checkRequired
87
import com.langchain.smith.core.http.Headers
@@ -19,18 +18,18 @@ import kotlin.jvm.optionals.getOrNull
1918
*/
2019
class CommitListParams
2120
private constructor(
22-
private val owner: JsonValue,
23-
private val repo: JsonValue?,
21+
private val owner: String,
22+
private val repo: String?,
2423
private val includeStats: Boolean?,
2524
private val limit: Long?,
2625
private val offset: Long?,
2726
private val additionalHeaders: Headers,
2827
private val additionalQueryParams: QueryParams,
2928
) : Params {
3029

31-
fun owner(): JsonValue = owner
30+
fun owner(): String = owner
3231

33-
fun repo(): Optional<JsonValue> = Optional.ofNullable(repo)
32+
fun repo(): Optional<String> = Optional.ofNullable(repo)
3433

3534
/** IncludeStats determines whether to compute num_downloads and num_views */
3635
fun includeStats(): Optional<Boolean> = Optional.ofNullable(includeStats)
@@ -65,8 +64,8 @@ private constructor(
6564
/** A builder for [CommitListParams]. */
6665
class Builder internal constructor() {
6766

68-
private var owner: JsonValue? = null
69-
private var repo: JsonValue? = null
67+
private var owner: String? = null
68+
private var repo: String? = null
7069
private var includeStats: Boolean? = null
7170
private var limit: Long? = null
7271
private var offset: Long? = null
@@ -84,12 +83,12 @@ private constructor(
8483
additionalQueryParams = commitListParams.additionalQueryParams.toBuilder()
8584
}
8685

87-
fun owner(owner: JsonValue) = apply { this.owner = owner }
86+
fun owner(owner: String) = apply { this.owner = owner }
8887

89-
fun repo(repo: JsonValue?) = apply { this.repo = repo }
88+
fun repo(repo: String?) = apply { this.repo = repo }
9089

9190
/** Alias for calling [Builder.repo] with `repo.orElse(null)`. */
92-
fun repo(repo: Optional<JsonValue>) = repo(repo.getOrNull())
91+
fun repo(repo: Optional<String>) = repo(repo.getOrNull())
9392

9493
/** IncludeStats determines whether to compute num_downloads and num_views */
9594
fun includeStats(includeStats: Boolean?) = apply { this.includeStats = includeStats }
@@ -254,8 +253,8 @@ private constructor(
254253

255254
fun _pathParam(index: Int): String =
256255
when (index) {
257-
0 -> owner.toString()
258-
1 -> repo?.toString() ?: ""
256+
0 -> owner
257+
1 -> repo ?: ""
259258
else -> ""
260259
}
261260

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
package com.langchain.smith.models.commits
44

5-
import com.langchain.smith.core.JsonValue
65
import com.langchain.smith.core.Params
76
import com.langchain.smith.core.checkRequired
87
import com.langchain.smith.core.http.Headers
@@ -21,21 +20,21 @@ import kotlin.jvm.optionals.getOrNull
2120
*/
2221
class CommitRetrieveParams
2322
private constructor(
24-
private val owner: JsonValue,
25-
private val repo: JsonValue,
26-
private val commit: JsonValue?,
23+
private val owner: String,
24+
private val repo: String,
25+
private val commit: String?,
2726
private val getExamples: Boolean?,
2827
private val includeModel: Boolean?,
2928
private val isView: Boolean?,
3029
private val additionalHeaders: Headers,
3130
private val additionalQueryParams: QueryParams,
3231
) : Params {
3332

34-
fun owner(): JsonValue = owner
33+
fun owner(): String = owner
3534

36-
fun repo(): JsonValue = repo
35+
fun repo(): String = repo
3736

38-
fun commit(): Optional<JsonValue> = Optional.ofNullable(commit)
37+
fun commit(): Optional<String> = Optional.ofNullable(commit)
3938

4039
fun getExamples(): Optional<Boolean> = Optional.ofNullable(getExamples)
4140

@@ -68,9 +67,9 @@ private constructor(
6867
/** A builder for [CommitRetrieveParams]. */
6968
class Builder internal constructor() {
7069

71-
private var owner: JsonValue? = null
72-
private var repo: JsonValue? = null
73-
private var commit: JsonValue? = null
70+
private var owner: String? = null
71+
private var repo: String? = null
72+
private var commit: String? = null
7473
private var getExamples: Boolean? = null
7574
private var includeModel: Boolean? = null
7675
private var isView: Boolean? = null
@@ -89,14 +88,14 @@ private constructor(
8988
additionalQueryParams = commitRetrieveParams.additionalQueryParams.toBuilder()
9089
}
9190

92-
fun owner(owner: JsonValue) = apply { this.owner = owner }
91+
fun owner(owner: String) = apply { this.owner = owner }
9392

94-
fun repo(repo: JsonValue) = apply { this.repo = repo }
93+
fun repo(repo: String) = apply { this.repo = repo }
9594

96-
fun commit(commit: JsonValue?) = apply { this.commit = commit }
95+
fun commit(commit: String?) = apply { this.commit = commit }
9796

9897
/** Alias for calling [Builder.commit] with `commit.orElse(null)`. */
99-
fun commit(commit: Optional<JsonValue>) = commit(commit.getOrNull())
98+
fun commit(commit: Optional<String>) = commit(commit.getOrNull())
10099

101100
fun getExamples(getExamples: Boolean?) = apply { this.getExamples = getExamples }
102101

@@ -260,9 +259,9 @@ private constructor(
260259

261260
fun _pathParam(index: Int): String =
262261
when (index) {
263-
0 -> owner.toString()
264-
1 -> repo.toString()
265-
2 -> commit?.toString() ?: ""
262+
0 -> owner
263+
1 -> repo
264+
2 -> commit ?: ""
266265
else -> ""
267266
}
268267

langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/CommitServiceAsync.kt

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package com.langchain.smith.services.async
44

55
import com.langchain.smith.core.ClientOptions
6-
import com.langchain.smith.core.JsonValue
76
import com.langchain.smith.core.RequestOptions
87
import com.langchain.smith.core.http.HttpResponseFor
98
import com.langchain.smith.models.commits.CommitCreateParams
@@ -33,14 +32,12 @@ interface CommitServiceAsync {
3332
* Creates a new commit in a repository. Requires authentication and write access to the
3433
* repository.
3534
*/
36-
fun create(
37-
repo: JsonValue,
38-
params: CommitCreateParams,
39-
): CompletableFuture<CommitCreateResponse> = create(repo, params, RequestOptions.none())
35+
fun create(repo: String, params: CommitCreateParams): CompletableFuture<CommitCreateResponse> =
36+
create(repo, params, RequestOptions.none())
4037

4138
/** @see create */
4239
fun create(
43-
repo: JsonValue,
40+
repo: String,
4441
params: CommitCreateParams,
4542
requestOptions: RequestOptions = RequestOptions.none(),
4643
): CompletableFuture<CommitCreateResponse> =
@@ -66,13 +63,13 @@ interface CommitServiceAsync {
6663
* - 8 or more characters: Prioritize commit hash over tag, check both
6764
*/
6865
fun retrieve(
69-
commit: JsonValue,
66+
commit: String,
7067
params: CommitRetrieveParams,
7168
): CompletableFuture<CommitRetrieveResponse> = retrieve(commit, params, RequestOptions.none())
7269

7370
/** @see retrieve */
7471
fun retrieve(
75-
commit: JsonValue,
72+
commit: String,
7673
params: CommitRetrieveParams,
7774
requestOptions: RequestOptions = RequestOptions.none(),
7875
): CompletableFuture<CommitRetrieveResponse> =
@@ -94,12 +91,12 @@ interface CommitServiceAsync {
9491
* unauthenticated users can only access public repos. The include_stats parameter controls
9592
* whether download and view statistics are computed (defaults to true).
9693
*/
97-
fun list(repo: JsonValue, params: CommitListParams): CompletableFuture<CommitListPageAsync> =
94+
fun list(repo: String, params: CommitListParams): CompletableFuture<CommitListPageAsync> =
9895
list(repo, params, RequestOptions.none())
9996

10097
/** @see list */
10198
fun list(
102-
repo: JsonValue,
99+
repo: String,
103100
params: CommitListParams,
104101
requestOptions: RequestOptions = RequestOptions.none(),
105102
): CompletableFuture<CommitListPageAsync> =
@@ -134,14 +131,14 @@ interface CommitServiceAsync {
134131
* as [CommitServiceAsync.create].
135132
*/
136133
fun create(
137-
repo: JsonValue,
134+
repo: String,
138135
params: CommitCreateParams,
139136
): CompletableFuture<HttpResponseFor<CommitCreateResponse>> =
140137
create(repo, params, RequestOptions.none())
141138

142139
/** @see create */
143140
fun create(
144-
repo: JsonValue,
141+
repo: String,
145142
params: CommitCreateParams,
146143
requestOptions: RequestOptions = RequestOptions.none(),
147144
): CompletableFuture<HttpResponseFor<CommitCreateResponse>> =
@@ -164,14 +161,14 @@ interface CommitServiceAsync {
164161
* the same as [CommitServiceAsync.retrieve].
165162
*/
166163
fun retrieve(
167-
commit: JsonValue,
164+
commit: String,
168165
params: CommitRetrieveParams,
169166
): CompletableFuture<HttpResponseFor<CommitRetrieveResponse>> =
170167
retrieve(commit, params, RequestOptions.none())
171168

172169
/** @see retrieve */
173170
fun retrieve(
174-
commit: JsonValue,
171+
commit: String,
175172
params: CommitRetrieveParams,
176173
requestOptions: RequestOptions = RequestOptions.none(),
177174
): CompletableFuture<HttpResponseFor<CommitRetrieveResponse>> =
@@ -194,14 +191,14 @@ interface CommitServiceAsync {
194191
* as [CommitServiceAsync.list].
195192
*/
196193
fun list(
197-
repo: JsonValue,
194+
repo: String,
198195
params: CommitListParams,
199196
): CompletableFuture<HttpResponseFor<CommitListPageAsync>> =
200197
list(repo, params, RequestOptions.none())
201198

202199
/** @see list */
203200
fun list(
204-
repo: JsonValue,
201+
repo: String,
205202
params: CommitListParams,
206203
requestOptions: RequestOptions = RequestOptions.none(),
207204
): CompletableFuture<HttpResponseFor<CommitListPageAsync>> =

langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/CommitServiceAsyncImpl.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package com.langchain.smith.services.async
44

55
import com.langchain.smith.core.ClientOptions
66
import com.langchain.smith.core.RequestOptions
7+
import com.langchain.smith.core.checkRequired
78
import com.langchain.smith.core.handlers.errorBodyHandler
89
import com.langchain.smith.core.handlers.errorHandler
910
import com.langchain.smith.core.handlers.jsonHandler
@@ -24,6 +25,7 @@ import com.langchain.smith.models.commits.CommitRetrieveParams
2425
import com.langchain.smith.models.commits.CommitRetrieveResponse
2526
import java.util.concurrent.CompletableFuture
2627
import java.util.function.Consumer
28+
import kotlin.jvm.optionals.getOrNull
2729

2830
class CommitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) :
2931
CommitServiceAsync {
@@ -78,6 +80,9 @@ class CommitServiceAsyncImpl internal constructor(private val clientOptions: Cli
7880
params: CommitCreateParams,
7981
requestOptions: RequestOptions,
8082
): CompletableFuture<HttpResponseFor<CommitCreateResponse>> {
83+
// We check here instead of in the params builder because this can be specified
84+
// positionally or in the params class.
85+
checkRequired("repo", params.repo().getOrNull())
8186
val request =
8287
HttpRequest.builder()
8388
.method(HttpMethod.POST)
@@ -109,6 +114,9 @@ class CommitServiceAsyncImpl internal constructor(private val clientOptions: Cli
109114
params: CommitRetrieveParams,
110115
requestOptions: RequestOptions,
111116
): CompletableFuture<HttpResponseFor<CommitRetrieveResponse>> {
117+
// We check here instead of in the params builder because this can be specified
118+
// positionally or in the params class.
119+
checkRequired("commit", params.commit().getOrNull())
112120
val request =
113121
HttpRequest.builder()
114122
.method(HttpMethod.GET)
@@ -144,6 +152,9 @@ class CommitServiceAsyncImpl internal constructor(private val clientOptions: Cli
144152
params: CommitListParams,
145153
requestOptions: RequestOptions,
146154
): CompletableFuture<HttpResponseFor<CommitListPageAsync>> {
155+
// We check here instead of in the params builder because this can be specified
156+
// positionally or in the params class.
157+
checkRequired("repo", params.repo().getOrNull())
147158
val request =
148159
HttpRequest.builder()
149160
.method(HttpMethod.GET)

0 commit comments

Comments
 (0)