diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b386befd..fac14074 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.19" + ".": "0.1.0-alpha.20" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index a98ceb5a..3adea82b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 100 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-624b469e0a8ed90f1574e609929702b6da43306d0681975f690ebda2d40a1c74.yml -openapi_spec_hash: 389b1d06dd9a4b9e83d410d8d8ece950 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-2bca48917a9e2f6cd8442710cc9170d50db781cc03534a7ea3ddcc13838f05c6.yml +openapi_spec_hash: 0f0142e66b6f782304e0f285b38d73dd config_hash: 4c81a93850b2f9805605749a196ed2df diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b8ba55..97c3d52c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 0.1.0-alpha.20 (2026-01-12) + +Full Changelog: [v0.1.0-alpha.19...v0.1.0-alpha.20](https://github.com/langchain-ai/langsmith-java/compare/v0.1.0-alpha.19...v0.1.0-alpha.20) + +### Features + +* **api:** api update ([4b197f0](https://github.com/langchain-ai/langsmith-java/commit/4b197f03e8a2d7658d2e268d854114398429f7a9)) +* **api:** api update ([5703f0f](https://github.com/langchain-ai/langsmith-java/commit/5703f0f838d16543a4c518dc108065d4e72e58b6)) +* **api:** api update ([e2e98b7](https://github.com/langchain-ai/langsmith-java/commit/e2e98b7e9ab23ea0298e79cfc38a49797db0e978)) +* **api:** api update ([96a6948](https://github.com/langchain-ai/langsmith-java/commit/96a69483bf3e39b21a65dfb1af1eea6914939dfa)) +* **api:** api update ([8895f35](https://github.com/langchain-ai/langsmith-java/commit/8895f3571aafdffce373dac1052a4f26fd38347d)) +* **api:** api update ([9c66288](https://github.com/langchain-ai/langsmith-java/commit/9c66288568aceb6d7b77b8742dc34e132c122b66)) +* **api:** api update ([f73c866](https://github.com/langchain-ai/langsmith-java/commit/f73c86620f221064be73d86d9ce540f4e8aeb5c6)) +* **client:** add `HttpRequest#url()` method ([7c51e6a](https://github.com/langchain-ai/langsmith-java/commit/7c51e6a7139f20c181bc4349c247da8aaa151a89)) +* **client:** allow configuring dispatcher executor service ([4a50a22](https://github.com/langchain-ai/langsmith-java/commit/4a50a22f62527d90e5584b9c805b34cfa8c0a7c8)) + ## 0.1.0-alpha.19 (2025-12-10) Full Changelog: [v0.1.0-alpha.18...v0.1.0-alpha.19](https://github.com/langchain-ai/langsmith-java/compare/v0.1.0-alpha.18...v0.1.0-alpha.19) diff --git a/LICENSE b/LICENSE index 15e2b5b7..09a1b8b1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2025 langChain +Copyright 2026 langChain Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 4e074db4..faa955c0 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.langchain.smith/langsmith-java)](https://central.sonatype.com/artifact/com.langchain.smith/langsmith-java/0.1.0-alpha.19) -[![javadoc](https://javadoc.io/badge2/com.langchain.smith/langsmith-java/0.1.0-alpha.19/javadoc.svg)](https://javadoc.io/doc/com.langchain.smith/langsmith-java/0.1.0-alpha.19) +[![Maven Central](https://img.shields.io/maven-central/v/com.langchain.smith/langsmith-java)](https://central.sonatype.com/artifact/com.langchain.smith/langsmith-java/0.1.0-alpha.20) +[![javadoc](https://javadoc.io/badge2/com.langchain.smith/langsmith-java/0.1.0-alpha.20/javadoc.svg)](https://javadoc.io/doc/com.langchain.smith/langsmith-java/0.1.0-alpha.20) @@ -13,7 +13,7 @@ To learn more about LangSmith, check out the [docs](https://docs.smith.langchain -The REST API documentation can be found on [docs.smith.langchain.com](https://docs.smith.langchain.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.langchain.smith/langsmith-java/0.1.0-alpha.19). +The REST API documentation can be found on [docs.smith.langchain.com](https://docs.smith.langchain.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.langchain.smith/langsmith-java/0.1.0-alpha.20). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.smith.langchain.com](https://do ### Gradle ```kotlin -implementation("com.langchain.smith:langsmith-java:0.1.0-alpha.19") +implementation("com.langchain.smith:langsmith-java:0.1.0-alpha.20") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.langchain.smith:langsmith-java:0.1.0-alpha.19") com.langchain.smith langsmith-java - 0.1.0-alpha.19 + 0.1.0-alpha.20 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 5e0d4d1c..c738d69d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.langchain.smith" - version = "0.1.0-alpha.19" // x-release-please-version + version = "0.1.0-alpha.20" // x-release-please-version } subprojects { diff --git a/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClient.kt b/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClient.kt index e6dca6d4..702c30fb 100644 --- a/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClient.kt +++ b/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClient.kt @@ -18,6 +18,7 @@ import java.time.Clock import java.time.Duration import java.util.Optional import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -46,11 +47,31 @@ class LangsmithOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -334,6 +355,7 @@ class LangsmithOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClientAsync.kt b/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClientAsync.kt index 41aa9aec..1b5b52de 100644 --- a/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClientAsync.kt +++ b/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/LangsmithOkHttpClientAsync.kt @@ -18,6 +18,7 @@ import java.time.Clock import java.time.Duration import java.util.Optional import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -46,11 +47,31 @@ class LangsmithOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -334,6 +355,7 @@ class LangsmithOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/OkHttpClient.kt b/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/OkHttpClient.kt index 68da8bb0..eddbba64 100644 --- a/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/OkHttpClient.kt +++ b/langsmith-java-client-okhttp/src/main/kotlin/com/langchain/smith/client/okhttp/OkHttpClient.kt @@ -15,11 +15,13 @@ import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -93,9 +95,9 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien clientBuilder.addNetworkInterceptor( HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("X-API-Key") - redactHeader("X-Tenant-Id") - redactHeader("Authorization") redactHeader("X-Organization-Id") + redactHeader("Authorization") + redactHeader("X-Tenant-Id") } ) } @@ -203,6 +205,7 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -213,6 +216,10 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { this.sslSocketFactory = sslSocketFactory } @@ -234,6 +241,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien .callTimeout(timeout.request()) .proxy(proxy) .apply { + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/ClientOptions.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/ClientOptions.kt index c338351e..9b46c817 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/ClientOptions.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/ClientOptions.kt @@ -507,9 +507,9 @@ private constructor( headers.put("X-API-Key", it) } } - tenantId?.let { + organizationId?.let { if (!it.isEmpty()) { - headers.put("X-Tenant-Id", it) + headers.put("X-Organization-Id", it) } } bearerToken?.let { @@ -517,9 +517,9 @@ private constructor( headers.put("Authorization", "Bearer $it") } } - organizationId?.let { + tenantId?.let { if (!it.isEmpty()) { - headers.put("X-Organization-Id", it) + headers.put("X-Tenant-Id", it) } } headers.replaceAll(this.headers.build()) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequest.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequest.kt index 52997693..4a89d2e3 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequest.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequest.kt @@ -2,6 +2,7 @@ package com.langchain.smith.core.http import com.langchain.smith.core.checkRequired import com.langchain.smith.core.toImmutable +import java.net.URLEncoder class HttpRequest private constructor( @@ -13,6 +14,35 @@ private constructor( @get:JvmName("body") val body: HttpRequestBody?, ) { + fun url(): String = buildString { + append(baseUrl) + + pathSegments.forEach { segment -> + if (!endsWith("/")) { + append("/") + } + append(URLEncoder.encode(segment, "UTF-8")) + } + + if (queryParams.isEmpty()) { + return@buildString + } + + append("?") + var isFirst = true + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { value -> + if (!isFirst) { + append("&") + } + append(URLEncoder.encode(key, "UTF-8")) + append("=") + append(URLEncoder.encode(value, "UTF-8")) + isFirst = false + } + } + } + fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParams.kt index 4937122f..4d1c6fe7 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParams.kt @@ -2,11 +2,34 @@ package com.langchain.smith.models.annotationqueues.runs +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.BaseDeserializer +import com.langchain.smith.core.BaseSerializer +import com.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue import com.langchain.smith.core.Params +import com.langchain.smith.core.allMaxBy import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.getOrThrow import com.langchain.smith.core.http.Headers import com.langchain.smith.core.http.QueryParams import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -15,14 +38,14 @@ import kotlin.jvm.optionals.getOrNull class RunCreateParams private constructor( private val queueId: String?, - private val body: List, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun queueId(): Optional = Optional.ofNullable(queueId) - fun body(): List = body + fun body(): Body = body /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -49,14 +72,14 @@ private constructor( class Builder internal constructor() { private var queueId: String? = null - private var body: MutableList? = null + private var body: Body? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(runCreateParams: RunCreateParams) = apply { queueId = runCreateParams.queueId - body = runCreateParams.body.toMutableList() + body = runCreateParams.body additionalHeaders = runCreateParams.additionalHeaders.toBuilder() additionalQueryParams = runCreateParams.additionalQueryParams.toBuilder() } @@ -66,16 +89,18 @@ private constructor( /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) - fun body(body: List) = apply { this.body = body.toMutableList() } + fun body(body: Body) = apply { this.body = body } + + /** Alias for calling [body] with `Body.ofStrings(strings)`. */ + fun bodyOfStrings(strings: List) = body(Body.ofStrings(strings)) /** - * Adds a single [String] to [Builder.body]. - * - * @throws IllegalStateException if the field was previously set to a non-list. + * Alias for calling [body] with + * `Body.ofAnnotationQueueRunAddSchemas(annotationQueueRunAddSchemas)`. */ - fun addBody(body: String) = apply { - this.body = (this.body ?: mutableListOf()).apply { add(body) } - } + fun bodyOfAnnotationQueueRunAddSchemas( + annotationQueueRunAddSchemas: List + ) = body(Body.ofAnnotationQueueRunAddSchemas(annotationQueueRunAddSchemas)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -190,13 +215,13 @@ private constructor( fun build(): RunCreateParams = RunCreateParams( queueId, - checkRequired("body", body).toImmutable(), + checkRequired("body", body), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): List = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { @@ -208,6 +233,706 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + private constructor( + private val strings: List? = null, + private val annotationQueueRunAddSchemas: List? = null, + private val _json: JsonValue? = null, + ) { + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun annotationQueueRunAddSchemas(): Optional> = + Optional.ofNullable(annotationQueueRunAddSchemas) + + fun isStrings(): Boolean = strings != null + + fun isAnnotationQueueRunAddSchemas(): Boolean = annotationQueueRunAddSchemas != null + + fun asStrings(): List = strings.getOrThrow("strings") + + fun asAnnotationQueueRunAddSchemas(): List = + annotationQueueRunAddSchemas.getOrThrow("annotationQueueRunAddSchemas") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + strings != null -> visitor.visitStrings(strings) + annotationQueueRunAddSchemas != null -> + visitor.visitAnnotationQueueRunAddSchemas(annotationQueueRunAddSchemas) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitStrings(strings: List) {} + + override fun visitAnnotationQueueRunAddSchemas( + annotationQueueRunAddSchemas: List + ) { + annotationQueueRunAddSchemas.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitStrings(strings: List) = strings.size + + override fun visitAnnotationQueueRunAddSchemas( + annotationQueueRunAddSchemas: List + ) = annotationQueueRunAddSchemas.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + strings == other.strings && + annotationQueueRunAddSchemas == other.annotationQueueRunAddSchemas + } + + override fun hashCode(): Int = Objects.hash(strings, annotationQueueRunAddSchemas) + + override fun toString(): String = + when { + strings != null -> "Body{strings=$strings}" + annotationQueueRunAddSchemas != null -> + "Body{annotationQueueRunAddSchemas=$annotationQueueRunAddSchemas}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } + + companion object { + + @JvmStatic fun ofStrings(strings: List) = Body(strings = strings.toImmutable()) + + @JvmStatic + fun ofAnnotationQueueRunAddSchemas( + annotationQueueRunAddSchemas: List + ) = Body(annotationQueueRunAddSchemas = annotationQueueRunAddSchemas.toImmutable()) + } + + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor { + + fun visitStrings(strings: List): T + + fun visitAnnotationQueueRunAddSchemas( + annotationQueueRunAddSchemas: List + ): T + + /** + * Maps an unknown variant of [Body] to a value of type [T]. + * + * An instance of [Body] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangChainInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangChainInvalidDataException("Unknown Body: $json") + } + } + + internal class Deserializer : BaseDeserializer(Body::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Body { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef>())?.let { + Body(strings = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { Body(annotationQueueRunAddSchemas = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Body(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Body::class) { + + override fun serialize( + value: Body, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.strings != null -> generator.writeObject(value.strings) + value.annotationQueueRunAddSchemas != null -> + generator.writeObject(value.annotationQueueRunAddSchemas) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } + } + + /** Schema for adding a run to an annotation queue with optional metadata. */ + class AnnotationQueueRunAddSchema + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val runId: JsonField, + private val parentRunId: JsonField, + private val sessionId: JsonField, + private val startTime: JsonField, + private val traceId: JsonField, + private val traceTier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("run_id") @ExcludeMissing runId: JsonField = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("trace_id") + @ExcludeMissing + traceId: JsonField = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField = JsonMissing.of(), + ) : this(runId, parentRunId, sessionId, startTime, traceId, traceTier, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun runId(): String = runId.getRequired("run_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun parentRunId(): Optional = parentRunId.getOptional("parent_run_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionId(): Optional = sessionId.getOptional("session_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceId(): Optional = traceId.getOptional("trace_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceTier(): Optional = traceTier.getOptional("trace_tier") + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField = runId + + /** + * Returns the raw JSON value of [parentRunId]. + * + * Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parent_run_id") + @ExcludeMissing + fun _parentRunId(): JsonField = parentRunId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("session_id") + @ExcludeMissing + fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField = traceId + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_tier") + @ExcludeMissing + fun _traceTier(): JsonField = traceTier + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRunAddSchema]. + * + * The following fields are required: + * ```java + * .runId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRunAddSchema]. */ + class Builder internal constructor() { + + private var runId: JsonField? = null + private var parentRunId: JsonField = JsonMissing.of() + private var sessionId: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var traceId: JsonField = JsonMissing.of() + private var traceTier: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueRunAddSchema: AnnotationQueueRunAddSchema) = + apply { + runId = annotationQueueRunAddSchema.runId + parentRunId = annotationQueueRunAddSchema.parentRunId + sessionId = annotationQueueRunAddSchema.sessionId + startTime = annotationQueueRunAddSchema.startTime + traceId = annotationQueueRunAddSchema.traceId + traceTier = annotationQueueRunAddSchema.traceTier + additionalProperties = + annotationQueueRunAddSchema.additionalProperties.toMutableMap() + } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runId(runId: JsonField) = apply { this.runId = runId } + + fun parentRunId(parentRunId: String?) = + parentRunId(JsonField.ofNullable(parentRunId)) + + /** Alias for calling [Builder.parentRunId] with `parentRunId.orElse(null)`. */ + fun parentRunId(parentRunId: Optional) = + parentRunId(parentRunId.getOrNull()) + + /** + * Sets [Builder.parentRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun parentRunId(parentRunId: JsonField) = apply { + this.parentRunId = parentRunId + } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun startTime(startTime: OffsetDateTime?) = + startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = + startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId)) + + /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ + fun traceId(traceId: Optional) = traceId(traceId.getOrNull()) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceId(traceId: JsonField) = apply { this.traceId = traceId } + + fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier)) + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceTier(traceTier: JsonField) = apply { + this.traceTier = traceTier + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueRunAddSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueueRunAddSchema = + AnnotationQueueRunAddSchema( + checkRequired("runId", runId), + parentRunId, + sessionId, + startTime, + traceId, + traceTier, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueRunAddSchema = apply { + if (validated) { + return@apply + } + + runId() + parentRunId() + sessionId() + startTime() + traceId() + traceTier().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (runId.asKnown().isPresent) 1 else 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + class TraceTier @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LONGLIVED = of("longlived") + + @JvmField val SHORTLIVED = of("shortlived") + + @JvmStatic fun of(value: String) = TraceTier(JsonField.of(value)) + } + + /** An enum containing [TraceTier]'s known values. */ + enum class Known { + LONGLIVED, + SHORTLIVED, + } + + /** + * An enum containing [TraceTier]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TraceTier] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LONGLIVED, + SHORTLIVED, + /** + * An enum member indicating that [TraceTier] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LONGLIVED -> Value.LONGLIVED + SHORTLIVED -> Value.SHORTLIVED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangChainInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LONGLIVED -> Known.LONGLIVED + SHORTLIVED -> Known.SHORTLIVED + else -> throw LangChainInvalidDataException("Unknown TraceTier: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangChainInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TraceTier = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TraceTier && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRunAddSchema && + runId == other.runId && + parentRunId == other.parentRunId && + sessionId == other.sessionId && + startTime == other.startTime && + traceId == other.traceId && + traceTier == other.traceTier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + runId, + parentRunId, + sessionId, + startTime, + traceId, + traceTier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueRunAddSchema{runId=$runId, parentRunId=$parentRunId, sessionId=$sessionId, startTime=$startTime, traceId=$traceId, traceTier=$traceTier, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitListParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitListParams.kt index fcb62b44..359db7a9 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitListParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitListParams.kt @@ -14,12 +14,14 @@ import kotlin.jvm.optionals.getOrNull /** * Lists all commits for a repository with pagination support. This endpoint supports both * authenticated and unauthenticated access. Authenticated users can access private repos, while - * unauthenticated users can only access public repos. + * unauthenticated users can only access public repos. The include_stats parameter controls whether + * download and view statistics are computed (defaults to true). */ class CommitListParams private constructor( private val owner: JsonValue, private val repo: JsonValue?, + private val includeStats: Boolean?, private val limit: Long?, private val offset: Long?, private val additionalHeaders: Headers, @@ -30,6 +32,9 @@ private constructor( fun repo(): Optional = Optional.ofNullable(repo) + /** IncludeStats determines whether to compute num_downloads and num_views */ + fun includeStats(): Optional = Optional.ofNullable(includeStats) + /** Limit is the pagination limit */ fun limit(): Optional = Optional.ofNullable(limit) @@ -62,6 +67,7 @@ private constructor( private var owner: JsonValue? = null private var repo: JsonValue? = null + private var includeStats: Boolean? = null private var limit: Long? = null private var offset: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -71,6 +77,7 @@ private constructor( internal fun from(commitListParams: CommitListParams) = apply { owner = commitListParams.owner repo = commitListParams.repo + includeStats = commitListParams.includeStats limit = commitListParams.limit offset = commitListParams.offset additionalHeaders = commitListParams.additionalHeaders.toBuilder() @@ -84,6 +91,19 @@ private constructor( /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ fun repo(repo: Optional) = repo(repo.getOrNull()) + /** IncludeStats determines whether to compute num_downloads and num_views */ + fun includeStats(includeStats: Boolean?) = apply { this.includeStats = includeStats } + + /** + * Alias for [Builder.includeStats]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeStats(includeStats: Boolean) = includeStats(includeStats as Boolean?) + + /** Alias for calling [Builder.includeStats] with `includeStats.orElse(null)`. */ + fun includeStats(includeStats: Optional) = includeStats(includeStats.getOrNull()) + /** Limit is the pagination limit */ fun limit(limit: Long?) = apply { this.limit = limit } @@ -224,6 +244,7 @@ private constructor( CommitListParams( checkRequired("owner", owner), repo, + includeStats, limit, offset, additionalHeaders.build(), @@ -243,6 +264,7 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { + includeStats?.let { put("include_stats", it.toString()) } limit?.let { put("limit", it.toString()) } offset?.let { put("offset", it.toString()) } putAll(additionalQueryParams) @@ -257,6 +279,7 @@ private constructor( return other is CommitListParams && owner == other.owner && repo == other.repo && + includeStats == other.includeStats && limit == other.limit && offset == other.offset && additionalHeaders == other.additionalHeaders && @@ -264,8 +287,16 @@ private constructor( } override fun hashCode(): Int = - Objects.hash(owner, repo, limit, offset, additionalHeaders, additionalQueryParams) + Objects.hash( + owner, + repo, + includeStats, + limit, + offset, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = - "CommitListParams{owner=$owner, repo=$repo, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CommitListParams{owner=$owner, repo=$repo, includeStats=$includeStats, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneParams.kt index 4d568d4a..55172304 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/DatasetCloneParams.kt @@ -69,6 +69,12 @@ private constructor( */ fun examples(): Optional> = body.examples() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun split(): Optional = body.split() + /** * Returns the raw JSON value of [sourceDatasetId]. * @@ -97,6 +103,13 @@ private constructor( */ fun _examples(): JsonField> = body._examples() + /** + * Returns the raw JSON value of [split]. + * + * Unlike [split], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _split(): JsonField = body._split() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -144,6 +157,8 @@ private constructor( * - [targetDatasetId] * - [asOf] * - [examples] + * - [split] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -218,6 +233,25 @@ private constructor( */ fun addExample(example: String) = apply { body.addExample(example) } + fun split(split: Split?) = apply { body.split(split) } + + /** Alias for calling [Builder.split] with `split.orElse(null)`. */ + fun split(split: Optional) = split(split.getOrNull()) + + /** + * Sets [Builder.split] to an arbitrary JSON value. + * + * You should usually call [Builder.split] with a well-typed [Split] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun split(split: JsonField) = apply { body.split(split) } + + /** Alias for calling [split] with `Split.ofString(string)`. */ + fun split(string: String) = apply { body.split(string) } + + /** Alias for calling [split] with `Split.ofStrings(strings)`. */ + fun splitOfStrings(strings: List) = apply { body.splitOfStrings(strings) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -369,6 +403,7 @@ private constructor( private val targetDatasetId: JsonField, private val asOf: JsonField, private val examples: JsonField>, + private val split: JsonField, private val additionalProperties: MutableMap, ) { @@ -384,7 +419,8 @@ private constructor( @JsonProperty("examples") @ExcludeMissing examples: JsonField> = JsonMissing.of(), - ) : this(sourceDatasetId, targetDatasetId, asOf, examples, mutableMapOf()) + @JsonProperty("split") @ExcludeMissing split: JsonField = JsonMissing.of(), + ) : this(sourceDatasetId, targetDatasetId, asOf, examples, split, mutableMapOf()) /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -413,6 +449,12 @@ private constructor( */ fun examples(): Optional> = examples.getOptional("examples") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun split(): Optional = split.getOptional("split") + /** * Returns the raw JSON value of [sourceDatasetId]. * @@ -449,6 +491,13 @@ private constructor( @ExcludeMissing fun _examples(): JsonField> = examples + /** + * Returns the raw JSON value of [split]. + * + * Unlike [split], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("split") @ExcludeMissing fun _split(): JsonField = split + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -482,6 +531,7 @@ private constructor( private var targetDatasetId: JsonField? = null private var asOf: JsonField = JsonMissing.of() private var examples: JsonField>? = null + private var split: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -490,6 +540,7 @@ private constructor( targetDatasetId = body.targetDatasetId asOf = body.asOf examples = body.examples.map { it.toMutableList() } + split = body.split additionalProperties = body.additionalProperties.toMutableMap() } @@ -570,6 +621,26 @@ private constructor( } } + fun split(split: Split?) = split(JsonField.ofNullable(split)) + + /** Alias for calling [Builder.split] with `split.orElse(null)`. */ + fun split(split: Optional) = split(split.getOrNull()) + + /** + * Sets [Builder.split] to an arbitrary JSON value. + * + * You should usually call [Builder.split] with a well-typed [Split] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun split(split: JsonField) = apply { this.split = split } + + /** Alias for calling [split] with `Split.ofString(string)`. */ + fun split(string: String) = split(Split.ofString(string)) + + /** Alias for calling [split] with `Split.ofStrings(strings)`. */ + fun splitOfStrings(strings: List) = split(Split.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -608,6 +679,7 @@ private constructor( checkRequired("targetDatasetId", targetDatasetId), asOf, (examples ?: JsonMissing.of()).map { it.toImmutable() }, + split, additionalProperties.toMutableMap(), ) } @@ -623,6 +695,7 @@ private constructor( targetDatasetId() asOf().ifPresent { it.validate() } examples() + split().ifPresent { it.validate() } validated = true } @@ -645,7 +718,8 @@ private constructor( (if (sourceDatasetId.asKnown().isPresent) 1 else 0) + (if (targetDatasetId.asKnown().isPresent) 1 else 0) + (asOf.asKnown().getOrNull()?.validity() ?: 0) + - (examples.asKnown().getOrNull()?.size ?: 0) + (examples.asKnown().getOrNull()?.size ?: 0) + + (split.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -657,17 +731,25 @@ private constructor( targetDatasetId == other.targetDatasetId && asOf == other.asOf && examples == other.examples && + split == other.split && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(sourceDatasetId, targetDatasetId, asOf, examples, additionalProperties) + Objects.hash( + sourceDatasetId, + targetDatasetId, + asOf, + examples, + split, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{sourceDatasetId=$sourceDatasetId, targetDatasetId=$targetDatasetId, asOf=$asOf, examples=$examples, additionalProperties=$additionalProperties}" + "Body{sourceDatasetId=$sourceDatasetId, targetDatasetId=$targetDatasetId, asOf=$asOf, examples=$examples, split=$split, additionalProperties=$additionalProperties}" } /** @@ -842,6 +924,173 @@ private constructor( } } + @JsonDeserialize(using = Split.Deserializer::class) + @JsonSerialize(using = Split.Serializer::class) + class Split + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Split = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitStrings(strings: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Split && string == other.string && strings == other.strings + } + + override fun hashCode(): Int = Objects.hash(string, strings) + + override fun toString(): String = + when { + string != null -> "Split{string=$string}" + strings != null -> "Split{strings=$strings}" + _json != null -> "Split{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Split") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Split(string = string) + + @JvmStatic fun ofStrings(strings: List) = Split(strings = strings.toImmutable()) + } + + /** An interface that defines how to map each variant of [Split] to a value of type [T]. */ + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + /** + * Maps an unknown variant of [Split] to a value of type [T]. + * + * An instance of [Split] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangChainInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangChainInvalidDataException("Unknown Split: $json") + } + } + + internal class Deserializer : BaseDeserializer(Split::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Split { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Split(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Split(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Split(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Split::class) { + + override fun serialize( + value: Split, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Split") + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRuns.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRuns.kt index 4e5cf8cf..bf151d24 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRuns.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRuns.kt @@ -29,6 +29,7 @@ private constructor( private val offset: JsonField, private val preview: JsonField, private val sortParams: JsonField, + private val stream: JsonField, private val additionalProperties: MutableMap, ) { @@ -47,6 +48,7 @@ private constructor( @JsonProperty("sort_params") @ExcludeMissing sortParams: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing stream: JsonField = JsonMissing.of(), ) : this( sessionIds, comparativeExperimentId, @@ -55,6 +57,7 @@ private constructor( offset, preview, sortParams, + stream, mutableMapOf(), ) @@ -102,6 +105,12 @@ private constructor( fun sortParams(): Optional = sortParams.getOptional("sort_params") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stream(): Optional = stream.getOptional("stream") + /** * Returns the raw JSON value of [sessionIds]. * @@ -158,6 +167,13 @@ private constructor( @ExcludeMissing fun _sortParams(): JsonField = sortParams + /** + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -193,6 +209,7 @@ private constructor( private var offset: JsonField = JsonMissing.of() private var preview: JsonField = JsonMissing.of() private var sortParams: JsonField = JsonMissing.of() + private var stream: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -204,6 +221,7 @@ private constructor( offset = queryExampleSchemaWithRuns.offset preview = queryExampleSchemaWithRuns.preview sortParams = queryExampleSchemaWithRuns.sortParams + stream = queryExampleSchemaWithRuns.stream additionalProperties = queryExampleSchemaWithRuns.additionalProperties.toMutableMap() } @@ -314,6 +332,16 @@ private constructor( this.sortParams = sortParams } + fun stream(stream: Boolean) = stream(JsonField.of(stream)) + + /** + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun stream(stream: JsonField) = apply { this.stream = stream } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -354,6 +382,7 @@ private constructor( offset, preview, sortParams, + stream, additionalProperties.toMutableMap(), ) } @@ -372,6 +401,7 @@ private constructor( offset() preview() sortParams().ifPresent { it.validate() } + stream() validated = true } @@ -396,7 +426,8 @@ private constructor( (if (limit.asKnown().isPresent) 1 else 0) + (if (offset.asKnown().isPresent) 1 else 0) + (if (preview.asKnown().isPresent) 1 else 0) + - (sortParams.asKnown().getOrNull()?.validity() ?: 0) + (sortParams.asKnown().getOrNull()?.validity() ?: 0) + + (if (stream.asKnown().isPresent) 1 else 0) class Filters @JsonCreator @@ -510,6 +541,7 @@ private constructor( offset == other.offset && preview == other.preview && sortParams == other.sortParams && + stream == other.stream && additionalProperties == other.additionalProperties } @@ -522,6 +554,7 @@ private constructor( offset, preview, sortParams, + stream, additionalProperties, ) } @@ -529,5 +562,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, additionalProperties=$additionalProperties}" + "QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParams.kt index 84097062..0a845b4a 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParams.kt @@ -2,11 +2,23 @@ package com.langchain.smith.models.datasets.runs +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing import com.langchain.smith.core.JsonValue import com.langchain.smith.core.Params +import com.langchain.smith.core.checkKnown import com.langchain.smith.core.checkRequired import com.langchain.smith.core.http.Headers import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -18,8 +30,8 @@ import kotlin.jvm.optionals.getOrNull class RunCreateParams private constructor( private val datasetId: String?, - private val format: String?, - private val queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns, + private val format: Format?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -27,12 +39,114 @@ private constructor( fun datasetId(): Optional = Optional.ofNullable(datasetId) /** Response format, e.g., 'csv' */ - fun format(): Optional = Optional.ofNullable(format) + fun format(): Optional = Optional.ofNullable(format) - fun queryExampleSchemaWithRuns(): QueryExampleSchemaWithRuns = queryExampleSchemaWithRuns + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionIds(): List = body.sessionIds() - fun _additionalBodyProperties(): Map = - queryExampleSchemaWithRuns._additionalProperties() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional = body.comparativeExperimentId() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filters(): Optional = body.filters() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun limit(): Optional = body.limit() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun offset(): Optional = body.offset() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preview(): Optional = body.preview() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sortParams(): Optional = body.sortParams() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun stream(): Optional = body.stream() + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionIds(): JsonField> = body._sessionIds() + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _comparativeExperimentId(): JsonField = body._comparativeExperimentId() + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filters(): JsonField = body._filters() + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limit(): JsonField = body._limit() + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _offset(): JsonField = body._offset() + + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _preview(): JsonField = body._preview() + + /** + * Returns the raw JSON value of [sortParams]. + * + * Unlike [sortParams], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sortParams(): JsonField = body._sortParams() + + /** + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _stream(): JsonField = body._stream() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -49,7 +163,7 @@ private constructor( * * The following fields are required: * ```java - * .queryExampleSchemaWithRuns() + * .sessionIds() * ``` */ @JvmStatic fun builder() = Builder() @@ -59,8 +173,8 @@ private constructor( class Builder internal constructor() { private var datasetId: String? = null - private var format: String? = null - private var queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns? = null + private var format: Format? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -68,7 +182,7 @@ private constructor( internal fun from(runCreateParams: RunCreateParams) = apply { datasetId = runCreateParams.datasetId format = runCreateParams.format - queryExampleSchemaWithRuns = runCreateParams.queryExampleSchemaWithRuns + body = runCreateParams.body.toBuilder() additionalHeaders = runCreateParams.additionalHeaders.toBuilder() additionalQueryParams = runCreateParams.additionalQueryParams.toBuilder() } @@ -79,16 +193,166 @@ private constructor( fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** Response format, e.g., 'csv' */ - fun format(format: String?) = apply { this.format = format } + fun format(format: Format?) = apply { this.format = format } /** Alias for calling [Builder.format] with `format.orElse(null)`. */ - fun format(format: Optional) = format(format.getOrNull()) + fun format(format: Optional) = format(format.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [sessionIds] + * - [comparativeExperimentId] + * - [filters] + * - [limit] + * - [offset] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun sessionIds(sessionIds: List) = apply { body.sessionIds(sessionIds) } + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField>) = apply { body.sessionIds(sessionIds) } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { body.addSessionId(sessionId) } + + fun comparativeExperimentId(comparativeExperimentId: String?) = apply { + body.comparativeExperimentId(comparativeExperimentId) + } + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField) = apply { + body.comparativeExperimentId(comparativeExperimentId) + } + + fun filters(filters: Filters?) = apply { body.filters(filters) } + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed [Filters] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField) = apply { body.filters(filters) } + + fun limit(limit: Long?) = apply { body.limit(limit) } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField) = apply { body.limit(limit) } + + fun offset(offset: Long) = apply { body.offset(offset) } + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun offset(offset: JsonField) = apply { body.offset(offset) } + + fun preview(preview: Boolean) = apply { body.preview(preview) } + + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun preview(preview: JsonField) = apply { body.preview(preview) } + + fun sortParams(sortParams: SortParamsForRunsComparisonView?) = apply { + body.sortParams(sortParams) + } + + /** Alias for calling [Builder.sortParams] with `sortParams.orElse(null)`. */ + fun sortParams(sortParams: Optional) = + sortParams(sortParams.getOrNull()) + + /** + * Sets [Builder.sortParams] to an arbitrary JSON value. + * + * You should usually call [Builder.sortParams] with a well-typed + * [SortParamsForRunsComparisonView] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun sortParams(sortParams: JsonField) = apply { + body.sortParams(sortParams) + } + + fun stream(stream: Boolean) = apply { body.stream(stream) } + + /** + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun stream(stream: JsonField) = apply { body.stream(stream) } - fun queryExampleSchemaWithRuns(queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns) = + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.queryExampleSchemaWithRuns = queryExampleSchemaWithRuns + body.putAllAdditionalProperties(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -194,7 +458,7 @@ private constructor( * * The following fields are required: * ```java - * .queryExampleSchemaWithRuns() + * .sessionIds() * ``` * * @throws IllegalStateException if any required field is unset. @@ -203,13 +467,13 @@ private constructor( RunCreateParams( datasetId, format, - checkRequired("queryExampleSchemaWithRuns", queryExampleSchemaWithRuns), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): QueryExampleSchemaWithRuns = queryExampleSchemaWithRuns + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { @@ -222,11 +486,702 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { - format?.let { put("format", it) } + format?.let { put("format", it.toString()) } putAll(additionalQueryParams) } .build() + /** + * Request DTO for querying examples with runs - used for API input. + * + * This is separate from the internal schema to cleanly handle optional limit values. When limit + * is None, the internal schema will apply appropriate defaults based on format and stream + * settings. + */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sessionIds: JsonField>, + private val comparativeExperimentId: JsonField, + private val filters: JsonField, + private val limit: JsonField, + private val offset: JsonField, + private val preview: JsonField, + private val sortParams: JsonField, + private val stream: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("session_ids") + @ExcludeMissing + sessionIds: JsonField> = JsonMissing.of(), + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + comparativeExperimentId: JsonField = JsonMissing.of(), + @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing preview: JsonField = JsonMissing.of(), + @JsonProperty("sort_params") + @ExcludeMissing + sortParams: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing stream: JsonField = JsonMissing.of(), + ) : this( + sessionIds, + comparativeExperimentId, + filters, + limit, + offset, + preview, + sortParams, + stream, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionIds(): List = sessionIds.getRequired("session_ids") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional = + comparativeExperimentId.getOptional("comparative_experiment_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filters(): Optional = filters.getOptional("filters") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional = limit.getOptional("limit") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offset(): Optional = offset.getOptional("offset") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun preview(): Optional = preview.getOptional("preview") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sortParams(): Optional = + sortParams.getOptional("sort_params") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun stream(): Optional = stream.getOptional("stream") + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_ids") + @ExcludeMissing + fun _sessionIds(): JsonField> = sessionIds + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + fun _comparativeExperimentId(): JsonField = comparativeExperimentId + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset + + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview + + /** + * Returns the raw JSON value of [sortParams]. + * + * Unlike [sortParams], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sort_params") + @ExcludeMissing + fun _sortParams(): JsonField = sortParams + + /** + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .sessionIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var sessionIds: JsonField>? = null + private var comparativeExperimentId: JsonField = JsonMissing.of() + private var filters: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var offset: JsonField = JsonMissing.of() + private var preview: JsonField = JsonMissing.of() + private var sortParams: JsonField = JsonMissing.of() + private var stream: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + sessionIds = body.sessionIds.map { it.toMutableList() } + comparativeExperimentId = body.comparativeExperimentId + filters = body.filters + limit = body.limit + offset = body.offset + preview = body.preview + sortParams = body.sortParams + stream = body.stream + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun sessionIds(sessionIds: List) = sessionIds(JsonField.of(sessionIds)) + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField>) = apply { + this.sessionIds = sessionIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { + sessionIds = + (sessionIds ?: JsonField.of(mutableListOf())).also { + checkKnown("sessionIds", it).add(sessionId) + } + } + + fun comparativeExperimentId(comparativeExperimentId: String?) = + comparativeExperimentId(JsonField.ofNullable(comparativeExperimentId)) + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + fun filters(filters: Filters?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed [Filters] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filters(filters: JsonField) = apply { this.filters = filters } + + fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun offset(offset: JsonField) = apply { this.offset = offset } + + fun preview(preview: Boolean) = preview(JsonField.of(preview)) + + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preview(preview: JsonField) = apply { this.preview = preview } + + fun sortParams(sortParams: SortParamsForRunsComparisonView?) = + sortParams(JsonField.ofNullable(sortParams)) + + /** Alias for calling [Builder.sortParams] with `sortParams.orElse(null)`. */ + fun sortParams(sortParams: Optional) = + sortParams(sortParams.getOrNull()) + + /** + * Sets [Builder.sortParams] to an arbitrary JSON value. + * + * You should usually call [Builder.sortParams] with a well-typed + * [SortParamsForRunsComparisonView] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun sortParams(sortParams: JsonField) = apply { + this.sortParams = sortParams + } + + fun stream(stream: Boolean) = stream(JsonField.of(stream)) + + /** + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stream(stream: JsonField) = apply { this.stream = stream } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("sessionIds", sessionIds).map { it.toImmutable() }, + comparativeExperimentId, + filters, + limit, + offset, + preview, + sortParams, + stream, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + sessionIds() + comparativeExperimentId() + filters().ifPresent { it.validate() } + limit() + offset() + preview() + sortParams().ifPresent { it.validate() } + stream() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (sessionIds.asKnown().getOrNull()?.size ?: 0) + + (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (offset.asKnown().isPresent) 1 else 0) + + (if (preview.asKnown().isPresent) 1 else 0) + + (sortParams.asKnown().getOrNull()?.validity() ?: 0) + + (if (stream.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + sessionIds == other.sessionIds && + comparativeExperimentId == other.comparativeExperimentId && + filters == other.filters && + limit == other.limit && + offset == other.offset && + preview == other.preview && + sortParams == other.sortParams && + stream == other.stream && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + sessionIds, + comparativeExperimentId, + filters, + limit, + offset, + preview, + sortParams, + stream, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}" + } + + class Filters + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Filters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filters]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filters: Filters) = apply { + additionalProperties = filters.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Filters = Filters(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Filters = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filters && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Filters{additionalProperties=$additionalProperties}" + } + + /** Response format, e.g., 'csv' */ + class Format @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CSV = of("csv") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + CSV + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CSV, + /** An enum member indicating that [Format] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CSV -> Value.CSV + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CSV -> Known.CSV + else -> throw LangChainInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -235,20 +1190,14 @@ private constructor( return other is RunCreateParams && datasetId == other.datasetId && format == other.format && - queryExampleSchemaWithRuns == other.queryExampleSchemaWithRuns && + body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash( - datasetId, - format, - queryExampleSchemaWithRuns, - additionalHeaders, - additionalQueryParams, - ) + Objects.hash(datasetId, format, body, additionalHeaders, additionalQueryParams) override fun toString() = - "RunCreateParams{datasetId=$datasetId, format=$format, queryExampleSchemaWithRuns=$queryExampleSchemaWithRuns, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "RunCreateParams{datasetId=$datasetId, format=$format, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParams.kt index 816df0ef..91f928ca 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParams.kt @@ -17,6 +17,7 @@ class ExampleRetrieveParams private constructor( private val exampleId: String?, private val asOf: AsOf?, + private val dataset: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -29,6 +30,8 @@ private constructor( */ fun asOf(): Optional = Optional.ofNullable(asOf) + fun dataset(): Optional = Optional.ofNullable(dataset) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -50,6 +53,7 @@ private constructor( private var exampleId: String? = null private var asOf: AsOf? = null + private var dataset: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -57,6 +61,7 @@ private constructor( internal fun from(exampleRetrieveParams: ExampleRetrieveParams) = apply { exampleId = exampleRetrieveParams.exampleId asOf = exampleRetrieveParams.asOf + dataset = exampleRetrieveParams.dataset additionalHeaders = exampleRetrieveParams.additionalHeaders.toBuilder() additionalQueryParams = exampleRetrieveParams.additionalQueryParams.toBuilder() } @@ -81,6 +86,11 @@ private constructor( /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ fun asOf(string: String) = asOf(AsOf.ofString(string)) + fun dataset(dataset: String?) = apply { this.dataset = dataset } + + /** Alias for calling [Builder.dataset] with `dataset.orElse(null)`. */ + fun dataset(dataset: Optional) = dataset(dataset.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -188,6 +198,7 @@ private constructor( ExampleRetrieveParams( exampleId, asOf, + dataset, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -218,6 +229,7 @@ private constructor( } } ) + dataset?.let { put("dataset", it) } putAll(additionalQueryParams) } .build() @@ -294,13 +306,14 @@ private constructor( return other is ExampleRetrieveParams && exampleId == other.exampleId && asOf == other.asOf && + dataset == other.dataset && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(exampleId, asOf, additionalHeaders, additionalQueryParams) + Objects.hash(exampleId, asOf, dataset, additionalHeaders, additionalQueryParams) override fun toString() = - "ExampleRetrieveParams{exampleId=$exampleId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ExampleRetrieveParams{exampleId=$exampleId, asOf=$asOf, dataset=$dataset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt index 44434060..ca238546 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchema.kt @@ -50,6 +50,7 @@ private constructor( private val runId: JsonField, private val score: JsonField, private val sessionId: JsonField, + private val startTime: JsonField, private val traceId: JsonField, private val value: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("run_id") @ExcludeMissing runId: JsonField = JsonMissing.of(), @JsonProperty("score") @ExcludeMissing score: JsonField = JsonMissing.of(), @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), ) : this( @@ -102,6 +106,7 @@ private constructor( runId, score, sessionId, + startTime, traceId, value, mutableMapOf(), @@ -194,6 +199,12 @@ private constructor( */ fun sessionId(): Optional = sessionId.getOptional("session_id") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -319,6 +330,15 @@ private constructor( */ @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + /** * Returns the raw JSON value of [traceId]. * @@ -375,6 +395,7 @@ private constructor( private var runId: JsonField = JsonMissing.of() private var score: JsonField = JsonMissing.of() private var sessionId: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() private var traceId: JsonField = JsonMissing.of() private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -395,6 +416,7 @@ private constructor( runId = feedbackCreateSchema.runId score = feedbackCreateSchema.score sessionId = feedbackCreateSchema.sessionId + startTime = feedbackCreateSchema.startTime traceId = feedbackCreateSchema.traceId value = feedbackCreateSchema.value additionalProperties = feedbackCreateSchema.additionalProperties.toMutableMap() @@ -634,6 +656,20 @@ private constructor( */ fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { this.startTime = startTime } + fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId)) /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ @@ -719,6 +755,7 @@ private constructor( runId, score, sessionId, + startTime, traceId, value, additionalProperties.toMutableMap(), @@ -746,6 +783,7 @@ private constructor( runId() score().ifPresent { it.validate() } sessionId() + startTime() traceId() value().ifPresent { it.validate() } validated = true @@ -780,6 +818,7 @@ private constructor( (if (runId.asKnown().isPresent) 1 else 0) + (score.asKnown().getOrNull()?.validity() ?: 0) + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + (if (traceId.asKnown().isPresent) 1 else 0) + (value.asKnown().getOrNull()?.validity() ?: 0) @@ -2440,6 +2479,7 @@ private constructor( runId == other.runId && score == other.score && sessionId == other.sessionId && + startTime == other.startTime && traceId == other.traceId && value == other.value && additionalProperties == other.additionalProperties @@ -2461,6 +2501,7 @@ private constructor( runId, score, sessionId, + startTime, traceId, value, additionalProperties, @@ -2470,5 +2511,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "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, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}" + "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}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryParams.kt index 6e87be8f..eaa112c5 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryParams.kt @@ -2667,6 +2667,8 @@ private constructor( @JvmField val MESSAGES = of("messages") + @JvmField val INSERTED_AT = of("inserted_at") + @JvmStatic fun of(value: String) = Select(JsonField.of(value)) } @@ -2731,6 +2733,7 @@ private constructor( THREAD_ID, TRACE_MIN_MAX_START_TIME, MESSAGES, + INSERTED_AT, } /** @@ -2802,6 +2805,7 @@ private constructor( THREAD_ID, TRACE_MIN_MAX_START_TIME, MESSAGES, + INSERTED_AT, /** An enum member indicating that [Select] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2874,6 +2878,7 @@ private constructor( THREAD_ID -> Value.THREAD_ID TRACE_MIN_MAX_START_TIME -> Value.TRACE_MIN_MAX_START_TIME MESSAGES -> Value.MESSAGES + INSERTED_AT -> Value.INSERTED_AT else -> Value._UNKNOWN } @@ -2947,6 +2952,7 @@ private constructor( THREAD_ID -> Known.THREAD_ID TRACE_MIN_MAX_START_TIME -> Known.TRACE_MIN_MAX_START_TIME MESSAGES -> Known.MESSAGES + INSERTED_AT -> Known.INSERTED_AT else -> throw LangChainInvalidDataException("Unknown Select: $value") } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/CommitServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/CommitServiceAsync.kt index c1832fe9..55a02b2f 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/CommitServiceAsync.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/CommitServiceAsync.kt @@ -91,7 +91,8 @@ interface CommitServiceAsync { /** * Lists all commits for a repository with pagination support. This endpoint supports both * authenticated and unauthenticated access. Authenticated users can access private repos, while - * unauthenticated users can only access public repos. + * unauthenticated users can only access public repos. The include_stats parameter controls + * whether download and view statistics are computed (defaults to true). */ fun list(repo: JsonValue, params: CommitListParams): CompletableFuture = list(repo, params, RequestOptions.none()) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/CommitService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/CommitService.kt index cd76e050..6b2e2752 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/CommitService.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/CommitService.kt @@ -85,7 +85,8 @@ interface CommitService { /** * Lists all commits for a repository with pagination support. This endpoint supports both * authenticated and unauthenticated access. Authenticated users can access private repos, while - * unauthenticated users can only access public repos. + * unauthenticated users can only access public repos. The include_stats parameter controls + * whether download and view statistics are computed (defaults to true). */ fun list(repo: JsonValue, params: CommitListParams): CommitListPage = list(repo, params, RequestOptions.none()) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/HttpRequestTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/HttpRequestTest.kt new file mode 100644 index 00000000..d438fd4e --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/HttpRequestTest.kt @@ -0,0 +1,110 @@ +package com.langchain.smith.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HttpRequestTest { + + enum class UrlTestCase(val request: HttpRequest, val expectedUrl: String) { + BASE_URL_ONLY( + HttpRequest.builder().method(HttpMethod.GET).baseUrl("https://api.example.com").build(), + expectedUrl = "https://api.example.com", + ), + BASE_URL_WITH_TRAILING_SLASH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .build(), + expectedUrl = "https://api.example.com/", + ), + SINGLE_PATH_SEGMENT( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + MULTIPLE_PATH_SEGMENTS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegments("users", "123", "profile") + .build(), + expectedUrl = "https://api.example.com/users/123/profile", + ), + PATH_SEGMENT_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("user name") + .build(), + expectedUrl = "https://api.example.com/user+name", + ), + SINGLE_QUERY_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .build(), + expectedUrl = "https://api.example.com/users?limit=10", + ), + MULTIPLE_QUERY_PARAMS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .putQueryParam("offset", "20") + .build(), + expectedUrl = "https://api.example.com/users?limit=10&offset=20", + ), + QUERY_PARAM_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("search") + .putQueryParam("q", "hello world") + .build(), + expectedUrl = "https://api.example.com/search?q=hello+world", + ), + MULTIPLE_VALUES_SAME_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParams("tags", listOf("admin", "user")) + .build(), + expectedUrl = "https://api.example.com/users?tags=admin&tags=user", + ), + BASE_URL_WITH_TRAILING_SLASH_AND_PATH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + COMPLEX_URL( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl("https://api.example.com") + .addPathSegments("v1", "users", "123") + .putQueryParams("include", listOf("profile", "settings")) + .putQueryParam("format", "json") + .build(), + expectedUrl = + "https://api.example.com/v1/users/123?include=profile&include=settings&format=json", + ), + } + + @ParameterizedTest + @EnumSource + fun url(testCase: UrlTestCase) { + val actualUrl = testCase.request.url() + + assertThat(actualUrl).isEqualTo(testCase.expectedUrl) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParamsTest.kt index 04e8e531..2fd86475 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunCreateParamsTest.kt @@ -11,7 +11,7 @@ internal class RunCreateParamsTest { fun create() { RunCreateParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() } @@ -20,7 +20,7 @@ internal class RunCreateParamsTest { val params = RunCreateParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -33,11 +33,14 @@ internal class RunCreateParamsTest { val params = RunCreateParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() val body = params._body() - assertThat(body).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body) + .isEqualTo( + RunCreateParams.Body.ofStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + ) } } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListParamsTest.kt index c48ff592..7f85161b 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitListParamsTest.kt @@ -14,6 +14,7 @@ internal class CommitListParamsTest { CommitListParams.builder() .owner(JsonValue.from(mapOf())) .repo(JsonValue.from(mapOf())) + .includeStats(true) .limit(1L) .offset(0L) .build() @@ -39,6 +40,7 @@ internal class CommitListParamsTest { CommitListParams.builder() .owner(JsonValue.from(mapOf())) .repo(JsonValue.from(mapOf())) + .includeStats(true) .limit(1L) .offset(0L) .build() @@ -46,7 +48,13 @@ internal class CommitListParamsTest { val queryParams = params._queryParams() assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("limit", "1").put("offset", "0").build()) + .isEqualTo( + QueryParams.builder() + .put("include_stats", "true") + .put("limit", "1") + .put("offset", "0") + .build() + ) } @Test diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneParamsTest.kt index 3acb58b2..30c8acf0 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetCloneParamsTest.kt @@ -16,6 +16,7 @@ internal class DatasetCloneParamsTest { .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .split("string") .build() } @@ -27,6 +28,7 @@ internal class DatasetCloneParamsTest { .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .split("string") .build() val body = params._body() @@ -41,6 +43,7 @@ internal class DatasetCloneParamsTest { ) assertThat(body.examples().getOrNull()) .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.split()).contains(DatasetCloneParams.Split.ofString("string")) } @Test diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRunsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRunsTest.kt index bf91ae03..5851150b 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRunsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/QueryExampleSchemaWithRunsTest.kt @@ -30,6 +30,7 @@ internal class QueryExampleSchemaWithRunsTest { .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) .build() ) + .stream(true) .build() assertThat(queryExampleSchemaWithRuns.sessionIds()) @@ -52,6 +53,7 @@ internal class QueryExampleSchemaWithRunsTest { .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) .build() ) + assertThat(queryExampleSchemaWithRuns.stream()).contains(true) } @Test @@ -75,6 +77,7 @@ internal class QueryExampleSchemaWithRunsTest { .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) .build() ) + .stream(true) .build() val roundtrippedQueryExampleSchemaWithRuns = diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParamsTest.kt index daff8cf6..f77a1005 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateParamsTest.kt @@ -13,27 +13,24 @@ internal class RunCreateParamsTest { fun create() { RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .format("format") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .filters( - QueryExampleSchemaWithRuns.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) - .build() - ) - .limit(1L) - .offset(0L) - .preview(true) - .sortParams( - SortParamsForRunsComparisonView.builder() - .sortBy("sort_by") - .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) - .build() - ) + .format(RunCreateParams.Format.CSV) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + RunCreateParams.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + SortParamsForRunsComparisonView.builder() + .sortBy("sort_by") + .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) + .build() + ) + .stream(true) .build() } @@ -42,11 +39,7 @@ internal class RunCreateParamsTest { val params = RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -59,32 +52,29 @@ internal class RunCreateParamsTest { val params = RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .format("format") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .filters( - QueryExampleSchemaWithRuns.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) - .build() - ) - .limit(1L) - .offset(0L) - .preview(true) - .sortParams( - SortParamsForRunsComparisonView.builder() - .sortBy("sort_by") - .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) - .build() - ) + .format(RunCreateParams.Format.CSV) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + RunCreateParams.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + SortParamsForRunsComparisonView.builder() + .sortBy("sort_by") + .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) + .build() + ) + .stream(true) .build() val queryParams = params._queryParams() - assertThat(queryParams).isEqualTo(QueryParams.builder().put("format", "format").build()) + assertThat(queryParams).isEqualTo(QueryParams.builder().put("format", "csv").build()) } @Test @@ -92,11 +82,7 @@ internal class RunCreateParamsTest { val params = RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val queryParams = params._queryParams() @@ -109,52 +95,47 @@ internal class RunCreateParamsTest { val params = RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .format("format") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .filters( - QueryExampleSchemaWithRuns.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) - .build() - ) - .limit(1L) - .offset(0L) - .preview(true) - .sortParams( - SortParamsForRunsComparisonView.builder() - .sortBy("sort_by") - .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) - .build() - ) + .format(RunCreateParams.Format.CSV) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + RunCreateParams.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + SortParamsForRunsComparisonView.builder() + .sortBy("sort_by") + .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) + .build() + ) + .stream(true) .build() val body = params._body() - assertThat(body) - .isEqualTo( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .filters( - QueryExampleSchemaWithRuns.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) - .build() - ) - .limit(1L) - .offset(0L) - .preview(true) - .sortParams( - SortParamsForRunsComparisonView.builder() - .sortBy("sort_by") - .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) - .build() - ) + assertThat(body.sessionIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.comparativeExperimentId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.filters()) + .contains( + RunCreateParams.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + assertThat(body.limit()).contains(1L) + assertThat(body.offset()).contains(0L) + assertThat(body.preview()).contains(true) + assertThat(body.sortParams()) + .contains( + SortParamsForRunsComparisonView.builder() + .sortBy("sort_by") + .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) .build() ) + assertThat(body.stream()).contains(true) } @Test @@ -162,20 +143,11 @@ internal class RunCreateParamsTest { val params = RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val body = params._body() - assertThat(body) - .isEqualTo( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + assertThat(body.sessionIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParamsTest.kt index f30b8233..d3416ae9 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleRetrieveParamsTest.kt @@ -14,6 +14,7 @@ internal class ExampleRetrieveParamsTest { ExampleRetrieveParams.builder() .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @@ -35,12 +36,18 @@ internal class ExampleRetrieveParamsTest { ExampleRetrieveParams.builder() .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val queryParams = params._queryParams() assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build()) + .isEqualTo( + QueryParams.builder() + .put("as_of", "2019-12-27T18:11:19.117Z") + .put("dataset", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt index 32d187d9..45d8f906 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateParamsTest.kt @@ -53,6 +53,7 @@ internal class FeedbackCreateParamsTest { .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .score(0.0) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .value(0.0) .build() @@ -105,6 +106,7 @@ internal class FeedbackCreateParamsTest { .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .score(0.0) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .value(0.0) .build() @@ -155,6 +157,7 @@ internal class FeedbackCreateParamsTest { .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .score(0.0) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .value(0.0) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt index dd8593f1..53d2815d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/feedback/FeedbackCreateSchemaTest.kt @@ -54,6 +54,7 @@ internal class FeedbackCreateSchemaTest { .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .score(0.0) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .value(0.0) .build() @@ -109,6 +110,8 @@ internal class FeedbackCreateSchemaTest { assertThat(feedbackCreateSchema.score()).contains(FeedbackCreateSchema.Score.ofNumber(0.0)) assertThat(feedbackCreateSchema.sessionId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateSchema.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(feedbackCreateSchema.traceId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(feedbackCreateSchema.value()).contains(FeedbackCreateSchema.Value.ofNumber(0.0)) } @@ -157,6 +160,7 @@ internal class FeedbackCreateSchemaTest { .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .score(0.0) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .value(0.0) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt index 84b73237..4b43f832 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncTest.kt @@ -222,6 +222,7 @@ internal class DatasetServiceAsyncTest { .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .split("string") .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt index 7ca08bd3..107b8967 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/ExampleServiceAsyncTest.kt @@ -82,6 +82,7 @@ internal class ExampleServiceAsyncTest { ExampleRetrieveParams.builder() .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt index 4ac31db6..8fba0317 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/FeedbackServiceAsyncTest.kt @@ -71,6 +71,7 @@ internal class FeedbackServiceAsyncTest { .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .score(0.0) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .value(0.0) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/annotationqueues/RunServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/annotationqueues/RunServiceAsyncTest.kt index 544e7de2..7edd21b5 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/annotationqueues/RunServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/annotationqueues/RunServiceAsyncTest.kt @@ -33,7 +33,7 @@ internal class RunServiceAsyncTest { runServiceAsync.create( RunCreateParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncTest.kt index 6e208f5d..220954d7 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.langchain.smith.services.async.datasets import com.langchain.smith.TestServerExtension import com.langchain.smith.client.okhttp.LangsmithOkHttpClientAsync import com.langchain.smith.core.JsonValue -import com.langchain.smith.models.datasets.runs.QueryExampleSchemaWithRuns import com.langchain.smith.models.datasets.runs.QueryFeedbackDelta import com.langchain.smith.models.datasets.runs.RunCreateParams import com.langchain.smith.models.datasets.runs.RunDeltaParams @@ -34,27 +33,24 @@ internal class RunServiceAsyncTest { runServiceAsync.create( RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .format("format") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .filters( - QueryExampleSchemaWithRuns.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) - .build() - ) - .limit(1L) - .offset(0L) - .preview(true) - .sortParams( - SortParamsForRunsComparisonView.builder() - .sortBy("sort_by") - .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) - .build() - ) + .format(RunCreateParams.Format.CSV) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + RunCreateParams.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + SortParamsForRunsComparisonView.builder() + .sortBy("sort_by") + .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) .build() ) + .stream(true) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt index 447da44f..8426ba39 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/DatasetServiceTest.kt @@ -217,6 +217,7 @@ internal class DatasetServiceTest { .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .split("string") .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt index 1dfa05d1..70f6cd11 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/ExampleServiceTest.kt @@ -81,6 +81,7 @@ internal class ExampleServiceTest { ExampleRetrieveParams.builder() .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt index df46004c..19cdb23f 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/FeedbackServiceTest.kt @@ -71,6 +71,7 @@ internal class FeedbackServiceTest { .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .score(0.0) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .value(0.0) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/annotationqueues/RunServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/annotationqueues/RunServiceTest.kt index a500902e..af224c6a 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/annotationqueues/RunServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/annotationqueues/RunServiceTest.kt @@ -33,7 +33,7 @@ internal class RunServiceTest { runService.create( RunCreateParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceTest.kt index a6e86da5..fadf7f11 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceTest.kt @@ -5,7 +5,6 @@ package com.langchain.smith.services.blocking.datasets import com.langchain.smith.TestServerExtension import com.langchain.smith.client.okhttp.LangsmithOkHttpClient import com.langchain.smith.core.JsonValue -import com.langchain.smith.models.datasets.runs.QueryExampleSchemaWithRuns import com.langchain.smith.models.datasets.runs.QueryFeedbackDelta import com.langchain.smith.models.datasets.runs.RunCreateParams import com.langchain.smith.models.datasets.runs.RunDeltaParams @@ -34,27 +33,24 @@ internal class RunServiceTest { runService.create( RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .format("format") - .queryExampleSchemaWithRuns( - QueryExampleSchemaWithRuns.builder() - .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .filters( - QueryExampleSchemaWithRuns.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) - .build() - ) - .limit(1L) - .offset(0L) - .preview(true) - .sortParams( - SortParamsForRunsComparisonView.builder() - .sortBy("sort_by") - .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) - .build() - ) + .format(RunCreateParams.Format.CSV) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + RunCreateParams.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + SortParamsForRunsComparisonView.builder() + .sortBy("sort_by") + .sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC) .build() ) + .stream(true) .build() )