diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb5355d37..fd1492e28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' @@ -17,7 +19,7 @@ jobs: timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/langsmith-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -44,7 +46,7 @@ jobs: contents: read id-token: write runs-on: ${{ github.repository == 'stainless-sdks/langsmith-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -65,14 +67,18 @@ jobs: run: ./scripts/build - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/langsmith-api-java' + if: |- + github.repository == 'stainless-sdks/langsmith-api-java' && + !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Build and upload Maven artifacts - if: github.repository == 'stainless-sdks/langsmith-api-java' + if: |- + github.repository == 'stainless-sdks/langsmith-api-java' && + !startsWith(github.ref, 'refs/heads/stl/') env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} diff --git a/.github/workflows/count-methods.yml b/.github/workflows/count-methods.yml deleted file mode 100644 index 1782d5aef..000000000 --- a/.github/workflows/count-methods.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Count number of methods in the SDK -on: - workflow_dispatch: - push: - pull_request: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' - -jobs: - count-methods: - name: count methods - runs-on: ubuntu-latest - if: github.event_name == 'push' || github.event_name == 'pull_request' - - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Read method count from .stats.yml - id: read_method_count - run: | - if [ ! -f .stats.yml ]; then - echo "Error: .stats.yml file not found" - exit 1 - fi - - METHOD_COUNT=$(grep -E '^configured_endpoints:\s*[0-9]+' .stats.yml | awk '{print $2}' || echo "") - - if [ -z "$METHOD_COUNT" ]; then - echo "Error: Could not find configured_endpoints in .stats.yml" - exit 1 - fi - - echo "Method count from .stats.yml: $METHOD_COUNT" - echo "method_count=$METHOD_COUNT" >> $GITHUB_OUTPUT - - - name: Fail if method count exceeds threshold - uses: actions/github-script@v8 - with: - script: | - const methodCount = parseInt('${{ steps.read_method_count.outputs.method_count }}'); - const threshold = 100; - - if (methodCount > threshold) { - core.setFailed( - ` Method count check failed!\n` + - ` Current method count: ${methodCount}\n` + - ` Maximum allowed: ${threshold}\n` + - ` Excess: ${methodCount - threshold} methods\n\n` + - `This check ensures the SDK doesn't exceed the configured endpoint limit.` - ); - } else { - console.log(`Currently at ${methodCount} methods`); - } diff --git a/.gitignore b/.gitignore index b1346e6d1..90b85e944 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log .gradle .idea .kotlin diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1c0bb8852..380b6f913 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.23" + ".": "0.1.0-alpha.24" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 3df379769..3503c6f83 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-9301fa88ebc17384444c65b726e0a222d018834fa33dedcc2d32f31f460337cb.yml -openapi_spec_hash: 3e08d32477a470030a45ceb0f15aabf2 -config_hash: dbf6574c76c5c4ae18ffb6d212de7a7c +configured_endpoints: 102 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-9b1a87757cd49a12277fb568ad9a86554c1b46ac115f0ca43fd19e8d8025286d.yml +openapi_spec_hash: 76801a4fc381af1c3435db9504a2b382 +config_hash: 787a12876983a14bce67ed57899e4a94 diff --git a/CHANGELOG.md b/CHANGELOG.md index 26d640782..c0df92411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,57 @@ # Changelog +## 0.1.0-alpha.24 (2026-03-25) + +Full Changelog: [v0.1.0-alpha.23...v0.1.0-alpha.24](https://github.com/langchain-ai/langsmith-java/compare/v0.1.0-alpha.23...v0.1.0-alpha.24) + +### Features + +* **api:** api update ([8e94d9d](https://github.com/langchain-ai/langsmith-java/commit/8e94d9dc65dfacd3f238e88631623a1338edec2e)) +* **api:** api update ([3288052](https://github.com/langchain-ai/langsmith-java/commit/32880529fe17d465d20ee922894a9e1af3351edd)) +* **api:** api update ([a4e3e5c](https://github.com/langchain-ai/langsmith-java/commit/a4e3e5cb858e66a9409ac162f04660c514cc24df)) +* **api:** api update ([ff16250](https://github.com/langchain-ai/langsmith-java/commit/ff162506f81ad1616567c9119ded36c1a344c774)) +* **api:** api update ([ef7c7a7](https://github.com/langchain-ai/langsmith-java/commit/ef7c7a798786b073e403d994ee2a9367d4db59ee)) +* **api:** api update ([643c7b1](https://github.com/langchain-ai/langsmith-java/commit/643c7b121acd874a72c36e80fbd6d8d4aa772319)) +* **api:** api update ([4b9c97d](https://github.com/langchain-ai/langsmith-java/commit/4b9c97d873492f919885fc1e394d1819fbedd09a)) +* **api:** api update ([ea4e843](https://github.com/langchain-ai/langsmith-java/commit/ea4e843eea1709113fd259659c2cc85fd6317fa5)) +* **api:** api update ([74d2131](https://github.com/langchain-ai/langsmith-java/commit/74d213181b7a2398fa8852235de5a1123ff0a7fe)) +* **api:** api update ([2708533](https://github.com/langchain-ai/langsmith-java/commit/27085335b36f0ecb249a3bd079f96d8d9fad6c1f)) +* **api:** api update ([8f48677](https://github.com/langchain-ai/langsmith-java/commit/8f48677e5ca0dfd9c9e9bc248c204863f233542a)) +* **api:** api update ([c11821f](https://github.com/langchain-ai/langsmith-java/commit/c11821f56ba08939568332468a1e9376c78e6372)) +* **api:** api update ([44fe8b3](https://github.com/langchain-ai/langsmith-java/commit/44fe8b31986af7ae7ac489c0a59335afb8021f9f)) +* **api:** api update ([d11c759](https://github.com/langchain-ai/langsmith-java/commit/d11c759b1cf0d360f07aa0807f554c36f3262b14)) +* **api:** manual updates ([09f1302](https://github.com/langchain-ai/langsmith-java/commit/09f1302329d0fcd9082bc52b2381271aabd71bab)) +* **api:** manual updates ([dbed70a](https://github.com/langchain-ai/langsmith-java/commit/dbed70af760f0e807626650a2a7d6ecb8d30f0ad)) +* **api:** manual updates ([48e2ca2](https://github.com/langchain-ai/langsmith-java/commit/48e2ca294bd412398290777db3ef14655ed47b1c)) +* **api:** manual updates ([d8ac870](https://github.com/langchain-ai/langsmith-java/commit/d8ac87089db42004a53e880f419dcf6749c60817)) +* **api:** manual updates ([bdb35f0](https://github.com/langchain-ai/langsmith-java/commit/bdb35f01f6374860fe6fa3c83f6f102f22590b23)) + + +### Bug Fixes + +* **client:** allow updating header/query affecting fields in `toBuilder()` ([5069881](https://github.com/langchain-ai/langsmith-java/commit/5069881aebcffc8ea2058de667a7af33efc15ec3)) +* **client:** incorrect `Retry-After` parsing ([b607264](https://github.com/langchain-ai/langsmith-java/commit/b607264e2c7e10374f5d79d922c6850208b6f839)) +* fix streaming in java sdk ([#95](https://github.com/langchain-ai/langsmith-java/issues/95)) ([76da93f](https://github.com/langchain-ai/langsmith-java/commit/76da93f2c0c3a0466feee196243a214e8642b303)) + + +### Chores + +* align user agent format ([#96](https://github.com/langchain-ai/langsmith-java/issues/96)) ([5cf06d6](https://github.com/langchain-ai/langsmith-java/commit/5cf06d612963f01b49d6f62117226d948e004046)) +* **ci:** skip lint on metadata-only changes ([4c1197c](https://github.com/langchain-ai/langsmith-java/commit/4c1197ce483f317defed85f81d3ec3f5053f68d3)) +* **ci:** skip uploading artifacts on stainless-internal branches ([c994122](https://github.com/langchain-ai/langsmith-java/commit/c994122d8c4eea78bb8a942b0ed1db58e6338e1e)) +* **deps:** bump the all-actions group with 5 updates ([#92](https://github.com/langchain-ai/langsmith-java/issues/92)) ([3a1a72f](https://github.com/langchain-ai/langsmith-java/commit/3a1a72f5595393a437a8ddf1acc69bb44529b0e8)) +* drop apache dependency ([75ca9d7](https://github.com/langchain-ai/langsmith-java/commit/75ca9d71b49bad02bdbd66141f693204b296a9ec)) +* **internal:** bump ktfmt ([d9a4a39](https://github.com/langchain-ai/langsmith-java/commit/d9a4a396ad92c9f33c5922dabc00a8ba2451199b)) +* **internal:** bump palantir-java-format ([576ebd2](https://github.com/langchain-ai/langsmith-java/commit/576ebd2a02613c632dd1e00ba9c606df99de8f37)) +* **internal:** codegen related update ([29d55b0](https://github.com/langchain-ai/langsmith-java/commit/29d55b0ee9f40c2d327f1c08a714ccd9cad1384b)) +* **internal:** expand imports ([4c7542f](https://github.com/langchain-ai/langsmith-java/commit/4c7542f4525b43d8fc2adcd7d084a080581b5c48)) +* **internal:** tweak CI branches ([b7cecc1](https://github.com/langchain-ai/langsmith-java/commit/b7cecc1caa774426df72acd5734a2c29a96a3e60)) +* **internal:** update gitignore ([d0df3fa](https://github.com/langchain-ai/langsmith-java/commit/d0df3fa13a923514d9d3c66d5d96b4fa1fea4a22)) +* **internal:** update retry delay tests ([a9c7999](https://github.com/langchain-ai/langsmith-java/commit/a9c7999f55bc12c2d1bac268ce3a2ca5bbd58dc5)) +* make `Properties` more resilient to `null` ([47c70f9](https://github.com/langchain-ai/langsmith-java/commit/47c70f91d5ec941fafc08a81baabf946602076c9)) +* remove old test ([#97](https://github.com/langchain-ai/langsmith-java/issues/97)) ([79d708b](https://github.com/langchain-ai/langsmith-java/commit/79d708b935ba234c50d10980a7fef8ad12c58f61)) +* update placeholder string ([be1baa7](https://github.com/langchain-ai/langsmith-java/commit/be1baa704ad8ebe899fbf8e4003f706fbc3d3f73)) + ## 0.1.0-alpha.23 (2026-02-20) Full Changelog: [v0.1.0-alpha.22...v0.1.0-alpha.23](https://github.com/langchain-ai/langsmith-java/compare/v0.1.0-alpha.22...v0.1.0-alpha.23) diff --git a/README.md b/README.md index 955bc4b0f..27a9835c8 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.23) -[![javadoc](https://javadoc.io/badge2/com.langchain.smith/langsmith-java/0.1.0-alpha.23/javadoc.svg)](https://javadoc.io/doc/com.langchain.smith/langsmith-java/0.1.0-alpha.23) +[![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.24) +[![javadoc](https://javadoc.io/badge2/com.langchain.smith/langsmith-java/0.1.0-alpha.24/javadoc.svg)](https://javadoc.io/doc/com.langchain.smith/langsmith-java/0.1.0-alpha.24) @@ -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.23). +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.24). @@ -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.23") +implementation("com.langchain.smith:langsmith-java:0.1.0-alpha.24") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.langchain.smith:langsmith-java:0.1.0-alpha.23") com.langchain.smith langsmith-java - 0.1.0-alpha.23 + 0.1.0-alpha.24 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 579c36df4..4c1f4f2c0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.langchain.smith" - version = "0.1.0-alpha.23" // x-release-please-version + version = "0.1.0-alpha.24" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/langchain.java.gradle.kts b/buildSrc/src/main/kotlin/langchain.java.gradle.kts index c18dbd1dc..52c35bb55 100644 --- a/buildSrc/src/main/kotlin/langchain.java.gradle.kts +++ b/buildSrc/src/main/kotlin/langchain.java.gradle.kts @@ -46,7 +46,7 @@ tasks.withType().configureEach { val palantir by configurations.creating dependencies { - palantir("com.palantir.javaformat:palantir-java-format:2.73.0") + palantir("com.palantir.javaformat:palantir-java-format:2.89.0") } fun registerPalantir( diff --git a/buildSrc/src/main/kotlin/langchain.kotlin.gradle.kts b/buildSrc/src/main/kotlin/langchain.kotlin.gradle.kts index b4b787ba9..2632d2095 100644 --- a/buildSrc/src/main/kotlin/langchain.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/langchain.kotlin.gradle.kts @@ -39,7 +39,7 @@ tasks.withType().configureEach { val ktfmt by configurations.creating dependencies { - ktfmt("com.facebook:ktfmt:0.56") + ktfmt("com.facebook:ktfmt:0.61") } fun registerKtfmt( diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientAsyncImpl.kt index 6cdb5155b..1e186df33 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientAsyncImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientAsyncImpl.kt @@ -33,7 +33,7 @@ class LangsmithClientAsyncImpl(private val clientOptions: ClientOptions) : Langs else clientOptions .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .putHeader("User-Agent", "langsmith-java/${getPackageVersion()}") .build() // Pass the original clientOptions so that this client sets its own User-Agent. diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientImpl.kt index 377984fa0..ba499902a 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/client/LangsmithClientImpl.kt @@ -33,7 +33,7 @@ class LangsmithClientImpl(private val clientOptions: ClientOptions) : LangsmithC else clientOptions .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .putHeader("User-Agent", "langsmith-java/${getPackageVersion()}") .build() // Pass the original clientOptions so that this client sets its own User-Agent. 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 c0ae8dc9b..5375f5baf 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 @@ -503,28 +503,29 @@ private constructor( headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) + // We replace after all the default headers to allow end-users to overwrite them. + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) apiKey?.let { if (!it.isEmpty()) { - headers.put("X-API-Key", it) + headers.replace("X-API-Key", it) } } organizationId?.let { if (!it.isEmpty()) { - headers.put("X-Organization-Id", it) + headers.replace("X-Organization-Id", it) } } bearerToken?.let { if (!it.isEmpty()) { - headers.put("Authorization", "Bearer $it") + headers.replace("Authorization", "Bearer $it") } } tenantId?.let { if (!it.isEmpty()) { - headers.put("X-Tenant-Id", it) + headers.replace("X-Tenant-Id", it) } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient, diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/Properties.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/Properties.kt index 490782e48..c18124cfb 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/Properties.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/Properties.kt @@ -34,9 +34,9 @@ fun getOsName(): String { } } -fun getOsVersion(): String = System.getProperty("os.version", "unknown") +fun getOsVersion(): String = System.getProperty("os.version", "unknown") ?: "unknown" fun getPackageVersion(): String = - LangsmithClient::class.java.`package`.implementationVersion ?: "unknown" + LangsmithClient::class.java.`package`?.implementationVersion ?: "unknown" -fun getJavaVersion(): String = System.getProperty("java.version", "unknown") +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") ?: "unknown" diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequestBodies.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequestBodies.kt index a28f37ba9..a94a4d8fb 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequestBodies.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/HttpRequestBodies.kt @@ -8,13 +8,13 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType import com.langchain.smith.core.MultipartField +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException +import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream +import java.util.UUID import kotlin.jvm.optionals.getOrNull -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder -import org.apache.hc.core5.http.ContentType -import org.apache.hc.core5.http.HttpEntity @JvmSynthetic internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = @@ -37,94 +37,231 @@ internal fun multipartFormData( jsonMapper: JsonMapper, fields: Map>, ): HttpRequestBody = - object : HttpRequestBody { - private val entity: HttpEntity by lazy { - MultipartEntityBuilder.create() - .apply { - fields.forEach { (name, field) -> - val knownValue = field.value.asKnown().getOrNull() - val parts = - if (knownValue is InputStream) { - // Read directly from the `InputStream` instead of reading it all - // into memory due to the `jsonMapper` serialization below. - sequenceOf(name to knownValue) - } else { - val node = jsonMapper.valueToTree(field.value) - serializePart(name, node) + MultipartBody.Builder() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + val partBody = + if (bytes is ByteArrayInputStream) { + val byteArray = bytes.readBytes() + + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(byteArray) + } + + override fun contentType(): String = field.contentType + + override fun contentLength(): Long = byteArray.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} } + } else { + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + bytes.copyTo(outputStream) + } + + override fun contentType(): String = field.contentType + + override fun contentLength(): Long = -1L - parts.forEach { (name, bytes) -> - addBinaryBody( - name, - bytes, - ContentType.parseLenient(field.contentType), - field.filename().getOrNull(), - ) + override fun repeatable(): Boolean = false + + override fun close() = bytes.close() + } } - } + + addPart( + MultipartBody.Part.create( + name, + field.filename().getOrNull(), + field.contentType, + partBody, + ) + ) } - .build() + } } + .build() - private fun serializePart( - name: String, - node: JsonNode, - ): Sequence> = - when (node.nodeType) { - JsonNodeType.MISSING, - JsonNodeType.NULL -> emptySequence() - JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) - JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) - JsonNodeType.BOOLEAN -> - sequenceOf(name to node.booleanValue().toString().inputStream()) - JsonNodeType.NUMBER -> - sequenceOf(name to node.numberValue().toString().inputStream()) - JsonNodeType.ARRAY -> - sequenceOf( - name to - node - .elements() - .asSequence() - .mapNotNull { element -> - when (element.nodeType) { - JsonNodeType.MISSING, - JsonNodeType.NULL -> null - JsonNodeType.STRING -> node.textValue() - JsonNodeType.BOOLEAN -> node.booleanValue().toString() - JsonNodeType.NUMBER -> node.numberValue().toString() - null, - JsonNodeType.BINARY, - JsonNodeType.ARRAY, - JsonNodeType.OBJECT, - JsonNodeType.POJO -> - throw LangChainInvalidDataException( - "Unexpected JsonNode type in array: ${node.nodeType}" - ) - } - } - .joinToString(",") - .inputStream() - ) - JsonNodeType.OBJECT -> - node.fields().asSequence().flatMap { (key, value) -> - serializePart("$name[$key]", value) - } - JsonNodeType.POJO, - null -> - throw LangChainInvalidDataException( - "Unexpected JsonNode type: ${node.nodeType}" - ) +private fun serializePart(name: String, node: JsonNode): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().byteInputStream()) + JsonNodeType.BOOLEAN -> sequenceOf(name to node.booleanValue().toString().byteInputStream()) + JsonNodeType.NUMBER -> sequenceOf(name to node.numberValue().toString().byteInputStream()) + JsonNodeType.ARRAY -> + sequenceOf( + name to + node + .elements() + .asSequence() + .mapNotNull { element -> + when (element.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> null + JsonNodeType.STRING -> element.textValue() + JsonNodeType.BOOLEAN -> element.booleanValue().toString() + JsonNodeType.NUMBER -> element.numberValue().toString() + null, + JsonNodeType.BINARY, + JsonNodeType.ARRAY, + JsonNodeType.OBJECT, + JsonNodeType.POJO -> + throw LangChainInvalidDataException( + "Unexpected JsonNode type in array: ${element.nodeType}" + ) + } + } + .joinToString(",") + .byteInputStream() + ) + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) } + JsonNodeType.POJO, + null -> throw LangChainInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + } - private fun String.inputStream(): InputStream = toByteArray().inputStream() +private class MultipartBody +private constructor(private val boundary: String, private val parts: List) : HttpRequestBody { + private val boundaryBytes: ByteArray = boundary.toByteArray() + private val contentType = "multipart/form-data; boundary=$boundary" - override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + // This must remain in sync with `contentLength`. + override fun writeTo(outputStream: OutputStream) { + parts.forEach { part -> + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(CRLF) - override fun contentType(): String = entity.contentType + outputStream.write(CONTENT_DISPOSITION) + outputStream.write(part.contentDisposition.toByteArray()) + outputStream.write(CRLF) - override fun contentLength(): Long = entity.contentLength + outputStream.write(CONTENT_TYPE) + outputStream.write(part.contentType.toByteArray()) + outputStream.write(CRLF) - override fun repeatable(): Boolean = entity.isRepeatable + outputStream.write(CRLF) + part.body.writeTo(outputStream) + outputStream.write(CRLF) + } - override fun close() = entity.close() + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(DASHDASH) + outputStream.write(CRLF) + } + + override fun contentType(): String = contentType + + // This must remain in sync with `writeTo`. + override fun contentLength(): Long { + var byteCount = 0L + + parts.forEach { part -> + val contentLength = part.body.contentLength() + if (contentLength == -1L) { + return -1L + } + + byteCount += + DASHDASH.size + + boundaryBytes.size + + CRLF.size + + CONTENT_DISPOSITION.size + + part.contentDisposition.toByteArray().size + + CRLF.size + + CONTENT_TYPE.size + + part.contentType.toByteArray().size + + CRLF.size + + CRLF.size + + contentLength + + CRLF.size + } + + byteCount += DASHDASH.size + boundaryBytes.size + DASHDASH.size + CRLF.size + return byteCount + } + + override fun repeatable(): Boolean = parts.all { it.body.repeatable() } + + override fun close() { + parts.forEach { it.body.close() } + } + + class Builder { + private val boundary = UUID.randomUUID().toString() + private val parts: MutableList = mutableListOf() + + fun addPart(part: Part) = apply { parts.add(part) } + + fun build() = MultipartBody(boundary, parts.toImmutable()) + } + + class Part + private constructor( + val contentDisposition: String, + val contentType: String, + val body: HttpRequestBody, + ) { + companion object { + fun create( + name: String, + filename: String?, + contentType: String, + body: HttpRequestBody, + ): Part { + val disposition = buildString { + append("form-data; name=") + appendQuotedString(name) + if (filename != null) { + append("; filename=") + appendQuotedString(filename) + } + } + return Part(disposition, contentType, body) + } + } + } + + companion object { + private val CRLF = byteArrayOf('\r'.code.toByte(), '\n'.code.toByte()) + private val DASHDASH = byteArrayOf('-'.code.toByte(), '-'.code.toByte()) + private val CONTENT_DISPOSITION = "Content-Disposition: ".toByteArray() + private val CONTENT_TYPE = "Content-Type: ".toByteArray() + + private fun StringBuilder.appendQuotedString(key: String) { + append('"') + for (ch in key) { + when (ch) { + '\n' -> append("%0A") + '\r' -> append("%0D") + '"' -> append("%22") + else -> append(ch) + } + } + append('"') + } } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/RetryingHttpClient.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/RetryingHttpClient.kt index ff292bb74..4eda48e78 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/RetryingHttpClient.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/core/http/RetryingHttpClient.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package com.langchain.smith.core.http import com.langchain.smith.core.DefaultSleeper @@ -199,7 +201,7 @@ private constructor( ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { - ChronoUnit.MILLIS.between( + ChronoUnit.NANOS.between( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, @@ -212,13 +214,8 @@ private constructor( } } ?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable - // amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter - } + // If the API asks us to wait a certain amount of time, do what it says. + return Duration.ofNanos(retryAfterNanos.toLong()) } // Apply exponential backoff, but not more than the max. diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/BadRequestException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/BadRequestException.kt index e7ce096f0..551a688f8 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/BadRequestException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/BadRequestException.kt @@ -10,7 +10,7 @@ import kotlin.jvm.optionals.getOrNull class BadRequestException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - LangChainServiceException("400: $body", cause) { + LangChainServiceException(formatMessage(400, body), cause) { override fun statusCode(): Int = 400 diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/InternalServerException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/InternalServerException.kt index c7e239181..982ff78fb 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/InternalServerException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/InternalServerException.kt @@ -14,7 +14,7 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : LangChainServiceException("$statusCode: $body", cause) { +) : LangChainServiceException(formatMessage(statusCode, body), cause) { override fun statusCode(): Int = statusCode diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/LangChainServiceException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/LangChainServiceException.kt index def4778b1..26d89bc9c 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/LangChainServiceException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/LangChainServiceException.kt @@ -2,6 +2,7 @@ package com.langchain.smith.errors +import com.fasterxml.jackson.databind.ObjectMapper import com.langchain.smith.core.JsonValue import com.langchain.smith.core.http.Headers @@ -14,4 +15,19 @@ protected constructor(message: String, cause: Throwable? = null) : abstract fun headers(): Headers abstract fun body(): JsonValue + + companion object { + + /** Formats a status code and [JsonValue] error body into an error message. */ + @JvmStatic + fun formatMessage(statusCode: Int, body: JsonValue): String { + val bodyStr = + try { + ObjectMapper().writeValueAsString(body) + } catch (_: Exception) { + body.toString() + } + return "$statusCode: $bodyStr" + } + } } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/NotFoundException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/NotFoundException.kt index a070b703e..74c3b1e71 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/NotFoundException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/NotFoundException.kt @@ -10,7 +10,7 @@ import kotlin.jvm.optionals.getOrNull class NotFoundException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - LangChainServiceException("404: $body", cause) { + LangChainServiceException(formatMessage(404, body), cause) { override fun statusCode(): Int = 404 diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/PermissionDeniedException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/PermissionDeniedException.kt index 5e2d1f819..d338288b4 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/PermissionDeniedException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/PermissionDeniedException.kt @@ -10,7 +10,7 @@ import kotlin.jvm.optionals.getOrNull class PermissionDeniedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - LangChainServiceException("403: $body", cause) { + LangChainServiceException(formatMessage(403, body), cause) { override fun statusCode(): Int = 403 diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/RateLimitException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/RateLimitException.kt index b8eda17b1..066d694a1 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/RateLimitException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/RateLimitException.kt @@ -10,7 +10,7 @@ import kotlin.jvm.optionals.getOrNull class RateLimitException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - LangChainServiceException("429: $body", cause) { + LangChainServiceException(formatMessage(429, body), cause) { override fun statusCode(): Int = 429 diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnauthorizedException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnauthorizedException.kt index d2c472329..7323d1806 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnauthorizedException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnauthorizedException.kt @@ -10,7 +10,7 @@ import kotlin.jvm.optionals.getOrNull class UnauthorizedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - LangChainServiceException("401: $body", cause) { + LangChainServiceException(formatMessage(401, body), cause) { override fun statusCode(): Int = 401 diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnexpectedStatusCodeException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnexpectedStatusCodeException.kt index d66069ed3..6c41c6233 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnexpectedStatusCodeException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnexpectedStatusCodeException.kt @@ -14,7 +14,7 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : LangChainServiceException("$statusCode: $body", cause) { +) : LangChainServiceException(formatMessage(statusCode, body), cause) { override fun statusCode(): Int = statusCode diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnprocessableEntityException.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnprocessableEntityException.kt index 5b38550df..e18c5988e 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnprocessableEntityException.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/errors/UnprocessableEntityException.kt @@ -10,7 +10,7 @@ import kotlin.jvm.optionals.getOrNull class UnprocessableEntityException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - LangChainServiceException("422: $body", cause) { + LangChainServiceException(formatMessage(422, body), cause) { override fun statusCode(): Int = 422 diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParams.kt index 579da9a65..4dc333d12 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParams.kt @@ -37,6 +37,12 @@ private constructor( */ fun endTime(): Optional = body.endTime() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeAnnotatorDetail(): Optional = body.includeAnnotatorDetail() + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -50,6 +56,14 @@ private constructor( */ fun _endTime(): JsonField = body._endTime() + /** + * Returns the raw JSON value of [includeAnnotatorDetail]. + * + * Unlike [includeAnnotatorDetail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _includeAnnotatorDetail(): JsonField = body._includeAnnotatorDetail() + /** * Returns the raw JSON value of [startTime]. * @@ -104,6 +118,7 @@ private constructor( * 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: * - [endTime] + * - [includeAnnotatorDetail] * - [startTime] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -122,6 +137,21 @@ private constructor( */ fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } + fun includeAnnotatorDetail(includeAnnotatorDetail: Boolean) = apply { + body.includeAnnotatorDetail(includeAnnotatorDetail) + } + + /** + * Sets [Builder.includeAnnotatorDetail] to an arbitrary JSON value. + * + * You should usually call [Builder.includeAnnotatorDetail] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun includeAnnotatorDetail(includeAnnotatorDetail: JsonField) = apply { + body.includeAnnotatorDetail(includeAnnotatorDetail) + } + fun startTime(startTime: OffsetDateTime?) = apply { body.startTime(startTime) } /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ @@ -284,6 +314,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endTime: JsonField, + private val includeAnnotatorDetail: JsonField, private val startTime: JsonField, private val additionalProperties: MutableMap, ) { @@ -293,10 +324,13 @@ private constructor( @JsonProperty("end_time") @ExcludeMissing endTime: JsonField = JsonMissing.of(), + @JsonProperty("include_annotator_detail") + @ExcludeMissing + includeAnnotatorDetail: JsonField = JsonMissing.of(), @JsonProperty("start_time") @ExcludeMissing startTime: JsonField = JsonMissing.of(), - ) : this(endTime, startTime, mutableMapOf()) + ) : this(endTime, includeAnnotatorDetail, startTime, mutableMapOf()) /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -304,6 +338,13 @@ private constructor( */ fun endTime(): Optional = endTime.getOptional("end_time") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeAnnotatorDetail(): Optional = + includeAnnotatorDetail.getOptional("include_annotator_detail") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -319,6 +360,16 @@ private constructor( @ExcludeMissing fun _endTime(): JsonField = endTime + /** + * Returns the raw JSON value of [includeAnnotatorDetail]. + * + * Unlike [includeAnnotatorDetail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("include_annotator_detail") + @ExcludeMissing + fun _includeAnnotatorDetail(): JsonField = includeAnnotatorDetail + /** * Returns the raw JSON value of [startTime]. * @@ -350,12 +401,14 @@ private constructor( class Builder internal constructor() { private var endTime: JsonField = JsonMissing.of() + private var includeAnnotatorDetail: JsonField = JsonMissing.of() private var startTime: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { endTime = body.endTime + includeAnnotatorDetail = body.includeAnnotatorDetail startTime = body.startTime additionalProperties = body.additionalProperties.toMutableMap() } @@ -374,6 +427,20 @@ private constructor( */ fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + fun includeAnnotatorDetail(includeAnnotatorDetail: Boolean) = + includeAnnotatorDetail(JsonField.of(includeAnnotatorDetail)) + + /** + * Sets [Builder.includeAnnotatorDetail] to an arbitrary JSON value. + * + * You should usually call [Builder.includeAnnotatorDetail] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeAnnotatorDetail(includeAnnotatorDetail: JsonField) = apply { + this.includeAnnotatorDetail = includeAnnotatorDetail + } + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ @@ -414,7 +481,13 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(endTime, startTime, additionalProperties.toMutableMap()) + fun build(): Body = + Body( + endTime, + includeAnnotatorDetail, + startTime, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -425,6 +498,7 @@ private constructor( } endTime() + includeAnnotatorDetail() startTime() validated = true } @@ -446,6 +520,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (endTime.asKnown().isPresent) 1 else 0) + + (if (includeAnnotatorDetail.asKnown().isPresent) 1 else 0) + (if (startTime.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -455,16 +530,19 @@ private constructor( return other is Body && endTime == other.endTime && + includeAnnotatorDetail == other.includeAnnotatorDetail && startTime == other.startTime && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(endTime, startTime, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(endTime, includeAnnotatorDetail, startTime, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{endTime=$endTime, startTime=$startTime, additionalProperties=$additionalProperties}" + "Body{endTime=$endTime, includeAnnotatorDetail=$includeAnnotatorDetail, startTime=$startTime, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParams.kt index f90faab0c..604ba02a3 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParams.kt @@ -2,9 +2,13 @@ package com.langchain.smith.models.annotationqueues +import com.fasterxml.jackson.annotation.JsonCreator +import com.langchain.smith.core.Enum +import com.langchain.smith.core.JsonField import com.langchain.smith.core.Params import com.langchain.smith.core.http.Headers import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -13,12 +17,15 @@ import kotlin.jvm.optionals.getOrNull class AnnotationQueueRetrieveSizeParams private constructor( private val queueId: String?, + private val status: Status?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun queueId(): Optional = Optional.ofNullable(queueId) + fun status(): Optional = Optional.ofNullable(status) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -42,6 +49,7 @@ private constructor( class Builder internal constructor() { private var queueId: String? = null + private var status: Status? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -49,6 +57,7 @@ private constructor( internal fun from(annotationQueueRetrieveSizeParams: AnnotationQueueRetrieveSizeParams) = apply { queueId = annotationQueueRetrieveSizeParams.queueId + status = annotationQueueRetrieveSizeParams.status additionalHeaders = annotationQueueRetrieveSizeParams.additionalHeaders.toBuilder() additionalQueryParams = annotationQueueRetrieveSizeParams.additionalQueryParams.toBuilder() @@ -59,6 +68,11 @@ private constructor( /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -165,6 +179,7 @@ private constructor( fun build(): AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams( queueId, + status, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -178,7 +193,146 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + status?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class Status @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 NEEDS_MY_REVIEW = of("needs_my_review") + + @JvmField val NEEDS_OTHERS_REVIEW = of("needs_others_review") + + @JvmField val COMPLETED = of("completed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + COMPLETED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + COMPLETED, + /** An enum member indicating that [Status] 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) { + NEEDS_MY_REVIEW -> Value.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Value.NEEDS_OTHERS_REVIEW + COMPLETED -> Value.COMPLETED + 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) { + NEEDS_MY_REVIEW -> Known.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Known.NEEDS_OTHERS_REVIEW + COMPLETED -> Known.COMPLETED + else -> throw LangChainInvalidDataException("Unknown Status: $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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -187,12 +341,14 @@ private constructor( return other is AnnotationQueueRetrieveSizeParams && queueId == other.queueId && + status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(queueId, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(queueId, status, additionalHeaders, additionalQueryParams) override fun toString() = - "AnnotationQueueRetrieveSizeParams{queueId=$queueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "AnnotationQueueRetrieveSizeParams{queueId=$queueId, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt index 52dbe98a5..df3073419 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt @@ -15,6 +15,7 @@ import com.langchain.smith.core.checkKnown import com.langchain.smith.core.checkRequired import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException +import com.langchain.smith.models.runs.RunTypeEnum import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -30,7 +31,7 @@ private constructor( private val dottedOrder: JsonField, private val name: JsonField, private val queueRunId: JsonField, - private val runType: JsonField, + private val runType: JsonField, private val sessionId: JsonField, private val status: JsonField, private val traceId: JsonField, @@ -98,7 +99,9 @@ private constructor( @JsonProperty("queue_run_id") @ExcludeMissing queueRunId: JsonField = JsonMissing.of(), - @JsonProperty("run_type") @ExcludeMissing runType: JsonField = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField = JsonMissing.of(), @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), @@ -331,7 +334,7 @@ private constructor( * @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 runType(): RunType = runType.getRequired("run_type") + fun runType(): RunTypeEnum = runType.getRequired("run_type") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -705,7 +708,7 @@ private constructor( * * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType /** * Returns the raw JSON value of [sessionId]. @@ -1195,7 +1198,7 @@ private constructor( private var dottedOrder: JsonField? = null private var name: JsonField? = null private var queueRunId: JsonField? = null - private var runType: JsonField? = null + private var runType: JsonField? = null private var sessionId: JsonField? = null private var status: JsonField? = null private var traceId: JsonField? = null @@ -1373,15 +1376,16 @@ private constructor( fun queueRunId(queueRunId: JsonField) = apply { this.queueRunId = queueRunId } /** Enum for run types. */ - fun runType(runType: RunType) = runType(JsonField.of(runType)) + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) /** * Sets [Builder.runType] to an arbitrary JSON value. * - * You should usually call [Builder.runType] with a well-typed [RunType] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun runType(runType: JsonField) = apply { this.runType = runType } + fun runType(runType: JsonField) = apply { this.runType = runType } fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) @@ -2539,164 +2543,6 @@ private constructor( (if (traceUpgrade.asKnown().isPresent) 1 else 0) + (if (ttlSeconds.asKnown().isPresent) 1 else 0) - /** Enum for run types. */ - class RunType @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 TOOL = of("tool") - - @JvmField val CHAIN = of("chain") - - @JvmField val LLM = of("llm") - - @JvmField val RETRIEVER = of("retriever") - - @JvmField val EMBEDDING = of("embedding") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PARSER = of("parser") - - @JvmStatic fun of(value: String) = RunType(JsonField.of(value)) - } - - /** An enum containing [RunType]'s known values. */ - enum class Known { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - } - - /** - * An enum containing [RunType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RunType] 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 { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - /** An enum member indicating that [RunType] 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) { - TOOL -> Value.TOOL - CHAIN -> Value.CHAIN - LLM -> Value.LLM - RETRIEVER -> Value.RETRIEVER - EMBEDDING -> Value.EMBEDDING - PROMPT -> Value.PROMPT - PARSER -> Value.PARSER - 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) { - TOOL -> Known.TOOL - CHAIN -> Known.CHAIN - LLM -> Known.LLM - RETRIEVER -> Known.RETRIEVER - EMBEDDING -> Known.EMBEDDING - PROMPT -> Known.PROMPT - PARSER -> Known.PARSER - else -> throw LangChainInvalidDataException("Unknown RunType: $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(): RunType = 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 RunType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - class CompletionCostDetails @JsonCreator private constructor( diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponse.kt index c456413b4..ed8a5a304 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponse.kt @@ -26,6 +26,7 @@ private constructor( private val version: JsonField, private val batchIngestConfig: JsonField, private val customerInfo: JsonField, + private val gitSha: JsonField, private val instanceFlags: JsonField, private val licenseExpirationTime: JsonField, private val additionalProperties: MutableMap, @@ -40,6 +41,7 @@ private constructor( @JsonProperty("customer_info") @ExcludeMissing customerInfo: JsonField = JsonMissing.of(), + @JsonProperty("git_sha") @ExcludeMissing gitSha: JsonField = JsonMissing.of(), @JsonProperty("instance_flags") @ExcludeMissing instanceFlags: JsonField = JsonMissing.of(), @@ -50,6 +52,7 @@ private constructor( version, batchIngestConfig, customerInfo, + gitSha, instanceFlags, licenseExpirationTime, mutableMapOf(), @@ -78,6 +81,12 @@ private constructor( */ fun customerInfo(): Optional = customerInfo.getOptional("customer_info") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gitSha(): Optional = gitSha.getOptional("git_sha") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -117,6 +126,13 @@ private constructor( @ExcludeMissing fun _customerInfo(): JsonField = customerInfo + /** + * Returns the raw JSON value of [gitSha]. + * + * Unlike [gitSha], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("git_sha") @ExcludeMissing fun _gitSha(): JsonField = gitSha + /** * Returns the raw JSON value of [instanceFlags]. * @@ -167,6 +183,7 @@ private constructor( private var version: JsonField? = null private var batchIngestConfig: JsonField = JsonMissing.of() private var customerInfo: JsonField = JsonMissing.of() + private var gitSha: JsonField = JsonMissing.of() private var instanceFlags: JsonField = JsonMissing.of() private var licenseExpirationTime: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -176,6 +193,7 @@ private constructor( version = infoListResponse.version batchIngestConfig = infoListResponse.batchIngestConfig customerInfo = infoListResponse.customerInfo + gitSha = infoListResponse.gitSha instanceFlags = infoListResponse.instanceFlags licenseExpirationTime = infoListResponse.licenseExpirationTime additionalProperties = infoListResponse.additionalProperties.toMutableMap() @@ -225,6 +243,19 @@ private constructor( this.customerInfo = customerInfo } + fun gitSha(gitSha: String?) = gitSha(JsonField.ofNullable(gitSha)) + + /** Alias for calling [Builder.gitSha] with `gitSha.orElse(null)`. */ + fun gitSha(gitSha: Optional) = gitSha(gitSha.getOrNull()) + + /** + * Sets [Builder.gitSha] to an arbitrary JSON value. + * + * You should usually call [Builder.gitSha] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun gitSha(gitSha: JsonField) = apply { this.gitSha = gitSha } + fun instanceFlags(instanceFlags: InstanceFlags) = instanceFlags(JsonField.of(instanceFlags)) /** @@ -295,6 +326,7 @@ private constructor( checkRequired("version", version), batchIngestConfig, customerInfo, + gitSha, instanceFlags, licenseExpirationTime, additionalProperties.toMutableMap(), @@ -311,6 +343,7 @@ private constructor( version() batchIngestConfig().ifPresent { it.validate() } customerInfo().ifPresent { it.validate() } + gitSha() instanceFlags().ifPresent { it.validate() } licenseExpirationTime() validated = true @@ -334,6 +367,7 @@ private constructor( (if (version.asKnown().isPresent) 1 else 0) + (batchIngestConfig.asKnown().getOrNull()?.validity() ?: 0) + (customerInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (gitSha.asKnown().isPresent) 1 else 0) + (instanceFlags.asKnown().getOrNull()?.validity() ?: 0) + (if (licenseExpirationTime.asKnown().isPresent) 1 else 0) @@ -1019,6 +1053,7 @@ private constructor( version == other.version && batchIngestConfig == other.batchIngestConfig && customerInfo == other.customerInfo && + gitSha == other.gitSha && instanceFlags == other.instanceFlags && licenseExpirationTime == other.licenseExpirationTime && additionalProperties == other.additionalProperties @@ -1029,6 +1064,7 @@ private constructor( version, batchIngestConfig, customerInfo, + gitSha, instanceFlags, licenseExpirationTime, additionalProperties, @@ -1038,5 +1074,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InfoListResponse{version=$version, batchIngestConfig=$batchIngestConfig, customerInfo=$customerInfo, instanceFlags=$instanceFlags, licenseExpirationTime=$licenseExpirationTime, additionalProperties=$additionalProperties}" + "InfoListResponse{version=$version, batchIngestConfig=$batchIngestConfig, customerInfo=$customerInfo, gitSha=$gitSha, instanceFlags=$instanceFlags, licenseExpirationTime=$licenseExpirationTime, additionalProperties=$additionalProperties}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParams.kt index afad240b3..849be9374 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParams.kt @@ -2,9 +2,13 @@ package com.langchain.smith.models.annotationqueues.runs +import com.fasterxml.jackson.annotation.JsonCreator +import com.langchain.smith.core.Enum +import com.langchain.smith.core.JsonField import com.langchain.smith.core.Params import com.langchain.smith.core.http.Headers import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -17,6 +21,7 @@ private constructor( private val includeStats: Boolean?, private val limit: Long?, private val offset: Long?, + private val status: Status?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -31,6 +36,8 @@ private constructor( fun offset(): Optional = Optional.ofNullable(offset) + fun status(): Optional = Optional.ofNullable(status) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -55,6 +62,7 @@ private constructor( private var includeStats: Boolean? = null private var limit: Long? = null private var offset: Long? = null + private var status: Status? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -65,6 +73,7 @@ private constructor( includeStats = runListParams.includeStats limit = runListParams.limit offset = runListParams.offset + status = runListParams.status additionalHeaders = runListParams.additionalHeaders.toBuilder() additionalQueryParams = runListParams.additionalQueryParams.toBuilder() } @@ -122,6 +131,11 @@ private constructor( /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ fun offset(offset: Optional) = offset(offset.getOrNull()) + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -232,6 +246,7 @@ private constructor( includeStats, limit, offset, + status, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -252,10 +267,144 @@ private constructor( includeStats?.let { put("include_stats", it.toString()) } limit?.let { put("limit", it.toString()) } offset?.let { put("offset", it.toString()) } + status?.let { put("status", it.toString()) } putAll(additionalQueryParams) } .build() + class Status @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 NEEDS_MY_REVIEW = of("needs_my_review") + + @JvmField val NEEDS_OTHERS_REVIEW = of("needs_others_review") + + @JvmField val COMPLETED = of("completed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + COMPLETED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + COMPLETED, + /** An enum member indicating that [Status] 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) { + NEEDS_MY_REVIEW -> Value.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Value.NEEDS_OTHERS_REVIEW + COMPLETED -> Value.COMPLETED + 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) { + NEEDS_MY_REVIEW -> Known.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Known.NEEDS_OTHERS_REVIEW + COMPLETED -> Known.COMPLETED + else -> throw LangChainInvalidDataException("Unknown Status: $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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -267,6 +416,7 @@ private constructor( includeStats == other.includeStats && limit == other.limit && offset == other.offset && + status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } @@ -278,10 +428,11 @@ private constructor( includeStats, limit, offset, + status, additionalHeaders, additionalQueryParams, ) override fun toString() = - "RunListParams{queueId=$queueId, archived=$archived, includeStats=$includeStats, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "RunListParams{queueId=$queueId, archived=$archived, includeStats=$includeStats, limit=$limit, offset=$offset, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 6e5aeae9b..31c9ce315 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 @@ -23,6 +23,7 @@ private constructor( private val includeStats: Boolean?, private val limit: Long?, private val offset: Long?, + private val tag: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -40,6 +41,9 @@ private constructor( /** Offset is the pagination offset */ fun offset(): Optional = Optional.ofNullable(offset) + /** Tag filters commits to only those with a specific tag (e.g. "production", "staging") */ + fun tag(): Optional = Optional.ofNullable(tag) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -69,6 +73,7 @@ private constructor( private var includeStats: Boolean? = null private var limit: Long? = null private var offset: Long? = null + private var tag: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -79,6 +84,7 @@ private constructor( includeStats = commitListParams.includeStats limit = commitListParams.limit offset = commitListParams.offset + tag = commitListParams.tag additionalHeaders = commitListParams.additionalHeaders.toBuilder() additionalQueryParams = commitListParams.additionalQueryParams.toBuilder() } @@ -129,6 +135,12 @@ private constructor( /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ fun offset(offset: Optional) = offset(offset.getOrNull()) + /** Tag filters commits to only those with a specific tag (e.g. "production", "staging") */ + fun tag(tag: String?) = apply { this.tag = tag } + + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ + fun tag(tag: Optional) = tag(tag.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -246,6 +258,7 @@ private constructor( includeStats, limit, offset, + tag, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -266,6 +279,7 @@ private constructor( includeStats?.let { put("include_stats", it.toString()) } limit?.let { put("limit", it.toString()) } offset?.let { put("offset", it.toString()) } + tag?.let { put("tag", it) } putAll(additionalQueryParams) } .build() @@ -281,6 +295,7 @@ private constructor( includeStats == other.includeStats && limit == other.limit && offset == other.offset && + tag == other.tag && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } @@ -292,10 +307,11 @@ private constructor( includeStats, limit, offset, + tag, additionalHeaders, additionalQueryParams, ) override fun toString() = - "CommitListParams{owner=$owner, repo=$repo, includeStats=$includeStats, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CommitListParams{owner=$owner, repo=$repo, includeStats=$includeStats, limit=$limit, offset=$offset, tag=$tag, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponse.kt index 933b7f27f..6a622a7da 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponse.kt @@ -24,6 +24,8 @@ private constructor( private val commitHash: JsonField, private val examples: JsonField>, private val manifest: JsonValue, + private val modelConfig: JsonValue, + private val modelProvider: JsonField, private val additionalProperties: MutableMap, ) { @@ -36,7 +38,11 @@ private constructor( @ExcludeMissing examples: JsonField> = JsonMissing.of(), @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), - ) : this(commitHash, examples, manifest, mutableMapOf()) + @JsonProperty("model_config") @ExcludeMissing modelConfig: JsonValue = JsonMissing.of(), + @JsonProperty("model_provider") + @ExcludeMissing + modelProvider: JsonField = JsonMissing.of(), + ) : this(commitHash, examples, manifest, modelConfig, modelProvider, mutableMapOf()) /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -58,6 +64,20 @@ private constructor( */ @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = commitRetrieveResponse.modelConfig().convert(MyClass.class); + * ``` + */ + @JsonProperty("model_config") @ExcludeMissing fun _modelConfig(): JsonValue = modelConfig + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modelProvider(): Optional = modelProvider.getOptional("model_provider") + /** * Returns the raw JSON value of [commitHash]. * @@ -72,6 +92,15 @@ private constructor( */ @JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField> = examples + /** + * Returns the raw JSON value of [modelProvider]. + * + * Unlike [modelProvider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model_provider") + @ExcludeMissing + fun _modelProvider(): JsonField = modelProvider + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -96,6 +125,8 @@ private constructor( private var commitHash: JsonField = JsonMissing.of() private var examples: JsonField>? = null private var manifest: JsonValue = JsonMissing.of() + private var modelConfig: JsonValue = JsonMissing.of() + private var modelProvider: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -103,6 +134,8 @@ private constructor( commitHash = commitRetrieveResponse.commitHash examples = commitRetrieveResponse.examples.map { it.toMutableList() } manifest = commitRetrieveResponse.manifest + modelConfig = commitRetrieveResponse.modelConfig + modelProvider = commitRetrieveResponse.modelProvider additionalProperties = commitRetrieveResponse.additionalProperties.toMutableMap() } @@ -144,6 +177,21 @@ private constructor( fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + fun modelConfig(modelConfig: JsonValue) = apply { this.modelConfig = modelConfig } + + fun modelProvider(modelProvider: String) = modelProvider(JsonField.of(modelProvider)) + + /** + * Sets [Builder.modelProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.modelProvider] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modelProvider(modelProvider: JsonField) = apply { + this.modelProvider = modelProvider + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -173,6 +221,8 @@ private constructor( commitHash, (examples ?: JsonMissing.of()).map { it.toImmutable() }, manifest, + modelConfig, + modelProvider, additionalProperties.toMutableMap(), ) } @@ -186,6 +236,7 @@ private constructor( commitHash() examples().ifPresent { it.forEach { it.validate() } } + modelProvider() validated = true } @@ -205,7 +256,8 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (commitHash.asKnown().isPresent) 1 else 0) + - (examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (modelProvider.asKnown().isPresent) 1 else 0) class Example @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -462,15 +514,24 @@ private constructor( commitHash == other.commitHash && examples == other.examples && manifest == other.manifest && + modelConfig == other.modelConfig && + modelProvider == other.modelProvider && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(commitHash, examples, manifest, additionalProperties) + Objects.hash( + commitHash, + examples, + manifest, + modelConfig, + modelProvider, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "CommitRetrieveResponse{commitHash=$commitHash, examples=$examples, manifest=$manifest, additionalProperties=$additionalProperties}" + "CommitRetrieveResponse{commitHash=$commitHash, examples=$examples, manifest=$manifest, modelConfig=$modelConfig, modelProvider=$modelProvider, additionalProperties=$additionalProperties}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListPage.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListPage.kt deleted file mode 100644 index e7242a5cb..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListPage.kt +++ /dev/null @@ -1,112 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.comparative - -import com.langchain.smith.core.AutoPager -import com.langchain.smith.core.Page -import com.langchain.smith.core.checkRequired -import com.langchain.smith.services.blocking.datasets.ComparativeService -import java.util.Objects -import kotlin.jvm.optionals.getOrDefault - -/** @see ComparativeService.list */ -class ComparativeListPage -private constructor( - private val service: ComparativeService, - private val params: ComparativeListParams, - private val items: List, -) : Page { - - override fun hasNextPage(): Boolean = items().isNotEmpty() - - fun nextPageParams(): ComparativeListParams { - val offset = params.offset().getOrDefault(0) - return params.toBuilder().offset(offset + items().size).build() - } - - override fun nextPage(): ComparativeListPage = service.list(nextPageParams()) - - fun autoPager(): AutoPager = AutoPager.from(this) - - /** The parameters that were used to request this page. */ - fun params(): ComparativeListParams = params - - /** The response that this page was parsed from. */ - override fun items(): List = items - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ComparativeListPage]. - * - * The following fields are required: - * ```java - * .service() - * .params() - * .items() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ComparativeListPage]. */ - class Builder internal constructor() { - - private var service: ComparativeService? = null - private var params: ComparativeListParams? = null - private var items: List? = null - - @JvmSynthetic - internal fun from(comparativeListPage: ComparativeListPage) = apply { - service = comparativeListPage.service - params = comparativeListPage.params - items = comparativeListPage.items - } - - fun service(service: ComparativeService) = apply { this.service = service } - - /** The parameters that were used to request this page. */ - fun params(params: ComparativeListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun items(items: List) = apply { this.items = items } - - /** - * Returns an immutable instance of [ComparativeListPage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .service() - * .params() - * .items() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ComparativeListPage = - ComparativeListPage( - checkRequired("service", service), - checkRequired("params", params), - checkRequired("items", items), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ComparativeListPage && - service == other.service && - params == other.params && - items == other.items - } - - override fun hashCode(): Int = Objects.hash(service, params, items) - - override fun toString() = "ComparativeListPage{service=$service, params=$params, items=$items}" -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListPageAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListPageAsync.kt deleted file mode 100644 index 5c0bf34c2..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListPageAsync.kt +++ /dev/null @@ -1,128 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.comparative - -import com.langchain.smith.core.AutoPagerAsync -import com.langchain.smith.core.PageAsync -import com.langchain.smith.core.checkRequired -import com.langchain.smith.services.async.datasets.ComparativeServiceAsync -import java.util.Objects -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import kotlin.jvm.optionals.getOrDefault - -/** @see ComparativeServiceAsync.list */ -class ComparativeListPageAsync -private constructor( - private val service: ComparativeServiceAsync, - private val streamHandlerExecutor: Executor, - private val params: ComparativeListParams, - private val items: List, -) : PageAsync { - - override fun hasNextPage(): Boolean = items().isNotEmpty() - - fun nextPageParams(): ComparativeListParams { - val offset = params.offset().getOrDefault(0) - return params.toBuilder().offset(offset + items().size).build() - } - - override fun nextPage(): CompletableFuture = - service.list(nextPageParams()) - - fun autoPager(): AutoPagerAsync = - AutoPagerAsync.from(this, streamHandlerExecutor) - - /** The parameters that were used to request this page. */ - fun params(): ComparativeListParams = params - - /** The response that this page was parsed from. */ - override fun items(): List = items - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ComparativeListPageAsync]. - * - * The following fields are required: - * ```java - * .service() - * .streamHandlerExecutor() - * .params() - * .items() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ComparativeListPageAsync]. */ - class Builder internal constructor() { - - private var service: ComparativeServiceAsync? = null - private var streamHandlerExecutor: Executor? = null - private var params: ComparativeListParams? = null - private var items: List? = null - - @JvmSynthetic - internal fun from(comparativeListPageAsync: ComparativeListPageAsync) = apply { - service = comparativeListPageAsync.service - streamHandlerExecutor = comparativeListPageAsync.streamHandlerExecutor - params = comparativeListPageAsync.params - items = comparativeListPageAsync.items - } - - fun service(service: ComparativeServiceAsync) = apply { this.service = service } - - fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { - this.streamHandlerExecutor = streamHandlerExecutor - } - - /** The parameters that were used to request this page. */ - fun params(params: ComparativeListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun items(items: List) = apply { this.items = items } - - /** - * Returns an immutable instance of [ComparativeListPageAsync]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .service() - * .streamHandlerExecutor() - * .params() - * .items() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ComparativeListPageAsync = - ComparativeListPageAsync( - checkRequired("service", service), - checkRequired("streamHandlerExecutor", streamHandlerExecutor), - checkRequired("params", params), - checkRequired("items", items), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ComparativeListPageAsync && - service == other.service && - streamHandlerExecutor == other.streamHandlerExecutor && - params == other.params && - items == other.items - } - - override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, items) - - override fun toString() = - "ComparativeListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, items=$items}" -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListParams.kt deleted file mode 100644 index e9de87387..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListParams.kt +++ /dev/null @@ -1,332 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.comparative - -import com.langchain.smith.core.Params -import com.langchain.smith.core.http.Headers -import com.langchain.smith.core.http.QueryParams -import com.langchain.smith.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get all comparative experiments for a given dataset. */ -class ComparativeListParams -private constructor( - private val datasetId: String?, - private val id: List?, - private val limit: Long?, - private val name: String?, - private val nameContains: String?, - private val offset: Long?, - private val sortBy: SortByComparativeExperimentColumn?, - private val sortByDesc: Boolean?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun datasetId(): Optional = Optional.ofNullable(datasetId) - - fun id(): Optional> = Optional.ofNullable(id) - - fun limit(): Optional = Optional.ofNullable(limit) - - fun name(): Optional = Optional.ofNullable(name) - - fun nameContains(): Optional = Optional.ofNullable(nameContains) - - fun offset(): Optional = Optional.ofNullable(offset) - - /** Enum for available comparative experiment columns to sort by. */ - fun sortBy(): Optional = Optional.ofNullable(sortBy) - - fun sortByDesc(): Optional = Optional.ofNullable(sortByDesc) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ComparativeListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ComparativeListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ComparativeListParams]. */ - class Builder internal constructor() { - - private var datasetId: String? = null - private var id: MutableList? = null - private var limit: Long? = null - private var name: String? = null - private var nameContains: String? = null - private var offset: Long? = null - private var sortBy: SortByComparativeExperimentColumn? = null - private var sortByDesc: Boolean? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(comparativeListParams: ComparativeListParams) = apply { - datasetId = comparativeListParams.datasetId - id = comparativeListParams.id?.toMutableList() - limit = comparativeListParams.limit - name = comparativeListParams.name - nameContains = comparativeListParams.nameContains - offset = comparativeListParams.offset - sortBy = comparativeListParams.sortBy - sortByDesc = comparativeListParams.sortByDesc - additionalHeaders = comparativeListParams.additionalHeaders.toBuilder() - additionalQueryParams = comparativeListParams.additionalQueryParams.toBuilder() - } - - fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } - - /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) - - fun id(id: List?) = apply { this.id = id?.toMutableList() } - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional>) = id(id.getOrNull()) - - /** - * Adds a single [String] to [Builder.id]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } - - fun limit(limit: Long?) = apply { this.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()) - - fun name(name: String?) = apply { this.name = name } - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } - - /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ - fun nameContains(nameContains: Optional) = nameContains(nameContains.getOrNull()) - - fun offset(offset: Long?) = apply { this.offset = offset } - - /** - * Alias for [Builder.offset]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun offset(offset: Long) = offset(offset as Long?) - - /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ - fun offset(offset: Optional) = offset(offset.getOrNull()) - - /** Enum for available comparative experiment columns to sort by. */ - fun sortBy(sortBy: SortByComparativeExperimentColumn?) = apply { this.sortBy = sortBy } - - /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ - fun sortBy(sortBy: Optional) = sortBy(sortBy.getOrNull()) - - fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } - - /** - * Alias for [Builder.sortByDesc]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) - - /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ - fun sortByDesc(sortByDesc: Optional) = sortByDesc(sortByDesc.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ComparativeListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ComparativeListParams = - ComparativeListParams( - datasetId, - id?.toImmutable(), - limit, - name, - nameContains, - offset, - sortBy, - sortByDesc, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> datasetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - id?.let { put("id", it.joinToString(",")) } - limit?.let { put("limit", it.toString()) } - name?.let { put("name", it) } - nameContains?.let { put("name_contains", it) } - offset?.let { put("offset", it.toString()) } - sortBy?.let { put("sort_by", it.toString()) } - sortByDesc?.let { put("sort_by_desc", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ComparativeListParams && - datasetId == other.datasetId && - id == other.id && - limit == other.limit && - name == other.name && - nameContains == other.nameContains && - offset == other.offset && - sortBy == other.sortBy && - sortByDesc == other.sortByDesc && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - datasetId, - id, - limit, - name, - nameContains, - offset, - sortBy, - sortByDesc, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "ComparativeListParams{datasetId=$datasetId, id=$id, limit=$limit, name=$name, nameContains=$nameContains, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponse.kt deleted file mode 100644 index a52a32302..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponse.kt +++ /dev/null @@ -1,757 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.comparative - -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.ExcludeMissing -import com.langchain.smith.core.JsonField -import com.langchain.smith.core.JsonMissing -import com.langchain.smith.core.JsonValue -import com.langchain.smith.core.checkKnown -import com.langchain.smith.core.checkRequired -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 - -/** ComparativeExperiment schema. */ -class ComparativeListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val createdAt: JsonField, - private val experimentsInfo: JsonField>, - private val modifiedAt: JsonField, - private val referenceDatasetId: JsonField, - private val tenantId: JsonField, - private val description: JsonField, - private val extra: JsonField, - private val feedbackStats: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("experiments_info") - @ExcludeMissing - experimentsInfo: JsonField> = JsonMissing.of(), - @JsonProperty("modified_at") - @ExcludeMissing - modifiedAt: JsonField = JsonMissing.of(), - @JsonProperty("reference_dataset_id") - @ExcludeMissing - referenceDatasetId: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), - @JsonProperty("feedback_stats") - @ExcludeMissing - feedbackStats: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this( - id, - createdAt, - experimentsInfo, - modifiedAt, - referenceDatasetId, - tenantId, - description, - extra, - feedbackStats, - name, - 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 id(): String = id.getRequired("id") - - /** - * @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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * @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 experimentsInfo(): List = - experimentsInfo.getRequired("experiments_info") - - /** - * @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 modifiedAt(): OffsetDateTime = modifiedAt.getRequired("modified_at") - - /** - * @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 referenceDatasetId(): String = referenceDatasetId.getRequired("reference_dataset_id") - - /** - * @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 tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun extra(): Optional = extra.getOptional("extra") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [experimentsInfo]. - * - * Unlike [experimentsInfo], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("experiments_info") - @ExcludeMissing - fun _experimentsInfo(): JsonField> = experimentsInfo - - /** - * Returns the raw JSON value of [modifiedAt]. - * - * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("modified_at") - @ExcludeMissing - fun _modifiedAt(): JsonField = modifiedAt - - /** - * Returns the raw JSON value of [referenceDatasetId]. - * - * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reference_dataset_id") - @ExcludeMissing - fun _referenceDatasetId(): JsonField = referenceDatasetId - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [extra]. - * - * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra - - /** - * Returns the raw JSON value of [feedbackStats]. - * - * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("feedback_stats") - @ExcludeMissing - fun _feedbackStats(): JsonField = feedbackStats - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @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 [ComparativeListResponse]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .experimentsInfo() - * .modifiedAt() - * .referenceDatasetId() - * .tenantId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ComparativeListResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var experimentsInfo: JsonField>? = null - private var modifiedAt: JsonField? = null - private var referenceDatasetId: JsonField? = null - private var tenantId: JsonField? = null - private var description: JsonField = JsonMissing.of() - private var extra: JsonField = JsonMissing.of() - private var feedbackStats: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(comparativeListResponse: ComparativeListResponse) = apply { - id = comparativeListResponse.id - createdAt = comparativeListResponse.createdAt - experimentsInfo = comparativeListResponse.experimentsInfo.map { it.toMutableList() } - modifiedAt = comparativeListResponse.modifiedAt - referenceDatasetId = comparativeListResponse.referenceDatasetId - tenantId = comparativeListResponse.tenantId - description = comparativeListResponse.description - extra = comparativeListResponse.extra - feedbackStats = comparativeListResponse.feedbackStats - name = comparativeListResponse.name - additionalProperties = comparativeListResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - fun experimentsInfo(experimentsInfo: List) = - experimentsInfo(JsonField.of(experimentsInfo)) - - /** - * Sets [Builder.experimentsInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.experimentsInfo] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun experimentsInfo(experimentsInfo: JsonField>) = apply { - this.experimentsInfo = experimentsInfo.map { it.toMutableList() } - } - - /** - * Adds a single [SimpleExperimentInfo] to [Builder.experimentsInfo]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExperimentsInfo(experimentsInfo: SimpleExperimentInfo) = apply { - this.experimentsInfo = - (this.experimentsInfo ?: JsonField.of(mutableListOf())).also { - checkKnown("experimentsInfo", it).add(experimentsInfo) - } - } - - fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) - - /** - * Sets [Builder.modifiedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modifiedAt(modifiedAt: JsonField) = apply { - this.modifiedAt = modifiedAt - } - - fun referenceDatasetId(referenceDatasetId: String) = - referenceDatasetId(JsonField.of(referenceDatasetId)) - - /** - * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun referenceDatasetId(referenceDatasetId: JsonField) = apply { - this.referenceDatasetId = referenceDatasetId - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun description(description: JsonField) = apply { this.description = description } - - fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - - /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ - fun extra(extra: Optional) = extra(extra.getOrNull()) - - /** - * Sets [Builder.extra] to an arbitrary JSON value. - * - * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun extra(extra: JsonField) = apply { this.extra = extra } - - fun feedbackStats(feedbackStats: FeedbackStats?) = - feedbackStats(JsonField.ofNullable(feedbackStats)) - - /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ - fun feedbackStats(feedbackStats: Optional) = - feedbackStats(feedbackStats.getOrNull()) - - /** - * Sets [Builder.feedbackStats] to an arbitrary JSON value. - * - * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun feedbackStats(feedbackStats: JsonField) = apply { - this.feedbackStats = feedbackStats - } - - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - 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 [ComparativeListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .experimentsInfo() - * .modifiedAt() - * .referenceDatasetId() - * .tenantId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ComparativeListResponse = - ComparativeListResponse( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("experimentsInfo", experimentsInfo).map { it.toImmutable() }, - checkRequired("modifiedAt", modifiedAt), - checkRequired("referenceDatasetId", referenceDatasetId), - checkRequired("tenantId", tenantId), - description, - extra, - feedbackStats, - name, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ComparativeListResponse = apply { - if (validated) { - return@apply - } - - id() - createdAt() - experimentsInfo().forEach { it.validate() } - modifiedAt() - referenceDatasetId() - tenantId() - description() - extra().ifPresent { it.validate() } - feedbackStats().ifPresent { it.validate() } - name() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (experimentsInfo.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (modifiedAt.asKnown().isPresent) 1 else 0) + - (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (extra.asKnown().getOrNull()?.validity() ?: 0) + - (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) - - class Extra - @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 [Extra]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Extra]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(extra: Extra) = apply { - additionalProperties = extra.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 [Extra]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Extra = Extra(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Extra = 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 Extra && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Extra{additionalProperties=$additionalProperties}" - } - - class FeedbackStats - @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 [FeedbackStats]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FeedbackStats]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedbackStats: FeedbackStats) = apply { - additionalProperties = feedbackStats.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 [FeedbackStats]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): FeedbackStats = 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 FeedbackStats && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ComparativeListResponse && - id == other.id && - createdAt == other.createdAt && - experimentsInfo == other.experimentsInfo && - modifiedAt == other.modifiedAt && - referenceDatasetId == other.referenceDatasetId && - tenantId == other.tenantId && - description == other.description && - extra == other.extra && - feedbackStats == other.feedbackStats && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - createdAt, - experimentsInfo, - modifiedAt, - referenceDatasetId, - tenantId, - description, - extra, - feedbackStats, - name, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ComparativeListResponse{id=$id, createdAt=$createdAt, experimentsInfo=$experimentsInfo, modifiedAt=$modifiedAt, referenceDatasetId=$referenceDatasetId, tenantId=$tenantId, description=$description, extra=$extra, feedbackStats=$feedbackStats, name=$name, additionalProperties=$additionalProperties}" -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt index 2cab7cc36..3ac47f55d 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponse.kt @@ -219,7 +219,7 @@ private constructor( * - latency_p50, latency_p99: aggregate latency stats across sessions * - feedback_stats: weighted average feedback across sessions * - * Additional aggregate stats (from ExampleWithRunsGroup): + * Additional aggregate stats: * - prompt_tokens, completion_tokens: separate token counts * - prompt_cost, completion_cost: separate costs * - error_rate: average error rate diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexCreateParams.kt deleted file mode 100644 index 870d7db50..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexCreateParams.kt +++ /dev/null @@ -1,408 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.index - -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.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.http.Headers -import com.langchain.smith.core.http.QueryParams -import com.langchain.smith.errors.LangChainInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Index a dataset. */ -class IndexCreateParams -private constructor( - private val datasetId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun datasetId(): Optional = Optional.ofNullable(datasetId) - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tag(): Optional = body.tag() - - /** - * Returns the raw JSON value of [tag]. - * - * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _tag(): JsonField = body._tag() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): IndexCreateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [IndexCreateParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [IndexCreateParams]. */ - class Builder internal constructor() { - - private var datasetId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(indexCreateParams: IndexCreateParams) = apply { - datasetId = indexCreateParams.datasetId - body = indexCreateParams.body.toBuilder() - additionalHeaders = indexCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = indexCreateParams.additionalQueryParams.toBuilder() - } - - fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } - - /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.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: - * - [tag] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun tag(tag: String?) = apply { body.tag(tag) } - - /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ - fun tag(tag: Optional) = tag(tag.getOrNull()) - - /** - * Sets [Builder.tag] to an arbitrary JSON value. - * - * You should usually call [Builder.tag] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tag(tag: JsonField) = apply { body.tag(tag) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - 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) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [IndexCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): IndexCreateParams = - IndexCreateParams( - datasetId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> datasetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - /** Dataset schema for serving. */ - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tag: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tag") @ExcludeMissing tag: JsonField = JsonMissing.of() - ) : this(tag, mutableMapOf()) - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun tag(): Optional = tag.getOptional("tag") - - /** - * Returns the raw JSON value of [tag]. - * - * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField = tag - - @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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var tag: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - tag = body.tag - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) - - /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ - fun tag(tag: Optional) = tag(tag.getOrNull()) - - /** - * Sets [Builder.tag] to an arbitrary JSON value. - * - * You should usually call [Builder.tag] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tag(tag: JsonField) = apply { this.tag = tag } - - 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. - */ - fun build(): Body = Body(tag, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - tag() - 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 (tag.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - tag == other.tag && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(tag, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{tag=$tag, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is IndexCreateParams && - datasetId == other.datasetId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "IndexCreateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRuns.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRuns.kt deleted file mode 100644 index 4c2a2aae1..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRuns.kt +++ /dev/null @@ -1,5280 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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.checkKnown -import com.langchain.smith.core.checkRequired -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 - -/** Example schema with list of runs. */ -class ExampleWithRuns -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val datasetId: JsonField, - private val inputs: JsonField, - private val name: JsonField, - private val runs: JsonField>, - private val attachmentUrls: JsonField, - private val createdAt: JsonField, - private val metadata: JsonField, - private val modifiedAt: JsonField, - private val outputs: JsonField, - private val sourceRunId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("runs") @ExcludeMissing runs: JsonField> = JsonMissing.of(), - @JsonProperty("attachment_urls") - @ExcludeMissing - attachmentUrls: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("modified_at") - @ExcludeMissing - modifiedAt: JsonField = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), - @JsonProperty("source_run_id") - @ExcludeMissing - sourceRunId: JsonField = JsonMissing.of(), - ) : this( - id, - datasetId, - inputs, - name, - runs, - attachmentUrls, - createdAt, - metadata, - modifiedAt, - outputs, - sourceRunId, - 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 id(): String = id.getRequired("id") - - /** - * @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 datasetId(): String = datasetId.getRequired("dataset_id") - - /** - * @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 inputs(): Inputs = inputs.getRequired("inputs") - - /** - * @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 name(): String = name.getRequired("name") - - /** - * @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 runs(): List = runs.getRequired("runs") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attachmentUrls(): Optional = attachmentUrls.getOptional("attachment_urls") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun createdAt(): Optional = createdAt.getOptional("created_at") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun modifiedAt(): Optional = modifiedAt.getOptional("modified_at") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun outputs(): Optional = outputs.getOptional("outputs") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun sourceRunId(): Optional = sourceRunId.getOptional("source_run_id") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [datasetId]. - * - * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId - - /** - * Returns the raw JSON value of [inputs]. - * - * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [runs]. - * - * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField> = runs - - /** - * Returns the raw JSON value of [attachmentUrls]. - * - * Unlike [attachmentUrls], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("attachment_urls") - @ExcludeMissing - fun _attachmentUrls(): JsonField = attachmentUrls - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [modifiedAt]. - * - * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("modified_at") - @ExcludeMissing - fun _modifiedAt(): JsonField = modifiedAt - - /** - * Returns the raw JSON value of [outputs]. - * - * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs - - /** - * Returns the raw JSON value of [sourceRunId]. - * - * Unlike [sourceRunId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source_run_id") - @ExcludeMissing - fun _sourceRunId(): JsonField = sourceRunId - - @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 [ExampleWithRuns]. - * - * The following fields are required: - * ```java - * .id() - * .datasetId() - * .inputs() - * .name() - * .runs() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExampleWithRuns]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var datasetId: JsonField? = null - private var inputs: JsonField? = null - private var name: JsonField? = null - private var runs: JsonField>? = null - private var attachmentUrls: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var modifiedAt: JsonField = JsonMissing.of() - private var outputs: JsonField = JsonMissing.of() - private var sourceRunId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(exampleWithRuns: ExampleWithRuns) = apply { - id = exampleWithRuns.id - datasetId = exampleWithRuns.datasetId - inputs = exampleWithRuns.inputs - name = exampleWithRuns.name - runs = exampleWithRuns.runs.map { it.toMutableList() } - attachmentUrls = exampleWithRuns.attachmentUrls - createdAt = exampleWithRuns.createdAt - metadata = exampleWithRuns.metadata - modifiedAt = exampleWithRuns.modifiedAt - outputs = exampleWithRuns.outputs - sourceRunId = exampleWithRuns.sourceRunId - additionalProperties = exampleWithRuns.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - - /** - * Sets [Builder.datasetId] to an arbitrary JSON value. - * - * You should usually call [Builder.datasetId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - - fun inputs(inputs: Inputs) = inputs(JsonField.of(inputs)) - - /** - * Sets [Builder.inputs] to an arbitrary JSON value. - * - * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun inputs(inputs: JsonField) = apply { this.inputs = inputs } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun runs(runs: List) = runs(JsonField.of(runs)) - - /** - * Sets [Builder.runs] to an arbitrary JSON value. - * - * You should usually call [Builder.runs] with a well-typed `List` value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun runs(runs: JsonField>) = apply { this.runs = runs.map { it.toMutableList() } } - - /** - * Adds a single [Run] to [runs]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRun(run: Run) = apply { - runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } - } - - fun attachmentUrls(attachmentUrls: AttachmentUrls?) = - attachmentUrls(JsonField.ofNullable(attachmentUrls)) - - /** Alias for calling [Builder.attachmentUrls] with `attachmentUrls.orElse(null)`. */ - fun attachmentUrls(attachmentUrls: Optional) = - attachmentUrls(attachmentUrls.getOrNull()) - - /** - * Sets [Builder.attachmentUrls] to an arbitrary JSON value. - * - * You should usually call [Builder.attachmentUrls] with a well-typed [AttachmentUrls] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attachmentUrls(attachmentUrls: JsonField) = apply { - this.attachmentUrls = attachmentUrls - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) - - /** Alias for calling [Builder.modifiedAt] with `modifiedAt.orElse(null)`. */ - fun modifiedAt(modifiedAt: Optional) = modifiedAt(modifiedAt.getOrNull()) - - /** - * Sets [Builder.modifiedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modifiedAt(modifiedAt: JsonField) = apply { - this.modifiedAt = modifiedAt - } - - fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) - - /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ - fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) - - /** - * Sets [Builder.outputs] to an arbitrary JSON value. - * - * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun outputs(outputs: JsonField) = apply { this.outputs = outputs } - - fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) - - /** Alias for calling [Builder.sourceRunId] with `sourceRunId.orElse(null)`. */ - fun sourceRunId(sourceRunId: Optional) = sourceRunId(sourceRunId.getOrNull()) - - /** - * Sets [Builder.sourceRunId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceRunId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun sourceRunId(sourceRunId: JsonField) = apply { this.sourceRunId = sourceRunId } - - 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 [ExampleWithRuns]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .datasetId() - * .inputs() - * .name() - * .runs() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ExampleWithRuns = - ExampleWithRuns( - checkRequired("id", id), - checkRequired("datasetId", datasetId), - checkRequired("inputs", inputs), - checkRequired("name", name), - checkRequired("runs", runs).map { it.toImmutable() }, - attachmentUrls, - createdAt, - metadata, - modifiedAt, - outputs, - sourceRunId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ExampleWithRuns = apply { - if (validated) { - return@apply - } - - id() - datasetId() - inputs().validate() - name() - runs().forEach { it.validate() } - attachmentUrls().ifPresent { it.validate() } - createdAt() - metadata().ifPresent { it.validate() } - modifiedAt() - outputs().ifPresent { it.validate() } - sourceRunId() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (datasetId.asKnown().isPresent) 1 else 0) + - (inputs.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (attachmentUrls.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (modifiedAt.asKnown().isPresent) 1 else 0) + - (outputs.asKnown().getOrNull()?.validity() ?: 0) + - (if (sourceRunId.asKnown().isPresent) 1 else 0) - - class Inputs - @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 [Inputs]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Inputs]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inputs: Inputs) = apply { - additionalProperties = inputs.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 [Inputs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Inputs = Inputs(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Inputs = 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 Inputs && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Inputs{additionalProperties=$additionalProperties}" - } - - /** Run schema. */ - class Run - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val appPath: JsonField, - private val dottedOrder: JsonField, - private val name: JsonField, - private val runType: JsonField, - private val sessionId: JsonField, - private val status: JsonField, - private val traceId: JsonField, - private val childRunIds: JsonField>, - private val completionCost: JsonField, - private val completionCostDetails: JsonField, - private val completionTokenDetails: JsonField, - private val completionTokens: JsonField, - private val directChildRunIds: JsonField>, - private val endTime: JsonField, - private val error: JsonField, - private val events: JsonField>, - private val executionOrder: JsonField, - private val extra: JsonField, - private val feedbackStats: JsonField, - private val firstTokenTime: JsonField, - private val inDataset: JsonField, - private val inputs: JsonField, - private val inputsPreview: JsonField, - private val inputsS3Urls: JsonField, - private val lastQueuedAt: JsonField, - private val manifestId: JsonField, - private val manifestS3Id: JsonField, - private val messages: JsonField>, - private val outputs: JsonField, - private val outputsPreview: JsonField, - private val outputsS3Urls: JsonField, - private val parentRunId: JsonField, - private val parentRunIds: JsonField>, - private val priceModelId: JsonField, - private val promptCost: JsonField, - private val promptCostDetails: JsonField, - private val promptTokenDetails: JsonField, - private val promptTokens: JsonField, - private val referenceDatasetId: JsonField, - private val referenceExampleId: JsonField, - private val s3Urls: JsonField, - private val serialized: JsonField, - private val shareToken: JsonField, - private val startTime: JsonField, - private val tags: JsonField>, - private val threadId: JsonField, - private val totalCost: JsonField, - private val totalTokens: JsonField, - private val traceFirstReceivedAt: JsonField, - private val traceMaxStartTime: JsonField, - private val traceMinStartTime: JsonField, - private val traceTier: JsonField, - private val traceUpgrade: JsonField, - private val ttlSeconds: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("app_path") @ExcludeMissing appPath: JsonField = JsonMissing.of(), - @JsonProperty("dotted_order") - @ExcludeMissing - dottedOrder: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("run_type") - @ExcludeMissing - runType: JsonField = JsonMissing.of(), - @JsonProperty("session_id") - @ExcludeMissing - sessionId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), - @JsonProperty("child_run_ids") - @ExcludeMissing - childRunIds: JsonField> = JsonMissing.of(), - @JsonProperty("completion_cost") - @ExcludeMissing - completionCost: JsonField = JsonMissing.of(), - @JsonProperty("completion_cost_details") - @ExcludeMissing - completionCostDetails: JsonField = JsonMissing.of(), - @JsonProperty("completion_token_details") - @ExcludeMissing - completionTokenDetails: JsonField = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - completionTokens: JsonField = JsonMissing.of(), - @JsonProperty("direct_child_run_ids") - @ExcludeMissing - directChildRunIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_time") - @ExcludeMissing - endTime: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("events") - @ExcludeMissing - events: JsonField> = JsonMissing.of(), - @JsonProperty("execution_order") - @ExcludeMissing - executionOrder: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), - @JsonProperty("feedback_stats") - @ExcludeMissing - feedbackStats: JsonField = JsonMissing.of(), - @JsonProperty("first_token_time") - @ExcludeMissing - firstTokenTime: JsonField = JsonMissing.of(), - @JsonProperty("in_dataset") - @ExcludeMissing - inDataset: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), - @JsonProperty("inputs_preview") - @ExcludeMissing - inputsPreview: JsonField = JsonMissing.of(), - @JsonProperty("inputs_s3_urls") - @ExcludeMissing - inputsS3Urls: JsonField = JsonMissing.of(), - @JsonProperty("last_queued_at") - @ExcludeMissing - lastQueuedAt: JsonField = JsonMissing.of(), - @JsonProperty("manifest_id") - @ExcludeMissing - manifestId: JsonField = JsonMissing.of(), - @JsonProperty("manifest_s3_id") - @ExcludeMissing - manifestS3Id: JsonField = JsonMissing.of(), - @JsonProperty("messages") - @ExcludeMissing - messages: JsonField> = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), - @JsonProperty("outputs_preview") - @ExcludeMissing - outputsPreview: JsonField = JsonMissing.of(), - @JsonProperty("outputs_s3_urls") - @ExcludeMissing - outputsS3Urls: JsonField = JsonMissing.of(), - @JsonProperty("parent_run_id") - @ExcludeMissing - parentRunId: JsonField = JsonMissing.of(), - @JsonProperty("parent_run_ids") - @ExcludeMissing - parentRunIds: JsonField> = JsonMissing.of(), - @JsonProperty("price_model_id") - @ExcludeMissing - priceModelId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_cost") - @ExcludeMissing - promptCost: JsonField = JsonMissing.of(), - @JsonProperty("prompt_cost_details") - @ExcludeMissing - promptCostDetails: JsonField = JsonMissing.of(), - @JsonProperty("prompt_token_details") - @ExcludeMissing - promptTokenDetails: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("reference_dataset_id") - @ExcludeMissing - referenceDatasetId: JsonField = JsonMissing.of(), - @JsonProperty("reference_example_id") - @ExcludeMissing - referenceExampleId: JsonField = JsonMissing.of(), - @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonField = JsonMissing.of(), - @JsonProperty("serialized") - @ExcludeMissing - serialized: JsonField = JsonMissing.of(), - @JsonProperty("share_token") - @ExcludeMissing - shareToken: JsonField = JsonMissing.of(), - @JsonProperty("start_time") - @ExcludeMissing - startTime: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), - @JsonProperty("thread_id") - @ExcludeMissing - threadId: JsonField = JsonMissing.of(), - @JsonProperty("total_cost") - @ExcludeMissing - totalCost: JsonField = JsonMissing.of(), - @JsonProperty("total_tokens") - @ExcludeMissing - totalTokens: JsonField = JsonMissing.of(), - @JsonProperty("trace_first_received_at") - @ExcludeMissing - traceFirstReceivedAt: JsonField = JsonMissing.of(), - @JsonProperty("trace_max_start_time") - @ExcludeMissing - traceMaxStartTime: JsonField = JsonMissing.of(), - @JsonProperty("trace_min_start_time") - @ExcludeMissing - traceMinStartTime: JsonField = JsonMissing.of(), - @JsonProperty("trace_tier") - @ExcludeMissing - traceTier: JsonField = JsonMissing.of(), - @JsonProperty("trace_upgrade") - @ExcludeMissing - traceUpgrade: JsonField = JsonMissing.of(), - @JsonProperty("ttl_seconds") - @ExcludeMissing - ttlSeconds: JsonField = JsonMissing.of(), - ) : this( - id, - appPath, - dottedOrder, - name, - runType, - sessionId, - status, - traceId, - childRunIds, - completionCost, - completionCostDetails, - completionTokenDetails, - completionTokens, - directChildRunIds, - endTime, - error, - events, - executionOrder, - extra, - feedbackStats, - firstTokenTime, - inDataset, - inputs, - inputsPreview, - inputsS3Urls, - lastQueuedAt, - manifestId, - manifestS3Id, - messages, - outputs, - outputsPreview, - outputsS3Urls, - parentRunId, - parentRunIds, - priceModelId, - promptCost, - promptCostDetails, - promptTokenDetails, - promptTokens, - referenceDatasetId, - referenceExampleId, - s3Urls, - serialized, - shareToken, - startTime, - tags, - threadId, - totalCost, - totalTokens, - traceFirstReceivedAt, - traceMaxStartTime, - traceMinStartTime, - traceTier, - traceUpgrade, - ttlSeconds, - 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 id(): String = id.getRequired("id") - - /** - * @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 appPath(): String = appPath.getRequired("app_path") - - /** - * @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 dottedOrder(): String = dottedOrder.getRequired("dotted_order") - - /** - * @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 name(): String = name.getRequired("name") - - /** - * Enum for run types. - * - * @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 runType(): RunType = runType.getRequired("run_type") - - /** - * @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 sessionId(): String = sessionId.getRequired("session_id") - - /** - * @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 status(): String = status.getRequired("status") - - /** - * @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 traceId(): String = traceId.getRequired("trace_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun childRunIds(): Optional> = childRunIds.getOptional("child_run_ids") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionCost(): Optional = completionCost.getOptional("completion_cost") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionCostDetails(): Optional = - completionCostDetails.getOptional("completion_cost_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionTokenDetails(): Optional = - completionTokenDetails.getOptional("completion_token_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun directChildRunIds(): Optional> = - directChildRunIds.getOptional("direct_child_run_ids") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endTime(): Optional = endTime.getOptional("end_time") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun error(): Optional = error.getOptional("error") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun events(): Optional> = events.getOptional("events") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun executionOrder(): Optional = executionOrder.getOptional("execution_order") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun extra(): Optional = extra.getOptional("extra") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun firstTokenTime(): Optional = - firstTokenTime.getOptional("first_token_time") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inDataset(): Optional = inDataset.getOptional("in_dataset") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inputs(): Optional = inputs.getOptional("inputs") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inputsS3Urls(): Optional = inputsS3Urls.getOptional("inputs_s3_urls") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun lastQueuedAt(): Optional = lastQueuedAt.getOptional("last_queued_at") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun manifestId(): Optional = manifestId.getOptional("manifest_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun messages(): Optional> = messages.getOptional("messages") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun outputs(): Optional = outputs.getOptional("outputs") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun outputsS3Urls(): Optional = outputsS3Urls.getOptional("outputs_s3_urls") - - /** - * @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 parentRunIds(): Optional> = parentRunIds.getOptional("parent_run_ids") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun priceModelId(): Optional = priceModelId.getOptional("price_model_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptCost(): Optional = promptCost.getOptional("prompt_cost") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptCostDetails(): Optional = - promptCostDetails.getOptional("prompt_cost_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptTokenDetails(): Optional = - promptTokenDetails.getOptional("prompt_token_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceDatasetId(): Optional = - referenceDatasetId.getOptional("reference_dataset_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceExampleId(): Optional = - referenceExampleId.getOptional("reference_example_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun s3Urls(): Optional = s3Urls.getOptional("s3_urls") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun serialized(): Optional = serialized.getOptional("serialized") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun shareToken(): Optional = shareToken.getOptional("share_token") - - /** - * @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 tags(): Optional> = tags.getOptional("tags") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun threadId(): Optional = threadId.getOptional("thread_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun totalCost(): Optional = totalCost.getOptional("total_cost") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceFirstReceivedAt(): Optional = - traceFirstReceivedAt.getOptional("trace_first_received_at") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceMaxStartTime(): Optional = - traceMaxStartTime.getOptional("trace_max_start_time") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceMinStartTime(): Optional = - traceMinStartTime.getOptional("trace_min_start_time") - - /** - * @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") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceUpgrade(): Optional = traceUpgrade.getOptional("trace_upgrade") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun ttlSeconds(): Optional = ttlSeconds.getOptional("ttl_seconds") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [appPath]. - * - * Unlike [appPath], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("app_path") @ExcludeMissing fun _appPath(): JsonField = appPath - - /** - * Returns the raw JSON value of [dottedOrder]. - * - * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("dotted_order") - @ExcludeMissing - fun _dottedOrder(): JsonField = dottedOrder - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [runType]. - * - * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType - - /** - * 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 [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * 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 [childRunIds]. - * - * Unlike [childRunIds], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("child_run_ids") - @ExcludeMissing - fun _childRunIds(): JsonField> = childRunIds - - /** - * Returns the raw JSON value of [completionCost]. - * - * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("completion_cost") - @ExcludeMissing - fun _completionCost(): JsonField = completionCost - - /** - * Returns the raw JSON value of [completionCostDetails]. - * - * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("completion_cost_details") - @ExcludeMissing - fun _completionCostDetails(): JsonField = completionCostDetails - - /** - * Returns the raw JSON value of [completionTokenDetails]. - * - * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("completion_token_details") - @ExcludeMissing - fun _completionTokenDetails(): JsonField = completionTokenDetails - - /** - * Returns the raw JSON value of [completionTokens]. - * - * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens(): JsonField = completionTokens - - /** - * Returns the raw JSON value of [directChildRunIds]. - * - * Unlike [directChildRunIds], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("direct_child_run_ids") - @ExcludeMissing - fun _directChildRunIds(): JsonField> = directChildRunIds - - /** - * Returns the raw JSON value of [endTime]. - * - * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("end_time") - @ExcludeMissing - fun _endTime(): JsonField = endTime - - /** - * Returns the raw JSON value of [error]. - * - * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error - - /** - * Returns the raw JSON value of [events]. - * - * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events - - /** - * Returns the raw JSON value of [executionOrder]. - * - * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("execution_order") - @ExcludeMissing - fun _executionOrder(): JsonField = executionOrder - - /** - * Returns the raw JSON value of [extra]. - * - * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra - - /** - * Returns the raw JSON value of [feedbackStats]. - * - * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("feedback_stats") - @ExcludeMissing - fun _feedbackStats(): JsonField = feedbackStats - - /** - * Returns the raw JSON value of [firstTokenTime]. - * - * Unlike [firstTokenTime], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("first_token_time") - @ExcludeMissing - fun _firstTokenTime(): JsonField = firstTokenTime - - /** - * Returns the raw JSON value of [inDataset]. - * - * Unlike [inDataset], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField = inDataset - - /** - * Returns the raw JSON value of [inputs]. - * - * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs - - /** - * Returns the raw JSON value of [inputsPreview]. - * - * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("inputs_preview") - @ExcludeMissing - fun _inputsPreview(): JsonField = inputsPreview - - /** - * Returns the raw JSON value of [inputsS3Urls]. - * - * Unlike [inputsS3Urls], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("inputs_s3_urls") - @ExcludeMissing - fun _inputsS3Urls(): JsonField = inputsS3Urls - - /** - * Returns the raw JSON value of [lastQueuedAt]. - * - * Unlike [lastQueuedAt], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("last_queued_at") - @ExcludeMissing - fun _lastQueuedAt(): JsonField = lastQueuedAt - - /** - * Returns the raw JSON value of [manifestId]. - * - * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("manifest_id") - @ExcludeMissing - fun _manifestId(): JsonField = manifestId - - /** - * Returns the raw JSON value of [manifestS3Id]. - * - * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("manifest_s3_id") - @ExcludeMissing - fun _manifestS3Id(): JsonField = manifestS3Id - - /** - * Returns the raw JSON value of [messages]. - * - * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messages") - @ExcludeMissing - fun _messages(): JsonField> = messages - - /** - * Returns the raw JSON value of [outputs]. - * - * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs - - /** - * Returns the raw JSON value of [outputsPreview]. - * - * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("outputs_preview") - @ExcludeMissing - fun _outputsPreview(): JsonField = outputsPreview - - /** - * Returns the raw JSON value of [outputsS3Urls]. - * - * Unlike [outputsS3Urls], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("outputs_s3_urls") - @ExcludeMissing - fun _outputsS3Urls(): JsonField = outputsS3Urls - - /** - * 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 [parentRunIds]. - * - * Unlike [parentRunIds], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parent_run_ids") - @ExcludeMissing - fun _parentRunIds(): JsonField> = parentRunIds - - /** - * Returns the raw JSON value of [priceModelId]. - * - * Unlike [priceModelId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("price_model_id") - @ExcludeMissing - fun _priceModelId(): JsonField = priceModelId - - /** - * Returns the raw JSON value of [promptCost]. - * - * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("prompt_cost") - @ExcludeMissing - fun _promptCost(): JsonField = promptCost - - /** - * Returns the raw JSON value of [promptCostDetails]. - * - * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("prompt_cost_details") - @ExcludeMissing - fun _promptCostDetails(): JsonField = promptCostDetails - - /** - * Returns the raw JSON value of [promptTokenDetails]. - * - * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prompt_token_details") - @ExcludeMissing - fun _promptTokenDetails(): JsonField = promptTokenDetails - - /** - * Returns the raw JSON value of [promptTokens]. - * - * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens(): JsonField = promptTokens - - /** - * Returns the raw JSON value of [referenceDatasetId]. - * - * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_dataset_id") - @ExcludeMissing - fun _referenceDatasetId(): JsonField = referenceDatasetId - - /** - * Returns the raw JSON value of [referenceExampleId]. - * - * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_example_id") - @ExcludeMissing - fun _referenceExampleId(): JsonField = referenceExampleId - - /** - * Returns the raw JSON value of [s3Urls]. - * - * Unlike [s3Urls], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonField = s3Urls - - /** - * Returns the raw JSON value of [serialized]. - * - * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("serialized") - @ExcludeMissing - fun _serialized(): JsonField = serialized - - /** - * Returns the raw JSON value of [shareToken]. - * - * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("share_token") - @ExcludeMissing - fun _shareToken(): JsonField = shareToken - - /** - * 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 [tags]. - * - * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags - - /** - * Returns the raw JSON value of [threadId]. - * - * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId - - /** - * Returns the raw JSON value of [totalCost]. - * - * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField = totalCost - - /** - * Returns the raw JSON value of [totalTokens]. - * - * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_tokens") - @ExcludeMissing - fun _totalTokens(): JsonField = totalTokens - - /** - * Returns the raw JSON value of [traceFirstReceivedAt]. - * - * Unlike [traceFirstReceivedAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("trace_first_received_at") - @ExcludeMissing - fun _traceFirstReceivedAt(): JsonField = traceFirstReceivedAt - - /** - * Returns the raw JSON value of [traceMaxStartTime]. - * - * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("trace_max_start_time") - @ExcludeMissing - fun _traceMaxStartTime(): JsonField = traceMaxStartTime - - /** - * Returns the raw JSON value of [traceMinStartTime]. - * - * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("trace_min_start_time") - @ExcludeMissing - fun _traceMinStartTime(): JsonField = traceMinStartTime - - /** - * 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 - - /** - * Returns the raw JSON value of [traceUpgrade]. - * - * Unlike [traceUpgrade], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("trace_upgrade") - @ExcludeMissing - fun _traceUpgrade(): JsonField = traceUpgrade - - /** - * Returns the raw JSON value of [ttlSeconds]. - * - * Unlike [ttlSeconds], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ttl_seconds") @ExcludeMissing fun _ttlSeconds(): JsonField = ttlSeconds - - @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 [Run]. - * - * The following fields are required: - * ```java - * .id() - * .appPath() - * .dottedOrder() - * .name() - * .runType() - * .sessionId() - * .status() - * .traceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Run]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var appPath: JsonField? = null - private var dottedOrder: JsonField? = null - private var name: JsonField? = null - private var runType: JsonField? = null - private var sessionId: JsonField? = null - private var status: JsonField? = null - private var traceId: JsonField? = null - private var childRunIds: JsonField>? = null - private var completionCost: JsonField = JsonMissing.of() - private var completionCostDetails: JsonField = JsonMissing.of() - private var completionTokenDetails: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var directChildRunIds: JsonField>? = null - private var endTime: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() - private var events: JsonField>? = null - private var executionOrder: JsonField = JsonMissing.of() - private var extra: JsonField = JsonMissing.of() - private var feedbackStats: JsonField = JsonMissing.of() - private var firstTokenTime: JsonField = JsonMissing.of() - private var inDataset: JsonField = JsonMissing.of() - private var inputs: JsonField = JsonMissing.of() - private var inputsPreview: JsonField = JsonMissing.of() - private var inputsS3Urls: JsonField = JsonMissing.of() - private var lastQueuedAt: JsonField = JsonMissing.of() - private var manifestId: JsonField = JsonMissing.of() - private var manifestS3Id: JsonField = JsonMissing.of() - private var messages: JsonField>? = null - private var outputs: JsonField = JsonMissing.of() - private var outputsPreview: JsonField = JsonMissing.of() - private var outputsS3Urls: JsonField = JsonMissing.of() - private var parentRunId: JsonField = JsonMissing.of() - private var parentRunIds: JsonField>? = null - private var priceModelId: JsonField = JsonMissing.of() - private var promptCost: JsonField = JsonMissing.of() - private var promptCostDetails: JsonField = JsonMissing.of() - private var promptTokenDetails: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var referenceDatasetId: JsonField = JsonMissing.of() - private var referenceExampleId: JsonField = JsonMissing.of() - private var s3Urls: JsonField = JsonMissing.of() - private var serialized: JsonField = JsonMissing.of() - private var shareToken: JsonField = JsonMissing.of() - private var startTime: JsonField = JsonMissing.of() - private var tags: JsonField>? = null - private var threadId: JsonField = JsonMissing.of() - private var totalCost: JsonField = JsonMissing.of() - private var totalTokens: JsonField = JsonMissing.of() - private var traceFirstReceivedAt: JsonField = JsonMissing.of() - private var traceMaxStartTime: JsonField = JsonMissing.of() - private var traceMinStartTime: JsonField = JsonMissing.of() - private var traceTier: JsonField = JsonMissing.of() - private var traceUpgrade: JsonField = JsonMissing.of() - private var ttlSeconds: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(run: Run) = apply { - id = run.id - appPath = run.appPath - dottedOrder = run.dottedOrder - name = run.name - runType = run.runType - sessionId = run.sessionId - status = run.status - traceId = run.traceId - childRunIds = run.childRunIds.map { it.toMutableList() } - completionCost = run.completionCost - completionCostDetails = run.completionCostDetails - completionTokenDetails = run.completionTokenDetails - completionTokens = run.completionTokens - directChildRunIds = run.directChildRunIds.map { it.toMutableList() } - endTime = run.endTime - error = run.error - events = run.events.map { it.toMutableList() } - executionOrder = run.executionOrder - extra = run.extra - feedbackStats = run.feedbackStats - firstTokenTime = run.firstTokenTime - inDataset = run.inDataset - inputs = run.inputs - inputsPreview = run.inputsPreview - inputsS3Urls = run.inputsS3Urls - lastQueuedAt = run.lastQueuedAt - manifestId = run.manifestId - manifestS3Id = run.manifestS3Id - messages = run.messages.map { it.toMutableList() } - outputs = run.outputs - outputsPreview = run.outputsPreview - outputsS3Urls = run.outputsS3Urls - parentRunId = run.parentRunId - parentRunIds = run.parentRunIds.map { it.toMutableList() } - priceModelId = run.priceModelId - promptCost = run.promptCost - promptCostDetails = run.promptCostDetails - promptTokenDetails = run.promptTokenDetails - promptTokens = run.promptTokens - referenceDatasetId = run.referenceDatasetId - referenceExampleId = run.referenceExampleId - s3Urls = run.s3Urls - serialized = run.serialized - shareToken = run.shareToken - startTime = run.startTime - tags = run.tags.map { it.toMutableList() } - threadId = run.threadId - totalCost = run.totalCost - totalTokens = run.totalTokens - traceFirstReceivedAt = run.traceFirstReceivedAt - traceMaxStartTime = run.traceMaxStartTime - traceMinStartTime = run.traceMinStartTime - traceTier = run.traceTier - traceUpgrade = run.traceUpgrade - ttlSeconds = run.ttlSeconds - additionalProperties = run.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun appPath(appPath: String) = appPath(JsonField.of(appPath)) - - /** - * Sets [Builder.appPath] to an arbitrary JSON value. - * - * You should usually call [Builder.appPath] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun appPath(appPath: JsonField) = apply { this.appPath = appPath } - - fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) - - /** - * Sets [Builder.dottedOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.dottedOrder] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun dottedOrder(dottedOrder: JsonField) = apply { - this.dottedOrder = dottedOrder - } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Enum for run types. */ - fun runType(runType: RunType) = runType(JsonField.of(runType)) - - /** - * Sets [Builder.runType] to an arbitrary JSON value. - * - * You should usually call [Builder.runType] with a well-typed [RunType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun runType(runType: JsonField) = apply { this.runType = runType } - - fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) - - /** - * 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 status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun traceId(traceId: String) = traceId(JsonField.of(traceId)) - - /** - * 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 childRunIds(childRunIds: List?) = - childRunIds(JsonField.ofNullable(childRunIds)) - - /** Alias for calling [Builder.childRunIds] with `childRunIds.orElse(null)`. */ - fun childRunIds(childRunIds: Optional>) = - childRunIds(childRunIds.getOrNull()) - - /** - * Sets [Builder.childRunIds] to an arbitrary JSON value. - * - * You should usually call [Builder.childRunIds] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun childRunIds(childRunIds: JsonField>) = apply { - this.childRunIds = childRunIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [childRunIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChildRunId(childRunId: String) = apply { - childRunIds = - (childRunIds ?: JsonField.of(mutableListOf())).also { - checkKnown("childRunIds", it).add(childRunId) - } - } - - fun completionCost(completionCost: String?) = - completionCost(JsonField.ofNullable(completionCost)) - - /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ - fun completionCost(completionCost: Optional) = - completionCost(completionCost.getOrNull()) - - /** - * Sets [Builder.completionCost] to an arbitrary JSON value. - * - * You should usually call [Builder.completionCost] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun completionCost(completionCost: JsonField) = apply { - this.completionCost = completionCost - } - - fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = - completionCostDetails(JsonField.ofNullable(completionCostDetails)) - - /** - * Alias for calling [Builder.completionCostDetails] with - * `completionCostDetails.orElse(null)`. - */ - fun completionCostDetails(completionCostDetails: Optional) = - completionCostDetails(completionCostDetails.getOrNull()) - - /** - * Sets [Builder.completionCostDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.completionCostDetails] with a well-typed - * [CompletionCostDetails] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun completionCostDetails(completionCostDetails: JsonField) = - apply { - this.completionCostDetails = completionCostDetails - } - - fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = - completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) - - /** - * Alias for calling [Builder.completionTokenDetails] with - * `completionTokenDetails.orElse(null)`. - */ - fun completionTokenDetails(completionTokenDetails: Optional) = - completionTokenDetails(completionTokenDetails.getOrNull()) - - /** - * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.completionTokenDetails] with a well-typed - * [CompletionTokenDetails] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun completionTokenDetails(completionTokenDetails: JsonField) = - apply { - this.completionTokenDetails = completionTokenDetails - } - - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * Sets [Builder.completionTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.completionTokens] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - fun directChildRunIds(directChildRunIds: List?) = - directChildRunIds(JsonField.ofNullable(directChildRunIds)) - - /** - * Alias for calling [Builder.directChildRunIds] with `directChildRunIds.orElse(null)`. - */ - fun directChildRunIds(directChildRunIds: Optional>) = - directChildRunIds(directChildRunIds.getOrNull()) - - /** - * Sets [Builder.directChildRunIds] to an arbitrary JSON value. - * - * You should usually call [Builder.directChildRunIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun directChildRunIds(directChildRunIds: JsonField>) = apply { - this.directChildRunIds = directChildRunIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [directChildRunIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addDirectChildRunId(directChildRunId: String) = apply { - directChildRunIds = - (directChildRunIds ?: JsonField.of(mutableListOf())).also { - checkKnown("directChildRunIds", it).add(directChildRunId) - } - } - - fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) - - /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ - fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) - - /** - * Sets [Builder.endTime] to an arbitrary JSON value. - * - * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - - fun error(error: String?) = error(JsonField.ofNullable(error)) - - /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) - - /** - * Sets [Builder.error] to an arbitrary JSON value. - * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun error(error: JsonField) = apply { this.error = error } - - fun events(events: List?) = events(JsonField.ofNullable(events)) - - /** Alias for calling [Builder.events] with `events.orElse(null)`. */ - fun events(events: Optional>) = events(events.getOrNull()) - - /** - * Sets [Builder.events] to an arbitrary JSON value. - * - * You should usually call [Builder.events] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } - - /** - * Adds a single [Event] to [events]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEvent(event: Event) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { - checkKnown("events", it).add(event) - } - } - - fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) - - /** - * Sets [Builder.executionOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.executionOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun executionOrder(executionOrder: JsonField) = apply { - this.executionOrder = executionOrder - } - - fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - - /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ - fun extra(extra: Optional) = extra(extra.getOrNull()) - - /** - * Sets [Builder.extra] to an arbitrary JSON value. - * - * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun extra(extra: JsonField) = apply { this.extra = extra } - - fun feedbackStats(feedbackStats: FeedbackStats?) = - feedbackStats(JsonField.ofNullable(feedbackStats)) - - /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ - fun feedbackStats(feedbackStats: Optional) = - feedbackStats(feedbackStats.getOrNull()) - - /** - * Sets [Builder.feedbackStats] to an arbitrary JSON value. - * - * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun feedbackStats(feedbackStats: JsonField) = apply { - this.feedbackStats = feedbackStats - } - - fun firstTokenTime(firstTokenTime: OffsetDateTime?) = - firstTokenTime(JsonField.ofNullable(firstTokenTime)) - - /** Alias for calling [Builder.firstTokenTime] with `firstTokenTime.orElse(null)`. */ - fun firstTokenTime(firstTokenTime: Optional) = - firstTokenTime(firstTokenTime.getOrNull()) - - /** - * Sets [Builder.firstTokenTime] to an arbitrary JSON value. - * - * You should usually call [Builder.firstTokenTime] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun firstTokenTime(firstTokenTime: JsonField) = apply { - this.firstTokenTime = firstTokenTime - } - - fun inDataset(inDataset: Boolean?) = inDataset(JsonField.ofNullable(inDataset)) - - /** - * Alias for [Builder.inDataset]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun inDataset(inDataset: Boolean) = inDataset(inDataset as Boolean?) - - /** Alias for calling [Builder.inDataset] with `inDataset.orElse(null)`. */ - fun inDataset(inDataset: Optional) = inDataset(inDataset.getOrNull()) - - /** - * Sets [Builder.inDataset] to an arbitrary JSON value. - * - * You should usually call [Builder.inDataset] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inDataset(inDataset: JsonField) = apply { this.inDataset = inDataset } - - fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - - /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ - fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - - /** - * Sets [Builder.inputs] to an arbitrary JSON value. - * - * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputs(inputs: JsonField) = apply { this.inputs = inputs } - - fun inputsPreview(inputsPreview: String?) = - inputsPreview(JsonField.ofNullable(inputsPreview)) - - /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ - fun inputsPreview(inputsPreview: Optional) = - inputsPreview(inputsPreview.getOrNull()) - - /** - * Sets [Builder.inputsPreview] to an arbitrary JSON value. - * - * You should usually call [Builder.inputsPreview] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputsPreview(inputsPreview: JsonField) = apply { - this.inputsPreview = inputsPreview - } - - fun inputsS3Urls(inputsS3Urls: InputsS3Urls?) = - inputsS3Urls(JsonField.ofNullable(inputsS3Urls)) - - /** Alias for calling [Builder.inputsS3Urls] with `inputsS3Urls.orElse(null)`. */ - fun inputsS3Urls(inputsS3Urls: Optional) = - inputsS3Urls(inputsS3Urls.getOrNull()) - - /** - * Sets [Builder.inputsS3Urls] to an arbitrary JSON value. - * - * You should usually call [Builder.inputsS3Urls] with a well-typed [InputsS3Urls] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputsS3Urls(inputsS3Urls: JsonField) = apply { - this.inputsS3Urls = inputsS3Urls - } - - fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = - lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) - - /** Alias for calling [Builder.lastQueuedAt] with `lastQueuedAt.orElse(null)`. */ - fun lastQueuedAt(lastQueuedAt: Optional) = - lastQueuedAt(lastQueuedAt.getOrNull()) - - /** - * Sets [Builder.lastQueuedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.lastQueuedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun lastQueuedAt(lastQueuedAt: JsonField) = apply { - this.lastQueuedAt = lastQueuedAt - } - - fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) - - /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ - fun manifestId(manifestId: Optional) = manifestId(manifestId.getOrNull()) - - /** - * Sets [Builder.manifestId] to an arbitrary JSON value. - * - * You should usually call [Builder.manifestId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun manifestId(manifestId: JsonField) = apply { this.manifestId = manifestId } - - fun manifestS3Id(manifestS3Id: String?) = - manifestS3Id(JsonField.ofNullable(manifestS3Id)) - - /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ - fun manifestS3Id(manifestS3Id: Optional) = - manifestS3Id(manifestS3Id.getOrNull()) - - /** - * Sets [Builder.manifestS3Id] to an arbitrary JSON value. - * - * You should usually call [Builder.manifestS3Id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun manifestS3Id(manifestS3Id: JsonField) = apply { - this.manifestS3Id = manifestS3Id - } - - fun messages(messages: List?) = messages(JsonField.ofNullable(messages)) - - /** Alias for calling [Builder.messages] with `messages.orElse(null)`. */ - fun messages(messages: Optional>) = messages(messages.getOrNull()) - - /** - * Sets [Builder.messages] to an arbitrary JSON value. - * - * You should usually call [Builder.messages] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messages(messages: JsonField>) = apply { - this.messages = messages.map { it.toMutableList() } - } - - /** - * Adds a single [Message] to [messages]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addMessage(message: Message) = apply { - messages = - (messages ?: JsonField.of(mutableListOf())).also { - checkKnown("messages", it).add(message) - } - } - - fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) - - /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ - fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) - - /** - * Sets [Builder.outputs] to an arbitrary JSON value. - * - * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun outputs(outputs: JsonField) = apply { this.outputs = outputs } - - fun outputsPreview(outputsPreview: String?) = - outputsPreview(JsonField.ofNullable(outputsPreview)) - - /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ - fun outputsPreview(outputsPreview: Optional) = - outputsPreview(outputsPreview.getOrNull()) - - /** - * Sets [Builder.outputsPreview] to an arbitrary JSON value. - * - * You should usually call [Builder.outputsPreview] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun outputsPreview(outputsPreview: JsonField) = apply { - this.outputsPreview = outputsPreview - } - - fun outputsS3Urls(outputsS3Urls: OutputsS3Urls?) = - outputsS3Urls(JsonField.ofNullable(outputsS3Urls)) - - /** Alias for calling [Builder.outputsS3Urls] with `outputsS3Urls.orElse(null)`. */ - fun outputsS3Urls(outputsS3Urls: Optional) = - outputsS3Urls(outputsS3Urls.getOrNull()) - - /** - * Sets [Builder.outputsS3Urls] to an arbitrary JSON value. - * - * You should usually call [Builder.outputsS3Urls] with a well-typed [OutputsS3Urls] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun outputsS3Urls(outputsS3Urls: JsonField) = apply { - this.outputsS3Urls = outputsS3Urls - } - - 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 parentRunIds(parentRunIds: List?) = - parentRunIds(JsonField.ofNullable(parentRunIds)) - - /** Alias for calling [Builder.parentRunIds] with `parentRunIds.orElse(null)`. */ - fun parentRunIds(parentRunIds: Optional>) = - parentRunIds(parentRunIds.getOrNull()) - - /** - * Sets [Builder.parentRunIds] to an arbitrary JSON value. - * - * You should usually call [Builder.parentRunIds] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parentRunIds(parentRunIds: JsonField>) = apply { - this.parentRunIds = parentRunIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [parentRunIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addParentRunId(parentRunId: String) = apply { - parentRunIds = - (parentRunIds ?: JsonField.of(mutableListOf())).also { - checkKnown("parentRunIds", it).add(parentRunId) - } - } - - fun priceModelId(priceModelId: String?) = - priceModelId(JsonField.ofNullable(priceModelId)) - - /** Alias for calling [Builder.priceModelId] with `priceModelId.orElse(null)`. */ - fun priceModelId(priceModelId: Optional) = - priceModelId(priceModelId.getOrNull()) - - /** - * Sets [Builder.priceModelId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceModelId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceModelId(priceModelId: JsonField) = apply { - this.priceModelId = priceModelId - } - - fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) - - /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ - fun promptCost(promptCost: Optional) = promptCost(promptCost.getOrNull()) - - /** - * Sets [Builder.promptCost] to an arbitrary JSON value. - * - * You should usually call [Builder.promptCost] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun promptCost(promptCost: JsonField) = apply { this.promptCost = promptCost } - - fun promptCostDetails(promptCostDetails: PromptCostDetails?) = - promptCostDetails(JsonField.ofNullable(promptCostDetails)) - - /** - * Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. - */ - fun promptCostDetails(promptCostDetails: Optional) = - promptCostDetails(promptCostDetails.getOrNull()) - - /** - * Sets [Builder.promptCostDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.promptCostDetails] with a well-typed - * [PromptCostDetails] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun promptCostDetails(promptCostDetails: JsonField) = apply { - this.promptCostDetails = promptCostDetails - } - - fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = - promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) - - /** - * Alias for calling [Builder.promptTokenDetails] with - * `promptTokenDetails.orElse(null)`. - */ - fun promptTokenDetails(promptTokenDetails: Optional) = - promptTokenDetails(promptTokenDetails.getOrNull()) - - /** - * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.promptTokenDetails] with a well-typed - * [PromptTokenDetails] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun promptTokenDetails(promptTokenDetails: JsonField) = apply { - this.promptTokenDetails = promptTokenDetails - } - - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * Sets [Builder.promptTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.promptTokens] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - fun referenceDatasetId(referenceDatasetId: String?) = - referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) - - /** - * Alias for calling [Builder.referenceDatasetId] with - * `referenceDatasetId.orElse(null)`. - */ - fun referenceDatasetId(referenceDatasetId: Optional) = - referenceDatasetId(referenceDatasetId.getOrNull()) - - /** - * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun referenceDatasetId(referenceDatasetId: JsonField) = apply { - this.referenceDatasetId = referenceDatasetId - } - - fun referenceExampleId(referenceExampleId: String?) = - referenceExampleId(JsonField.ofNullable(referenceExampleId)) - - /** - * Alias for calling [Builder.referenceExampleId] with - * `referenceExampleId.orElse(null)`. - */ - fun referenceExampleId(referenceExampleId: Optional) = - referenceExampleId(referenceExampleId.getOrNull()) - - /** - * Sets [Builder.referenceExampleId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceExampleId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun referenceExampleId(referenceExampleId: JsonField) = apply { - this.referenceExampleId = referenceExampleId - } - - fun s3Urls(s3Urls: S3Urls?) = s3Urls(JsonField.ofNullable(s3Urls)) - - /** Alias for calling [Builder.s3Urls] with `s3Urls.orElse(null)`. */ - fun s3Urls(s3Urls: Optional) = s3Urls(s3Urls.getOrNull()) - - /** - * Sets [Builder.s3Urls] to an arbitrary JSON value. - * - * You should usually call [Builder.s3Urls] with a well-typed [S3Urls] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun s3Urls(s3Urls: JsonField) = apply { this.s3Urls = s3Urls } - - fun serialized(serialized: Serialized?) = serialized(JsonField.ofNullable(serialized)) - - /** Alias for calling [Builder.serialized] with `serialized.orElse(null)`. */ - fun serialized(serialized: Optional) = serialized(serialized.getOrNull()) - - /** - * Sets [Builder.serialized] to an arbitrary JSON value. - * - * You should usually call [Builder.serialized] with a well-typed [Serialized] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun serialized(serialized: JsonField) = apply { - this.serialized = serialized - } - - fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) - - /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ - fun shareToken(shareToken: Optional) = shareToken(shareToken.getOrNull()) - - /** - * Sets [Builder.shareToken] to an arbitrary JSON value. - * - * You should usually call [Builder.shareToken] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun shareToken(shareToken: JsonField) = apply { this.shareToken = shareToken } - - fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) - - /** - * 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 tags(tags: List?) = tags(JsonField.ofNullable(tags)) - - /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ - fun tags(tags: Optional>) = tags(tags.getOrNull()) - - /** - * Sets [Builder.tags] to an arbitrary JSON value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun threadId(threadId: String?) = threadId(JsonField.ofNullable(threadId)) - - /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ - fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) - - /** - * Sets [Builder.threadId] to an arbitrary JSON value. - * - * You should usually call [Builder.threadId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun threadId(threadId: JsonField) = apply { this.threadId = threadId } - - fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) - - /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ - fun totalCost(totalCost: Optional) = totalCost(totalCost.getOrNull()) - - /** - * Sets [Builder.totalCost] to an arbitrary JSON value. - * - * You should usually call [Builder.totalCost] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalCost(totalCost: JsonField) = apply { this.totalCost = totalCost } - - fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) - - /** - * Sets [Builder.totalTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalTokens(totalTokens: JsonField) = apply { this.totalTokens = totalTokens } - - fun traceFirstReceivedAt(traceFirstReceivedAt: OffsetDateTime?) = - traceFirstReceivedAt(JsonField.ofNullable(traceFirstReceivedAt)) - - /** - * Alias for calling [Builder.traceFirstReceivedAt] with - * `traceFirstReceivedAt.orElse(null)`. - */ - fun traceFirstReceivedAt(traceFirstReceivedAt: Optional) = - traceFirstReceivedAt(traceFirstReceivedAt.getOrNull()) - - /** - * Sets [Builder.traceFirstReceivedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.traceFirstReceivedAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun traceFirstReceivedAt(traceFirstReceivedAt: JsonField) = apply { - this.traceFirstReceivedAt = traceFirstReceivedAt - } - - fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = - traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) - - /** - * Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. - */ - fun traceMaxStartTime(traceMaxStartTime: Optional) = - traceMaxStartTime(traceMaxStartTime.getOrNull()) - - /** - * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. - * - * You should usually call [Builder.traceMaxStartTime] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun traceMaxStartTime(traceMaxStartTime: JsonField) = apply { - this.traceMaxStartTime = traceMaxStartTime - } - - fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = - traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) - - /** - * Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. - */ - fun traceMinStartTime(traceMinStartTime: Optional) = - traceMinStartTime(traceMinStartTime.getOrNull()) - - /** - * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. - * - * You should usually call [Builder.traceMinStartTime] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun traceMinStartTime(traceMinStartTime: JsonField) = apply { - this.traceMinStartTime = traceMinStartTime - } - - 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 traceUpgrade(traceUpgrade: Boolean) = traceUpgrade(JsonField.of(traceUpgrade)) - - /** - * Sets [Builder.traceUpgrade] to an arbitrary JSON value. - * - * You should usually call [Builder.traceUpgrade] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun traceUpgrade(traceUpgrade: JsonField) = apply { - this.traceUpgrade = traceUpgrade - } - - fun ttlSeconds(ttlSeconds: Long?) = ttlSeconds(JsonField.ofNullable(ttlSeconds)) - - /** - * Alias for [Builder.ttlSeconds]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun ttlSeconds(ttlSeconds: Long) = ttlSeconds(ttlSeconds as Long?) - - /** Alias for calling [Builder.ttlSeconds] with `ttlSeconds.orElse(null)`. */ - fun ttlSeconds(ttlSeconds: Optional) = ttlSeconds(ttlSeconds.getOrNull()) - - /** - * Sets [Builder.ttlSeconds] to an arbitrary JSON value. - * - * You should usually call [Builder.ttlSeconds] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun ttlSeconds(ttlSeconds: JsonField) = apply { this.ttlSeconds = ttlSeconds } - - 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 [Run]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .appPath() - * .dottedOrder() - * .name() - * .runType() - * .sessionId() - * .status() - * .traceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Run = - Run( - checkRequired("id", id), - checkRequired("appPath", appPath), - checkRequired("dottedOrder", dottedOrder), - checkRequired("name", name), - checkRequired("runType", runType), - checkRequired("sessionId", sessionId), - checkRequired("status", status), - checkRequired("traceId", traceId), - (childRunIds ?: JsonMissing.of()).map { it.toImmutable() }, - completionCost, - completionCostDetails, - completionTokenDetails, - completionTokens, - (directChildRunIds ?: JsonMissing.of()).map { it.toImmutable() }, - endTime, - error, - (events ?: JsonMissing.of()).map { it.toImmutable() }, - executionOrder, - extra, - feedbackStats, - firstTokenTime, - inDataset, - inputs, - inputsPreview, - inputsS3Urls, - lastQueuedAt, - manifestId, - manifestS3Id, - (messages ?: JsonMissing.of()).map { it.toImmutable() }, - outputs, - outputsPreview, - outputsS3Urls, - parentRunId, - (parentRunIds ?: JsonMissing.of()).map { it.toImmutable() }, - priceModelId, - promptCost, - promptCostDetails, - promptTokenDetails, - promptTokens, - referenceDatasetId, - referenceExampleId, - s3Urls, - serialized, - shareToken, - startTime, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - threadId, - totalCost, - totalTokens, - traceFirstReceivedAt, - traceMaxStartTime, - traceMinStartTime, - traceTier, - traceUpgrade, - ttlSeconds, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Run = apply { - if (validated) { - return@apply - } - - id() - appPath() - dottedOrder() - name() - runType().validate() - sessionId() - status() - traceId() - childRunIds() - completionCost() - completionCostDetails().ifPresent { it.validate() } - completionTokenDetails().ifPresent { it.validate() } - completionTokens() - directChildRunIds() - endTime() - error() - events().ifPresent { it.forEach { it.validate() } } - executionOrder() - extra().ifPresent { it.validate() } - feedbackStats().ifPresent { it.validate() } - firstTokenTime() - inDataset() - inputs().ifPresent { it.validate() } - inputsPreview() - inputsS3Urls().ifPresent { it.validate() } - lastQueuedAt() - manifestId() - manifestS3Id() - messages().ifPresent { it.forEach { it.validate() } } - outputs().ifPresent { it.validate() } - outputsPreview() - outputsS3Urls().ifPresent { it.validate() } - parentRunId() - parentRunIds() - priceModelId() - promptCost() - promptCostDetails().ifPresent { it.validate() } - promptTokenDetails().ifPresent { it.validate() } - promptTokens() - referenceDatasetId() - referenceExampleId() - s3Urls().ifPresent { it.validate() } - serialized().ifPresent { it.validate() } - shareToken() - startTime() - tags() - threadId() - totalCost() - totalTokens() - traceFirstReceivedAt() - traceMaxStartTime() - traceMinStartTime() - traceTier().ifPresent { it.validate() } - traceUpgrade() - ttlSeconds() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (appPath.asKnown().isPresent) 1 else 0) + - (if (dottedOrder.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (runType.asKnown().getOrNull()?.validity() ?: 0) + - (if (sessionId.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (traceId.asKnown().isPresent) 1 else 0) + - (childRunIds.asKnown().getOrNull()?.size ?: 0) + - (if (completionCost.asKnown().isPresent) 1 else 0) + - (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + - (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + - (if (completionTokens.asKnown().isPresent) 1 else 0) + - (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + - (if (endTime.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + - (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (executionOrder.asKnown().isPresent) 1 else 0) + - (extra.asKnown().getOrNull()?.validity() ?: 0) + - (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + - (if (firstTokenTime.asKnown().isPresent) 1 else 0) + - (if (inDataset.asKnown().isPresent) 1 else 0) + - (inputs.asKnown().getOrNull()?.validity() ?: 0) + - (if (inputsPreview.asKnown().isPresent) 1 else 0) + - (inputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + - (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + - (if (manifestId.asKnown().isPresent) 1 else 0) + - (if (manifestS3Id.asKnown().isPresent) 1 else 0) + - (messages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (outputs.asKnown().getOrNull()?.validity() ?: 0) + - (if (outputsPreview.asKnown().isPresent) 1 else 0) + - (outputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + - (if (parentRunId.asKnown().isPresent) 1 else 0) + - (parentRunIds.asKnown().getOrNull()?.size ?: 0) + - (if (priceModelId.asKnown().isPresent) 1 else 0) + - (if (promptCost.asKnown().isPresent) 1 else 0) + - (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + - (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + - (if (promptTokens.asKnown().isPresent) 1 else 0) + - (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + - (if (referenceExampleId.asKnown().isPresent) 1 else 0) + - (s3Urls.asKnown().getOrNull()?.validity() ?: 0) + - (serialized.asKnown().getOrNull()?.validity() ?: 0) + - (if (shareToken.asKnown().isPresent) 1 else 0) + - (if (startTime.asKnown().isPresent) 1 else 0) + - (tags.asKnown().getOrNull()?.size ?: 0) + - (if (threadId.asKnown().isPresent) 1 else 0) + - (if (totalCost.asKnown().isPresent) 1 else 0) + - (if (totalTokens.asKnown().isPresent) 1 else 0) + - (if (traceFirstReceivedAt.asKnown().isPresent) 1 else 0) + - (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + - (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + - (traceTier.asKnown().getOrNull()?.validity() ?: 0) + - (if (traceUpgrade.asKnown().isPresent) 1 else 0) + - (if (ttlSeconds.asKnown().isPresent) 1 else 0) - - /** Enum for run types. */ - class RunType @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 TOOL = of("tool") - - @JvmField val CHAIN = of("chain") - - @JvmField val LLM = of("llm") - - @JvmField val RETRIEVER = of("retriever") - - @JvmField val EMBEDDING = of("embedding") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PARSER = of("parser") - - @JvmStatic fun of(value: String) = RunType(JsonField.of(value)) - } - - /** An enum containing [RunType]'s known values. */ - enum class Known { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - } - - /** - * An enum containing [RunType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RunType] 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 { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - /** - * An enum member indicating that [RunType] 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) { - TOOL -> Value.TOOL - CHAIN -> Value.CHAIN - LLM -> Value.LLM - RETRIEVER -> Value.RETRIEVER - EMBEDDING -> Value.EMBEDDING - PROMPT -> Value.PROMPT - PARSER -> Value.PARSER - 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) { - TOOL -> Known.TOOL - CHAIN -> Known.CHAIN - LLM -> Known.LLM - RETRIEVER -> Known.RETRIEVER - EMBEDDING -> Known.EMBEDDING - PROMPT -> Known.PROMPT - PARSER -> Known.PARSER - else -> throw LangChainInvalidDataException("Unknown RunType: $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(): RunType = 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 RunType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class CompletionCostDetails - @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 - * [CompletionCostDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CompletionCostDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(completionCostDetails: CompletionCostDetails) = apply { - additionalProperties = completionCostDetails.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 [CompletionCostDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CompletionCostDetails = - CompletionCostDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CompletionCostDetails = 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 CompletionCostDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CompletionCostDetails{additionalProperties=$additionalProperties}" - } - - class CompletionTokenDetails - @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 - * [CompletionTokenDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CompletionTokenDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { - additionalProperties = - completionTokenDetails.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 [CompletionTokenDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CompletionTokenDetails = - CompletionTokenDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CompletionTokenDetails = 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 CompletionTokenDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CompletionTokenDetails{additionalProperties=$additionalProperties}" - } - - class Event - @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 [Event]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Event]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(event: Event) = apply { - additionalProperties = event.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 [Event]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Event = Event(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Event = 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 Event && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Event{additionalProperties=$additionalProperties}" - } - - class Extra - @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 [Extra]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Extra]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(extra: Extra) = apply { - additionalProperties = extra.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 [Extra]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Extra = Extra(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Extra = 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 Extra && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Extra{additionalProperties=$additionalProperties}" - } - - class FeedbackStats - @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 [FeedbackStats]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FeedbackStats]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedbackStats: FeedbackStats) = apply { - additionalProperties = feedbackStats.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 [FeedbackStats]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): FeedbackStats = 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 FeedbackStats && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" - } - - class Inputs - @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 [Inputs]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Inputs]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inputs: Inputs) = apply { - additionalProperties = inputs.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 [Inputs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Inputs = Inputs(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Inputs = 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 Inputs && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Inputs{additionalProperties=$additionalProperties}" - } - - class InputsS3Urls - @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 [InputsS3Urls]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputsS3Urls]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inputsS3Urls: InputsS3Urls) = apply { - additionalProperties = inputsS3Urls.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 [InputsS3Urls]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InputsS3Urls = InputsS3Urls(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InputsS3Urls = 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 InputsS3Urls && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "InputsS3Urls{additionalProperties=$additionalProperties}" - } - - class Message - @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 [Message]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Message]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(message: Message) = apply { - additionalProperties = message.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 [Message]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Message = Message(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Message = 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 Message && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Message{additionalProperties=$additionalProperties}" - } - - class Outputs - @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 [Outputs]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Outputs]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(outputs: Outputs) = apply { - additionalProperties = outputs.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 [Outputs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Outputs = Outputs(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Outputs = 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 Outputs && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Outputs{additionalProperties=$additionalProperties}" - } - - class OutputsS3Urls - @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 [OutputsS3Urls]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputsS3Urls]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(outputsS3Urls: OutputsS3Urls) = apply { - additionalProperties = outputsS3Urls.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 [OutputsS3Urls]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): OutputsS3Urls = OutputsS3Urls(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): OutputsS3Urls = 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 OutputsS3Urls && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "OutputsS3Urls{additionalProperties=$additionalProperties}" - } - - class PromptCostDetails - @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 [PromptCostDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PromptCostDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptCostDetails: PromptCostDetails) = apply { - additionalProperties = promptCostDetails.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 [PromptCostDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PromptCostDetails = - PromptCostDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): PromptCostDetails = 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 PromptCostDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PromptCostDetails{additionalProperties=$additionalProperties}" - } - - class PromptTokenDetails - @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 [PromptTokenDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PromptTokenDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptTokenDetails: PromptTokenDetails) = apply { - additionalProperties = promptTokenDetails.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 [PromptTokenDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PromptTokenDetails = - PromptTokenDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): PromptTokenDetails = 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 PromptTokenDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PromptTokenDetails{additionalProperties=$additionalProperties}" - } - - class S3Urls - @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 [S3Urls]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [S3Urls]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(s3Urls: S3Urls) = apply { - additionalProperties = s3Urls.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 [S3Urls]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): S3Urls = S3Urls(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): S3Urls = 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 S3Urls && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "S3Urls{additionalProperties=$additionalProperties}" - } - - class Serialized - @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 [Serialized]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Serialized]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(serialized: Serialized) = apply { - additionalProperties = serialized.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 [Serialized]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Serialized = Serialized(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Serialized = 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 Serialized && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Serialized{additionalProperties=$additionalProperties}" - } - - 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 Run && - id == other.id && - appPath == other.appPath && - dottedOrder == other.dottedOrder && - name == other.name && - runType == other.runType && - sessionId == other.sessionId && - status == other.status && - traceId == other.traceId && - childRunIds == other.childRunIds && - completionCost == other.completionCost && - completionCostDetails == other.completionCostDetails && - completionTokenDetails == other.completionTokenDetails && - completionTokens == other.completionTokens && - directChildRunIds == other.directChildRunIds && - endTime == other.endTime && - error == other.error && - events == other.events && - executionOrder == other.executionOrder && - extra == other.extra && - feedbackStats == other.feedbackStats && - firstTokenTime == other.firstTokenTime && - inDataset == other.inDataset && - inputs == other.inputs && - inputsPreview == other.inputsPreview && - inputsS3Urls == other.inputsS3Urls && - lastQueuedAt == other.lastQueuedAt && - manifestId == other.manifestId && - manifestS3Id == other.manifestS3Id && - messages == other.messages && - outputs == other.outputs && - outputsPreview == other.outputsPreview && - outputsS3Urls == other.outputsS3Urls && - parentRunId == other.parentRunId && - parentRunIds == other.parentRunIds && - priceModelId == other.priceModelId && - promptCost == other.promptCost && - promptCostDetails == other.promptCostDetails && - promptTokenDetails == other.promptTokenDetails && - promptTokens == other.promptTokens && - referenceDatasetId == other.referenceDatasetId && - referenceExampleId == other.referenceExampleId && - s3Urls == other.s3Urls && - serialized == other.serialized && - shareToken == other.shareToken && - startTime == other.startTime && - tags == other.tags && - threadId == other.threadId && - totalCost == other.totalCost && - totalTokens == other.totalTokens && - traceFirstReceivedAt == other.traceFirstReceivedAt && - traceMaxStartTime == other.traceMaxStartTime && - traceMinStartTime == other.traceMinStartTime && - traceTier == other.traceTier && - traceUpgrade == other.traceUpgrade && - ttlSeconds == other.ttlSeconds && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - appPath, - dottedOrder, - name, - runType, - sessionId, - status, - traceId, - childRunIds, - completionCost, - completionCostDetails, - completionTokenDetails, - completionTokens, - directChildRunIds, - endTime, - error, - events, - executionOrder, - extra, - feedbackStats, - firstTokenTime, - inDataset, - inputs, - inputsPreview, - inputsS3Urls, - lastQueuedAt, - manifestId, - manifestS3Id, - messages, - outputs, - outputsPreview, - outputsS3Urls, - parentRunId, - parentRunIds, - priceModelId, - promptCost, - promptCostDetails, - promptTokenDetails, - promptTokens, - referenceDatasetId, - referenceExampleId, - s3Urls, - serialized, - shareToken, - startTime, - tags, - threadId, - totalCost, - totalTokens, - traceFirstReceivedAt, - traceMaxStartTime, - traceMinStartTime, - traceTier, - traceUpgrade, - ttlSeconds, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Run{id=$id, appPath=$appPath, dottedOrder=$dottedOrder, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inDataset=$inDataset, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, lastQueuedAt=$lastQueuedAt, manifestId=$manifestId, manifestS3Id=$manifestS3Id, messages=$messages, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, shareToken=$shareToken, startTime=$startTime, tags=$tags, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceFirstReceivedAt=$traceFirstReceivedAt, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, traceTier=$traceTier, traceUpgrade=$traceUpgrade, ttlSeconds=$ttlSeconds, additionalProperties=$additionalProperties}" - } - - class AttachmentUrls - @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 [AttachmentUrls]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AttachmentUrls]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attachmentUrls: AttachmentUrls) = apply { - additionalProperties = attachmentUrls.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 [AttachmentUrls]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AttachmentUrls = AttachmentUrls(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): AttachmentUrls = 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 AttachmentUrls && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "AttachmentUrls{additionalProperties=$additionalProperties}" - } - - class Metadata - @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 [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.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 [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = 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 Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class Outputs - @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 [Outputs]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Outputs]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(outputs: Outputs) = apply { - additionalProperties = outputs.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 [Outputs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Outputs = Outputs(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Outputs = 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 Outputs && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Outputs{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExampleWithRuns && - id == other.id && - datasetId == other.datasetId && - inputs == other.inputs && - name == other.name && - runs == other.runs && - attachmentUrls == other.attachmentUrls && - createdAt == other.createdAt && - metadata == other.metadata && - modifiedAt == other.modifiedAt && - outputs == other.outputs && - sourceRunId == other.sourceRunId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - datasetId, - inputs, - name, - runs, - attachmentUrls, - createdAt, - metadata, - modifiedAt, - outputs, - sourceRunId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExampleWithRuns{id=$id, datasetId=$datasetId, inputs=$inputs, name=$name, runs=$runs, attachmentUrls=$attachmentUrls, createdAt=$createdAt, metadata=$metadata, modifiedAt=$modifiedAt, outputs=$outputs, sourceRunId=$sourceRunId, additionalProperties=$additionalProperties}" -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt index 324604c6d..6858c0d73 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsCh.kt @@ -6,7 +6,6 @@ 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 @@ -16,6 +15,7 @@ import com.langchain.smith.core.checkRequired import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException import com.langchain.smith.models.feedback.FeedbackSchema +import com.langchain.smith.models.runs.RunTypeEnum import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -645,7 +645,7 @@ private constructor( private constructor( private val id: JsonField, private val name: JsonField, - private val runType: JsonField, + private val runType: JsonField, private val sessionId: JsonField, private val status: JsonField, private val traceId: JsonField, @@ -689,7 +689,7 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("run_type") @ExcludeMissing - runType: JsonField = JsonMissing.of(), + runType: JsonField = JsonMissing.of(), @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), @@ -833,7 +833,7 @@ private constructor( * @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 runType(): RunType = runType.getRequired("run_type") + fun runType(): RunTypeEnum = runType.getRequired("run_type") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -1061,7 +1061,7 @@ private constructor( * * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType /** * Returns the raw JSON value of [sessionId]. @@ -1393,7 +1393,7 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null - private var runType: JsonField? = null + private var runType: JsonField? = null private var sessionId: JsonField? = null private var status: JsonField? = null private var traceId: JsonField? = null @@ -1495,16 +1495,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Enum for run types. */ - fun runType(runType: RunType) = runType(JsonField.of(runType)) + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) /** * Sets [Builder.runType] to an arbitrary JSON value. * - * You should usually call [Builder.runType] with a well-typed [RunType] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun runType(runType: JsonField) = apply { this.runType = runType } + fun runType(runType: JsonField) = apply { this.runType = runType } fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) @@ -2271,167 +2271,6 @@ private constructor( (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + (if (traceMinStartTime.asKnown().isPresent) 1 else 0) - /** Enum for run types. */ - class RunType @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 TOOL = of("tool") - - @JvmField val CHAIN = of("chain") - - @JvmField val LLM = of("llm") - - @JvmField val RETRIEVER = of("retriever") - - @JvmField val EMBEDDING = of("embedding") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PARSER = of("parser") - - @JvmStatic fun of(value: String) = RunType(JsonField.of(value)) - } - - /** An enum containing [RunType]'s known values. */ - enum class Known { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - } - - /** - * An enum containing [RunType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RunType] 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 { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - /** - * An enum member indicating that [RunType] 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) { - TOOL -> Value.TOOL - CHAIN -> Value.CHAIN - LLM -> Value.LLM - RETRIEVER -> Value.RETRIEVER - EMBEDDING -> Value.EMBEDDING - PROMPT -> Value.PROMPT - PARSER -> Value.PARSER - 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) { - TOOL -> Known.TOOL - CHAIN -> Known.CHAIN - LLM -> Known.LLM - RETRIEVER -> Known.RETRIEVER - EMBEDDING -> Known.EMBEDDING - PROMPT -> Known.PROMPT - PARSER -> Known.PARSER - else -> throw LangChainInvalidDataException("Unknown RunType: $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(): RunType = 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 RunType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - class Event @JsonCreator private constructor( 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 d2956391e..80ad7dbfc 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 @@ -26,6 +26,7 @@ private constructor( private val comparativeExperimentId: JsonField, private val exampleIds: JsonField>, private val filters: JsonField, + private val includeAnnotatorDetail: JsonField, private val limit: JsonField, private val offset: JsonField, private val preview: JsonField, @@ -46,6 +47,9 @@ private constructor( @ExcludeMissing exampleIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), + @JsonProperty("include_annotator_detail") + @ExcludeMissing + includeAnnotatorDetail: JsonField = JsonMissing.of(), @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), @JsonProperty("preview") @ExcludeMissing preview: JsonField = JsonMissing.of(), @@ -58,6 +62,7 @@ private constructor( comparativeExperimentId, exampleIds, filters, + includeAnnotatorDetail, limit, offset, preview, @@ -91,6 +96,13 @@ private constructor( */ 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 includeAnnotatorDetail(): Optional = + includeAnnotatorDetail.getOptional("include_annotator_detail") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -157,6 +169,16 @@ private constructor( */ @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters + /** + * Returns the raw JSON value of [includeAnnotatorDetail]. + * + * Unlike [includeAnnotatorDetail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("include_annotator_detail") + @ExcludeMissing + fun _includeAnnotatorDetail(): JsonField = includeAnnotatorDetail + /** * Returns the raw JSON value of [limit]. * @@ -226,6 +248,7 @@ private constructor( private var comparativeExperimentId: JsonField = JsonMissing.of() private var exampleIds: JsonField>? = null private var filters: JsonField = JsonMissing.of() + private var includeAnnotatorDetail: JsonField = JsonMissing.of() private var limit: JsonField = JsonMissing.of() private var offset: JsonField = JsonMissing.of() private var preview: JsonField = JsonMissing.of() @@ -239,6 +262,7 @@ private constructor( comparativeExperimentId = queryExampleSchemaWithRuns.comparativeExperimentId exampleIds = queryExampleSchemaWithRuns.exampleIds.map { it.toMutableList() } filters = queryExampleSchemaWithRuns.filters + includeAnnotatorDetail = queryExampleSchemaWithRuns.includeAnnotatorDetail limit = queryExampleSchemaWithRuns.limit offset = queryExampleSchemaWithRuns.offset preview = queryExampleSchemaWithRuns.preview @@ -334,6 +358,20 @@ private constructor( */ fun filters(filters: JsonField) = apply { this.filters = filters } + fun includeAnnotatorDetail(includeAnnotatorDetail: Boolean) = + includeAnnotatorDetail(JsonField.of(includeAnnotatorDetail)) + + /** + * Sets [Builder.includeAnnotatorDetail] to an arbitrary JSON value. + * + * You should usually call [Builder.includeAnnotatorDetail] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun includeAnnotatorDetail(includeAnnotatorDetail: JsonField) = apply { + this.includeAnnotatorDetail = includeAnnotatorDetail + } + fun limit(limit: Long) = limit(JsonField.of(limit)) /** @@ -429,6 +467,7 @@ private constructor( comparativeExperimentId, (exampleIds ?: JsonMissing.of()).map { it.toImmutable() }, filters, + includeAnnotatorDetail, limit, offset, preview, @@ -449,6 +488,7 @@ private constructor( comparativeExperimentId() exampleIds() filters().ifPresent { it.validate() } + includeAnnotatorDetail() limit() offset() preview() @@ -476,6 +516,7 @@ private constructor( (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + (exampleIds.asKnown().getOrNull()?.size ?: 0) + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (if (includeAnnotatorDetail.asKnown().isPresent) 1 else 0) + (if (limit.asKnown().isPresent) 1 else 0) + (if (offset.asKnown().isPresent) 1 else 0) + (if (preview.asKnown().isPresent) 1 else 0) + @@ -591,6 +632,7 @@ private constructor( comparativeExperimentId == other.comparativeExperimentId && exampleIds == other.exampleIds && filters == other.filters && + includeAnnotatorDetail == other.includeAnnotatorDetail && limit == other.limit && offset == other.offset && preview == other.preview && @@ -605,6 +647,7 @@ private constructor( comparativeExperimentId, exampleIds, filters, + includeAnnotatorDetail, limit, offset, preview, @@ -617,5 +660,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, exampleIds=$exampleIds, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}" + "QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, exampleIds=$exampleIds, filters=$filters, includeAnnotatorDetail=$includeAnnotatorDetail, 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 412e096d3..461b7fa97 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 @@ -65,6 +65,12 @@ private constructor( */ 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 includeAnnotatorDetail(): Optional = body.includeAnnotatorDetail() + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -124,6 +130,14 @@ private constructor( */ fun _filters(): JsonField = body._filters() + /** + * Returns the raw JSON value of [includeAnnotatorDetail]. + * + * Unlike [includeAnnotatorDetail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _includeAnnotatorDetail(): JsonField = body._includeAnnotatorDetail() + /** * Returns the raw JSON value of [limit]. * @@ -220,7 +234,7 @@ private constructor( * - [comparativeExperimentId] * - [exampleIds] * - [filters] - * - [limit] + * - [includeAnnotatorDetail] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -299,6 +313,21 @@ private constructor( */ fun filters(filters: JsonField) = apply { body.filters(filters) } + fun includeAnnotatorDetail(includeAnnotatorDetail: Boolean) = apply { + body.includeAnnotatorDetail(includeAnnotatorDetail) + } + + /** + * Sets [Builder.includeAnnotatorDetail] to an arbitrary JSON value. + * + * You should usually call [Builder.includeAnnotatorDetail] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun includeAnnotatorDetail(includeAnnotatorDetail: JsonField) = apply { + body.includeAnnotatorDetail(includeAnnotatorDetail) + } + fun limit(limit: Long?) = apply { body.limit(limit) } /** @@ -539,6 +568,7 @@ private constructor( private val comparativeExperimentId: JsonField, private val exampleIds: JsonField>, private val filters: JsonField, + private val includeAnnotatorDetail: JsonField, private val limit: JsonField, private val offset: JsonField, private val preview: JsonField, @@ -559,6 +589,9 @@ private constructor( @ExcludeMissing exampleIds: JsonField> = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), + @JsonProperty("include_annotator_detail") + @ExcludeMissing + includeAnnotatorDetail: JsonField = JsonMissing.of(), @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), @JsonProperty("preview") @ExcludeMissing preview: JsonField = JsonMissing.of(), @@ -571,6 +604,7 @@ private constructor( comparativeExperimentId, exampleIds, filters, + includeAnnotatorDetail, limit, offset, preview, @@ -604,6 +638,13 @@ private constructor( */ 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 includeAnnotatorDetail(): Optional = + includeAnnotatorDetail.getOptional("include_annotator_detail") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -670,6 +711,16 @@ private constructor( */ @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters + /** + * Returns the raw JSON value of [includeAnnotatorDetail]. + * + * Unlike [includeAnnotatorDetail], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("include_annotator_detail") + @ExcludeMissing + fun _includeAnnotatorDetail(): JsonField = includeAnnotatorDetail + /** * Returns the raw JSON value of [limit]. * @@ -739,6 +790,7 @@ private constructor( private var comparativeExperimentId: JsonField = JsonMissing.of() private var exampleIds: JsonField>? = null private var filters: JsonField = JsonMissing.of() + private var includeAnnotatorDetail: JsonField = JsonMissing.of() private var limit: JsonField = JsonMissing.of() private var offset: JsonField = JsonMissing.of() private var preview: JsonField = JsonMissing.of() @@ -752,6 +804,7 @@ private constructor( comparativeExperimentId = body.comparativeExperimentId exampleIds = body.exampleIds.map { it.toMutableList() } filters = body.filters + includeAnnotatorDetail = body.includeAnnotatorDetail limit = body.limit offset = body.offset preview = body.preview @@ -848,6 +901,20 @@ private constructor( */ fun filters(filters: JsonField) = apply { this.filters = filters } + fun includeAnnotatorDetail(includeAnnotatorDetail: Boolean) = + includeAnnotatorDetail(JsonField.of(includeAnnotatorDetail)) + + /** + * Sets [Builder.includeAnnotatorDetail] to an arbitrary JSON value. + * + * You should usually call [Builder.includeAnnotatorDetail] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeAnnotatorDetail(includeAnnotatorDetail: JsonField) = apply { + this.includeAnnotatorDetail = includeAnnotatorDetail + } + fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** @@ -957,6 +1024,7 @@ private constructor( comparativeExperimentId, (exampleIds ?: JsonMissing.of()).map { it.toImmutable() }, filters, + includeAnnotatorDetail, limit, offset, preview, @@ -977,6 +1045,7 @@ private constructor( comparativeExperimentId() exampleIds() filters().ifPresent { it.validate() } + includeAnnotatorDetail() limit() offset() preview() @@ -1005,6 +1074,7 @@ private constructor( (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + (exampleIds.asKnown().getOrNull()?.size ?: 0) + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (if (includeAnnotatorDetail.asKnown().isPresent) 1 else 0) + (if (limit.asKnown().isPresent) 1 else 0) + (if (offset.asKnown().isPresent) 1 else 0) + (if (preview.asKnown().isPresent) 1 else 0) + @@ -1021,6 +1091,7 @@ private constructor( comparativeExperimentId == other.comparativeExperimentId && exampleIds == other.exampleIds && filters == other.filters && + includeAnnotatorDetail == other.includeAnnotatorDetail && limit == other.limit && offset == other.offset && preview == other.preview && @@ -1035,6 +1106,7 @@ private constructor( comparativeExperimentId, exampleIds, filters, + includeAnnotatorDetail, limit, offset, preview, @@ -1047,7 +1119,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, exampleIds=$exampleIds, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}" + "Body{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, exampleIds=$exampleIds, filters=$filters, includeAnnotatorDetail=$includeAnnotatorDetail, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}" } class Filters diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponse.kt deleted file mode 100644 index 6d0616107..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponse.kt +++ /dev/null @@ -1,208 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.runs - -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.JsonValue -import com.langchain.smith.core.allMaxBy -import com.langchain.smith.core.getOrThrow -import com.langchain.smith.core.toImmutable -import com.langchain.smith.errors.LangChainInvalidDataException -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(using = RunCreateResponse.Deserializer::class) -@JsonSerialize(using = RunCreateResponse.Serializer::class) -class RunCreateResponse -private constructor( - private val examplesWithRuns: List? = null, - private val exampleWithRunsChes: List? = null, - private val _json: JsonValue? = null, -) { - - fun examplesWithRuns(): Optional> = Optional.ofNullable(examplesWithRuns) - - fun exampleWithRunsChes(): Optional> = - Optional.ofNullable(exampleWithRunsChes) - - fun isExamplesWithRuns(): Boolean = examplesWithRuns != null - - fun isExampleWithRunsChes(): Boolean = exampleWithRunsChes != null - - fun asExamplesWithRuns(): List = - examplesWithRuns.getOrThrow("examplesWithRuns") - - fun asExampleWithRunsChes(): List = - exampleWithRunsChes.getOrThrow("exampleWithRunsChes") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - examplesWithRuns != null -> visitor.visitExamplesWithRuns(examplesWithRuns) - exampleWithRunsChes != null -> visitor.visitExampleWithRunsChes(exampleWithRunsChes) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): RunCreateResponse = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitExamplesWithRuns(examplesWithRuns: List) { - examplesWithRuns.forEach { it.validate() } - } - - override fun visitExampleWithRunsChes( - exampleWithRunsChes: List - ) { - exampleWithRunsChes.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 visitExamplesWithRuns(examplesWithRuns: List) = - examplesWithRuns.sumOf { it.validity().toInt() } - - override fun visitExampleWithRunsChes( - exampleWithRunsChes: List - ) = exampleWithRunsChes.sumOf { it.validity().toInt() } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RunCreateResponse && - examplesWithRuns == other.examplesWithRuns && - exampleWithRunsChes == other.exampleWithRunsChes - } - - override fun hashCode(): Int = Objects.hash(examplesWithRuns, exampleWithRunsChes) - - override fun toString(): String = - when { - examplesWithRuns != null -> "RunCreateResponse{examplesWithRuns=$examplesWithRuns}" - exampleWithRunsChes != null -> - "RunCreateResponse{exampleWithRunsChes=$exampleWithRunsChes}" - _json != null -> "RunCreateResponse{_unknown=$_json}" - else -> throw IllegalStateException("Invalid RunCreateResponse") - } - - companion object { - - @JvmStatic - fun ofExamplesWithRuns(examplesWithRuns: List) = - RunCreateResponse(examplesWithRuns = examplesWithRuns.toImmutable()) - - @JvmStatic - fun ofExampleWithRunsChes(exampleWithRunsChes: List) = - RunCreateResponse(exampleWithRunsChes = exampleWithRunsChes.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [RunCreateResponse] to a value of type - * [T]. - */ - interface Visitor { - - fun visitExamplesWithRuns(examplesWithRuns: List): T - - fun visitExampleWithRunsChes(exampleWithRunsChes: List): T - - /** - * Maps an unknown variant of [RunCreateResponse] to a value of type [T]. - * - * An instance of [RunCreateResponse] 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 RunCreateResponse: $json") - } - } - - internal class Deserializer : BaseDeserializer(RunCreateResponse::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): RunCreateResponse { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef>())?.let { - RunCreateResponse(examplesWithRuns = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef>())?.let { - RunCreateResponse(exampleWithRunsChes = 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 -> RunCreateResponse(_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(RunCreateResponse::class) { - - override fun serialize( - value: RunCreateResponse, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.examplesWithRuns != null -> generator.writeObject(value.examplesWithRuns) - value.exampleWithRunsChes != null -> - generator.writeObject(value.exampleWithRunsChes) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid RunCreateResponse") - } - } - } -} 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 fc9fe4d5d..ac287b547 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 @@ -43,7 +43,6 @@ private constructor( private val correction: JsonField, private val createdAt: JsonField, private val error: JsonField, - private val extra: JsonField, private val feedbackConfig: JsonField, private val feedbackGroupId: JsonField, private val feedbackSource: JsonField, @@ -72,7 +71,6 @@ private constructor( @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), @JsonProperty("feedback_config") @ExcludeMissing feedbackConfig: JsonField = JsonMissing.of(), @@ -101,7 +99,6 @@ private constructor( correction, createdAt, error, - extra, feedbackConfig, feedbackGroupId, feedbackSource, @@ -158,12 +155,6 @@ private constructor( */ fun error(): Optional = error.getOptional("error") - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun extra(): Optional = extra.getOptional("extra") - /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -282,13 +273,6 @@ private constructor( */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error - /** - * Returns the raw JSON value of [extra]. - * - * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra - /** * Returns the raw JSON value of [feedbackConfig]. * @@ -404,7 +388,6 @@ private constructor( private var correction: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var error: JsonField = JsonMissing.of() - private var extra: JsonField = JsonMissing.of() private var feedbackConfig: JsonField = JsonMissing.of() private var feedbackGroupId: JsonField = JsonMissing.of() private var feedbackSource: JsonField = JsonMissing.of() @@ -426,7 +409,6 @@ private constructor( correction = feedbackCreateSchema.correction createdAt = feedbackCreateSchema.createdAt error = feedbackCreateSchema.error - extra = feedbackCreateSchema.extra feedbackConfig = feedbackCreateSchema.feedbackConfig feedbackGroupId = feedbackCreateSchema.feedbackGroupId feedbackSource = feedbackCreateSchema.feedbackSource @@ -546,19 +528,6 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } - fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - - /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ - fun extra(extra: Optional) = extra(extra.getOrNull()) - - /** - * Sets [Builder.extra] to an arbitrary JSON value. - * - * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun extra(extra: JsonField) = apply { this.extra = extra } - fun feedbackConfig(feedbackConfig: FeedbackConfig?) = feedbackConfig(JsonField.ofNullable(feedbackConfig)) @@ -779,7 +748,6 @@ private constructor( correction, createdAt, error, - extra, feedbackConfig, feedbackGroupId, feedbackSource, @@ -808,7 +776,6 @@ private constructor( correction().ifPresent { it.validate() } createdAt() error() - extra().ifPresent { it.validate() } feedbackConfig().ifPresent { it.validate() } feedbackGroupId() feedbackSource().ifPresent { it.validate() } @@ -844,7 +811,6 @@ private constructor( (correction.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (error.asKnown().isPresent) 1 else 0) + - (extra.asKnown().getOrNull()?.validity() ?: 0) + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (feedbackGroupId.asKnown().isPresent) 1 else 0) + (feedbackSource.asKnown().getOrNull()?.validity() ?: 0) + @@ -1133,105 +1099,6 @@ private constructor( } } - class Extra - @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 [Extra]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Extra]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(extra: Extra) = apply { - additionalProperties = extra.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 [Extra]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Extra = Extra(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Extra = 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 Extra && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Extra{additionalProperties=$additionalProperties}" - } - class FeedbackConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -2605,7 +2472,6 @@ private constructor( correction == other.correction && createdAt == other.createdAt && error == other.error && - extra == other.extra && feedbackConfig == other.feedbackConfig && feedbackGroupId == other.feedbackGroupId && feedbackSource == other.feedbackSource && @@ -2628,7 +2494,6 @@ private constructor( correction, createdAt, error, - extra, feedbackConfig, feedbackGroupId, feedbackSource, @@ -2646,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, extra=$extra, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, startTime=$startTime, 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/repos/RepoCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoCreateParams.kt index 844d34a11..0e0f3d893 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoCreateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoCreateParams.kt @@ -6,6 +6,7 @@ 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 @@ -54,6 +55,18 @@ private constructor( */ fun readme(): Optional = body.readme() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun repoType(): Optional = body.repoType() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun restrictedMode(): Optional = body.restrictedMode() + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -88,6 +101,20 @@ private constructor( */ fun _readme(): JsonField = body._readme() + /** + * Returns the raw JSON value of [repoType]. + * + * Unlike [repoType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repoType(): JsonField = body._repoType() + + /** + * Returns the raw JSON value of [restrictedMode]. + * + * Unlike [restrictedMode], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _restrictedMode(): JsonField = body._restrictedMode() + /** * Returns the raw JSON value of [tags]. * @@ -142,7 +169,7 @@ private constructor( * - [repoHandle] * - [description] * - [readme] - * - [tags] + * - [repoType] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -196,6 +223,41 @@ private constructor( */ fun readme(readme: JsonField) = apply { body.readme(readme) } + fun repoType(repoType: RepoType) = apply { body.repoType(repoType) } + + /** + * Sets [Builder.repoType] to an arbitrary JSON value. + * + * You should usually call [Builder.repoType] with a well-typed [RepoType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repoType(repoType: JsonField) = apply { body.repoType(repoType) } + + fun restrictedMode(restrictedMode: Boolean?) = apply { body.restrictedMode(restrictedMode) } + + /** + * Alias for [Builder.restrictedMode]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun restrictedMode(restrictedMode: Boolean) = restrictedMode(restrictedMode as Boolean?) + + /** Alias for calling [Builder.restrictedMode] with `restrictedMode.orElse(null)`. */ + fun restrictedMode(restrictedMode: Optional) = + restrictedMode(restrictedMode.getOrNull()) + + /** + * Sets [Builder.restrictedMode] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictedMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun restrictedMode(restrictedMode: JsonField) = apply { + body.restrictedMode(restrictedMode) + } + fun tags(tags: List?) = apply { body.tags(tags) } /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ @@ -365,6 +427,8 @@ private constructor( private val repoHandle: JsonField, private val description: JsonField, private val readme: JsonField, + private val repoType: JsonField, + private val restrictedMode: JsonField, private val tags: JsonField>, private val additionalProperties: MutableMap, ) { @@ -381,8 +445,23 @@ private constructor( @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("readme") @ExcludeMissing readme: JsonField = JsonMissing.of(), + @JsonProperty("repo_type") + @ExcludeMissing + repoType: JsonField = JsonMissing.of(), + @JsonProperty("restricted_mode") + @ExcludeMissing + restrictedMode: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), - ) : this(isPublic, repoHandle, description, readme, tags, mutableMapOf()) + ) : this( + isPublic, + repoHandle, + description, + readme, + repoType, + restrictedMode, + tags, + mutableMapOf(), + ) /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type or is @@ -408,6 +487,18 @@ private constructor( */ fun readme(): Optional = readme.getOptional("readme") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun repoType(): Optional = repoType.getOptional("repo_type") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun restrictedMode(): Optional = restrictedMode.getOptional("restricted_mode") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -446,6 +537,23 @@ private constructor( */ @JsonProperty("readme") @ExcludeMissing fun _readme(): JsonField = readme + /** + * Returns the raw JSON value of [repoType]. + * + * Unlike [repoType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_type") @ExcludeMissing fun _repoType(): JsonField = repoType + + /** + * Returns the raw JSON value of [restrictedMode]. + * + * Unlike [restrictedMode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("restricted_mode") + @ExcludeMissing + fun _restrictedMode(): JsonField = restrictedMode + /** * Returns the raw JSON value of [tags]. * @@ -486,6 +594,8 @@ private constructor( private var repoHandle: JsonField? = null private var description: JsonField = JsonMissing.of() private var readme: JsonField = JsonMissing.of() + private var repoType: JsonField = JsonMissing.of() + private var restrictedMode: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -495,6 +605,8 @@ private constructor( repoHandle = body.repoHandle description = body.description readme = body.readme + repoType = body.repoType + restrictedMode = body.restrictedMode tags = body.tags.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } @@ -551,6 +663,42 @@ private constructor( */ fun readme(readme: JsonField) = apply { this.readme = readme } + fun repoType(repoType: RepoType) = repoType(JsonField.of(repoType)) + + /** + * Sets [Builder.repoType] to an arbitrary JSON value. + * + * You should usually call [Builder.repoType] with a well-typed [RepoType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repoType(repoType: JsonField) = apply { this.repoType = repoType } + + fun restrictedMode(restrictedMode: Boolean?) = + restrictedMode(JsonField.ofNullable(restrictedMode)) + + /** + * Alias for [Builder.restrictedMode]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun restrictedMode(restrictedMode: Boolean) = restrictedMode(restrictedMode as Boolean?) + + /** Alias for calling [Builder.restrictedMode] with `restrictedMode.orElse(null)`. */ + fun restrictedMode(restrictedMode: Optional) = + restrictedMode(restrictedMode.getOrNull()) + + /** + * Sets [Builder.restrictedMode] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictedMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun restrictedMode(restrictedMode: JsonField) = apply { + this.restrictedMode = restrictedMode + } + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ @@ -615,6 +763,8 @@ private constructor( checkRequired("repoHandle", repoHandle), description, readme, + repoType, + restrictedMode, (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -631,6 +781,8 @@ private constructor( repoHandle() description() readme() + repoType().ifPresent { it.validate() } + restrictedMode() tags() validated = true } @@ -655,6 +807,8 @@ private constructor( (if (repoHandle.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (readme.asKnown().isPresent) 1 else 0) + + (repoType.asKnown().getOrNull()?.validity() ?: 0) + + (if (restrictedMode.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) override fun equals(other: Any?): Boolean { @@ -667,18 +821,168 @@ private constructor( repoHandle == other.repoHandle && description == other.description && readme == other.readme && + repoType == other.repoType && + restrictedMode == other.restrictedMode && tags == other.tags && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(isPublic, repoHandle, description, readme, tags, additionalProperties) + Objects.hash( + isPublic, + repoHandle, + description, + readme, + repoType, + restrictedMode, + tags, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{isPublic=$isPublic, repoHandle=$repoHandle, description=$description, readme=$readme, tags=$tags, additionalProperties=$additionalProperties}" + "Body{isPublic=$isPublic, repoHandle=$repoHandle, description=$description, readme=$readme, repoType=$repoType, restrictedMode=$restrictedMode, tags=$tags, additionalProperties=$additionalProperties}" + } + + class RepoType @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 PROMPT = of("prompt") + + @JvmField val FILE = of("file") + + @JvmField val AGENT = of("agent") + + @JvmField val SKILL = of("skill") + + @JvmStatic fun of(value: String) = RepoType(JsonField.of(value)) + } + + /** An enum containing [RepoType]'s known values. */ + enum class Known { + PROMPT, + FILE, + AGENT, + SKILL, + } + + /** + * An enum containing [RepoType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RepoType] 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 { + PROMPT, + FILE, + AGENT, + SKILL, + /** An enum member indicating that [RepoType] 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) { + PROMPT -> Value.PROMPT + FILE -> Value.FILE + AGENT -> Value.AGENT + SKILL -> Value.SKILL + 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) { + PROMPT -> Known.PROMPT + FILE -> Known.FILE + AGENT -> Known.AGENT + SKILL -> Known.SKILL + else -> throw LangChainInvalidDataException("Unknown RepoType: $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(): RepoType = 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 RepoType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoListParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoListParams.kt index f0fd74ad3..78edf7fab 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoListParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoListParams.kt @@ -23,6 +23,7 @@ private constructor( private val limit: Long?, private val offset: Long?, private val query: String?, + private val repoType: RepoType?, private val sortDirection: SortDirection?, private val sortField: SortField?, private val tagValueId: List?, @@ -48,6 +49,8 @@ private constructor( fun query(): Optional = Optional.ofNullable(query) + fun repoType(): Optional = Optional.ofNullable(repoType) + fun sortDirection(): Optional = Optional.ofNullable(sortDirection) fun sortField(): Optional = Optional.ofNullable(sortField) @@ -91,6 +94,7 @@ private constructor( private var limit: Long? = null private var offset: Long? = null private var query: String? = null + private var repoType: RepoType? = null private var sortDirection: SortDirection? = null private var sortField: SortField? = null private var tagValueId: MutableList? = null @@ -111,6 +115,7 @@ private constructor( limit = repoListParams.limit offset = repoListParams.offset query = repoListParams.query + repoType = repoListParams.repoType sortDirection = repoListParams.sortDirection sortField = repoListParams.sortField tagValueId = repoListParams.tagValueId?.toMutableList() @@ -175,6 +180,11 @@ private constructor( /** Alias for calling [Builder.query] with `query.orElse(null)`. */ fun query(query: Optional) = query(query.getOrNull()) + fun repoType(repoType: RepoType?) = apply { this.repoType = repoType } + + /** Alias for calling [Builder.repoType] with `repoType.orElse(null)`. */ + fun repoType(repoType: Optional) = repoType(repoType.getOrNull()) + fun sortDirection(sortDirection: SortDirection?) = apply { this.sortDirection = sortDirection } @@ -373,6 +383,7 @@ private constructor( limit, offset, query, + repoType, sortDirection, sortField, tagValueId?.toImmutable(), @@ -398,6 +409,7 @@ private constructor( limit?.let { put("limit", it.toString()) } offset?.let { put("offset", it.toString()) } query?.let { put("query", it) } + repoType?.let { put("repo_type", it.toString()) } sortDirection?.let { put("sort_direction", it.toString()) } sortField?.let { put("sort_field", it.toString()) } tagValueId?.let { put("tag_value_id", it.joinToString(",")) } @@ -673,6 +685,145 @@ private constructor( override fun toString() = value.toString() } + class RepoType @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 PROMPT = of("prompt") + + @JvmField val FILE = of("file") + + @JvmField val AGENT = of("agent") + + @JvmField val SKILL = of("skill") + + @JvmStatic fun of(value: String) = RepoType(JsonField.of(value)) + } + + /** An enum containing [RepoType]'s known values. */ + enum class Known { + PROMPT, + FILE, + AGENT, + SKILL, + } + + /** + * An enum containing [RepoType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RepoType] 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 { + PROMPT, + FILE, + AGENT, + SKILL, + /** An enum member indicating that [RepoType] 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) { + PROMPT -> Value.PROMPT + FILE -> Value.FILE + AGENT -> Value.AGENT + SKILL -> Value.SKILL + 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) { + PROMPT -> Known.PROMPT + FILE -> Known.FILE + AGENT -> Known.AGENT + SKILL -> Known.SKILL + else -> throw LangChainInvalidDataException("Unknown RepoType: $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(): RepoType = 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 RepoType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class SortDirection @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -963,6 +1114,7 @@ private constructor( limit == other.limit && offset == other.offset && query == other.query && + repoType == other.repoType && sortDirection == other.sortDirection && sortField == other.sortField && tagValueId == other.tagValueId && @@ -984,6 +1136,7 @@ private constructor( limit, offset, query, + repoType, sortDirection, sortField, tagValueId, @@ -998,5 +1151,5 @@ private constructor( ) override fun toString() = - "RepoListParams{hasCommits=$hasCommits, isArchived=$isArchived, isPublic=$isPublic, limit=$limit, offset=$offset, query=$query, sortDirection=$sortDirection, sortField=$sortField, tagValueId=$tagValueId, tags=$tags, tenantHandle=$tenantHandle, tenantId=$tenantId, upstreamRepoHandle=$upstreamRepoHandle, upstreamRepoOwner=$upstreamRepoOwner, withLatestManifest=$withLatestManifest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "RepoListParams{hasCommits=$hasCommits, isArchived=$isArchived, isPublic=$isPublic, limit=$limit, offset=$offset, query=$query, repoType=$repoType, sortDirection=$sortDirection, sortField=$sortField, tagValueId=$tagValueId, tags=$tags, tenantHandle=$tenantHandle, tenantId=$tenantId, upstreamRepoHandle=$upstreamRepoHandle, upstreamRepoOwner=$upstreamRepoOwner, withLatestManifest=$withLatestManifest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoUpdateParams.kt index 74ac3930f..c2e342f63 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoUpdateParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoUpdateParams.kt @@ -60,6 +60,12 @@ private constructor( */ fun readme(): Optional = body.readme() + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun restrictedMode(): Optional = body.restrictedMode() + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -94,6 +100,13 @@ private constructor( */ fun _readme(): JsonField = body._readme() + /** + * Returns the raw JSON value of [restrictedMode]. + * + * Unlike [restrictedMode], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _restrictedMode(): JsonField = body._restrictedMode() + /** * Returns the raw JSON value of [tags]. * @@ -158,7 +171,7 @@ private constructor( * - [isArchived] * - [isPublic] * - [readme] - * - [tags] + * - [restrictedMode] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -232,6 +245,30 @@ private constructor( */ fun readme(readme: JsonField) = apply { body.readme(readme) } + fun restrictedMode(restrictedMode: Boolean?) = apply { body.restrictedMode(restrictedMode) } + + /** + * Alias for [Builder.restrictedMode]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun restrictedMode(restrictedMode: Boolean) = restrictedMode(restrictedMode as Boolean?) + + /** Alias for calling [Builder.restrictedMode] with `restrictedMode.orElse(null)`. */ + fun restrictedMode(restrictedMode: Optional) = + restrictedMode(restrictedMode.getOrNull()) + + /** + * Sets [Builder.restrictedMode] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictedMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun restrictedMode(restrictedMode: JsonField) = apply { + body.restrictedMode(restrictedMode) + } + fun tags(tags: List?) = apply { body.tags(tags) } /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ @@ -413,6 +450,7 @@ private constructor( private val isArchived: JsonField, private val isPublic: JsonField, private val readme: JsonField, + private val restrictedMode: JsonField, private val tags: JsonField>, private val additionalProperties: MutableMap, ) { @@ -429,8 +467,11 @@ private constructor( @ExcludeMissing isPublic: JsonField = JsonMissing.of(), @JsonProperty("readme") @ExcludeMissing readme: JsonField = JsonMissing.of(), + @JsonProperty("restricted_mode") + @ExcludeMissing + restrictedMode: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), - ) : this(description, isArchived, isPublic, readme, tags, mutableMapOf()) + ) : this(description, isArchived, isPublic, readme, restrictedMode, tags, mutableMapOf()) /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -456,6 +497,12 @@ private constructor( */ fun readme(): Optional = readme.getOptional("readme") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun restrictedMode(): Optional = restrictedMode.getOptional("restricted_mode") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -494,6 +541,16 @@ private constructor( */ @JsonProperty("readme") @ExcludeMissing fun _readme(): JsonField = readme + /** + * Returns the raw JSON value of [restrictedMode]. + * + * Unlike [restrictedMode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("restricted_mode") + @ExcludeMissing + fun _restrictedMode(): JsonField = restrictedMode + /** * Returns the raw JSON value of [tags]. * @@ -526,6 +583,7 @@ private constructor( private var isArchived: JsonField = JsonMissing.of() private var isPublic: JsonField = JsonMissing.of() private var readme: JsonField = JsonMissing.of() + private var restrictedMode: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -535,6 +593,7 @@ private constructor( isArchived = body.isArchived isPublic = body.isPublic readme = body.readme + restrictedMode = body.restrictedMode tags = body.tags.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } @@ -611,6 +670,31 @@ private constructor( */ fun readme(readme: JsonField) = apply { this.readme = readme } + fun restrictedMode(restrictedMode: Boolean?) = + restrictedMode(JsonField.ofNullable(restrictedMode)) + + /** + * Alias for [Builder.restrictedMode]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun restrictedMode(restrictedMode: Boolean) = restrictedMode(restrictedMode as Boolean?) + + /** Alias for calling [Builder.restrictedMode] with `restrictedMode.orElse(null)`. */ + fun restrictedMode(restrictedMode: Optional) = + restrictedMode(restrictedMode.getOrNull()) + + /** + * Sets [Builder.restrictedMode] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictedMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun restrictedMode(restrictedMode: JsonField) = apply { + this.restrictedMode = restrictedMode + } + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ @@ -667,6 +751,7 @@ private constructor( isArchived, isPublic, readme, + restrictedMode, (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -683,6 +768,7 @@ private constructor( isArchived() isPublic() readme() + restrictedMode() tags() validated = true } @@ -707,6 +793,7 @@ private constructor( (if (isArchived.asKnown().isPresent) 1 else 0) + (if (isPublic.asKnown().isPresent) 1 else 0) + (if (readme.asKnown().isPresent) 1 else 0) + + (if (restrictedMode.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) override fun equals(other: Any?): Boolean { @@ -719,18 +806,27 @@ private constructor( isArchived == other.isArchived && isPublic == other.isPublic && readme == other.readme && + restrictedMode == other.restrictedMode && tags == other.tags && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(description, isArchived, isPublic, readme, tags, additionalProperties) + Objects.hash( + description, + isArchived, + isPublic, + readme, + restrictedMode, + tags, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{description=$description, isArchived=$isArchived, isPublic=$isPublic, readme=$readme, tags=$tags, additionalProperties=$additionalProperties}" + "Body{description=$description, isArchived=$isArchived, isPublic=$isPublic, readme=$readme, restrictedMode=$restrictedMode, tags=$tags, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoWithLookups.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoWithLookups.kt index 99958aa78..f83d8e3a8 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoWithLookups.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/repos/RepoWithLookups.kt @@ -6,6 +6,7 @@ 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 @@ -36,6 +37,7 @@ private constructor( private val numViews: JsonField, private val owner: JsonField, private val repoHandle: JsonField, + private val repoType: JsonField, private val tags: JsonField>, private val tenantId: JsonField, private val updatedAt: JsonField, @@ -48,6 +50,7 @@ private constructor( private val originalRepoFullName: JsonField, private val originalRepoId: JsonField, private val readme: JsonField, + private val restrictedMode: JsonField, private val upstreamRepoFullName: JsonField, private val upstreamRepoId: JsonField, private val additionalProperties: MutableMap, @@ -74,6 +77,7 @@ private constructor( @JsonProperty("repo_handle") @ExcludeMissing repoHandle: JsonField = JsonMissing.of(), + @JsonProperty("repo_type") @ExcludeMissing repoType: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), @JsonProperty("updated_at") @@ -102,6 +106,9 @@ private constructor( @ExcludeMissing originalRepoId: JsonField = JsonMissing.of(), @JsonProperty("readme") @ExcludeMissing readme: JsonField = JsonMissing.of(), + @JsonProperty("restricted_mode") + @ExcludeMissing + restrictedMode: JsonField = JsonMissing.of(), @JsonProperty("upstream_repo_full_name") @ExcludeMissing upstreamRepoFullName: JsonField = JsonMissing.of(), @@ -120,6 +127,7 @@ private constructor( numViews, owner, repoHandle, + repoType, tags, tenantId, updatedAt, @@ -132,6 +140,7 @@ private constructor( originalRepoFullName, originalRepoId, readme, + restrictedMode, upstreamRepoFullName, upstreamRepoId, mutableMapOf(), @@ -203,6 +212,12 @@ private constructor( */ fun repoHandle(): String = repoHandle.getRequired("repo_handle") + /** + * @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 repoType(): RepoType = repoType.getRequired("repo_type") + /** * @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). @@ -279,6 +294,12 @@ private constructor( */ fun readme(): Optional = readme.getOptional("readme") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun restrictedMode(): Optional = restrictedMode.getOptional("restricted_mode") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -373,6 +394,13 @@ private constructor( */ @JsonProperty("repo_handle") @ExcludeMissing fun _repoHandle(): JsonField = repoHandle + /** + * Returns the raw JSON value of [repoType]. + * + * Unlike [repoType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_type") @ExcludeMissing fun _repoType(): JsonField = repoType + /** * Returns the raw JSON value of [tags]. * @@ -473,6 +501,15 @@ private constructor( */ @JsonProperty("readme") @ExcludeMissing fun _readme(): JsonField = readme + /** + * Returns the raw JSON value of [restrictedMode]. + * + * Unlike [restrictedMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("restricted_mode") + @ExcludeMissing + fun _restrictedMode(): JsonField = restrictedMode + /** * Returns the raw JSON value of [upstreamRepoFullName]. * @@ -522,6 +559,7 @@ private constructor( * .numViews() * .owner() * .repoHandle() + * .repoType() * .tags() * .tenantId() * .updatedAt() @@ -544,6 +582,7 @@ private constructor( private var numViews: JsonField? = null private var owner: JsonField? = null private var repoHandle: JsonField? = null + private var repoType: JsonField? = null private var tags: JsonField>? = null private var tenantId: JsonField? = null private var updatedAt: JsonField? = null @@ -556,6 +595,7 @@ private constructor( private var originalRepoFullName: JsonField = JsonMissing.of() private var originalRepoId: JsonField = JsonMissing.of() private var readme: JsonField = JsonMissing.of() + private var restrictedMode: JsonField = JsonMissing.of() private var upstreamRepoFullName: JsonField = JsonMissing.of() private var upstreamRepoId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -573,6 +613,7 @@ private constructor( numViews = repoWithLookups.numViews owner = repoWithLookups.owner repoHandle = repoWithLookups.repoHandle + repoType = repoWithLookups.repoType tags = repoWithLookups.tags.map { it.toMutableList() } tenantId = repoWithLookups.tenantId updatedAt = repoWithLookups.updatedAt @@ -585,6 +626,7 @@ private constructor( originalRepoFullName = repoWithLookups.originalRepoFullName originalRepoId = repoWithLookups.originalRepoId readme = repoWithLookups.readme + restrictedMode = repoWithLookups.restrictedMode upstreamRepoFullName = repoWithLookups.upstreamRepoFullName upstreamRepoId = repoWithLookups.upstreamRepoId additionalProperties = repoWithLookups.additionalProperties.toMutableMap() @@ -708,6 +750,17 @@ private constructor( */ fun repoHandle(repoHandle: JsonField) = apply { this.repoHandle = repoHandle } + fun repoType(repoType: RepoType) = repoType(JsonField.of(repoType)) + + /** + * Sets [Builder.repoType] to an arbitrary JSON value. + * + * You should usually call [Builder.repoType] with a well-typed [RepoType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repoType(repoType: JsonField) = apply { this.repoType = repoType } + fun tags(tags: List) = tags(JsonField.of(tags)) /** @@ -921,6 +974,19 @@ private constructor( */ fun readme(readme: JsonField) = apply { this.readme = readme } + fun restrictedMode(restrictedMode: Boolean) = restrictedMode(JsonField.of(restrictedMode)) + + /** + * Sets [Builder.restrictedMode] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictedMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun restrictedMode(restrictedMode: JsonField) = apply { + this.restrictedMode = restrictedMode + } + fun upstreamRepoFullName(upstreamRepoFullName: String?) = upstreamRepoFullName(JsonField.ofNullable(upstreamRepoFullName)) @@ -997,6 +1063,7 @@ private constructor( * .numViews() * .owner() * .repoHandle() + * .repoType() * .tags() * .tenantId() * .updatedAt() @@ -1017,6 +1084,7 @@ private constructor( checkRequired("numViews", numViews), checkRequired("owner", owner), checkRequired("repoHandle", repoHandle), + checkRequired("repoType", repoType), checkRequired("tags", tags).map { it.toImmutable() }, checkRequired("tenantId", tenantId), checkRequired("updatedAt", updatedAt), @@ -1029,6 +1097,7 @@ private constructor( originalRepoFullName, originalRepoId, readme, + restrictedMode, upstreamRepoFullName, upstreamRepoId, additionalProperties.toMutableMap(), @@ -1053,6 +1122,7 @@ private constructor( numViews() owner() repoHandle() + repoType().validate() tags() tenantId() updatedAt() @@ -1065,6 +1135,7 @@ private constructor( originalRepoFullName() originalRepoId() readme() + restrictedMode() upstreamRepoFullName() upstreamRepoId() validated = true @@ -1096,6 +1167,7 @@ private constructor( (if (numViews.asKnown().isPresent) 1 else 0) + (if (owner.asKnown().isPresent) 1 else 0) + (if (repoHandle.asKnown().isPresent) 1 else 0) + + (repoType.asKnown().getOrNull()?.validity() ?: 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (tenantId.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + @@ -1108,9 +1180,149 @@ private constructor( (if (originalRepoFullName.asKnown().isPresent) 1 else 0) + (if (originalRepoId.asKnown().isPresent) 1 else 0) + (if (readme.asKnown().isPresent) 1 else 0) + + (if (restrictedMode.asKnown().isPresent) 1 else 0) + (if (upstreamRepoFullName.asKnown().isPresent) 1 else 0) + (if (upstreamRepoId.asKnown().isPresent) 1 else 0) + class RepoType @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 PROMPT = of("prompt") + + @JvmField val FILE = of("file") + + @JvmField val AGENT = of("agent") + + @JvmField val SKILL = of("skill") + + @JvmStatic fun of(value: String) = RepoType(JsonField.of(value)) + } + + /** An enum containing [RepoType]'s known values. */ + enum class Known { + PROMPT, + FILE, + AGENT, + SKILL, + } + + /** + * An enum containing [RepoType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RepoType] 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 { + PROMPT, + FILE, + AGENT, + SKILL, + /** An enum member indicating that [RepoType] 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) { + PROMPT -> Value.PROMPT + FILE -> Value.FILE + AGENT -> Value.AGENT + SKILL -> Value.SKILL + 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) { + PROMPT -> Known.PROMPT + FILE -> Known.FILE + AGENT -> Known.AGENT + SKILL -> Known.SKILL + else -> throw LangChainInvalidDataException("Unknown RepoType: $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(): RepoType = 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 RepoType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1128,6 +1340,7 @@ private constructor( numViews == other.numViews && owner == other.owner && repoHandle == other.repoHandle && + repoType == other.repoType && tags == other.tags && tenantId == other.tenantId && updatedAt == other.updatedAt && @@ -1140,6 +1353,7 @@ private constructor( originalRepoFullName == other.originalRepoFullName && originalRepoId == other.originalRepoId && readme == other.readme && + restrictedMode == other.restrictedMode && upstreamRepoFullName == other.upstreamRepoFullName && upstreamRepoId == other.upstreamRepoId && additionalProperties == other.additionalProperties @@ -1158,6 +1372,7 @@ private constructor( numViews, owner, repoHandle, + repoType, tags, tenantId, updatedAt, @@ -1170,6 +1385,7 @@ private constructor( originalRepoFullName, originalRepoId, readme, + restrictedMode, upstreamRepoFullName, upstreamRepoId, additionalProperties, @@ -1179,5 +1395,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RepoWithLookups{id=$id, createdAt=$createdAt, fullName=$fullName, isArchived=$isArchived, isPublic=$isPublic, numCommits=$numCommits, numDownloads=$numDownloads, numLikes=$numLikes, numViews=$numViews, owner=$owner, repoHandle=$repoHandle, tags=$tags, tenantId=$tenantId, updatedAt=$updatedAt, commitTags=$commitTags, createdBy=$createdBy, description=$description, lastCommitHash=$lastCommitHash, latestCommitManifest=$latestCommitManifest, likedByAuthUser=$likedByAuthUser, originalRepoFullName=$originalRepoFullName, originalRepoId=$originalRepoId, readme=$readme, upstreamRepoFullName=$upstreamRepoFullName, upstreamRepoId=$upstreamRepoId, additionalProperties=$additionalProperties}" + "RepoWithLookups{id=$id, createdAt=$createdAt, fullName=$fullName, isArchived=$isArchived, isPublic=$isPublic, numCommits=$numCommits, numDownloads=$numDownloads, numLikes=$numLikes, numViews=$numViews, owner=$owner, repoHandle=$repoHandle, repoType=$repoType, tags=$tags, tenantId=$tenantId, updatedAt=$updatedAt, commitTags=$commitTags, createdBy=$createdBy, description=$description, lastCommitHash=$lastCommitHash, latestCommitManifest=$latestCommitManifest, likedByAuthUser=$likedByAuthUser, originalRepoFullName=$originalRepoFullName, originalRepoId=$originalRepoId, readme=$readme, restrictedMode=$restrictedMode, upstreamRepoFullName=$upstreamRepoFullName, upstreamRepoId=$upstreamRepoId, additionalProperties=$additionalProperties}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/BodyParamsForRunSchema.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/BodyParamsForRunSchema.kt new file mode 100644 index 000000000..039d243f9 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/BodyParamsForRunSchema.kt @@ -0,0 +1,1766 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.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.checkKnown +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 + +/** Query params for run endpoints. */ +class BodyParamsForRunSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField>, + private val cursor: JsonField, + private val dataSourceType: JsonField, + private val endTime: JsonField, + private val error: JsonField, + private val executionOrder: JsonField, + private val filter: JsonField, + private val isRoot: JsonField, + private val limit: JsonField, + private val order: JsonField, + private val parentRun: JsonField, + private val query: JsonField, + private val referenceExample: JsonField>, + private val runType: JsonField, + private val searchFilter: JsonField, + private val select: JsonField>, + private val session: JsonField>, + private val skipPagination: JsonField, + private val skipPrevCursor: JsonField, + private val startTime: JsonField, + private val trace: JsonField, + private val traceFilter: JsonField, + private val treeFilter: JsonField, + private val useExperimentalSearch: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + @JsonProperty("data_source_type") + @ExcludeMissing + dataSourceType: JsonField = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing isRoot: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("order") @ExcludeMissing order: JsonField = JsonMissing.of(), + @JsonProperty("parent_run") @ExcludeMissing parentRun: JsonField = JsonMissing.of(), + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("reference_example") + @ExcludeMissing + referenceExample: JsonField> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField = JsonMissing.of(), + @JsonProperty("search_filter") + @ExcludeMissing + searchFilter: JsonField = JsonMissing.of(), + @JsonProperty("select") @ExcludeMissing select: JsonField> = JsonMissing.of(), + @JsonProperty("session") + @ExcludeMissing + session: JsonField> = JsonMissing.of(), + @JsonProperty("skip_pagination") + @ExcludeMissing + skipPagination: JsonField = JsonMissing.of(), + @JsonProperty("skip_prev_cursor") + @ExcludeMissing + skipPrevCursor: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("trace") @ExcludeMissing trace: JsonField = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField = JsonMissing.of(), + @JsonProperty("use_experimental_search") + @ExcludeMissing + useExperimentalSearch: JsonField = JsonMissing.of(), + ) : this( + id, + cursor, + dataSourceType, + endTime, + error, + executionOrder, + filter, + isRoot, + limit, + order, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + skipPrevCursor, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional> = id.getOptional("id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * Enum for run data source types. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dataSourceType(): Optional = + dataSourceType.getOptional("data_source_type") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun executionOrder(): Optional = executionOrder.getOptional("execution_order") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isRoot(): Optional = isRoot.getOptional("is_root") + + /** + * @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") + + /** + * Enum for run start date order. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun order(): Optional = order.getOptional("order") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parentRun(): Optional = parentRun.getOptional("parent_run") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun query(): Optional = query.getOptional("query") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceExample(): Optional> = + referenceExample.getOptional("reference_example") + + /** + * Enum for run types. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun runType(): Optional = runType.getOptional("run_type") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun searchFilter(): Optional = searchFilter.getOptional("search_filter") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun select(): Optional> = select.getOptional("select") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun session(): Optional> = session.getOptional("session") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun skipPagination(): Optional = skipPagination.getOptional("skip_pagination") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun skipPrevCursor(): Optional = skipPrevCursor.getOptional("skip_prev_cursor") + + /** + * @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 trace(): Optional = trace.getOptional("trace") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun traceFilter(): Optional = traceFilter.getOptional("trace_filter") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun treeFilter(): Optional = treeFilter.getOptional("tree_filter") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useExperimentalSearch(): Optional = + useExperimentalSearch.getOptional("use_experimental_search") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField> = id + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * Returns the raw JSON value of [dataSourceType]. + * + * Unlike [dataSourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_source_type") + @ExcludeMissing + fun _dataSourceType(): JsonField = dataSourceType + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField = executionOrder + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [isRoot]. + * + * Unlike [isRoot], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + + /** + * 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 [order]. + * + * Unlike [order], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("order") @ExcludeMissing fun _order(): JsonField = order + + /** + * Returns the raw JSON value of [parentRun]. + * + * Unlike [parentRun], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run") @ExcludeMissing fun _parentRun(): JsonField = parentRun + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [referenceExample]. + * + * Unlike [referenceExample], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example") + @ExcludeMissing + fun _referenceExample(): JsonField> = referenceExample + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType + + /** + * Returns the raw JSON value of [searchFilter]. + * + * Unlike [searchFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("search_filter") + @ExcludeMissing + fun _searchFilter(): JsonField = searchFilter + + /** + * Returns the raw JSON value of [select]. + * + * Unlike [select], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("select") @ExcludeMissing fun _select(): JsonField> = select + + /** + * Returns the raw JSON value of [session]. + * + * Unlike [session], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session") @ExcludeMissing fun _session(): JsonField> = session + + /** + * Returns the raw JSON value of [skipPagination]. + * + * Unlike [skipPagination], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("skip_pagination") + @ExcludeMissing + fun _skipPagination(): JsonField = skipPagination + + /** + * Returns the raw JSON value of [skipPrevCursor]. + * + * Unlike [skipPrevCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("skip_prev_cursor") + @ExcludeMissing + fun _skipPrevCursor(): JsonField = skipPrevCursor + + /** + * 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 [trace]. + * + * Unlike [trace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace") @ExcludeMissing fun _trace(): JsonField = trace + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField = traceFilter + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") @ExcludeMissing fun _treeFilter(): JsonField = treeFilter + + /** + * Returns the raw JSON value of [useExperimentalSearch]. + * + * Unlike [useExperimentalSearch], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_experimental_search") + @ExcludeMissing + fun _useExperimentalSearch(): JsonField = useExperimentalSearch + + @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 [BodyParamsForRunSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BodyParamsForRunSchema]. */ + class Builder internal constructor() { + + private var id: JsonField>? = null + private var cursor: JsonField = JsonMissing.of() + private var dataSourceType: JsonField = JsonMissing.of() + private var endTime: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() + private var executionOrder: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var isRoot: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var order: JsonField = JsonMissing.of() + private var parentRun: JsonField = JsonMissing.of() + private var query: JsonField = JsonMissing.of() + private var referenceExample: JsonField>? = null + private var runType: JsonField = JsonMissing.of() + private var searchFilter: JsonField = JsonMissing.of() + private var select: JsonField>? = null + private var session: JsonField>? = null + private var skipPagination: JsonField = JsonMissing.of() + private var skipPrevCursor: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var trace: JsonField = JsonMissing.of() + private var traceFilter: JsonField = JsonMissing.of() + private var treeFilter: JsonField = JsonMissing.of() + private var useExperimentalSearch: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bodyParamsForRunSchema: BodyParamsForRunSchema) = apply { + id = bodyParamsForRunSchema.id.map { it.toMutableList() } + cursor = bodyParamsForRunSchema.cursor + dataSourceType = bodyParamsForRunSchema.dataSourceType + endTime = bodyParamsForRunSchema.endTime + error = bodyParamsForRunSchema.error + executionOrder = bodyParamsForRunSchema.executionOrder + filter = bodyParamsForRunSchema.filter + isRoot = bodyParamsForRunSchema.isRoot + limit = bodyParamsForRunSchema.limit + order = bodyParamsForRunSchema.order + parentRun = bodyParamsForRunSchema.parentRun + query = bodyParamsForRunSchema.query + referenceExample = bodyParamsForRunSchema.referenceExample.map { it.toMutableList() } + runType = bodyParamsForRunSchema.runType + searchFilter = bodyParamsForRunSchema.searchFilter + select = bodyParamsForRunSchema.select.map { it.toMutableList() } + session = bodyParamsForRunSchema.session.map { it.toMutableList() } + skipPagination = bodyParamsForRunSchema.skipPagination + skipPrevCursor = bodyParamsForRunSchema.skipPrevCursor + startTime = bodyParamsForRunSchema.startTime + trace = bodyParamsForRunSchema.trace + traceFilter = bodyParamsForRunSchema.traceFilter + treeFilter = bodyParamsForRunSchema.treeFilter + useExperimentalSearch = bodyParamsForRunSchema.useExperimentalSearch + additionalProperties = bodyParamsForRunSchema.additionalProperties.toMutableMap() + } + + fun id(id: List?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField>) = apply { this.id = id.map { it.toMutableList() } } + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { + this.id = + (this.id ?: JsonField.of(mutableListOf())).also { checkKnown("id", it).add(id) } + } + + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + /** Enum for run data source types. */ + fun dataSourceType(dataSourceType: RunsFilterDataSourceTypeEnum?) = + dataSourceType(JsonField.ofNullable(dataSourceType)) + + /** Alias for calling [Builder.dataSourceType] with `dataSourceType.orElse(null)`. */ + fun dataSourceType(dataSourceType: Optional) = + dataSourceType(dataSourceType.getOrNull()) + + /** + * Sets [Builder.dataSourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataSourceType] with a well-typed + * [RunsFilterDataSourceTypeEnum] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dataSourceType(dataSourceType: JsonField) = apply { + this.dataSourceType = dataSourceType + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun error(error: Boolean?) = error(JsonField.ofNullable(error)) + + /** + * Alias for [Builder.error]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun error(error: Boolean) = error(error as Boolean?) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun executionOrder(executionOrder: Long?) = + executionOrder(JsonField.ofNullable(executionOrder)) + + /** + * Alias for [Builder.executionOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionOrder(executionOrder: Long) = executionOrder(executionOrder as Long?) + + /** Alias for calling [Builder.executionOrder] with `executionOrder.orElse(null)`. */ + fun executionOrder(executionOrder: Optional) = + executionOrder(executionOrder.getOrNull()) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField) = apply { + this.executionOrder = executionOrder + } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) + + /** + * Alias for [Builder.isRoot]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) + + /** Alias for calling [Builder.isRoot] with `isRoot.orElse(null)`. */ + fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) + + /** + * Sets [Builder.isRoot] to an arbitrary JSON value. + * + * You should usually call [Builder.isRoot] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * 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 } + + /** Enum for run start date order. */ + fun order(order: Order) = order(JsonField.of(order)) + + /** + * Sets [Builder.order] to an arbitrary JSON value. + * + * You should usually call [Builder.order] with a well-typed [Order] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun order(order: JsonField) = apply { this.order = order } + + fun parentRun(parentRun: String?) = parentRun(JsonField.ofNullable(parentRun)) + + /** Alias for calling [Builder.parentRun] with `parentRun.orElse(null)`. */ + fun parentRun(parentRun: Optional) = parentRun(parentRun.getOrNull()) + + /** + * Sets [Builder.parentRun] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRun] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRun(parentRun: JsonField) = apply { this.parentRun = parentRun } + + fun query(query: String?) = query(JsonField.ofNullable(query)) + + /** Alias for calling [Builder.query] with `query.orElse(null)`. */ + fun query(query: Optional) = query(query.getOrNull()) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + fun referenceExample(referenceExample: List?) = + referenceExample(JsonField.ofNullable(referenceExample)) + + /** Alias for calling [Builder.referenceExample] with `referenceExample.orElse(null)`. */ + fun referenceExample(referenceExample: Optional>) = + referenceExample(referenceExample.getOrNull()) + + /** + * Sets [Builder.referenceExample] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExample] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExample(referenceExample: JsonField>) = apply { + this.referenceExample = referenceExample.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.referenceExample]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addReferenceExample(referenceExample: String) = apply { + this.referenceExample = + (this.referenceExample ?: JsonField.of(mutableListOf())).also { + checkKnown("referenceExample", it).add(referenceExample) + } + } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum?) = runType(JsonField.ofNullable(runType)) + + /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ + fun runType(runType: Optional) = runType(runType.getOrNull()) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField) = apply { this.runType = runType } + + fun searchFilter(searchFilter: String?) = searchFilter(JsonField.ofNullable(searchFilter)) + + /** Alias for calling [Builder.searchFilter] with `searchFilter.orElse(null)`. */ + fun searchFilter(searchFilter: Optional) = searchFilter(searchFilter.getOrNull()) + + /** + * Sets [Builder.searchFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.searchFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun searchFilter(searchFilter: JsonField) = apply { + this.searchFilter = searchFilter + } + + fun select(select: List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun select(select: JsonField>) = apply { + this.select = select.map { it.toMutableList() } + } + + /** + * Adds a single [Select] to [Builder.select]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelect(select: Select) = apply { + this.select = + (this.select ?: JsonField.of(mutableListOf())).also { + checkKnown("select", it).add(select) + } + } + + fun session(session: List?) = session(JsonField.ofNullable(session)) + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional>) = session(session.getOrNull()) + + /** + * Sets [Builder.session] to an arbitrary JSON value. + * + * You should usually call [Builder.session] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun session(session: JsonField>) = apply { + this.session = session.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = + (this.session ?: JsonField.of(mutableListOf())).also { + checkKnown("session", it).add(session) + } + } + + fun skipPagination(skipPagination: Boolean?) = + skipPagination(JsonField.ofNullable(skipPagination)) + + /** + * Alias for [Builder.skipPagination]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun skipPagination(skipPagination: Boolean) = skipPagination(skipPagination as Boolean?) + + /** Alias for calling [Builder.skipPagination] with `skipPagination.orElse(null)`. */ + fun skipPagination(skipPagination: Optional) = + skipPagination(skipPagination.getOrNull()) + + /** + * Sets [Builder.skipPagination] to an arbitrary JSON value. + * + * You should usually call [Builder.skipPagination] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipPagination(skipPagination: JsonField) = apply { + this.skipPagination = skipPagination + } + + fun skipPrevCursor(skipPrevCursor: Boolean) = skipPrevCursor(JsonField.of(skipPrevCursor)) + + /** + * Sets [Builder.skipPrevCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.skipPrevCursor] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipPrevCursor(skipPrevCursor: JsonField) = apply { + this.skipPrevCursor = skipPrevCursor + } + + 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 trace(trace: String?) = trace(JsonField.ofNullable(trace)) + + /** Alias for calling [Builder.trace] with `trace.orElse(null)`. */ + fun trace(trace: Optional) = trace(trace.getOrNull()) + + /** + * Sets [Builder.trace] to an arbitrary JSON value. + * + * You should usually call [Builder.trace] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun trace(trace: JsonField) = apply { this.trace = trace } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField) = apply { this.traceFilter = traceFilter } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField) = apply { this.treeFilter = treeFilter } + + fun useExperimentalSearch(useExperimentalSearch: Boolean) = + useExperimentalSearch(JsonField.of(useExperimentalSearch)) + + /** + * Sets [Builder.useExperimentalSearch] to an arbitrary JSON value. + * + * You should usually call [Builder.useExperimentalSearch] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useExperimentalSearch(useExperimentalSearch: JsonField) = apply { + this.useExperimentalSearch = useExperimentalSearch + } + + 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 [BodyParamsForRunSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BodyParamsForRunSchema = + BodyParamsForRunSchema( + (id ?: JsonMissing.of()).map { it.toImmutable() }, + cursor, + dataSourceType, + endTime, + error, + executionOrder, + filter, + isRoot, + limit, + order, + parentRun, + query, + (referenceExample ?: JsonMissing.of()).map { it.toImmutable() }, + runType, + searchFilter, + (select ?: JsonMissing.of()).map { it.toImmutable() }, + (session ?: JsonMissing.of()).map { it.toImmutable() }, + skipPagination, + skipPrevCursor, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BodyParamsForRunSchema = apply { + if (validated) { + return@apply + } + + id() + cursor() + dataSourceType().ifPresent { it.validate() } + endTime() + error() + executionOrder() + filter() + isRoot() + limit() + order().ifPresent { it.validate() } + parentRun() + query() + referenceExample() + runType().ifPresent { it.validate() } + searchFilter() + select().ifPresent { it.forEach { it.validate() } } + session() + skipPagination() + skipPrevCursor() + startTime() + trace() + traceFilter() + treeFilter() + useExperimentalSearch() + 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 = + (id.asKnown().getOrNull()?.size ?: 0) + + (if (cursor.asKnown().isPresent) 1 else 0) + + (dataSourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (isRoot.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (order.asKnown().getOrNull()?.validity() ?: 0) + + (if (parentRun.asKnown().isPresent) 1 else 0) + + (if (query.asKnown().isPresent) 1 else 0) + + (referenceExample.asKnown().getOrNull()?.size ?: 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (searchFilter.asKnown().isPresent) 1 else 0) + + (select.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (session.asKnown().getOrNull()?.size ?: 0) + + (if (skipPagination.asKnown().isPresent) 1 else 0) + + (if (skipPrevCursor.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (trace.asKnown().isPresent) 1 else 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + (if (useExperimentalSearch.asKnown().isPresent) 1 else 0) + + /** Enum for run start date order. */ + class Order @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 ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = Order(JsonField.of(value)) + } + + /** An enum containing [Order]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [Order]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Order] 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 { + ASC, + DESC, + /** An enum member indicating that [Order] 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) { + ASC -> Value.ASC + DESC -> Value.DESC + 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) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw LangChainInvalidDataException("Unknown Order: $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(): Order = 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 Order && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Enum for available run columns. */ + class Select @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 ID = of("id") + + @JvmField val NAME = of("name") + + @JvmField val RUN_TYPE = of("run_type") + + @JvmField val START_TIME = of("start_time") + + @JvmField val END_TIME = of("end_time") + + @JvmField val STATUS = of("status") + + @JvmField val ERROR = of("error") + + @JvmField val EXTRA = of("extra") + + @JvmField val EVENTS = of("events") + + @JvmField val INPUTS = of("inputs") + + @JvmField val INPUTS_PREVIEW = of("inputs_preview") + + @JvmField val INPUTS_S3_URLS = of("inputs_s3_urls") + + @JvmField val INPUTS_OR_SIGNED_URL = of("inputs_or_signed_url") + + @JvmField val OUTPUTS = of("outputs") + + @JvmField val OUTPUTS_PREVIEW = of("outputs_preview") + + @JvmField val OUTPUTS_S3_URLS = of("outputs_s3_urls") + + @JvmField val OUTPUTS_OR_SIGNED_URL = of("outputs_or_signed_url") + + @JvmField val S3_URLS = of("s3_urls") + + @JvmField val ERROR_OR_SIGNED_URL = of("error_or_signed_url") + + @JvmField val EVENTS_OR_SIGNED_URL = of("events_or_signed_url") + + @JvmField val EXTRA_OR_SIGNED_URL = of("extra_or_signed_url") + + @JvmField val SERIALIZED_OR_SIGNED_URL = of("serialized_or_signed_url") + + @JvmField val PARENT_RUN_ID = of("parent_run_id") + + @JvmField val MANIFEST_ID = of("manifest_id") + + @JvmField val MANIFEST_S3_ID = of("manifest_s3_id") + + @JvmField val MANIFEST = of("manifest") + + @JvmField val SESSION_ID = of("session_id") + + @JvmField val SERIALIZED = of("serialized") + + @JvmField val REFERENCE_EXAMPLE_ID = of("reference_example_id") + + @JvmField val REFERENCE_DATASET_ID = of("reference_dataset_id") + + @JvmField val TOTAL_TOKENS = of("total_tokens") + + @JvmField val PROMPT_TOKENS = of("prompt_tokens") + + @JvmField val PROMPT_TOKEN_DETAILS = of("prompt_token_details") + + @JvmField val COMPLETION_TOKENS = of("completion_tokens") + + @JvmField val COMPLETION_TOKEN_DETAILS = of("completion_token_details") + + @JvmField val TOTAL_COST = of("total_cost") + + @JvmField val PROMPT_COST = of("prompt_cost") + + @JvmField val PROMPT_COST_DETAILS = of("prompt_cost_details") + + @JvmField val COMPLETION_COST = of("completion_cost") + + @JvmField val COMPLETION_COST_DETAILS = of("completion_cost_details") + + @JvmField val PRICE_MODEL_ID = of("price_model_id") + + @JvmField val FIRST_TOKEN_TIME = of("first_token_time") + + @JvmField val TRACE_ID = of("trace_id") + + @JvmField val DOTTED_ORDER = of("dotted_order") + + @JvmField val LAST_QUEUED_AT = of("last_queued_at") + + @JvmField val FEEDBACK_STATS = of("feedback_stats") + + @JvmField val CHILD_RUN_IDS = of("child_run_ids") + + @JvmField val PARENT_RUN_IDS = of("parent_run_ids") + + @JvmField val TAGS = of("tags") + + @JvmField val IN_DATASET = of("in_dataset") + + @JvmField val APP_PATH = of("app_path") + + @JvmField val SHARE_TOKEN = of("share_token") + + @JvmField val TRACE_TIER = of("trace_tier") + + @JvmField val TRACE_FIRST_RECEIVED_AT = of("trace_first_received_at") + + @JvmField val TTL_SECONDS = of("ttl_seconds") + + @JvmField val TRACE_UPGRADE = of("trace_upgrade") + + @JvmField val THREAD_ID = of("thread_id") + + @JvmField val TRACE_MIN_MAX_START_TIME = of("trace_min_max_start_time") + + @JvmField val MESSAGES = of("messages") + + @JvmField val INSERTED_AT = of("inserted_at") + + @JvmStatic fun of(value: String) = Select(JsonField.of(value)) + } + + /** An enum containing [Select]'s known values. */ + enum class Known { + ID, + NAME, + RUN_TYPE, + START_TIME, + END_TIME, + STATUS, + ERROR, + EXTRA, + EVENTS, + INPUTS, + INPUTS_PREVIEW, + INPUTS_S3_URLS, + INPUTS_OR_SIGNED_URL, + OUTPUTS, + OUTPUTS_PREVIEW, + OUTPUTS_S3_URLS, + OUTPUTS_OR_SIGNED_URL, + S3_URLS, + ERROR_OR_SIGNED_URL, + EVENTS_OR_SIGNED_URL, + EXTRA_OR_SIGNED_URL, + SERIALIZED_OR_SIGNED_URL, + PARENT_RUN_ID, + MANIFEST_ID, + MANIFEST_S3_ID, + MANIFEST, + SESSION_ID, + SERIALIZED, + REFERENCE_EXAMPLE_ID, + REFERENCE_DATASET_ID, + TOTAL_TOKENS, + PROMPT_TOKENS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKENS, + COMPLETION_TOKEN_DETAILS, + TOTAL_COST, + PROMPT_COST, + PROMPT_COST_DETAILS, + COMPLETION_COST, + COMPLETION_COST_DETAILS, + PRICE_MODEL_ID, + FIRST_TOKEN_TIME, + TRACE_ID, + DOTTED_ORDER, + LAST_QUEUED_AT, + FEEDBACK_STATS, + CHILD_RUN_IDS, + PARENT_RUN_IDS, + TAGS, + IN_DATASET, + APP_PATH, + SHARE_TOKEN, + TRACE_TIER, + TRACE_FIRST_RECEIVED_AT, + TTL_SECONDS, + TRACE_UPGRADE, + THREAD_ID, + TRACE_MIN_MAX_START_TIME, + MESSAGES, + INSERTED_AT, + } + + /** + * An enum containing [Select]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Select] 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 { + ID, + NAME, + RUN_TYPE, + START_TIME, + END_TIME, + STATUS, + ERROR, + EXTRA, + EVENTS, + INPUTS, + INPUTS_PREVIEW, + INPUTS_S3_URLS, + INPUTS_OR_SIGNED_URL, + OUTPUTS, + OUTPUTS_PREVIEW, + OUTPUTS_S3_URLS, + OUTPUTS_OR_SIGNED_URL, + S3_URLS, + ERROR_OR_SIGNED_URL, + EVENTS_OR_SIGNED_URL, + EXTRA_OR_SIGNED_URL, + SERIALIZED_OR_SIGNED_URL, + PARENT_RUN_ID, + MANIFEST_ID, + MANIFEST_S3_ID, + MANIFEST, + SESSION_ID, + SERIALIZED, + REFERENCE_EXAMPLE_ID, + REFERENCE_DATASET_ID, + TOTAL_TOKENS, + PROMPT_TOKENS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKENS, + COMPLETION_TOKEN_DETAILS, + TOTAL_COST, + PROMPT_COST, + PROMPT_COST_DETAILS, + COMPLETION_COST, + COMPLETION_COST_DETAILS, + PRICE_MODEL_ID, + FIRST_TOKEN_TIME, + TRACE_ID, + DOTTED_ORDER, + LAST_QUEUED_AT, + FEEDBACK_STATS, + CHILD_RUN_IDS, + PARENT_RUN_IDS, + TAGS, + IN_DATASET, + APP_PATH, + SHARE_TOKEN, + TRACE_TIER, + TRACE_FIRST_RECEIVED_AT, + TTL_SECONDS, + TRACE_UPGRADE, + THREAD_ID, + TRACE_MIN_MAX_START_TIME, + MESSAGES, + INSERTED_AT, + /** An enum member indicating that [Select] 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) { + ID -> Value.ID + NAME -> Value.NAME + RUN_TYPE -> Value.RUN_TYPE + START_TIME -> Value.START_TIME + END_TIME -> Value.END_TIME + STATUS -> Value.STATUS + ERROR -> Value.ERROR + EXTRA -> Value.EXTRA + EVENTS -> Value.EVENTS + INPUTS -> Value.INPUTS + INPUTS_PREVIEW -> Value.INPUTS_PREVIEW + INPUTS_S3_URLS -> Value.INPUTS_S3_URLS + INPUTS_OR_SIGNED_URL -> Value.INPUTS_OR_SIGNED_URL + OUTPUTS -> Value.OUTPUTS + OUTPUTS_PREVIEW -> Value.OUTPUTS_PREVIEW + OUTPUTS_S3_URLS -> Value.OUTPUTS_S3_URLS + OUTPUTS_OR_SIGNED_URL -> Value.OUTPUTS_OR_SIGNED_URL + S3_URLS -> Value.S3_URLS + ERROR_OR_SIGNED_URL -> Value.ERROR_OR_SIGNED_URL + EVENTS_OR_SIGNED_URL -> Value.EVENTS_OR_SIGNED_URL + EXTRA_OR_SIGNED_URL -> Value.EXTRA_OR_SIGNED_URL + SERIALIZED_OR_SIGNED_URL -> Value.SERIALIZED_OR_SIGNED_URL + PARENT_RUN_ID -> Value.PARENT_RUN_ID + MANIFEST_ID -> Value.MANIFEST_ID + MANIFEST_S3_ID -> Value.MANIFEST_S3_ID + MANIFEST -> Value.MANIFEST + SESSION_ID -> Value.SESSION_ID + SERIALIZED -> Value.SERIALIZED + REFERENCE_EXAMPLE_ID -> Value.REFERENCE_EXAMPLE_ID + REFERENCE_DATASET_ID -> Value.REFERENCE_DATASET_ID + TOTAL_TOKENS -> Value.TOTAL_TOKENS + PROMPT_TOKENS -> Value.PROMPT_TOKENS + PROMPT_TOKEN_DETAILS -> Value.PROMPT_TOKEN_DETAILS + COMPLETION_TOKENS -> Value.COMPLETION_TOKENS + COMPLETION_TOKEN_DETAILS -> Value.COMPLETION_TOKEN_DETAILS + TOTAL_COST -> Value.TOTAL_COST + PROMPT_COST -> Value.PROMPT_COST + PROMPT_COST_DETAILS -> Value.PROMPT_COST_DETAILS + COMPLETION_COST -> Value.COMPLETION_COST + COMPLETION_COST_DETAILS -> Value.COMPLETION_COST_DETAILS + PRICE_MODEL_ID -> Value.PRICE_MODEL_ID + FIRST_TOKEN_TIME -> Value.FIRST_TOKEN_TIME + TRACE_ID -> Value.TRACE_ID + DOTTED_ORDER -> Value.DOTTED_ORDER + LAST_QUEUED_AT -> Value.LAST_QUEUED_AT + FEEDBACK_STATS -> Value.FEEDBACK_STATS + CHILD_RUN_IDS -> Value.CHILD_RUN_IDS + PARENT_RUN_IDS -> Value.PARENT_RUN_IDS + TAGS -> Value.TAGS + IN_DATASET -> Value.IN_DATASET + APP_PATH -> Value.APP_PATH + SHARE_TOKEN -> Value.SHARE_TOKEN + TRACE_TIER -> Value.TRACE_TIER + TRACE_FIRST_RECEIVED_AT -> Value.TRACE_FIRST_RECEIVED_AT + TTL_SECONDS -> Value.TTL_SECONDS + TRACE_UPGRADE -> Value.TRACE_UPGRADE + 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 + } + + /** + * 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) { + ID -> Known.ID + NAME -> Known.NAME + RUN_TYPE -> Known.RUN_TYPE + START_TIME -> Known.START_TIME + END_TIME -> Known.END_TIME + STATUS -> Known.STATUS + ERROR -> Known.ERROR + EXTRA -> Known.EXTRA + EVENTS -> Known.EVENTS + INPUTS -> Known.INPUTS + INPUTS_PREVIEW -> Known.INPUTS_PREVIEW + INPUTS_S3_URLS -> Known.INPUTS_S3_URLS + INPUTS_OR_SIGNED_URL -> Known.INPUTS_OR_SIGNED_URL + OUTPUTS -> Known.OUTPUTS + OUTPUTS_PREVIEW -> Known.OUTPUTS_PREVIEW + OUTPUTS_S3_URLS -> Known.OUTPUTS_S3_URLS + OUTPUTS_OR_SIGNED_URL -> Known.OUTPUTS_OR_SIGNED_URL + S3_URLS -> Known.S3_URLS + ERROR_OR_SIGNED_URL -> Known.ERROR_OR_SIGNED_URL + EVENTS_OR_SIGNED_URL -> Known.EVENTS_OR_SIGNED_URL + EXTRA_OR_SIGNED_URL -> Known.EXTRA_OR_SIGNED_URL + SERIALIZED_OR_SIGNED_URL -> Known.SERIALIZED_OR_SIGNED_URL + PARENT_RUN_ID -> Known.PARENT_RUN_ID + MANIFEST_ID -> Known.MANIFEST_ID + MANIFEST_S3_ID -> Known.MANIFEST_S3_ID + MANIFEST -> Known.MANIFEST + SESSION_ID -> Known.SESSION_ID + SERIALIZED -> Known.SERIALIZED + REFERENCE_EXAMPLE_ID -> Known.REFERENCE_EXAMPLE_ID + REFERENCE_DATASET_ID -> Known.REFERENCE_DATASET_ID + TOTAL_TOKENS -> Known.TOTAL_TOKENS + PROMPT_TOKENS -> Known.PROMPT_TOKENS + PROMPT_TOKEN_DETAILS -> Known.PROMPT_TOKEN_DETAILS + COMPLETION_TOKENS -> Known.COMPLETION_TOKENS + COMPLETION_TOKEN_DETAILS -> Known.COMPLETION_TOKEN_DETAILS + TOTAL_COST -> Known.TOTAL_COST + PROMPT_COST -> Known.PROMPT_COST + PROMPT_COST_DETAILS -> Known.PROMPT_COST_DETAILS + COMPLETION_COST -> Known.COMPLETION_COST + COMPLETION_COST_DETAILS -> Known.COMPLETION_COST_DETAILS + PRICE_MODEL_ID -> Known.PRICE_MODEL_ID + FIRST_TOKEN_TIME -> Known.FIRST_TOKEN_TIME + TRACE_ID -> Known.TRACE_ID + DOTTED_ORDER -> Known.DOTTED_ORDER + LAST_QUEUED_AT -> Known.LAST_QUEUED_AT + FEEDBACK_STATS -> Known.FEEDBACK_STATS + CHILD_RUN_IDS -> Known.CHILD_RUN_IDS + PARENT_RUN_IDS -> Known.PARENT_RUN_IDS + TAGS -> Known.TAGS + IN_DATASET -> Known.IN_DATASET + APP_PATH -> Known.APP_PATH + SHARE_TOKEN -> Known.SHARE_TOKEN + TRACE_TIER -> Known.TRACE_TIER + TRACE_FIRST_RECEIVED_AT -> Known.TRACE_FIRST_RECEIVED_AT + TTL_SECONDS -> Known.TTL_SECONDS + TRACE_UPGRADE -> Known.TRACE_UPGRADE + 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") + } + + /** + * 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(): Select = 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 Select && 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 BodyParamsForRunSchema && + id == other.id && + cursor == other.cursor && + dataSourceType == other.dataSourceType && + endTime == other.endTime && + error == other.error && + executionOrder == other.executionOrder && + filter == other.filter && + isRoot == other.isRoot && + limit == other.limit && + order == other.order && + parentRun == other.parentRun && + query == other.query && + referenceExample == other.referenceExample && + runType == other.runType && + searchFilter == other.searchFilter && + select == other.select && + session == other.session && + skipPagination == other.skipPagination && + skipPrevCursor == other.skipPrevCursor && + startTime == other.startTime && + trace == other.trace && + traceFilter == other.traceFilter && + treeFilter == other.treeFilter && + useExperimentalSearch == other.useExperimentalSearch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + cursor, + dataSourceType, + endTime, + error, + executionOrder, + filter, + isRoot, + limit, + order, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + skipPrevCursor, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BodyParamsForRunSchema{id=$id, cursor=$cursor, dataSourceType=$dataSourceType, endTime=$endTime, error=$error, executionOrder=$executionOrder, filter=$filter, isRoot=$isRoot, limit=$limit, order=$order, parentRun=$parentRun, query=$query, referenceExample=$referenceExample, runType=$runType, searchFilter=$searchFilter, select=$select, session=$session, skipPagination=$skipPagination, skipPrevCursor=$skipPrevCursor, startTime=$startTime, trace=$trace, traceFilter=$traceFilter, treeFilter=$treeFilter, useExperimentalSearch=$useExperimentalSearch, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RequestBodyForRunsGenerateQuery.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RequestBodyForRunsGenerateQuery.kt new file mode 100644 index 000000000..451b0e0e5 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RequestBodyForRunsGenerateQuery.kt @@ -0,0 +1,391 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.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.checkKnown +import com.langchain.smith.core.checkRequired +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 + +class RequestBodyForRunsGenerateQuery +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val query: JsonField, + private val feedbackKeys: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("feedback_keys") + @ExcludeMissing + feedbackKeys: JsonField> = JsonMissing.of(), + ) : this(query, feedbackKeys, 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 query(): String = query.getRequired("query") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun feedbackKeys(): Optional> = feedbackKeys.getOptional("feedback_keys") + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [feedbackKeys]. + * + * Unlike [feedbackKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_keys") + @ExcludeMissing + fun _feedbackKeys(): JsonField> = feedbackKeys + + @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 + * [RequestBodyForRunsGenerateQuery]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RequestBodyForRunsGenerateQuery]. */ + class Builder internal constructor() { + + private var query: JsonField? = null + private var feedbackKeys: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery) = + apply { + query = requestBodyForRunsGenerateQuery.query + feedbackKeys = + requestBodyForRunsGenerateQuery.feedbackKeys.map { it.toMutableList() } + additionalProperties = + requestBodyForRunsGenerateQuery.additionalProperties.toMutableMap() + } + + fun query(query: String) = query(JsonField.of(query)) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + fun feedbackKeys(feedbackKeys: List) = feedbackKeys(JsonField.of(feedbackKeys)) + + /** + * Sets [Builder.feedbackKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKeys] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun feedbackKeys(feedbackKeys: JsonField>) = apply { + this.feedbackKeys = feedbackKeys.map { it.toMutableList() } + } + + /** + * Adds a single [FeedbackKey] to [feedbackKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFeedbackKey(feedbackKey: FeedbackKey) = apply { + feedbackKeys = + (feedbackKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("feedbackKeys", it).add(feedbackKey) + } + } + + 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 [RequestBodyForRunsGenerateQuery]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RequestBodyForRunsGenerateQuery = + RequestBodyForRunsGenerateQuery( + checkRequired("query", query), + (feedbackKeys ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RequestBodyForRunsGenerateQuery = apply { + if (validated) { + return@apply + } + + query() + feedbackKeys().ifPresent { it.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 = + (if (query.asKnown().isPresent) 1 else 0) + + (feedbackKeys.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class FeedbackKey @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 USER_SCORE = of("user_score") + + @JvmField val USER_EDITED = of("user_edited") + + @JvmField val USER_REMOVED = of("user_removed") + + @JvmField val USER_OPENED_RUN = of("user_opened_run") + + @JvmField val USER_SELECTED_RUN = of("user_selected_run") + + @JvmField val RESULTS_SIZE = of("results_size") + + @JvmField val VALID_FILTER = of("valid_filter") + + @JvmStatic fun of(value: String) = FeedbackKey(JsonField.of(value)) + } + + /** An enum containing [FeedbackKey]'s known values. */ + enum class Known { + USER_SCORE, + USER_EDITED, + USER_REMOVED, + USER_OPENED_RUN, + USER_SELECTED_RUN, + RESULTS_SIZE, + VALID_FILTER, + } + + /** + * An enum containing [FeedbackKey]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FeedbackKey] 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 { + USER_SCORE, + USER_EDITED, + USER_REMOVED, + USER_OPENED_RUN, + USER_SELECTED_RUN, + RESULTS_SIZE, + VALID_FILTER, + /** + * An enum member indicating that [FeedbackKey] 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) { + USER_SCORE -> Value.USER_SCORE + USER_EDITED -> Value.USER_EDITED + USER_REMOVED -> Value.USER_REMOVED + USER_OPENED_RUN -> Value.USER_OPENED_RUN + USER_SELECTED_RUN -> Value.USER_SELECTED_RUN + RESULTS_SIZE -> Value.RESULTS_SIZE + VALID_FILTER -> Value.VALID_FILTER + 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) { + USER_SCORE -> Known.USER_SCORE + USER_EDITED -> Known.USER_EDITED + USER_REMOVED -> Known.USER_REMOVED + USER_OPENED_RUN -> Known.USER_OPENED_RUN + USER_SELECTED_RUN -> Known.USER_SELECTED_RUN + RESULTS_SIZE -> Known.RESULTS_SIZE + VALID_FILTER -> Known.VALID_FILTER + else -> throw LangChainInvalidDataException("Unknown FeedbackKey: $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(): FeedbackKey = 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 FeedbackKey && 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 RequestBodyForRunsGenerateQuery && + query == other.query && + feedbackKeys == other.feedbackKeys && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(query, feedbackKeys, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RequestBodyForRunsGenerateQuery{query=$query, feedbackKeys=$feedbackKeys, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/ResponseBodyForRunsGenerateQuery.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/ResponseBodyForRunsGenerateQuery.kt new file mode 100644 index 000000000..a77183467 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/ResponseBodyForRunsGenerateQuery.kt @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.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.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ResponseBodyForRunsGenerateQuery +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val feedbackUrls: JsonField, + private val filter: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_urls") + @ExcludeMissing + feedbackUrls: JsonField = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + ) : this(feedbackUrls, filter, 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 feedbackUrls(): FeedbackUrls = feedbackUrls.getRequired("feedback_urls") + + /** + * @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 filter(): String = filter.getRequired("filter") + + /** + * Returns the raw JSON value of [feedbackUrls]. + * + * Unlike [feedbackUrls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_urls") + @ExcludeMissing + fun _feedbackUrls(): JsonField = feedbackUrls + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + @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 + * [ResponseBodyForRunsGenerateQuery]. + * + * The following fields are required: + * ```java + * .feedbackUrls() + * .filter() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseBodyForRunsGenerateQuery]. */ + class Builder internal constructor() { + + private var feedbackUrls: JsonField? = null + private var filter: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responseBodyForRunsGenerateQuery: ResponseBodyForRunsGenerateQuery) = + apply { + feedbackUrls = responseBodyForRunsGenerateQuery.feedbackUrls + filter = responseBodyForRunsGenerateQuery.filter + additionalProperties = + responseBodyForRunsGenerateQuery.additionalProperties.toMutableMap() + } + + fun feedbackUrls(feedbackUrls: FeedbackUrls) = feedbackUrls(JsonField.of(feedbackUrls)) + + /** + * Sets [Builder.feedbackUrls] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackUrls] with a well-typed [FeedbackUrls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackUrls(feedbackUrls: JsonField) = apply { + this.feedbackUrls = feedbackUrls + } + + fun filter(filter: String) = filter(JsonField.of(filter)) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + 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 [ResponseBodyForRunsGenerateQuery]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackUrls() + * .filter() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResponseBodyForRunsGenerateQuery = + ResponseBodyForRunsGenerateQuery( + checkRequired("feedbackUrls", feedbackUrls), + checkRequired("filter", filter), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ResponseBodyForRunsGenerateQuery = apply { + if (validated) { + return@apply + } + + feedbackUrls().validate() + filter() + 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 = + (feedbackUrls.asKnown().getOrNull()?.validity() ?: 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + class FeedbackUrls + @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 [FeedbackUrls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackUrls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackUrls: FeedbackUrls) = apply { + additionalProperties = feedbackUrls.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 [FeedbackUrls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackUrls = FeedbackUrls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackUrls = 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 FeedbackUrls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackUrls{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseBodyForRunsGenerateQuery && + feedbackUrls == other.feedbackUrls && + filter == other.filter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(feedbackUrls, filter, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResponseBodyForRunsGenerateQuery{feedbackUrls=$feedbackUrls, filter=$filter, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunCreateParams.kt new file mode 100644 index 000000000..086b36630 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunCreateParams.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import java.util.Objects + +/** + * Queues a single run for ingestion. The request body must be a JSON-encoded run object that + * follows the Run schema. + */ +class RunCreateParams +private constructor( + private val run: Run, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun run(): Run = run + + fun _additionalBodyProperties(): Map = run._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunCreateParams]. + * + * The following fields are required: + * ```java + * .run() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunCreateParams]. */ + class Builder internal constructor() { + + private var run: Run? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runCreateParams: RunCreateParams) = apply { + run = runCreateParams.run + additionalHeaders = runCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = runCreateParams.additionalQueryParams.toBuilder() + } + + fun run(run: Run) = apply { this.run = run } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .run() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunCreateParams = + RunCreateParams( + checkRequired("run", run), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Run = run + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunCreateParams && + run == other.run && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(run, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunCreateParams{run=$run, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexCreateResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunCreateResponse.kt similarity index 63% rename from langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexCreateResponse.kt rename to langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunCreateResponse.kt index 9fb5e8baf..420f7ae8d 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexCreateResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunCreateResponse.kt @@ -1,48 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package com.langchain.smith.models.datasets.index +package com.langchain.smith.models.runs import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.langchain.smith.core.ExcludeMissing import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable import com.langchain.smith.errors.LangChainInvalidDataException -import java.util.Collections import java.util.Objects -class IndexCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor(private val additionalProperties: MutableMap) { - - @JsonCreator private constructor() : this(mutableMapOf()) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } +class RunCreateResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map +) { @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [IndexCreateResponse]. */ + /** Returns a mutable builder for constructing an instance of [RunCreateResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [IndexCreateResponse]. */ + /** A builder for [RunCreateResponse]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(indexCreateResponse: IndexCreateResponse) = apply { - additionalProperties = indexCreateResponse.additionalProperties.toMutableMap() + internal fun from(runCreateResponse: RunCreateResponse) = apply { + additionalProperties = runCreateResponse.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -65,16 +59,16 @@ private constructor(private val additionalProperties: MutableMap !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is IndexCreateResponse && additionalProperties == other.additionalProperties + return other is RunCreateResponse && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "IndexCreateResponse{additionalProperties=$additionalProperties}" + override fun toString() = "RunCreateResponse{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 eaa112c50..9bfcfd8f0 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 @@ -49,7 +49,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun dataSourceType(): Optional = body.dataSourceType() + fun dataSourceType(): Optional = body.dataSourceType() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -119,7 +119,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun runType(): Optional = body.runType() + fun runType(): Optional = body.runType() /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -200,7 +200,7 @@ private constructor( * * Unlike [dataSourceType], this method doesn't throw if the JSON field has an unexpected type. */ - fun _dataSourceType(): JsonField = body._dataSourceType() + fun _dataSourceType(): JsonField = body._dataSourceType() /** * Returns the raw JSON value of [endTime]. @@ -278,7 +278,7 @@ private constructor( * * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. */ - fun _runType(): JsonField = body._runType() + fun _runType(): JsonField = body._runType() /** * Returns the raw JSON value of [searchFilter]. @@ -431,22 +431,22 @@ private constructor( fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } /** Enum for run data source types. */ - fun dataSourceType(dataSourceType: DataSourceType?) = apply { + fun dataSourceType(dataSourceType: RunsFilterDataSourceTypeEnum?) = apply { body.dataSourceType(dataSourceType) } /** Alias for calling [Builder.dataSourceType] with `dataSourceType.orElse(null)`. */ - fun dataSourceType(dataSourceType: Optional) = + fun dataSourceType(dataSourceType: Optional) = dataSourceType(dataSourceType.getOrNull()) /** * Sets [Builder.dataSourceType] to an arbitrary JSON value. * - * You should usually call [Builder.dataSourceType] with a well-typed [DataSourceType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.dataSourceType] with a well-typed + * [RunsFilterDataSourceTypeEnum] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun dataSourceType(dataSourceType: JsonField) = apply { + fun dataSourceType(dataSourceType: JsonField) = apply { body.dataSourceType(dataSourceType) } @@ -618,18 +618,19 @@ private constructor( } /** Enum for run types. */ - fun runType(runType: RunType?) = apply { body.runType(runType) } + fun runType(runType: RunTypeEnum?) = apply { body.runType(runType) } /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ - fun runType(runType: Optional) = runType(runType.getOrNull()) + fun runType(runType: Optional) = runType(runType.getOrNull()) /** * Sets [Builder.runType] to an arbitrary JSON value. * - * You should usually call [Builder.runType] with a well-typed [RunType] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun runType(runType: JsonField) = apply { body.runType(runType) } + fun runType(runType: JsonField) = apply { body.runType(runType) } fun searchFilter(searchFilter: String?) = apply { body.searchFilter(searchFilter) } @@ -931,7 +932,7 @@ private constructor( private constructor( private val id: JsonField>, private val cursor: JsonField, - private val dataSourceType: JsonField, + private val dataSourceType: JsonField, private val endTime: JsonField, private val error: JsonField, private val executionOrder: JsonField, @@ -942,7 +943,7 @@ private constructor( private val parentRun: JsonField, private val query: JsonField, private val referenceExample: JsonField>, - private val runType: JsonField, + private val runType: JsonField, private val searchFilter: JsonField, private val select: JsonField>, private val session: JsonField>, @@ -962,7 +963,7 @@ private constructor( @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), @JsonProperty("data_source_type") @ExcludeMissing - dataSourceType: JsonField = JsonMissing.of(), + dataSourceType: JsonField = JsonMissing.of(), @JsonProperty("end_time") @ExcludeMissing endTime: JsonField = JsonMissing.of(), @@ -983,7 +984,7 @@ private constructor( referenceExample: JsonField> = JsonMissing.of(), @JsonProperty("run_type") @ExcludeMissing - runType: JsonField = JsonMissing.of(), + runType: JsonField = JsonMissing.of(), @JsonProperty("search_filter") @ExcludeMissing searchFilter: JsonField = JsonMissing.of(), @@ -1058,7 +1059,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun dataSourceType(): Optional = + fun dataSourceType(): Optional = dataSourceType.getOptional("data_source_type") /** @@ -1130,7 +1131,7 @@ private constructor( * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun runType(): Optional = runType.getOptional("run_type") + fun runType(): Optional = runType.getOptional("run_type") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1215,7 +1216,7 @@ private constructor( */ @JsonProperty("data_source_type") @ExcludeMissing - fun _dataSourceType(): JsonField = dataSourceType + fun _dataSourceType(): JsonField = dataSourceType /** * Returns the raw JSON value of [endTime]. @@ -1300,7 +1301,7 @@ private constructor( * * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType /** * Returns the raw JSON value of [searchFilter]. @@ -1413,7 +1414,7 @@ private constructor( private var id: JsonField>? = null private var cursor: JsonField = JsonMissing.of() - private var dataSourceType: JsonField = JsonMissing.of() + private var dataSourceType: JsonField = JsonMissing.of() private var endTime: JsonField = JsonMissing.of() private var error: JsonField = JsonMissing.of() private var executionOrder: JsonField = JsonMissing.of() @@ -1424,7 +1425,7 @@ private constructor( private var parentRun: JsonField = JsonMissing.of() private var query: JsonField = JsonMissing.of() private var referenceExample: JsonField>? = null - private var runType: JsonField = JsonMissing.of() + private var runType: JsonField = JsonMissing.of() private var searchFilter: JsonField = JsonMissing.of() private var select: JsonField>? = null private var session: JsonField>? = null @@ -1505,21 +1506,21 @@ private constructor( fun cursor(cursor: JsonField) = apply { this.cursor = cursor } /** Enum for run data source types. */ - fun dataSourceType(dataSourceType: DataSourceType?) = + fun dataSourceType(dataSourceType: RunsFilterDataSourceTypeEnum?) = dataSourceType(JsonField.ofNullable(dataSourceType)) /** Alias for calling [Builder.dataSourceType] with `dataSourceType.orElse(null)`. */ - fun dataSourceType(dataSourceType: Optional) = + fun dataSourceType(dataSourceType: Optional) = dataSourceType(dataSourceType.getOrNull()) /** * Sets [Builder.dataSourceType] to an arbitrary JSON value. * - * You should usually call [Builder.dataSourceType] with a well-typed [DataSourceType] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.dataSourceType] with a well-typed + * [RunsFilterDataSourceTypeEnum] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun dataSourceType(dataSourceType: JsonField) = apply { + fun dataSourceType(dataSourceType: JsonField) = apply { this.dataSourceType = dataSourceType } @@ -1702,19 +1703,19 @@ private constructor( } /** Enum for run types. */ - fun runType(runType: RunType?) = runType(JsonField.ofNullable(runType)) + fun runType(runType: RunTypeEnum?) = runType(JsonField.ofNullable(runType)) /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ - fun runType(runType: Optional) = runType(runType.getOrNull()) + fun runType(runType: Optional) = runType(runType.getOrNull()) /** * Sets [Builder.runType] to an arbitrary JSON value. * - * You should usually call [Builder.runType] with a well-typed [RunType] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun runType(runType: JsonField) = apply { this.runType = runType } + fun runType(runType: JsonField) = apply { this.runType = runType } fun searchFilter(searchFilter: String?) = searchFilter(JsonField.ofNullable(searchFilter)) @@ -2098,156 +2099,6 @@ private constructor( "Body{id=$id, cursor=$cursor, dataSourceType=$dataSourceType, endTime=$endTime, error=$error, executionOrder=$executionOrder, filter=$filter, isRoot=$isRoot, limit=$limit, order=$order, parentRun=$parentRun, query=$query, referenceExample=$referenceExample, runType=$runType, searchFilter=$searchFilter, select=$select, session=$session, skipPagination=$skipPagination, skipPrevCursor=$skipPrevCursor, startTime=$startTime, trace=$trace, traceFilter=$traceFilter, treeFilter=$treeFilter, useExperimentalSearch=$useExperimentalSearch, additionalProperties=$additionalProperties}" } - /** Enum for run data source types. */ - class DataSourceType @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 CURRENT = of("current") - - @JvmField val HISTORICAL = of("historical") - - @JvmField val LITE = of("lite") - - @JvmField val ROOT_LITE = of("root_lite") - - @JvmField val RUNS_FEEDBACKS_RMT_WIDE = of("runs_feedbacks_rmt_wide") - - @JvmStatic fun of(value: String) = DataSourceType(JsonField.of(value)) - } - - /** An enum containing [DataSourceType]'s known values. */ - enum class Known { - CURRENT, - HISTORICAL, - LITE, - ROOT_LITE, - RUNS_FEEDBACKS_RMT_WIDE, - } - - /** - * An enum containing [DataSourceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [DataSourceType] 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 { - CURRENT, - HISTORICAL, - LITE, - ROOT_LITE, - RUNS_FEEDBACKS_RMT_WIDE, - /** - * An enum member indicating that [DataSourceType] 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) { - CURRENT -> Value.CURRENT - HISTORICAL -> Value.HISTORICAL - LITE -> Value.LITE - ROOT_LITE -> Value.ROOT_LITE - RUNS_FEEDBACKS_RMT_WIDE -> Value.RUNS_FEEDBACKS_RMT_WIDE - 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) { - CURRENT -> Known.CURRENT - HISTORICAL -> Known.HISTORICAL - LITE -> Known.LITE - ROOT_LITE -> Known.ROOT_LITE - RUNS_FEEDBACKS_RMT_WIDE -> Known.RUNS_FEEDBACKS_RMT_WIDE - else -> throw LangChainInvalidDataException("Unknown DataSourceType: $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(): DataSourceType = 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 DataSourceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Enum for run start date order. */ class Order @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2376,164 +2227,6 @@ private constructor( override fun toString() = value.toString() } - /** Enum for run types. */ - class RunType @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 TOOL = of("tool") - - @JvmField val CHAIN = of("chain") - - @JvmField val LLM = of("llm") - - @JvmField val RETRIEVER = of("retriever") - - @JvmField val EMBEDDING = of("embedding") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PARSER = of("parser") - - @JvmStatic fun of(value: String) = RunType(JsonField.of(value)) - } - - /** An enum containing [RunType]'s known values. */ - enum class Known { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - } - - /** - * An enum containing [RunType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RunType] 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 { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - /** An enum member indicating that [RunType] 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) { - TOOL -> Value.TOOL - CHAIN -> Value.CHAIN - LLM -> Value.LLM - RETRIEVER -> Value.RETRIEVER - EMBEDDING -> Value.EMBEDDING - PROMPT -> Value.PROMPT - PARSER -> Value.PARSER - 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) { - TOOL -> Known.TOOL - CHAIN -> Known.CHAIN - LLM -> Known.LLM - RETRIEVER -> Known.RETRIEVER - EMBEDDING -> Known.EMBEDDING - PROMPT -> Known.PROMPT - PARSER -> Known.PARSER - else -> throw LangChainInvalidDataException("Unknown RunType: $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(): RunType = 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 RunType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Enum for available run columns. */ class Select @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt index 17e628b82..c83652d44 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunQueryResponse.kt @@ -6,7 +6,6 @@ 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 @@ -15,7 +14,6 @@ import com.langchain.smith.core.checkKnown import com.langchain.smith.core.checkRequired 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 @@ -25,7 +23,7 @@ class RunQueryResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cursors: JsonField, - private val runs: JsonField>, + private val runs: JsonField>, private val parsedQuery: JsonField, private val searchCursors: JsonField, private val additionalProperties: MutableMap, @@ -34,7 +32,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("cursors") @ExcludeMissing cursors: JsonField = JsonMissing.of(), - @JsonProperty("runs") @ExcludeMissing runs: JsonField> = JsonMissing.of(), + @JsonProperty("runs") @ExcludeMissing runs: JsonField> = JsonMissing.of(), @JsonProperty("parsed_query") @ExcludeMissing parsedQuery: JsonField = JsonMissing.of(), @@ -53,7 +51,7 @@ private constructor( * @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 runs(): List = runs.getRequired("runs") + fun runs(): List = runs.getRequired("runs") /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -79,7 +77,7 @@ private constructor( * * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField> = runs + @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField> = runs /** * Returns the raw JSON value of [parsedQuery]. @@ -129,7 +127,7 @@ private constructor( class Builder internal constructor() { private var cursors: JsonField? = null - private var runs: JsonField>? = null + private var runs: JsonField>? = null private var parsedQuery: JsonField = JsonMissing.of() private var searchCursors: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -153,22 +151,25 @@ private constructor( */ fun cursors(cursors: JsonField) = apply { this.cursors = cursors } - fun runs(runs: List) = runs(JsonField.of(runs)) + fun runs(runs: List) = runs(JsonField.of(runs)) /** * Sets [Builder.runs] to an arbitrary JSON value. * - * You should usually call [Builder.runs] with a well-typed `List` value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.runs] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun runs(runs: JsonField>) = apply { this.runs = runs.map { it.toMutableList() } } + fun runs(runs: JsonField>) = apply { + this.runs = runs.map { it.toMutableList() } + } /** - * Adds a single [Run] to [runs]. + * Adds a single [RunSchema] to [runs]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addRun(run: Run) = apply { + fun addRun(run: RunSchema) = apply { runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } } @@ -379,4313 +380,6 @@ private constructor( override fun toString() = "Cursors{additionalProperties=$additionalProperties}" } - /** Run schema. */ - class Run - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val appPath: JsonField, - private val dottedOrder: JsonField, - private val name: JsonField, - private val runType: JsonField, - private val sessionId: JsonField, - private val status: JsonField, - private val traceId: JsonField, - private val childRunIds: JsonField>, - private val completionCost: JsonField, - private val completionCostDetails: JsonField, - private val completionTokenDetails: JsonField, - private val completionTokens: JsonField, - private val directChildRunIds: JsonField>, - private val endTime: JsonField, - private val error: JsonField, - private val events: JsonField>, - private val executionOrder: JsonField, - private val extra: JsonField, - private val feedbackStats: JsonField, - private val firstTokenTime: JsonField, - private val inDataset: JsonField, - private val inputs: JsonField, - private val inputsPreview: JsonField, - private val inputsS3Urls: JsonField, - private val lastQueuedAt: JsonField, - private val manifestId: JsonField, - private val manifestS3Id: JsonField, - private val messages: JsonField>, - private val outputs: JsonField, - private val outputsPreview: JsonField, - private val outputsS3Urls: JsonField, - private val parentRunId: JsonField, - private val parentRunIds: JsonField>, - private val priceModelId: JsonField, - private val promptCost: JsonField, - private val promptCostDetails: JsonField, - private val promptTokenDetails: JsonField, - private val promptTokens: JsonField, - private val referenceDatasetId: JsonField, - private val referenceExampleId: JsonField, - private val s3Urls: JsonField, - private val serialized: JsonField, - private val shareToken: JsonField, - private val startTime: JsonField, - private val tags: JsonField>, - private val threadId: JsonField, - private val totalCost: JsonField, - private val totalTokens: JsonField, - private val traceFirstReceivedAt: JsonField, - private val traceMaxStartTime: JsonField, - private val traceMinStartTime: JsonField, - private val traceTier: JsonField, - private val traceUpgrade: JsonField, - private val ttlSeconds: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("app_path") @ExcludeMissing appPath: JsonField = JsonMissing.of(), - @JsonProperty("dotted_order") - @ExcludeMissing - dottedOrder: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("run_type") - @ExcludeMissing - runType: JsonField = JsonMissing.of(), - @JsonProperty("session_id") - @ExcludeMissing - sessionId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), - @JsonProperty("child_run_ids") - @ExcludeMissing - childRunIds: JsonField> = JsonMissing.of(), - @JsonProperty("completion_cost") - @ExcludeMissing - completionCost: JsonField = JsonMissing.of(), - @JsonProperty("completion_cost_details") - @ExcludeMissing - completionCostDetails: JsonField = JsonMissing.of(), - @JsonProperty("completion_token_details") - @ExcludeMissing - completionTokenDetails: JsonField = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - completionTokens: JsonField = JsonMissing.of(), - @JsonProperty("direct_child_run_ids") - @ExcludeMissing - directChildRunIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_time") - @ExcludeMissing - endTime: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("events") - @ExcludeMissing - events: JsonField> = JsonMissing.of(), - @JsonProperty("execution_order") - @ExcludeMissing - executionOrder: JsonField = JsonMissing.of(), - @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), - @JsonProperty("feedback_stats") - @ExcludeMissing - feedbackStats: JsonField = JsonMissing.of(), - @JsonProperty("first_token_time") - @ExcludeMissing - firstTokenTime: JsonField = JsonMissing.of(), - @JsonProperty("in_dataset") - @ExcludeMissing - inDataset: JsonField = JsonMissing.of(), - @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), - @JsonProperty("inputs_preview") - @ExcludeMissing - inputsPreview: JsonField = JsonMissing.of(), - @JsonProperty("inputs_s3_urls") - @ExcludeMissing - inputsS3Urls: JsonField = JsonMissing.of(), - @JsonProperty("last_queued_at") - @ExcludeMissing - lastQueuedAt: JsonField = JsonMissing.of(), - @JsonProperty("manifest_id") - @ExcludeMissing - manifestId: JsonField = JsonMissing.of(), - @JsonProperty("manifest_s3_id") - @ExcludeMissing - manifestS3Id: JsonField = JsonMissing.of(), - @JsonProperty("messages") - @ExcludeMissing - messages: JsonField> = JsonMissing.of(), - @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), - @JsonProperty("outputs_preview") - @ExcludeMissing - outputsPreview: JsonField = JsonMissing.of(), - @JsonProperty("outputs_s3_urls") - @ExcludeMissing - outputsS3Urls: JsonField = JsonMissing.of(), - @JsonProperty("parent_run_id") - @ExcludeMissing - parentRunId: JsonField = JsonMissing.of(), - @JsonProperty("parent_run_ids") - @ExcludeMissing - parentRunIds: JsonField> = JsonMissing.of(), - @JsonProperty("price_model_id") - @ExcludeMissing - priceModelId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_cost") - @ExcludeMissing - promptCost: JsonField = JsonMissing.of(), - @JsonProperty("prompt_cost_details") - @ExcludeMissing - promptCostDetails: JsonField = JsonMissing.of(), - @JsonProperty("prompt_token_details") - @ExcludeMissing - promptTokenDetails: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("reference_dataset_id") - @ExcludeMissing - referenceDatasetId: JsonField = JsonMissing.of(), - @JsonProperty("reference_example_id") - @ExcludeMissing - referenceExampleId: JsonField = JsonMissing.of(), - @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonField = JsonMissing.of(), - @JsonProperty("serialized") - @ExcludeMissing - serialized: JsonField = JsonMissing.of(), - @JsonProperty("share_token") - @ExcludeMissing - shareToken: JsonField = JsonMissing.of(), - @JsonProperty("start_time") - @ExcludeMissing - startTime: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), - @JsonProperty("thread_id") - @ExcludeMissing - threadId: JsonField = JsonMissing.of(), - @JsonProperty("total_cost") - @ExcludeMissing - totalCost: JsonField = JsonMissing.of(), - @JsonProperty("total_tokens") - @ExcludeMissing - totalTokens: JsonField = JsonMissing.of(), - @JsonProperty("trace_first_received_at") - @ExcludeMissing - traceFirstReceivedAt: JsonField = JsonMissing.of(), - @JsonProperty("trace_max_start_time") - @ExcludeMissing - traceMaxStartTime: JsonField = JsonMissing.of(), - @JsonProperty("trace_min_start_time") - @ExcludeMissing - traceMinStartTime: JsonField = JsonMissing.of(), - @JsonProperty("trace_tier") - @ExcludeMissing - traceTier: JsonField = JsonMissing.of(), - @JsonProperty("trace_upgrade") - @ExcludeMissing - traceUpgrade: JsonField = JsonMissing.of(), - @JsonProperty("ttl_seconds") - @ExcludeMissing - ttlSeconds: JsonField = JsonMissing.of(), - ) : this( - id, - appPath, - dottedOrder, - name, - runType, - sessionId, - status, - traceId, - childRunIds, - completionCost, - completionCostDetails, - completionTokenDetails, - completionTokens, - directChildRunIds, - endTime, - error, - events, - executionOrder, - extra, - feedbackStats, - firstTokenTime, - inDataset, - inputs, - inputsPreview, - inputsS3Urls, - lastQueuedAt, - manifestId, - manifestS3Id, - messages, - outputs, - outputsPreview, - outputsS3Urls, - parentRunId, - parentRunIds, - priceModelId, - promptCost, - promptCostDetails, - promptTokenDetails, - promptTokens, - referenceDatasetId, - referenceExampleId, - s3Urls, - serialized, - shareToken, - startTime, - tags, - threadId, - totalCost, - totalTokens, - traceFirstReceivedAt, - traceMaxStartTime, - traceMinStartTime, - traceTier, - traceUpgrade, - ttlSeconds, - 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 id(): String = id.getRequired("id") - - /** - * @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 appPath(): String = appPath.getRequired("app_path") - - /** - * @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 dottedOrder(): String = dottedOrder.getRequired("dotted_order") - - /** - * @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 name(): String = name.getRequired("name") - - /** - * Enum for run types. - * - * @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 runType(): RunType = runType.getRequired("run_type") - - /** - * @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 sessionId(): String = sessionId.getRequired("session_id") - - /** - * @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 status(): String = status.getRequired("status") - - /** - * @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 traceId(): String = traceId.getRequired("trace_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun childRunIds(): Optional> = childRunIds.getOptional("child_run_ids") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionCost(): Optional = completionCost.getOptional("completion_cost") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionCostDetails(): Optional = - completionCostDetails.getOptional("completion_cost_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionTokenDetails(): Optional = - completionTokenDetails.getOptional("completion_token_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun directChildRunIds(): Optional> = - directChildRunIds.getOptional("direct_child_run_ids") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endTime(): Optional = endTime.getOptional("end_time") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun error(): Optional = error.getOptional("error") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun events(): Optional> = events.getOptional("events") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun executionOrder(): Optional = executionOrder.getOptional("execution_order") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun extra(): Optional = extra.getOptional("extra") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun firstTokenTime(): Optional = - firstTokenTime.getOptional("first_token_time") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inDataset(): Optional = inDataset.getOptional("in_dataset") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inputs(): Optional = inputs.getOptional("inputs") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun inputsS3Urls(): Optional = inputsS3Urls.getOptional("inputs_s3_urls") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun lastQueuedAt(): Optional = lastQueuedAt.getOptional("last_queued_at") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun manifestId(): Optional = manifestId.getOptional("manifest_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun messages(): Optional> = messages.getOptional("messages") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun outputs(): Optional = outputs.getOptional("outputs") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun outputsS3Urls(): Optional = outputsS3Urls.getOptional("outputs_s3_urls") - - /** - * @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 parentRunIds(): Optional> = parentRunIds.getOptional("parent_run_ids") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun priceModelId(): Optional = priceModelId.getOptional("price_model_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptCost(): Optional = promptCost.getOptional("prompt_cost") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptCostDetails(): Optional = - promptCostDetails.getOptional("prompt_cost_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptTokenDetails(): Optional = - promptTokenDetails.getOptional("prompt_token_details") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceDatasetId(): Optional = - referenceDatasetId.getOptional("reference_dataset_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceExampleId(): Optional = - referenceExampleId.getOptional("reference_example_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun s3Urls(): Optional = s3Urls.getOptional("s3_urls") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun serialized(): Optional = serialized.getOptional("serialized") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun shareToken(): Optional = shareToken.getOptional("share_token") - - /** - * @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 tags(): Optional> = tags.getOptional("tags") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun threadId(): Optional = threadId.getOptional("thread_id") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun totalCost(): Optional = totalCost.getOptional("total_cost") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceFirstReceivedAt(): Optional = - traceFirstReceivedAt.getOptional("trace_first_received_at") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceMaxStartTime(): Optional = - traceMaxStartTime.getOptional("trace_max_start_time") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceMinStartTime(): Optional = - traceMinStartTime.getOptional("trace_min_start_time") - - /** - * @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") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun traceUpgrade(): Optional = traceUpgrade.getOptional("trace_upgrade") - - /** - * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun ttlSeconds(): Optional = ttlSeconds.getOptional("ttl_seconds") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [appPath]. - * - * Unlike [appPath], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("app_path") @ExcludeMissing fun _appPath(): JsonField = appPath - - /** - * Returns the raw JSON value of [dottedOrder]. - * - * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("dotted_order") - @ExcludeMissing - fun _dottedOrder(): JsonField = dottedOrder - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [runType]. - * - * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType - - /** - * 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 [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * 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 [childRunIds]. - * - * Unlike [childRunIds], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("child_run_ids") - @ExcludeMissing - fun _childRunIds(): JsonField> = childRunIds - - /** - * Returns the raw JSON value of [completionCost]. - * - * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("completion_cost") - @ExcludeMissing - fun _completionCost(): JsonField = completionCost - - /** - * Returns the raw JSON value of [completionCostDetails]. - * - * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("completion_cost_details") - @ExcludeMissing - fun _completionCostDetails(): JsonField = completionCostDetails - - /** - * Returns the raw JSON value of [completionTokenDetails]. - * - * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("completion_token_details") - @ExcludeMissing - fun _completionTokenDetails(): JsonField = completionTokenDetails - - /** - * Returns the raw JSON value of [completionTokens]. - * - * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens(): JsonField = completionTokens - - /** - * Returns the raw JSON value of [directChildRunIds]. - * - * Unlike [directChildRunIds], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("direct_child_run_ids") - @ExcludeMissing - fun _directChildRunIds(): JsonField> = directChildRunIds - - /** - * Returns the raw JSON value of [endTime]. - * - * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("end_time") - @ExcludeMissing - fun _endTime(): JsonField = endTime - - /** - * Returns the raw JSON value of [error]. - * - * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error - - /** - * Returns the raw JSON value of [events]. - * - * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events - - /** - * Returns the raw JSON value of [executionOrder]. - * - * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("execution_order") - @ExcludeMissing - fun _executionOrder(): JsonField = executionOrder - - /** - * Returns the raw JSON value of [extra]. - * - * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra - - /** - * Returns the raw JSON value of [feedbackStats]. - * - * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("feedback_stats") - @ExcludeMissing - fun _feedbackStats(): JsonField = feedbackStats - - /** - * Returns the raw JSON value of [firstTokenTime]. - * - * Unlike [firstTokenTime], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("first_token_time") - @ExcludeMissing - fun _firstTokenTime(): JsonField = firstTokenTime - - /** - * Returns the raw JSON value of [inDataset]. - * - * Unlike [inDataset], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField = inDataset - - /** - * Returns the raw JSON value of [inputs]. - * - * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs - - /** - * Returns the raw JSON value of [inputsPreview]. - * - * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("inputs_preview") - @ExcludeMissing - fun _inputsPreview(): JsonField = inputsPreview - - /** - * Returns the raw JSON value of [inputsS3Urls]. - * - * Unlike [inputsS3Urls], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("inputs_s3_urls") - @ExcludeMissing - fun _inputsS3Urls(): JsonField = inputsS3Urls - - /** - * Returns the raw JSON value of [lastQueuedAt]. - * - * Unlike [lastQueuedAt], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("last_queued_at") - @ExcludeMissing - fun _lastQueuedAt(): JsonField = lastQueuedAt - - /** - * Returns the raw JSON value of [manifestId]. - * - * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("manifest_id") - @ExcludeMissing - fun _manifestId(): JsonField = manifestId - - /** - * Returns the raw JSON value of [manifestS3Id]. - * - * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("manifest_s3_id") - @ExcludeMissing - fun _manifestS3Id(): JsonField = manifestS3Id - - /** - * Returns the raw JSON value of [messages]. - * - * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messages") - @ExcludeMissing - fun _messages(): JsonField> = messages - - /** - * Returns the raw JSON value of [outputs]. - * - * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs - - /** - * Returns the raw JSON value of [outputsPreview]. - * - * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("outputs_preview") - @ExcludeMissing - fun _outputsPreview(): JsonField = outputsPreview - - /** - * Returns the raw JSON value of [outputsS3Urls]. - * - * Unlike [outputsS3Urls], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("outputs_s3_urls") - @ExcludeMissing - fun _outputsS3Urls(): JsonField = outputsS3Urls - - /** - * 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 [parentRunIds]. - * - * Unlike [parentRunIds], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parent_run_ids") - @ExcludeMissing - fun _parentRunIds(): JsonField> = parentRunIds - - /** - * Returns the raw JSON value of [priceModelId]. - * - * Unlike [priceModelId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("price_model_id") - @ExcludeMissing - fun _priceModelId(): JsonField = priceModelId - - /** - * Returns the raw JSON value of [promptCost]. - * - * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("prompt_cost") - @ExcludeMissing - fun _promptCost(): JsonField = promptCost - - /** - * Returns the raw JSON value of [promptCostDetails]. - * - * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("prompt_cost_details") - @ExcludeMissing - fun _promptCostDetails(): JsonField = promptCostDetails - - /** - * Returns the raw JSON value of [promptTokenDetails]. - * - * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("prompt_token_details") - @ExcludeMissing - fun _promptTokenDetails(): JsonField = promptTokenDetails - - /** - * Returns the raw JSON value of [promptTokens]. - * - * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens(): JsonField = promptTokens - - /** - * Returns the raw JSON value of [referenceDatasetId]. - * - * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_dataset_id") - @ExcludeMissing - fun _referenceDatasetId(): JsonField = referenceDatasetId - - /** - * Returns the raw JSON value of [referenceExampleId]. - * - * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_example_id") - @ExcludeMissing - fun _referenceExampleId(): JsonField = referenceExampleId - - /** - * Returns the raw JSON value of [s3Urls]. - * - * Unlike [s3Urls], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonField = s3Urls - - /** - * Returns the raw JSON value of [serialized]. - * - * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("serialized") - @ExcludeMissing - fun _serialized(): JsonField = serialized - - /** - * Returns the raw JSON value of [shareToken]. - * - * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("share_token") - @ExcludeMissing - fun _shareToken(): JsonField = shareToken - - /** - * 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 [tags]. - * - * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags - - /** - * Returns the raw JSON value of [threadId]. - * - * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId - - /** - * Returns the raw JSON value of [totalCost]. - * - * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField = totalCost - - /** - * Returns the raw JSON value of [totalTokens]. - * - * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_tokens") - @ExcludeMissing - fun _totalTokens(): JsonField = totalTokens - - /** - * Returns the raw JSON value of [traceFirstReceivedAt]. - * - * Unlike [traceFirstReceivedAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("trace_first_received_at") - @ExcludeMissing - fun _traceFirstReceivedAt(): JsonField = traceFirstReceivedAt - - /** - * Returns the raw JSON value of [traceMaxStartTime]. - * - * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("trace_max_start_time") - @ExcludeMissing - fun _traceMaxStartTime(): JsonField = traceMaxStartTime - - /** - * Returns the raw JSON value of [traceMinStartTime]. - * - * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("trace_min_start_time") - @ExcludeMissing - fun _traceMinStartTime(): JsonField = traceMinStartTime - - /** - * 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 - - /** - * Returns the raw JSON value of [traceUpgrade]. - * - * Unlike [traceUpgrade], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("trace_upgrade") - @ExcludeMissing - fun _traceUpgrade(): JsonField = traceUpgrade - - /** - * Returns the raw JSON value of [ttlSeconds]. - * - * Unlike [ttlSeconds], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ttl_seconds") @ExcludeMissing fun _ttlSeconds(): JsonField = ttlSeconds - - @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 [Run]. - * - * The following fields are required: - * ```java - * .id() - * .appPath() - * .dottedOrder() - * .name() - * .runType() - * .sessionId() - * .status() - * .traceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Run]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var appPath: JsonField? = null - private var dottedOrder: JsonField? = null - private var name: JsonField? = null - private var runType: JsonField? = null - private var sessionId: JsonField? = null - private var status: JsonField? = null - private var traceId: JsonField? = null - private var childRunIds: JsonField>? = null - private var completionCost: JsonField = JsonMissing.of() - private var completionCostDetails: JsonField = JsonMissing.of() - private var completionTokenDetails: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var directChildRunIds: JsonField>? = null - private var endTime: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() - private var events: JsonField>? = null - private var executionOrder: JsonField = JsonMissing.of() - private var extra: JsonField = JsonMissing.of() - private var feedbackStats: JsonField = JsonMissing.of() - private var firstTokenTime: JsonField = JsonMissing.of() - private var inDataset: JsonField = JsonMissing.of() - private var inputs: JsonField = JsonMissing.of() - private var inputsPreview: JsonField = JsonMissing.of() - private var inputsS3Urls: JsonField = JsonMissing.of() - private var lastQueuedAt: JsonField = JsonMissing.of() - private var manifestId: JsonField = JsonMissing.of() - private var manifestS3Id: JsonField = JsonMissing.of() - private var messages: JsonField>? = null - private var outputs: JsonField = JsonMissing.of() - private var outputsPreview: JsonField = JsonMissing.of() - private var outputsS3Urls: JsonField = JsonMissing.of() - private var parentRunId: JsonField = JsonMissing.of() - private var parentRunIds: JsonField>? = null - private var priceModelId: JsonField = JsonMissing.of() - private var promptCost: JsonField = JsonMissing.of() - private var promptCostDetails: JsonField = JsonMissing.of() - private var promptTokenDetails: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var referenceDatasetId: JsonField = JsonMissing.of() - private var referenceExampleId: JsonField = JsonMissing.of() - private var s3Urls: JsonField = JsonMissing.of() - private var serialized: JsonField = JsonMissing.of() - private var shareToken: JsonField = JsonMissing.of() - private var startTime: JsonField = JsonMissing.of() - private var tags: JsonField>? = null - private var threadId: JsonField = JsonMissing.of() - private var totalCost: JsonField = JsonMissing.of() - private var totalTokens: JsonField = JsonMissing.of() - private var traceFirstReceivedAt: JsonField = JsonMissing.of() - private var traceMaxStartTime: JsonField = JsonMissing.of() - private var traceMinStartTime: JsonField = JsonMissing.of() - private var traceTier: JsonField = JsonMissing.of() - private var traceUpgrade: JsonField = JsonMissing.of() - private var ttlSeconds: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(run: Run) = apply { - id = run.id - appPath = run.appPath - dottedOrder = run.dottedOrder - name = run.name - runType = run.runType - sessionId = run.sessionId - status = run.status - traceId = run.traceId - childRunIds = run.childRunIds.map { it.toMutableList() } - completionCost = run.completionCost - completionCostDetails = run.completionCostDetails - completionTokenDetails = run.completionTokenDetails - completionTokens = run.completionTokens - directChildRunIds = run.directChildRunIds.map { it.toMutableList() } - endTime = run.endTime - error = run.error - events = run.events.map { it.toMutableList() } - executionOrder = run.executionOrder - extra = run.extra - feedbackStats = run.feedbackStats - firstTokenTime = run.firstTokenTime - inDataset = run.inDataset - inputs = run.inputs - inputsPreview = run.inputsPreview - inputsS3Urls = run.inputsS3Urls - lastQueuedAt = run.lastQueuedAt - manifestId = run.manifestId - manifestS3Id = run.manifestS3Id - messages = run.messages.map { it.toMutableList() } - outputs = run.outputs - outputsPreview = run.outputsPreview - outputsS3Urls = run.outputsS3Urls - parentRunId = run.parentRunId - parentRunIds = run.parentRunIds.map { it.toMutableList() } - priceModelId = run.priceModelId - promptCost = run.promptCost - promptCostDetails = run.promptCostDetails - promptTokenDetails = run.promptTokenDetails - promptTokens = run.promptTokens - referenceDatasetId = run.referenceDatasetId - referenceExampleId = run.referenceExampleId - s3Urls = run.s3Urls - serialized = run.serialized - shareToken = run.shareToken - startTime = run.startTime - tags = run.tags.map { it.toMutableList() } - threadId = run.threadId - totalCost = run.totalCost - totalTokens = run.totalTokens - traceFirstReceivedAt = run.traceFirstReceivedAt - traceMaxStartTime = run.traceMaxStartTime - traceMinStartTime = run.traceMinStartTime - traceTier = run.traceTier - traceUpgrade = run.traceUpgrade - ttlSeconds = run.ttlSeconds - additionalProperties = run.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun appPath(appPath: String) = appPath(JsonField.of(appPath)) - - /** - * Sets [Builder.appPath] to an arbitrary JSON value. - * - * You should usually call [Builder.appPath] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun appPath(appPath: JsonField) = apply { this.appPath = appPath } - - fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) - - /** - * Sets [Builder.dottedOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.dottedOrder] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun dottedOrder(dottedOrder: JsonField) = apply { - this.dottedOrder = dottedOrder - } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Enum for run types. */ - fun runType(runType: RunType) = runType(JsonField.of(runType)) - - /** - * Sets [Builder.runType] to an arbitrary JSON value. - * - * You should usually call [Builder.runType] with a well-typed [RunType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun runType(runType: JsonField) = apply { this.runType = runType } - - fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) - - /** - * 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 status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun traceId(traceId: String) = traceId(JsonField.of(traceId)) - - /** - * 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 childRunIds(childRunIds: List?) = - childRunIds(JsonField.ofNullable(childRunIds)) - - /** Alias for calling [Builder.childRunIds] with `childRunIds.orElse(null)`. */ - fun childRunIds(childRunIds: Optional>) = - childRunIds(childRunIds.getOrNull()) - - /** - * Sets [Builder.childRunIds] to an arbitrary JSON value. - * - * You should usually call [Builder.childRunIds] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun childRunIds(childRunIds: JsonField>) = apply { - this.childRunIds = childRunIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [childRunIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChildRunId(childRunId: String) = apply { - childRunIds = - (childRunIds ?: JsonField.of(mutableListOf())).also { - checkKnown("childRunIds", it).add(childRunId) - } - } - - fun completionCost(completionCost: String?) = - completionCost(JsonField.ofNullable(completionCost)) - - /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ - fun completionCost(completionCost: Optional) = - completionCost(completionCost.getOrNull()) - - /** - * Sets [Builder.completionCost] to an arbitrary JSON value. - * - * You should usually call [Builder.completionCost] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun completionCost(completionCost: JsonField) = apply { - this.completionCost = completionCost - } - - fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = - completionCostDetails(JsonField.ofNullable(completionCostDetails)) - - /** - * Alias for calling [Builder.completionCostDetails] with - * `completionCostDetails.orElse(null)`. - */ - fun completionCostDetails(completionCostDetails: Optional) = - completionCostDetails(completionCostDetails.getOrNull()) - - /** - * Sets [Builder.completionCostDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.completionCostDetails] with a well-typed - * [CompletionCostDetails] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun completionCostDetails(completionCostDetails: JsonField) = - apply { - this.completionCostDetails = completionCostDetails - } - - fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = - completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) - - /** - * Alias for calling [Builder.completionTokenDetails] with - * `completionTokenDetails.orElse(null)`. - */ - fun completionTokenDetails(completionTokenDetails: Optional) = - completionTokenDetails(completionTokenDetails.getOrNull()) - - /** - * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.completionTokenDetails] with a well-typed - * [CompletionTokenDetails] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun completionTokenDetails(completionTokenDetails: JsonField) = - apply { - this.completionTokenDetails = completionTokenDetails - } - - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * Sets [Builder.completionTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.completionTokens] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - fun directChildRunIds(directChildRunIds: List?) = - directChildRunIds(JsonField.ofNullable(directChildRunIds)) - - /** - * Alias for calling [Builder.directChildRunIds] with `directChildRunIds.orElse(null)`. - */ - fun directChildRunIds(directChildRunIds: Optional>) = - directChildRunIds(directChildRunIds.getOrNull()) - - /** - * Sets [Builder.directChildRunIds] to an arbitrary JSON value. - * - * You should usually call [Builder.directChildRunIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun directChildRunIds(directChildRunIds: JsonField>) = apply { - this.directChildRunIds = directChildRunIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [directChildRunIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addDirectChildRunId(directChildRunId: String) = apply { - directChildRunIds = - (directChildRunIds ?: JsonField.of(mutableListOf())).also { - checkKnown("directChildRunIds", it).add(directChildRunId) - } - } - - fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) - - /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ - fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) - - /** - * Sets [Builder.endTime] to an arbitrary JSON value. - * - * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun endTime(endTime: JsonField) = apply { this.endTime = endTime } - - fun error(error: String?) = error(JsonField.ofNullable(error)) - - /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) - - /** - * Sets [Builder.error] to an arbitrary JSON value. - * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun error(error: JsonField) = apply { this.error = error } - - fun events(events: List?) = events(JsonField.ofNullable(events)) - - /** Alias for calling [Builder.events] with `events.orElse(null)`. */ - fun events(events: Optional>) = events(events.getOrNull()) - - /** - * Sets [Builder.events] to an arbitrary JSON value. - * - * You should usually call [Builder.events] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } - - /** - * Adds a single [Event] to [events]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEvent(event: Event) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { - checkKnown("events", it).add(event) - } - } - - fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) - - /** - * Sets [Builder.executionOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.executionOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun executionOrder(executionOrder: JsonField) = apply { - this.executionOrder = executionOrder - } - - fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) - - /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ - fun extra(extra: Optional) = extra(extra.getOrNull()) - - /** - * Sets [Builder.extra] to an arbitrary JSON value. - * - * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun extra(extra: JsonField) = apply { this.extra = extra } - - fun feedbackStats(feedbackStats: FeedbackStats?) = - feedbackStats(JsonField.ofNullable(feedbackStats)) - - /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ - fun feedbackStats(feedbackStats: Optional) = - feedbackStats(feedbackStats.getOrNull()) - - /** - * Sets [Builder.feedbackStats] to an arbitrary JSON value. - * - * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun feedbackStats(feedbackStats: JsonField) = apply { - this.feedbackStats = feedbackStats - } - - fun firstTokenTime(firstTokenTime: OffsetDateTime?) = - firstTokenTime(JsonField.ofNullable(firstTokenTime)) - - /** Alias for calling [Builder.firstTokenTime] with `firstTokenTime.orElse(null)`. */ - fun firstTokenTime(firstTokenTime: Optional) = - firstTokenTime(firstTokenTime.getOrNull()) - - /** - * Sets [Builder.firstTokenTime] to an arbitrary JSON value. - * - * You should usually call [Builder.firstTokenTime] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun firstTokenTime(firstTokenTime: JsonField) = apply { - this.firstTokenTime = firstTokenTime - } - - fun inDataset(inDataset: Boolean?) = inDataset(JsonField.ofNullable(inDataset)) - - /** - * Alias for [Builder.inDataset]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun inDataset(inDataset: Boolean) = inDataset(inDataset as Boolean?) - - /** Alias for calling [Builder.inDataset] with `inDataset.orElse(null)`. */ - fun inDataset(inDataset: Optional) = inDataset(inDataset.getOrNull()) - - /** - * Sets [Builder.inDataset] to an arbitrary JSON value. - * - * You should usually call [Builder.inDataset] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inDataset(inDataset: JsonField) = apply { this.inDataset = inDataset } - - fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) - - /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ - fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) - - /** - * Sets [Builder.inputs] to an arbitrary JSON value. - * - * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputs(inputs: JsonField) = apply { this.inputs = inputs } - - fun inputsPreview(inputsPreview: String?) = - inputsPreview(JsonField.ofNullable(inputsPreview)) - - /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ - fun inputsPreview(inputsPreview: Optional) = - inputsPreview(inputsPreview.getOrNull()) - - /** - * Sets [Builder.inputsPreview] to an arbitrary JSON value. - * - * You should usually call [Builder.inputsPreview] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputsPreview(inputsPreview: JsonField) = apply { - this.inputsPreview = inputsPreview - } - - fun inputsS3Urls(inputsS3Urls: InputsS3Urls?) = - inputsS3Urls(JsonField.ofNullable(inputsS3Urls)) - - /** Alias for calling [Builder.inputsS3Urls] with `inputsS3Urls.orElse(null)`. */ - fun inputsS3Urls(inputsS3Urls: Optional) = - inputsS3Urls(inputsS3Urls.getOrNull()) - - /** - * Sets [Builder.inputsS3Urls] to an arbitrary JSON value. - * - * You should usually call [Builder.inputsS3Urls] with a well-typed [InputsS3Urls] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun inputsS3Urls(inputsS3Urls: JsonField) = apply { - this.inputsS3Urls = inputsS3Urls - } - - fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = - lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) - - /** Alias for calling [Builder.lastQueuedAt] with `lastQueuedAt.orElse(null)`. */ - fun lastQueuedAt(lastQueuedAt: Optional) = - lastQueuedAt(lastQueuedAt.getOrNull()) - - /** - * Sets [Builder.lastQueuedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.lastQueuedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun lastQueuedAt(lastQueuedAt: JsonField) = apply { - this.lastQueuedAt = lastQueuedAt - } - - fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) - - /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ - fun manifestId(manifestId: Optional) = manifestId(manifestId.getOrNull()) - - /** - * Sets [Builder.manifestId] to an arbitrary JSON value. - * - * You should usually call [Builder.manifestId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun manifestId(manifestId: JsonField) = apply { this.manifestId = manifestId } - - fun manifestS3Id(manifestS3Id: String?) = - manifestS3Id(JsonField.ofNullable(manifestS3Id)) - - /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ - fun manifestS3Id(manifestS3Id: Optional) = - manifestS3Id(manifestS3Id.getOrNull()) - - /** - * Sets [Builder.manifestS3Id] to an arbitrary JSON value. - * - * You should usually call [Builder.manifestS3Id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun manifestS3Id(manifestS3Id: JsonField) = apply { - this.manifestS3Id = manifestS3Id - } - - fun messages(messages: List?) = messages(JsonField.ofNullable(messages)) - - /** Alias for calling [Builder.messages] with `messages.orElse(null)`. */ - fun messages(messages: Optional>) = messages(messages.getOrNull()) - - /** - * Sets [Builder.messages] to an arbitrary JSON value. - * - * You should usually call [Builder.messages] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messages(messages: JsonField>) = apply { - this.messages = messages.map { it.toMutableList() } - } - - /** - * Adds a single [Message] to [messages]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addMessage(message: Message) = apply { - messages = - (messages ?: JsonField.of(mutableListOf())).also { - checkKnown("messages", it).add(message) - } - } - - fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) - - /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ - fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) - - /** - * Sets [Builder.outputs] to an arbitrary JSON value. - * - * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun outputs(outputs: JsonField) = apply { this.outputs = outputs } - - fun outputsPreview(outputsPreview: String?) = - outputsPreview(JsonField.ofNullable(outputsPreview)) - - /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ - fun outputsPreview(outputsPreview: Optional) = - outputsPreview(outputsPreview.getOrNull()) - - /** - * Sets [Builder.outputsPreview] to an arbitrary JSON value. - * - * You should usually call [Builder.outputsPreview] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun outputsPreview(outputsPreview: JsonField) = apply { - this.outputsPreview = outputsPreview - } - - fun outputsS3Urls(outputsS3Urls: OutputsS3Urls?) = - outputsS3Urls(JsonField.ofNullable(outputsS3Urls)) - - /** Alias for calling [Builder.outputsS3Urls] with `outputsS3Urls.orElse(null)`. */ - fun outputsS3Urls(outputsS3Urls: Optional) = - outputsS3Urls(outputsS3Urls.getOrNull()) - - /** - * Sets [Builder.outputsS3Urls] to an arbitrary JSON value. - * - * You should usually call [Builder.outputsS3Urls] with a well-typed [OutputsS3Urls] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun outputsS3Urls(outputsS3Urls: JsonField) = apply { - this.outputsS3Urls = outputsS3Urls - } - - 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 parentRunIds(parentRunIds: List?) = - parentRunIds(JsonField.ofNullable(parentRunIds)) - - /** Alias for calling [Builder.parentRunIds] with `parentRunIds.orElse(null)`. */ - fun parentRunIds(parentRunIds: Optional>) = - parentRunIds(parentRunIds.getOrNull()) - - /** - * Sets [Builder.parentRunIds] to an arbitrary JSON value. - * - * You should usually call [Builder.parentRunIds] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parentRunIds(parentRunIds: JsonField>) = apply { - this.parentRunIds = parentRunIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [parentRunIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addParentRunId(parentRunId: String) = apply { - parentRunIds = - (parentRunIds ?: JsonField.of(mutableListOf())).also { - checkKnown("parentRunIds", it).add(parentRunId) - } - } - - fun priceModelId(priceModelId: String?) = - priceModelId(JsonField.ofNullable(priceModelId)) - - /** Alias for calling [Builder.priceModelId] with `priceModelId.orElse(null)`. */ - fun priceModelId(priceModelId: Optional) = - priceModelId(priceModelId.getOrNull()) - - /** - * Sets [Builder.priceModelId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceModelId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceModelId(priceModelId: JsonField) = apply { - this.priceModelId = priceModelId - } - - fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) - - /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ - fun promptCost(promptCost: Optional) = promptCost(promptCost.getOrNull()) - - /** - * Sets [Builder.promptCost] to an arbitrary JSON value. - * - * You should usually call [Builder.promptCost] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun promptCost(promptCost: JsonField) = apply { this.promptCost = promptCost } - - fun promptCostDetails(promptCostDetails: PromptCostDetails?) = - promptCostDetails(JsonField.ofNullable(promptCostDetails)) - - /** - * Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. - */ - fun promptCostDetails(promptCostDetails: Optional) = - promptCostDetails(promptCostDetails.getOrNull()) - - /** - * Sets [Builder.promptCostDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.promptCostDetails] with a well-typed - * [PromptCostDetails] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun promptCostDetails(promptCostDetails: JsonField) = apply { - this.promptCostDetails = promptCostDetails - } - - fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = - promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) - - /** - * Alias for calling [Builder.promptTokenDetails] with - * `promptTokenDetails.orElse(null)`. - */ - fun promptTokenDetails(promptTokenDetails: Optional) = - promptTokenDetails(promptTokenDetails.getOrNull()) - - /** - * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. - * - * You should usually call [Builder.promptTokenDetails] with a well-typed - * [PromptTokenDetails] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun promptTokenDetails(promptTokenDetails: JsonField) = apply { - this.promptTokenDetails = promptTokenDetails - } - - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * Sets [Builder.promptTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.promptTokens] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - fun referenceDatasetId(referenceDatasetId: String?) = - referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) - - /** - * Alias for calling [Builder.referenceDatasetId] with - * `referenceDatasetId.orElse(null)`. - */ - fun referenceDatasetId(referenceDatasetId: Optional) = - referenceDatasetId(referenceDatasetId.getOrNull()) - - /** - * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun referenceDatasetId(referenceDatasetId: JsonField) = apply { - this.referenceDatasetId = referenceDatasetId - } - - fun referenceExampleId(referenceExampleId: String?) = - referenceExampleId(JsonField.ofNullable(referenceExampleId)) - - /** - * Alias for calling [Builder.referenceExampleId] with - * `referenceExampleId.orElse(null)`. - */ - fun referenceExampleId(referenceExampleId: Optional) = - referenceExampleId(referenceExampleId.getOrNull()) - - /** - * Sets [Builder.referenceExampleId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceExampleId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun referenceExampleId(referenceExampleId: JsonField) = apply { - this.referenceExampleId = referenceExampleId - } - - fun s3Urls(s3Urls: S3Urls?) = s3Urls(JsonField.ofNullable(s3Urls)) - - /** Alias for calling [Builder.s3Urls] with `s3Urls.orElse(null)`. */ - fun s3Urls(s3Urls: Optional) = s3Urls(s3Urls.getOrNull()) - - /** - * Sets [Builder.s3Urls] to an arbitrary JSON value. - * - * You should usually call [Builder.s3Urls] with a well-typed [S3Urls] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun s3Urls(s3Urls: JsonField) = apply { this.s3Urls = s3Urls } - - fun serialized(serialized: Serialized?) = serialized(JsonField.ofNullable(serialized)) - - /** Alias for calling [Builder.serialized] with `serialized.orElse(null)`. */ - fun serialized(serialized: Optional) = serialized(serialized.getOrNull()) - - /** - * Sets [Builder.serialized] to an arbitrary JSON value. - * - * You should usually call [Builder.serialized] with a well-typed [Serialized] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun serialized(serialized: JsonField) = apply { - this.serialized = serialized - } - - fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) - - /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ - fun shareToken(shareToken: Optional) = shareToken(shareToken.getOrNull()) - - /** - * Sets [Builder.shareToken] to an arbitrary JSON value. - * - * You should usually call [Builder.shareToken] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun shareToken(shareToken: JsonField) = apply { this.shareToken = shareToken } - - fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) - - /** - * 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 tags(tags: List?) = tags(JsonField.ofNullable(tags)) - - /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ - fun tags(tags: Optional>) = tags(tags.getOrNull()) - - /** - * Sets [Builder.tags] to an arbitrary JSON value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun threadId(threadId: String?) = threadId(JsonField.ofNullable(threadId)) - - /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ - fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) - - /** - * Sets [Builder.threadId] to an arbitrary JSON value. - * - * You should usually call [Builder.threadId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun threadId(threadId: JsonField) = apply { this.threadId = threadId } - - fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) - - /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ - fun totalCost(totalCost: Optional) = totalCost(totalCost.getOrNull()) - - /** - * Sets [Builder.totalCost] to an arbitrary JSON value. - * - * You should usually call [Builder.totalCost] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalCost(totalCost: JsonField) = apply { this.totalCost = totalCost } - - fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) - - /** - * Sets [Builder.totalTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalTokens(totalTokens: JsonField) = apply { this.totalTokens = totalTokens } - - fun traceFirstReceivedAt(traceFirstReceivedAt: OffsetDateTime?) = - traceFirstReceivedAt(JsonField.ofNullable(traceFirstReceivedAt)) - - /** - * Alias for calling [Builder.traceFirstReceivedAt] with - * `traceFirstReceivedAt.orElse(null)`. - */ - fun traceFirstReceivedAt(traceFirstReceivedAt: Optional) = - traceFirstReceivedAt(traceFirstReceivedAt.getOrNull()) - - /** - * Sets [Builder.traceFirstReceivedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.traceFirstReceivedAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun traceFirstReceivedAt(traceFirstReceivedAt: JsonField) = apply { - this.traceFirstReceivedAt = traceFirstReceivedAt - } - - fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = - traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) - - /** - * Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. - */ - fun traceMaxStartTime(traceMaxStartTime: Optional) = - traceMaxStartTime(traceMaxStartTime.getOrNull()) - - /** - * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. - * - * You should usually call [Builder.traceMaxStartTime] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun traceMaxStartTime(traceMaxStartTime: JsonField) = apply { - this.traceMaxStartTime = traceMaxStartTime - } - - fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = - traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) - - /** - * Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. - */ - fun traceMinStartTime(traceMinStartTime: Optional) = - traceMinStartTime(traceMinStartTime.getOrNull()) - - /** - * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. - * - * You should usually call [Builder.traceMinStartTime] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun traceMinStartTime(traceMinStartTime: JsonField) = apply { - this.traceMinStartTime = traceMinStartTime - } - - 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 traceUpgrade(traceUpgrade: Boolean) = traceUpgrade(JsonField.of(traceUpgrade)) - - /** - * Sets [Builder.traceUpgrade] to an arbitrary JSON value. - * - * You should usually call [Builder.traceUpgrade] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun traceUpgrade(traceUpgrade: JsonField) = apply { - this.traceUpgrade = traceUpgrade - } - - fun ttlSeconds(ttlSeconds: Long?) = ttlSeconds(JsonField.ofNullable(ttlSeconds)) - - /** - * Alias for [Builder.ttlSeconds]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun ttlSeconds(ttlSeconds: Long) = ttlSeconds(ttlSeconds as Long?) - - /** Alias for calling [Builder.ttlSeconds] with `ttlSeconds.orElse(null)`. */ - fun ttlSeconds(ttlSeconds: Optional) = ttlSeconds(ttlSeconds.getOrNull()) - - /** - * Sets [Builder.ttlSeconds] to an arbitrary JSON value. - * - * You should usually call [Builder.ttlSeconds] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun ttlSeconds(ttlSeconds: JsonField) = apply { this.ttlSeconds = ttlSeconds } - - 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 [Run]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .appPath() - * .dottedOrder() - * .name() - * .runType() - * .sessionId() - * .status() - * .traceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Run = - Run( - checkRequired("id", id), - checkRequired("appPath", appPath), - checkRequired("dottedOrder", dottedOrder), - checkRequired("name", name), - checkRequired("runType", runType), - checkRequired("sessionId", sessionId), - checkRequired("status", status), - checkRequired("traceId", traceId), - (childRunIds ?: JsonMissing.of()).map { it.toImmutable() }, - completionCost, - completionCostDetails, - completionTokenDetails, - completionTokens, - (directChildRunIds ?: JsonMissing.of()).map { it.toImmutable() }, - endTime, - error, - (events ?: JsonMissing.of()).map { it.toImmutable() }, - executionOrder, - extra, - feedbackStats, - firstTokenTime, - inDataset, - inputs, - inputsPreview, - inputsS3Urls, - lastQueuedAt, - manifestId, - manifestS3Id, - (messages ?: JsonMissing.of()).map { it.toImmutable() }, - outputs, - outputsPreview, - outputsS3Urls, - parentRunId, - (parentRunIds ?: JsonMissing.of()).map { it.toImmutable() }, - priceModelId, - promptCost, - promptCostDetails, - promptTokenDetails, - promptTokens, - referenceDatasetId, - referenceExampleId, - s3Urls, - serialized, - shareToken, - startTime, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - threadId, - totalCost, - totalTokens, - traceFirstReceivedAt, - traceMaxStartTime, - traceMinStartTime, - traceTier, - traceUpgrade, - ttlSeconds, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Run = apply { - if (validated) { - return@apply - } - - id() - appPath() - dottedOrder() - name() - runType().validate() - sessionId() - status() - traceId() - childRunIds() - completionCost() - completionCostDetails().ifPresent { it.validate() } - completionTokenDetails().ifPresent { it.validate() } - completionTokens() - directChildRunIds() - endTime() - error() - events().ifPresent { it.forEach { it.validate() } } - executionOrder() - extra().ifPresent { it.validate() } - feedbackStats().ifPresent { it.validate() } - firstTokenTime() - inDataset() - inputs().ifPresent { it.validate() } - inputsPreview() - inputsS3Urls().ifPresent { it.validate() } - lastQueuedAt() - manifestId() - manifestS3Id() - messages().ifPresent { it.forEach { it.validate() } } - outputs().ifPresent { it.validate() } - outputsPreview() - outputsS3Urls().ifPresent { it.validate() } - parentRunId() - parentRunIds() - priceModelId() - promptCost() - promptCostDetails().ifPresent { it.validate() } - promptTokenDetails().ifPresent { it.validate() } - promptTokens() - referenceDatasetId() - referenceExampleId() - s3Urls().ifPresent { it.validate() } - serialized().ifPresent { it.validate() } - shareToken() - startTime() - tags() - threadId() - totalCost() - totalTokens() - traceFirstReceivedAt() - traceMaxStartTime() - traceMinStartTime() - traceTier().ifPresent { it.validate() } - traceUpgrade() - ttlSeconds() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (appPath.asKnown().isPresent) 1 else 0) + - (if (dottedOrder.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (runType.asKnown().getOrNull()?.validity() ?: 0) + - (if (sessionId.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (traceId.asKnown().isPresent) 1 else 0) + - (childRunIds.asKnown().getOrNull()?.size ?: 0) + - (if (completionCost.asKnown().isPresent) 1 else 0) + - (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + - (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + - (if (completionTokens.asKnown().isPresent) 1 else 0) + - (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + - (if (endTime.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + - (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (executionOrder.asKnown().isPresent) 1 else 0) + - (extra.asKnown().getOrNull()?.validity() ?: 0) + - (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + - (if (firstTokenTime.asKnown().isPresent) 1 else 0) + - (if (inDataset.asKnown().isPresent) 1 else 0) + - (inputs.asKnown().getOrNull()?.validity() ?: 0) + - (if (inputsPreview.asKnown().isPresent) 1 else 0) + - (inputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + - (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + - (if (manifestId.asKnown().isPresent) 1 else 0) + - (if (manifestS3Id.asKnown().isPresent) 1 else 0) + - (messages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (outputs.asKnown().getOrNull()?.validity() ?: 0) + - (if (outputsPreview.asKnown().isPresent) 1 else 0) + - (outputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + - (if (parentRunId.asKnown().isPresent) 1 else 0) + - (parentRunIds.asKnown().getOrNull()?.size ?: 0) + - (if (priceModelId.asKnown().isPresent) 1 else 0) + - (if (promptCost.asKnown().isPresent) 1 else 0) + - (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + - (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + - (if (promptTokens.asKnown().isPresent) 1 else 0) + - (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + - (if (referenceExampleId.asKnown().isPresent) 1 else 0) + - (s3Urls.asKnown().getOrNull()?.validity() ?: 0) + - (serialized.asKnown().getOrNull()?.validity() ?: 0) + - (if (shareToken.asKnown().isPresent) 1 else 0) + - (if (startTime.asKnown().isPresent) 1 else 0) + - (tags.asKnown().getOrNull()?.size ?: 0) + - (if (threadId.asKnown().isPresent) 1 else 0) + - (if (totalCost.asKnown().isPresent) 1 else 0) + - (if (totalTokens.asKnown().isPresent) 1 else 0) + - (if (traceFirstReceivedAt.asKnown().isPresent) 1 else 0) + - (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + - (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + - (traceTier.asKnown().getOrNull()?.validity() ?: 0) + - (if (traceUpgrade.asKnown().isPresent) 1 else 0) + - (if (ttlSeconds.asKnown().isPresent) 1 else 0) - - /** Enum for run types. */ - class RunType @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 TOOL = of("tool") - - @JvmField val CHAIN = of("chain") - - @JvmField val LLM = of("llm") - - @JvmField val RETRIEVER = of("retriever") - - @JvmField val EMBEDDING = of("embedding") - - @JvmField val PROMPT = of("prompt") - - @JvmField val PARSER = of("parser") - - @JvmStatic fun of(value: String) = RunType(JsonField.of(value)) - } - - /** An enum containing [RunType]'s known values. */ - enum class Known { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - } - - /** - * An enum containing [RunType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RunType] 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 { - TOOL, - CHAIN, - LLM, - RETRIEVER, - EMBEDDING, - PROMPT, - PARSER, - /** - * An enum member indicating that [RunType] 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) { - TOOL -> Value.TOOL - CHAIN -> Value.CHAIN - LLM -> Value.LLM - RETRIEVER -> Value.RETRIEVER - EMBEDDING -> Value.EMBEDDING - PROMPT -> Value.PROMPT - PARSER -> Value.PARSER - 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) { - TOOL -> Known.TOOL - CHAIN -> Known.CHAIN - LLM -> Known.LLM - RETRIEVER -> Known.RETRIEVER - EMBEDDING -> Known.EMBEDDING - PROMPT -> Known.PROMPT - PARSER -> Known.PARSER - else -> throw LangChainInvalidDataException("Unknown RunType: $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(): RunType = 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 RunType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class CompletionCostDetails - @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 - * [CompletionCostDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CompletionCostDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(completionCostDetails: CompletionCostDetails) = apply { - additionalProperties = completionCostDetails.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 [CompletionCostDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CompletionCostDetails = - CompletionCostDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CompletionCostDetails = 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 CompletionCostDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CompletionCostDetails{additionalProperties=$additionalProperties}" - } - - class CompletionTokenDetails - @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 - * [CompletionTokenDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CompletionTokenDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { - additionalProperties = - completionTokenDetails.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 [CompletionTokenDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CompletionTokenDetails = - CompletionTokenDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CompletionTokenDetails = 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 CompletionTokenDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CompletionTokenDetails{additionalProperties=$additionalProperties}" - } - - class Event - @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 [Event]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Event]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(event: Event) = apply { - additionalProperties = event.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 [Event]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Event = Event(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Event = 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 Event && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Event{additionalProperties=$additionalProperties}" - } - - class Extra - @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 [Extra]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Extra]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(extra: Extra) = apply { - additionalProperties = extra.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 [Extra]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Extra = Extra(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Extra = 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 Extra && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Extra{additionalProperties=$additionalProperties}" - } - - class FeedbackStats - @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 [FeedbackStats]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FeedbackStats]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedbackStats: FeedbackStats) = apply { - additionalProperties = feedbackStats.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 [FeedbackStats]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): FeedbackStats = 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 FeedbackStats && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" - } - - class Inputs - @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 [Inputs]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Inputs]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inputs: Inputs) = apply { - additionalProperties = inputs.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 [Inputs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Inputs = Inputs(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Inputs = 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 Inputs && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Inputs{additionalProperties=$additionalProperties}" - } - - class InputsS3Urls - @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 [InputsS3Urls]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InputsS3Urls]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inputsS3Urls: InputsS3Urls) = apply { - additionalProperties = inputsS3Urls.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 [InputsS3Urls]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InputsS3Urls = InputsS3Urls(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InputsS3Urls = 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 InputsS3Urls && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "InputsS3Urls{additionalProperties=$additionalProperties}" - } - - class Message - @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 [Message]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Message]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(message: Message) = apply { - additionalProperties = message.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 [Message]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Message = Message(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Message = 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 Message && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Message{additionalProperties=$additionalProperties}" - } - - class Outputs - @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 [Outputs]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Outputs]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(outputs: Outputs) = apply { - additionalProperties = outputs.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 [Outputs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Outputs = Outputs(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Outputs = 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 Outputs && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Outputs{additionalProperties=$additionalProperties}" - } - - class OutputsS3Urls - @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 [OutputsS3Urls]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OutputsS3Urls]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(outputsS3Urls: OutputsS3Urls) = apply { - additionalProperties = outputsS3Urls.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 [OutputsS3Urls]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): OutputsS3Urls = OutputsS3Urls(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): OutputsS3Urls = 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 OutputsS3Urls && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "OutputsS3Urls{additionalProperties=$additionalProperties}" - } - - class PromptCostDetails - @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 [PromptCostDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PromptCostDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptCostDetails: PromptCostDetails) = apply { - additionalProperties = promptCostDetails.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 [PromptCostDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PromptCostDetails = - PromptCostDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): PromptCostDetails = 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 PromptCostDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PromptCostDetails{additionalProperties=$additionalProperties}" - } - - class PromptTokenDetails - @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 [PromptTokenDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PromptTokenDetails]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptTokenDetails: PromptTokenDetails) = apply { - additionalProperties = promptTokenDetails.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 [PromptTokenDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PromptTokenDetails = - PromptTokenDetails(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): PromptTokenDetails = 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 PromptTokenDetails && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PromptTokenDetails{additionalProperties=$additionalProperties}" - } - - class S3Urls - @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 [S3Urls]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [S3Urls]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(s3Urls: S3Urls) = apply { - additionalProperties = s3Urls.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 [S3Urls]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): S3Urls = S3Urls(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): S3Urls = 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 S3Urls && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "S3Urls{additionalProperties=$additionalProperties}" - } - - class Serialized - @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 [Serialized]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Serialized]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(serialized: Serialized) = apply { - additionalProperties = serialized.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 [Serialized]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Serialized = Serialized(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Serialized = 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 Serialized && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Serialized{additionalProperties=$additionalProperties}" - } - - 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 Run && - id == other.id && - appPath == other.appPath && - dottedOrder == other.dottedOrder && - name == other.name && - runType == other.runType && - sessionId == other.sessionId && - status == other.status && - traceId == other.traceId && - childRunIds == other.childRunIds && - completionCost == other.completionCost && - completionCostDetails == other.completionCostDetails && - completionTokenDetails == other.completionTokenDetails && - completionTokens == other.completionTokens && - directChildRunIds == other.directChildRunIds && - endTime == other.endTime && - error == other.error && - events == other.events && - executionOrder == other.executionOrder && - extra == other.extra && - feedbackStats == other.feedbackStats && - firstTokenTime == other.firstTokenTime && - inDataset == other.inDataset && - inputs == other.inputs && - inputsPreview == other.inputsPreview && - inputsS3Urls == other.inputsS3Urls && - lastQueuedAt == other.lastQueuedAt && - manifestId == other.manifestId && - manifestS3Id == other.manifestS3Id && - messages == other.messages && - outputs == other.outputs && - outputsPreview == other.outputsPreview && - outputsS3Urls == other.outputsS3Urls && - parentRunId == other.parentRunId && - parentRunIds == other.parentRunIds && - priceModelId == other.priceModelId && - promptCost == other.promptCost && - promptCostDetails == other.promptCostDetails && - promptTokenDetails == other.promptTokenDetails && - promptTokens == other.promptTokens && - referenceDatasetId == other.referenceDatasetId && - referenceExampleId == other.referenceExampleId && - s3Urls == other.s3Urls && - serialized == other.serialized && - shareToken == other.shareToken && - startTime == other.startTime && - tags == other.tags && - threadId == other.threadId && - totalCost == other.totalCost && - totalTokens == other.totalTokens && - traceFirstReceivedAt == other.traceFirstReceivedAt && - traceMaxStartTime == other.traceMaxStartTime && - traceMinStartTime == other.traceMinStartTime && - traceTier == other.traceTier && - traceUpgrade == other.traceUpgrade && - ttlSeconds == other.ttlSeconds && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - appPath, - dottedOrder, - name, - runType, - sessionId, - status, - traceId, - childRunIds, - completionCost, - completionCostDetails, - completionTokenDetails, - completionTokens, - directChildRunIds, - endTime, - error, - events, - executionOrder, - extra, - feedbackStats, - firstTokenTime, - inDataset, - inputs, - inputsPreview, - inputsS3Urls, - lastQueuedAt, - manifestId, - manifestS3Id, - messages, - outputs, - outputsPreview, - outputsS3Urls, - parentRunId, - parentRunIds, - priceModelId, - promptCost, - promptCostDetails, - promptTokenDetails, - promptTokens, - referenceDatasetId, - referenceExampleId, - s3Urls, - serialized, - shareToken, - startTime, - tags, - threadId, - totalCost, - totalTokens, - traceFirstReceivedAt, - traceMaxStartTime, - traceMinStartTime, - traceTier, - traceUpgrade, - ttlSeconds, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Run{id=$id, appPath=$appPath, dottedOrder=$dottedOrder, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inDataset=$inDataset, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, lastQueuedAt=$lastQueuedAt, manifestId=$manifestId, manifestS3Id=$manifestS3Id, messages=$messages, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, shareToken=$shareToken, startTime=$startTime, tags=$tags, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceFirstReceivedAt=$traceFirstReceivedAt, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, traceTier=$traceTier, traceUpgrade=$traceUpgrade, ttlSeconds=$ttlSeconds, additionalProperties=$additionalProperties}" - } - class SearchCursors @JsonCreator private constructor( diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunRetrieveParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunRetrieveParams.kt new file mode 100644 index 000000000..b3f4030fe --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunRetrieveParams.kt @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.langchain.smith.core.Params +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific run. */ +class RunRetrieveParams +private constructor( + private val runId: String?, + private val excludeS3StoredAttributes: Boolean?, + private val excludeSerialized: Boolean?, + private val includeMessages: Boolean?, + private val sessionId: String?, + private val startTime: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun runId(): Optional = Optional.ofNullable(runId) + + fun excludeS3StoredAttributes(): Optional = + Optional.ofNullable(excludeS3StoredAttributes) + + fun excludeSerialized(): Optional = Optional.ofNullable(excludeSerialized) + + fun includeMessages(): Optional = Optional.ofNullable(includeMessages) + + fun sessionId(): Optional = Optional.ofNullable(sessionId) + + fun startTime(): Optional = Optional.ofNullable(startTime) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRetrieveParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var excludeS3StoredAttributes: Boolean? = null + private var excludeSerialized: Boolean? = null + private var includeMessages: Boolean? = null + private var sessionId: String? = null + private var startTime: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runRetrieveParams: RunRetrieveParams) = apply { + runId = runRetrieveParams.runId + excludeS3StoredAttributes = runRetrieveParams.excludeS3StoredAttributes + excludeSerialized = runRetrieveParams.excludeSerialized + includeMessages = runRetrieveParams.includeMessages + sessionId = runRetrieveParams.sessionId + startTime = runRetrieveParams.startTime + additionalHeaders = runRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = runRetrieveParams.additionalQueryParams.toBuilder() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional) = runId(runId.getOrNull()) + + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean?) = apply { + this.excludeS3StoredAttributes = excludeS3StoredAttributes + } + + /** + * Alias for [Builder.excludeS3StoredAttributes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean) = + excludeS3StoredAttributes(excludeS3StoredAttributes as Boolean?) + + /** + * Alias for calling [Builder.excludeS3StoredAttributes] with + * `excludeS3StoredAttributes.orElse(null)`. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Optional) = + excludeS3StoredAttributes(excludeS3StoredAttributes.getOrNull()) + + fun excludeSerialized(excludeSerialized: Boolean?) = apply { + this.excludeSerialized = excludeSerialized + } + + /** + * Alias for [Builder.excludeSerialized]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeSerialized(excludeSerialized: Boolean) = + excludeSerialized(excludeSerialized as Boolean?) + + /** Alias for calling [Builder.excludeSerialized] with `excludeSerialized.orElse(null)`. */ + fun excludeSerialized(excludeSerialized: Optional) = + excludeSerialized(excludeSerialized.getOrNull()) + + fun includeMessages(includeMessages: Boolean?) = apply { + this.includeMessages = includeMessages + } + + /** + * Alias for [Builder.includeMessages]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeMessages(includeMessages: Boolean) = includeMessages(includeMessages as Boolean?) + + /** Alias for calling [Builder.includeMessages] with `includeMessages.orElse(null)`. */ + fun includeMessages(includeMessages: Optional) = + includeMessages(includeMessages.getOrNull()) + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional) = sessionId(sessionId.getOrNull()) + + fun startTime(startTime: OffsetDateTime?) = apply { this.startTime = startTime } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = startTime(startTime.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunRetrieveParams = + RunRetrieveParams( + runId, + excludeS3StoredAttributes, + excludeSerialized, + includeMessages, + sessionId, + startTime, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + excludeS3StoredAttributes?.let { + put("exclude_s3_stored_attributes", it.toString()) + } + excludeSerialized?.let { put("exclude_serialized", it.toString()) } + includeMessages?.let { put("include_messages", it.toString()) } + sessionId?.let { put("session_id", it) } + startTime?.let { + put("start_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRetrieveParams && + runId == other.runId && + excludeS3StoredAttributes == other.excludeS3StoredAttributes && + excludeSerialized == other.excludeSerialized && + includeMessages == other.includeMessages && + sessionId == other.sessionId && + startTime == other.startTime && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + runId, + excludeS3StoredAttributes, + excludeSerialized, + includeMessages, + sessionId, + startTime, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunRetrieveParams{runId=$runId, excludeS3StoredAttributes=$excludeS3StoredAttributes, excludeSerialized=$excludeSerialized, includeMessages=$includeMessages, sessionId=$sessionId, startTime=$startTime, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunSchema.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunSchema.kt new file mode 100644 index 000000000..3b92cfa64 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunSchema.kt @@ -0,0 +1,4030 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.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.checkKnown +import com.langchain.smith.core.checkRequired +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 + +/** Run schema. */ +class RunSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val appPath: JsonField, + private val dottedOrder: JsonField, + private val name: JsonField, + private val runType: JsonField, + private val sessionId: JsonField, + private val status: JsonField, + private val traceId: JsonField, + private val childRunIds: JsonField>, + private val completionCost: JsonField, + private val completionCostDetails: JsonField, + private val completionTokenDetails: JsonField, + private val completionTokens: JsonField, + private val directChildRunIds: JsonField>, + private val endTime: JsonField, + private val error: JsonField, + private val events: JsonField>, + private val executionOrder: JsonField, + private val extra: JsonField, + private val feedbackStats: JsonField, + private val firstTokenTime: JsonField, + private val inDataset: JsonField, + private val inputs: JsonField, + private val inputsPreview: JsonField, + private val inputsS3Urls: JsonField, + private val lastQueuedAt: JsonField, + private val manifestId: JsonField, + private val manifestS3Id: JsonField, + private val messages: JsonField>, + private val outputs: JsonField, + private val outputsPreview: JsonField, + private val outputsS3Urls: JsonField, + private val parentRunId: JsonField, + private val parentRunIds: JsonField>, + private val priceModelId: JsonField, + private val promptCost: JsonField, + private val promptCostDetails: JsonField, + private val promptTokenDetails: JsonField, + private val promptTokens: JsonField, + private val referenceDatasetId: JsonField, + private val referenceExampleId: JsonField, + private val s3Urls: JsonField, + private val serialized: JsonField, + private val shareToken: JsonField, + private val startTime: JsonField, + private val tags: JsonField>, + private val threadId: JsonField, + private val totalCost: JsonField, + private val totalTokens: JsonField, + private val traceFirstReceivedAt: JsonField, + private val traceMaxStartTime: JsonField, + private val traceMinStartTime: JsonField, + private val traceTier: JsonField, + private val traceUpgrade: JsonField, + private val ttlSeconds: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("app_path") @ExcludeMissing appPath: JsonField = JsonMissing.of(), + @JsonProperty("dotted_order") + @ExcludeMissing + dottedOrder: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), + @JsonProperty("child_run_ids") + @ExcludeMissing + childRunIds: JsonField> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonField = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField = JsonMissing.of(), + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + directChildRunIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("events") @ExcludeMissing events: JsonField> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField = JsonMissing.of(), + @JsonProperty("first_token_time") + @ExcludeMissing + firstTokenTime: JsonField = JsonMissing.of(), + @JsonProperty("in_dataset") + @ExcludeMissing + inDataset: JsonField = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField = JsonMissing.of(), + @JsonProperty("inputs_preview") + @ExcludeMissing + inputsPreview: JsonField = JsonMissing.of(), + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + inputsS3Urls: JsonField = JsonMissing.of(), + @JsonProperty("last_queued_at") + @ExcludeMissing + lastQueuedAt: JsonField = JsonMissing.of(), + @JsonProperty("manifest_id") + @ExcludeMissing + manifestId: JsonField = JsonMissing.of(), + @JsonProperty("manifest_s3_id") + @ExcludeMissing + manifestS3Id: JsonField = JsonMissing.of(), + @JsonProperty("messages") + @ExcludeMissing + messages: JsonField> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField = JsonMissing.of(), + @JsonProperty("outputs_preview") + @ExcludeMissing + outputsPreview: JsonField = JsonMissing.of(), + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + outputsS3Urls: JsonField = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField = JsonMissing.of(), + @JsonProperty("parent_run_ids") + @ExcludeMissing + parentRunIds: JsonField> = JsonMissing.of(), + @JsonProperty("price_model_id") + @ExcludeMissing + priceModelId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("reference_example_id") + @ExcludeMissing + referenceExampleId: JsonField = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonField = JsonMissing.of(), + @JsonProperty("serialized") + @ExcludeMissing + serialized: JsonField = JsonMissing.of(), + @JsonProperty("share_token") + @ExcludeMissing + shareToken: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("thread_id") @ExcludeMissing threadId: JsonField = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField = JsonMissing.of(), + @JsonProperty("trace_first_received_at") + @ExcludeMissing + traceFirstReceivedAt: JsonField = JsonMissing.of(), + @JsonProperty("trace_max_start_time") + @ExcludeMissing + traceMaxStartTime: JsonField = JsonMissing.of(), + @JsonProperty("trace_min_start_time") + @ExcludeMissing + traceMinStartTime: JsonField = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField = JsonMissing.of(), + @JsonProperty("trace_upgrade") + @ExcludeMissing + traceUpgrade: JsonField = JsonMissing.of(), + @JsonProperty("ttl_seconds") @ExcludeMissing ttlSeconds: JsonField = JsonMissing.of(), + ) : this( + id, + appPath, + dottedOrder, + name, + runType, + sessionId, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + manifestId, + manifestS3Id, + messages, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + tags, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + 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 id(): String = id.getRequired("id") + + /** + * @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 appPath(): String = appPath.getRequired("app_path") + + /** + * @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 dottedOrder(): String = dottedOrder.getRequired("dotted_order") + + /** + * @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 name(): String = name.getRequired("name") + + /** + * Enum for run types. + * + * @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 runType(): RunTypeEnum = runType.getRequired("run_type") + + /** + * @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 sessionId(): String = sessionId.getRequired("session_id") + + /** + * @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 status(): String = status.getRequired("status") + + /** + * @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 traceId(): String = traceId.getRequired("trace_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun childRunIds(): Optional> = childRunIds.getOptional("child_run_ids") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun completionCost(): Optional = completionCost.getOptional("completion_cost") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun completionCostDetails(): Optional = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun completionTokenDetails(): Optional = + completionTokenDetails.getOptional("completion_token_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun directChildRunIds(): Optional> = + directChildRunIds.getOptional("direct_child_run_ids") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = events.getOptional("events") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun executionOrder(): Optional = executionOrder.getOptional("execution_order") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extra(): Optional = extra.getOptional("extra") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun firstTokenTime(): Optional = firstTokenTime.getOptional("first_token_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inDataset(): Optional = inDataset.getOptional("in_dataset") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputs(): Optional = inputs.getOptional("inputs") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inputsS3Urls(): Optional = inputsS3Urls.getOptional("inputs_s3_urls") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastQueuedAt(): Optional = lastQueuedAt.getOptional("last_queued_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun manifestId(): Optional = manifestId.getOptional("manifest_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun messages(): Optional> = messages.getOptional("messages") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputs(): Optional = outputs.getOptional("outputs") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun outputsS3Urls(): Optional = outputsS3Urls.getOptional("outputs_s3_urls") + + /** + * @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 parentRunIds(): Optional> = parentRunIds.getOptional("parent_run_ids") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceModelId(): Optional = priceModelId.getOptional("price_model_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun promptCost(): Optional = promptCost.getOptional("prompt_cost") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun promptCostDetails(): Optional = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun promptTokenDetails(): Optional = + promptTokenDetails.getOptional("prompt_token_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceDatasetId(): Optional = + referenceDatasetId.getOptional("reference_dataset_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceExampleId(): Optional = + referenceExampleId.getOptional("reference_example_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun s3Urls(): Optional = s3Urls.getOptional("s3_urls") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serialized(): Optional = serialized.getOptional("serialized") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun shareToken(): Optional = shareToken.getOptional("share_token") + + /** + * @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 tags(): Optional> = tags.getOptional("tags") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun threadId(): Optional = threadId.getOptional("thread_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalCost(): Optional = totalCost.getOptional("total_cost") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun traceFirstReceivedAt(): Optional = + traceFirstReceivedAt.getOptional("trace_first_received_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun traceMaxStartTime(): Optional = + traceMaxStartTime.getOptional("trace_max_start_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun traceMinStartTime(): Optional = + traceMinStartTime.getOptional("trace_min_start_time") + + /** + * @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") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun traceUpgrade(): Optional = traceUpgrade.getOptional("trace_upgrade") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ttlSeconds(): Optional = ttlSeconds.getOptional("ttl_seconds") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [appPath]. + * + * Unlike [appPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app_path") @ExcludeMissing fun _appPath(): JsonField = appPath + + /** + * Returns the raw JSON value of [dottedOrder]. + * + * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dotted_order") + @ExcludeMissing + fun _dottedOrder(): JsonField = dottedOrder + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType + + /** + * 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 [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * 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 [childRunIds]. + * + * Unlike [childRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("child_run_ids") + @ExcludeMissing + fun _childRunIds(): JsonField> = childRunIds + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField = completionCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField = completionCostDetails + + /** + * Returns the raw JSON value of [completionTokenDetails]. + * + * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonField = completionTokenDetails + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField = completionTokens + + /** + * Returns the raw JSON value of [directChildRunIds]. + * + * Unlike [directChildRunIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + fun _directChildRunIds(): JsonField> = directChildRunIds + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField = executionOrder + + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField = extra + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + + /** + * Returns the raw JSON value of [firstTokenTime]. + * + * Unlike [firstTokenTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_time") + @ExcludeMissing + fun _firstTokenTime(): JsonField = firstTokenTime + + /** + * Returns the raw JSON value of [inDataset]. + * + * Unlike [inDataset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField = inDataset + + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField = inputs + + /** + * Returns the raw JSON value of [inputsPreview]. + * + * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs_preview") + @ExcludeMissing + fun _inputsPreview(): JsonField = inputsPreview + + /** + * Returns the raw JSON value of [inputsS3Urls]. + * + * Unlike [inputsS3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + fun _inputsS3Urls(): JsonField = inputsS3Urls + + /** + * Returns the raw JSON value of [lastQueuedAt]. + * + * Unlike [lastQueuedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_queued_at") + @ExcludeMissing + fun _lastQueuedAt(): JsonField = lastQueuedAt + + /** + * Returns the raw JSON value of [manifestId]. + * + * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_id") @ExcludeMissing fun _manifestId(): JsonField = manifestId + + /** + * Returns the raw JSON value of [manifestS3Id]. + * + * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_s3_id") + @ExcludeMissing + fun _manifestS3Id(): JsonField = manifestS3Id + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messages") @ExcludeMissing fun _messages(): JsonField> = messages + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField = outputs + + /** + * Returns the raw JSON value of [outputsPreview]. + * + * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs_preview") + @ExcludeMissing + fun _outputsPreview(): JsonField = outputsPreview + + /** + * Returns the raw JSON value of [outputsS3Urls]. + * + * Unlike [outputsS3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + fun _outputsS3Urls(): JsonField = outputsS3Urls + + /** + * 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 [parentRunIds]. + * + * Unlike [parentRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_ids") + @ExcludeMissing + fun _parentRunIds(): JsonField> = parentRunIds + + /** + * Returns the raw JSON value of [priceModelId]. + * + * Unlike [priceModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_model_id") + @ExcludeMissing + fun _priceModelId(): JsonField = priceModelId + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField = promptCost + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField = promptCostDetails + + /** + * Returns the raw JSON value of [promptTokenDetails]. + * + * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonField = promptTokenDetails + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField = promptTokens + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField = referenceDatasetId + + /** + * Returns the raw JSON value of [referenceExampleId]. + * + * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example_id") + @ExcludeMissing + fun _referenceExampleId(): JsonField = referenceExampleId + + /** + * Returns the raw JSON value of [s3Urls]. + * + * Unlike [s3Urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonField = s3Urls + + /** + * Returns the raw JSON value of [serialized]. + * + * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("serialized") + @ExcludeMissing + fun _serialized(): JsonField = serialized + + /** + * Returns the raw JSON value of [shareToken]. + * + * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("share_token") @ExcludeMissing fun _shareToken(): JsonField = shareToken + + /** + * 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 [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField = totalTokens + + /** + * Returns the raw JSON value of [traceFirstReceivedAt]. + * + * Unlike [traceFirstReceivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_first_received_at") + @ExcludeMissing + fun _traceFirstReceivedAt(): JsonField = traceFirstReceivedAt + + /** + * Returns the raw JSON value of [traceMaxStartTime]. + * + * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_max_start_time") + @ExcludeMissing + fun _traceMaxStartTime(): JsonField = traceMaxStartTime + + /** + * Returns the raw JSON value of [traceMinStartTime]. + * + * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_min_start_time") + @ExcludeMissing + fun _traceMinStartTime(): JsonField = traceMinStartTime + + /** + * 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 + + /** + * Returns the raw JSON value of [traceUpgrade]. + * + * Unlike [traceUpgrade], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_upgrade") + @ExcludeMissing + fun _traceUpgrade(): JsonField = traceUpgrade + + /** + * Returns the raw JSON value of [ttlSeconds]. + * + * Unlike [ttlSeconds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttl_seconds") @ExcludeMissing fun _ttlSeconds(): JsonField = ttlSeconds + + @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 [RunSchema]. + * + * The following fields are required: + * ```java + * .id() + * .appPath() + * .dottedOrder() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunSchema]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var appPath: JsonField? = null + private var dottedOrder: JsonField? = null + private var name: JsonField? = null + private var runType: JsonField? = null + private var sessionId: JsonField? = null + private var status: JsonField? = null + private var traceId: JsonField? = null + private var childRunIds: JsonField>? = null + private var completionCost: JsonField = JsonMissing.of() + private var completionCostDetails: JsonField = JsonMissing.of() + private var completionTokenDetails: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var directChildRunIds: JsonField>? = null + private var endTime: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() + private var events: JsonField>? = null + private var executionOrder: JsonField = JsonMissing.of() + private var extra: JsonField = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() + private var firstTokenTime: JsonField = JsonMissing.of() + private var inDataset: JsonField = JsonMissing.of() + private var inputs: JsonField = JsonMissing.of() + private var inputsPreview: JsonField = JsonMissing.of() + private var inputsS3Urls: JsonField = JsonMissing.of() + private var lastQueuedAt: JsonField = JsonMissing.of() + private var manifestId: JsonField = JsonMissing.of() + private var manifestS3Id: JsonField = JsonMissing.of() + private var messages: JsonField>? = null + private var outputs: JsonField = JsonMissing.of() + private var outputsPreview: JsonField = JsonMissing.of() + private var outputsS3Urls: JsonField = JsonMissing.of() + private var parentRunId: JsonField = JsonMissing.of() + private var parentRunIds: JsonField>? = null + private var priceModelId: JsonField = JsonMissing.of() + private var promptCost: JsonField = JsonMissing.of() + private var promptCostDetails: JsonField = JsonMissing.of() + private var promptTokenDetails: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var referenceDatasetId: JsonField = JsonMissing.of() + private var referenceExampleId: JsonField = JsonMissing.of() + private var s3Urls: JsonField = JsonMissing.of() + private var serialized: JsonField = JsonMissing.of() + private var shareToken: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var threadId: JsonField = JsonMissing.of() + private var totalCost: JsonField = JsonMissing.of() + private var totalTokens: JsonField = JsonMissing.of() + private var traceFirstReceivedAt: JsonField = JsonMissing.of() + private var traceMaxStartTime: JsonField = JsonMissing.of() + private var traceMinStartTime: JsonField = JsonMissing.of() + private var traceTier: JsonField = JsonMissing.of() + private var traceUpgrade: JsonField = JsonMissing.of() + private var ttlSeconds: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runSchema: RunSchema) = apply { + id = runSchema.id + appPath = runSchema.appPath + dottedOrder = runSchema.dottedOrder + name = runSchema.name + runType = runSchema.runType + sessionId = runSchema.sessionId + status = runSchema.status + traceId = runSchema.traceId + childRunIds = runSchema.childRunIds.map { it.toMutableList() } + completionCost = runSchema.completionCost + completionCostDetails = runSchema.completionCostDetails + completionTokenDetails = runSchema.completionTokenDetails + completionTokens = runSchema.completionTokens + directChildRunIds = runSchema.directChildRunIds.map { it.toMutableList() } + endTime = runSchema.endTime + error = runSchema.error + events = runSchema.events.map { it.toMutableList() } + executionOrder = runSchema.executionOrder + extra = runSchema.extra + feedbackStats = runSchema.feedbackStats + firstTokenTime = runSchema.firstTokenTime + inDataset = runSchema.inDataset + inputs = runSchema.inputs + inputsPreview = runSchema.inputsPreview + inputsS3Urls = runSchema.inputsS3Urls + lastQueuedAt = runSchema.lastQueuedAt + manifestId = runSchema.manifestId + manifestS3Id = runSchema.manifestS3Id + messages = runSchema.messages.map { it.toMutableList() } + outputs = runSchema.outputs + outputsPreview = runSchema.outputsPreview + outputsS3Urls = runSchema.outputsS3Urls + parentRunId = runSchema.parentRunId + parentRunIds = runSchema.parentRunIds.map { it.toMutableList() } + priceModelId = runSchema.priceModelId + promptCost = runSchema.promptCost + promptCostDetails = runSchema.promptCostDetails + promptTokenDetails = runSchema.promptTokenDetails + promptTokens = runSchema.promptTokens + referenceDatasetId = runSchema.referenceDatasetId + referenceExampleId = runSchema.referenceExampleId + s3Urls = runSchema.s3Urls + serialized = runSchema.serialized + shareToken = runSchema.shareToken + startTime = runSchema.startTime + tags = runSchema.tags.map { it.toMutableList() } + threadId = runSchema.threadId + totalCost = runSchema.totalCost + totalTokens = runSchema.totalTokens + traceFirstReceivedAt = runSchema.traceFirstReceivedAt + traceMaxStartTime = runSchema.traceMaxStartTime + traceMinStartTime = runSchema.traceMinStartTime + traceTier = runSchema.traceTier + traceUpgrade = runSchema.traceUpgrade + ttlSeconds = runSchema.ttlSeconds + additionalProperties = runSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun appPath(appPath: String) = appPath(JsonField.of(appPath)) + + /** + * Sets [Builder.appPath] to an arbitrary JSON value. + * + * You should usually call [Builder.appPath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun appPath(appPath: JsonField) = apply { this.appPath = appPath } + + fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) + + /** + * Sets [Builder.dottedOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.dottedOrder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dottedOrder(dottedOrder: JsonField) = apply { this.dottedOrder = dottedOrder } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField) = apply { this.runType = runType } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * 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 status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * 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 childRunIds(childRunIds: List?) = childRunIds(JsonField.ofNullable(childRunIds)) + + /** Alias for calling [Builder.childRunIds] with `childRunIds.orElse(null)`. */ + fun childRunIds(childRunIds: Optional>) = childRunIds(childRunIds.getOrNull()) + + /** + * Sets [Builder.childRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.childRunIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun childRunIds(childRunIds: JsonField>) = apply { + this.childRunIds = childRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [childRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChildRunId(childRunId: String) = apply { + childRunIds = + (childRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("childRunIds", it).add(childRunId) + } + } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField) = apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = + completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) + + /** + * Alias for calling [Builder.completionTokenDetails] with + * `completionTokenDetails.orElse(null)`. + */ + fun completionTokenDetails(completionTokenDetails: Optional) = + completionTokenDetails(completionTokenDetails.getOrNull()) + + /** + * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokenDetails] with a well-typed + * [CompletionTokenDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionTokenDetails(completionTokenDetails: JsonField) = + apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + fun directChildRunIds(directChildRunIds: List?) = + directChildRunIds(JsonField.ofNullable(directChildRunIds)) + + /** Alias for calling [Builder.directChildRunIds] with `directChildRunIds.orElse(null)`. */ + fun directChildRunIds(directChildRunIds: Optional>) = + directChildRunIds(directChildRunIds.getOrNull()) + + /** + * Sets [Builder.directChildRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.directChildRunIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun directChildRunIds(directChildRunIds: JsonField>) = apply { + this.directChildRunIds = directChildRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [directChildRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDirectChildRunId(directChildRunId: String) = apply { + directChildRunIds = + (directChildRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("directChildRunIds", it).add(directChildRunId) + } + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun events(events: List?) = events(JsonField.ofNullable(events)) + + /** Alias for calling [Builder.events] with `events.orElse(null)`. */ + fun events(events: Optional>) = events(events.getOrNull()) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Event] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Event) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField) = apply { + this.executionOrder = executionOrder + } + + fun extra(extra: Extra?) = extra(JsonField.ofNullable(extra)) + + /** Alias for calling [Builder.extra] with `extra.orElse(null)`. */ + fun extra(extra: Optional) = extra(extra.getOrNull()) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { + this.feedbackStats = feedbackStats + } + + fun firstTokenTime(firstTokenTime: OffsetDateTime?) = + firstTokenTime(JsonField.ofNullable(firstTokenTime)) + + /** Alias for calling [Builder.firstTokenTime] with `firstTokenTime.orElse(null)`. */ + fun firstTokenTime(firstTokenTime: Optional) = + firstTokenTime(firstTokenTime.getOrNull()) + + /** + * Sets [Builder.firstTokenTime] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstTokenTime(firstTokenTime: JsonField) = apply { + this.firstTokenTime = firstTokenTime + } + + fun inDataset(inDataset: Boolean?) = inDataset(JsonField.ofNullable(inDataset)) + + /** + * Alias for [Builder.inDataset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inDataset(inDataset: Boolean) = inDataset(inDataset as Boolean?) + + /** Alias for calling [Builder.inDataset] with `inDataset.orElse(null)`. */ + fun inDataset(inDataset: Optional) = inDataset(inDataset.getOrNull()) + + /** + * Sets [Builder.inDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.inDataset] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inDataset(inDataset: JsonField) = apply { this.inDataset = inDataset } + + fun inputs(inputs: Inputs?) = inputs(JsonField.ofNullable(inputs)) + + /** Alias for calling [Builder.inputs] with `inputs.orElse(null)`. */ + fun inputs(inputs: Optional) = inputs(inputs.getOrNull()) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField) = apply { this.inputs = inputs } + + fun inputsPreview(inputsPreview: String?) = + inputsPreview(JsonField.ofNullable(inputsPreview)) + + /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ + fun inputsPreview(inputsPreview: Optional) = + inputsPreview(inputsPreview.getOrNull()) + + /** + * Sets [Builder.inputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsPreview] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inputsPreview(inputsPreview: JsonField) = apply { + this.inputsPreview = inputsPreview + } + + fun inputsS3Urls(inputsS3Urls: InputsS3Urls?) = + inputsS3Urls(JsonField.ofNullable(inputsS3Urls)) + + /** Alias for calling [Builder.inputsS3Urls] with `inputsS3Urls.orElse(null)`. */ + fun inputsS3Urls(inputsS3Urls: Optional) = + inputsS3Urls(inputsS3Urls.getOrNull()) + + /** + * Sets [Builder.inputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsS3Urls] with a well-typed [InputsS3Urls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputsS3Urls(inputsS3Urls: JsonField) = apply { + this.inputsS3Urls = inputsS3Urls + } + + fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = + lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) + + /** Alias for calling [Builder.lastQueuedAt] with `lastQueuedAt.orElse(null)`. */ + fun lastQueuedAt(lastQueuedAt: Optional) = + lastQueuedAt(lastQueuedAt.getOrNull()) + + /** + * Sets [Builder.lastQueuedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastQueuedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastQueuedAt(lastQueuedAt: JsonField) = apply { + this.lastQueuedAt = lastQueuedAt + } + + fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) + + /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ + fun manifestId(manifestId: Optional) = manifestId(manifestId.getOrNull()) + + /** + * Sets [Builder.manifestId] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestId(manifestId: JsonField) = apply { this.manifestId = manifestId } + + fun manifestS3Id(manifestS3Id: String?) = manifestS3Id(JsonField.ofNullable(manifestS3Id)) + + /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ + fun manifestS3Id(manifestS3Id: Optional) = manifestS3Id(manifestS3Id.getOrNull()) + + /** + * Sets [Builder.manifestS3Id] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestS3Id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestS3Id(manifestS3Id: JsonField) = apply { + this.manifestS3Id = manifestS3Id + } + + fun messages(messages: List?) = messages(JsonField.ofNullable(messages)) + + /** Alias for calling [Builder.messages] with `messages.orElse(null)`. */ + fun messages(messages: Optional>) = messages(messages.getOrNull()) + + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messages(messages: JsonField>) = apply { + this.messages = messages.map { it.toMutableList() } + } + + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).also { + checkKnown("messages", it).add(message) + } + } + + fun outputs(outputs: Outputs?) = outputs(JsonField.ofNullable(outputs)) + + /** Alias for calling [Builder.outputs] with `outputs.orElse(null)`. */ + fun outputs(outputs: Optional) = outputs(outputs.getOrNull()) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField) = apply { this.outputs = outputs } + + fun outputsPreview(outputsPreview: String?) = + outputsPreview(JsonField.ofNullable(outputsPreview)) + + /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ + fun outputsPreview(outputsPreview: Optional) = + outputsPreview(outputsPreview.getOrNull()) + + /** + * Sets [Builder.outputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsPreview] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsPreview(outputsPreview: JsonField) = apply { + this.outputsPreview = outputsPreview + } + + fun outputsS3Urls(outputsS3Urls: OutputsS3Urls?) = + outputsS3Urls(JsonField.ofNullable(outputsS3Urls)) + + /** Alias for calling [Builder.outputsS3Urls] with `outputsS3Urls.orElse(null)`. */ + fun outputsS3Urls(outputsS3Urls: Optional) = + outputsS3Urls(outputsS3Urls.getOrNull()) + + /** + * Sets [Builder.outputsS3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsS3Urls] with a well-typed [OutputsS3Urls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsS3Urls(outputsS3Urls: JsonField) = apply { + this.outputsS3Urls = outputsS3Urls + } + + 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 parentRunIds(parentRunIds: List?) = + parentRunIds(JsonField.ofNullable(parentRunIds)) + + /** Alias for calling [Builder.parentRunIds] with `parentRunIds.orElse(null)`. */ + fun parentRunIds(parentRunIds: Optional>) = + parentRunIds(parentRunIds.getOrNull()) + + /** + * Sets [Builder.parentRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentRunIds(parentRunIds: JsonField>) = apply { + this.parentRunIds = parentRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [parentRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParentRunId(parentRunId: String) = apply { + parentRunIds = + (parentRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("parentRunIds", it).add(parentRunId) + } + } + + fun priceModelId(priceModelId: String?) = priceModelId(JsonField.ofNullable(priceModelId)) + + /** Alias for calling [Builder.priceModelId] with `priceModelId.orElse(null)`. */ + fun priceModelId(priceModelId: Optional) = priceModelId(priceModelId.getOrNull()) + + /** + * Sets [Builder.priceModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun priceModelId(priceModelId: JsonField) = apply { + this.priceModelId = priceModelId + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. */ + fun promptCostDetails(promptCostDetails: Optional) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed [PromptCostDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = + promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) + + /** + * Alias for calling [Builder.promptTokenDetails] with `promptTokenDetails.orElse(null)`. + */ + fun promptTokenDetails(promptTokenDetails: Optional) = + promptTokenDetails(promptTokenDetails.getOrNull()) + + /** + * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokenDetails] with a well-typed + * [PromptTokenDetails] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun promptTokenDetails(promptTokenDetails: JsonField) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens } + + fun referenceDatasetId(referenceDatasetId: String?) = + referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) + + /** + * Alias for calling [Builder.referenceDatasetId] with `referenceDatasetId.orElse(null)`. + */ + fun referenceDatasetId(referenceDatasetId: Optional) = + referenceDatasetId(referenceDatasetId.getOrNull()) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun referenceExampleId(referenceExampleId: String?) = + referenceExampleId(JsonField.ofNullable(referenceExampleId)) + + /** + * Alias for calling [Builder.referenceExampleId] with `referenceExampleId.orElse(null)`. + */ + fun referenceExampleId(referenceExampleId: Optional) = + referenceExampleId(referenceExampleId.getOrNull()) + + /** + * Sets [Builder.referenceExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExampleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExampleId(referenceExampleId: JsonField) = apply { + this.referenceExampleId = referenceExampleId + } + + fun s3Urls(s3Urls: S3Urls?) = s3Urls(JsonField.ofNullable(s3Urls)) + + /** Alias for calling [Builder.s3Urls] with `s3Urls.orElse(null)`. */ + fun s3Urls(s3Urls: Optional) = s3Urls(s3Urls.getOrNull()) + + /** + * Sets [Builder.s3Urls] to an arbitrary JSON value. + * + * You should usually call [Builder.s3Urls] with a well-typed [S3Urls] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun s3Urls(s3Urls: JsonField) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: Serialized?) = serialized(JsonField.ofNullable(serialized)) + + /** Alias for calling [Builder.serialized] with `serialized.orElse(null)`. */ + fun serialized(serialized: Optional) = serialized(serialized.getOrNull()) + + /** + * Sets [Builder.serialized] to an arbitrary JSON value. + * + * You should usually call [Builder.serialized] with a well-typed [Serialized] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serialized(serialized: JsonField) = apply { this.serialized = serialized } + + fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional) = shareToken(shareToken.getOrNull()) + + /** + * Sets [Builder.shareToken] to an arbitrary JSON value. + * + * You should usually call [Builder.shareToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun shareToken(shareToken: JsonField) = apply { this.shareToken = shareToken } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * 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 tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun threadId(threadId: String?) = threadId(JsonField.ofNullable(threadId)) + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun threadId(threadId: JsonField) = apply { this.threadId = threadId } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField) = apply { this.totalTokens = totalTokens } + + fun traceFirstReceivedAt(traceFirstReceivedAt: OffsetDateTime?) = + traceFirstReceivedAt(JsonField.ofNullable(traceFirstReceivedAt)) + + /** + * Alias for calling [Builder.traceFirstReceivedAt] with + * `traceFirstReceivedAt.orElse(null)`. + */ + fun traceFirstReceivedAt(traceFirstReceivedAt: Optional) = + traceFirstReceivedAt(traceFirstReceivedAt.getOrNull()) + + /** + * Sets [Builder.traceFirstReceivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFirstReceivedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceFirstReceivedAt(traceFirstReceivedAt: JsonField) = apply { + this.traceFirstReceivedAt = traceFirstReceivedAt + } + + fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = + traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) + + /** Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. */ + fun traceMaxStartTime(traceMaxStartTime: Optional) = + traceMaxStartTime(traceMaxStartTime.getOrNull()) + + /** + * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMaxStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMaxStartTime(traceMaxStartTime: JsonField) = apply { + this.traceMaxStartTime = traceMaxStartTime + } + + fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = + traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) + + /** Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. */ + fun traceMinStartTime(traceMinStartTime: Optional) = + traceMinStartTime(traceMinStartTime.getOrNull()) + + /** + * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMinStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMinStartTime(traceMinStartTime: JsonField) = apply { + this.traceMinStartTime = traceMinStartTime + } + + 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 traceUpgrade(traceUpgrade: Boolean) = traceUpgrade(JsonField.of(traceUpgrade)) + + /** + * Sets [Builder.traceUpgrade] to an arbitrary JSON value. + * + * You should usually call [Builder.traceUpgrade] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceUpgrade(traceUpgrade: JsonField) = apply { + this.traceUpgrade = traceUpgrade + } + + fun ttlSeconds(ttlSeconds: Long?) = ttlSeconds(JsonField.ofNullable(ttlSeconds)) + + /** + * Alias for [Builder.ttlSeconds]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun ttlSeconds(ttlSeconds: Long) = ttlSeconds(ttlSeconds as Long?) + + /** Alias for calling [Builder.ttlSeconds] with `ttlSeconds.orElse(null)`. */ + fun ttlSeconds(ttlSeconds: Optional) = ttlSeconds(ttlSeconds.getOrNull()) + + /** + * Sets [Builder.ttlSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.ttlSeconds] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ttlSeconds(ttlSeconds: JsonField) = apply { this.ttlSeconds = ttlSeconds } + + 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 [RunSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .appPath() + * .dottedOrder() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunSchema = + RunSchema( + checkRequired("id", id), + checkRequired("appPath", appPath), + checkRequired("dottedOrder", dottedOrder), + checkRequired("name", name), + checkRequired("runType", runType), + checkRequired("sessionId", sessionId), + checkRequired("status", status), + checkRequired("traceId", traceId), + (childRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + (directChildRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + endTime, + error, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + manifestId, + manifestS3Id, + (messages ?: JsonMissing.of()).map { it.toImmutable() }, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + (parentRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunSchema = apply { + if (validated) { + return@apply + } + + id() + appPath() + dottedOrder() + name() + runType().validate() + sessionId() + status() + traceId() + childRunIds() + completionCost() + completionCostDetails().ifPresent { it.validate() } + completionTokenDetails().ifPresent { it.validate() } + completionTokens() + directChildRunIds() + endTime() + error() + events().ifPresent { it.forEach { it.validate() } } + executionOrder() + extra().ifPresent { it.validate() } + feedbackStats().ifPresent { it.validate() } + firstTokenTime() + inDataset() + inputs().ifPresent { it.validate() } + inputsPreview() + inputsS3Urls().ifPresent { it.validate() } + lastQueuedAt() + manifestId() + manifestS3Id() + messages().ifPresent { it.forEach { it.validate() } } + outputs().ifPresent { it.validate() } + outputsPreview() + outputsS3Urls().ifPresent { it.validate() } + parentRunId() + parentRunIds() + priceModelId() + promptCost() + promptCostDetails().ifPresent { it.validate() } + promptTokenDetails().ifPresent { it.validate() } + promptTokens() + referenceDatasetId() + referenceExampleId() + s3Urls().ifPresent { it.validate() } + serialized().ifPresent { it.validate() } + shareToken() + startTime() + tags() + threadId() + totalCost() + totalTokens() + traceFirstReceivedAt() + traceMaxStartTime() + traceMinStartTime() + traceTier().ifPresent { it.validate() } + traceUpgrade() + ttlSeconds() + 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 (id.asKnown().isPresent) 1 else 0) + + (if (appPath.asKnown().isPresent) 1 else 0) + + (if (dottedOrder.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (childRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + + (if (inDataset.asKnown().isPresent) 1 else 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (inputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + + (if (manifestId.asKnown().isPresent) 1 else 0) + + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (messages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (outputsS3Urls.asKnown().getOrNull()?.validity() ?: 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (priceModelId.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (s3Urls.asKnown().getOrNull()?.validity() ?: 0) + + (serialized.asKnown().getOrNull()?.validity() ?: 0) + + (if (shareToken.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (if (traceFirstReceivedAt.asKnown().isPresent) 1 else 0) + + (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + + (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + (if (traceUpgrade.asKnown().isPresent) 1 else 0) + + (if (ttlSeconds.asKnown().isPresent) 1 else 0) + + class CompletionCostDetails + @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 [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.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 [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = 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 CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class CompletionTokenDetails + @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 [CompletionTokenDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { + additionalProperties = completionTokenDetails.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 [CompletionTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionTokenDetails = + CompletionTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionTokenDetails = 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 CompletionTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionTokenDetails{additionalProperties=$additionalProperties}" + } + + class Event + @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 [Event]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Event]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(event: Event) = apply { + additionalProperties = event.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 [Event]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Event = Event(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Event = 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 Event && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Event{additionalProperties=$additionalProperties}" + } + + class Extra + @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 [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.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 [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = 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 Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @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 [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.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 [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = 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 FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class Inputs + @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 [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.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 [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = 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 Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class InputsS3Urls + @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 [InputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inputsS3Urls: InputsS3Urls) = apply { + additionalProperties = inputsS3Urls.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 [InputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputsS3Urls = InputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputsS3Urls = 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 InputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "InputsS3Urls{additionalProperties=$additionalProperties}" + } + + class Message + @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 [Message]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Message]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(message: Message) = apply { + additionalProperties = message.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 [Message]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Message = Message(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Message = 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 Message && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Message{additionalProperties=$additionalProperties}" + } + + class Outputs + @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 [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.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 [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = 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 Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + + class OutputsS3Urls + @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 [OutputsS3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputsS3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(outputsS3Urls: OutputsS3Urls) = apply { + additionalProperties = outputsS3Urls.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 [OutputsS3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputsS3Urls = OutputsS3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputsS3Urls = 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 OutputsS3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OutputsS3Urls{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @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 [PromptCostDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.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 [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = 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 PromptCostDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptTokenDetails + @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 [PromptTokenDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(promptTokenDetails: PromptTokenDetails) = apply { + additionalProperties = promptTokenDetails.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 [PromptTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptTokenDetails = PromptTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptTokenDetails = 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 PromptTokenDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptTokenDetails{additionalProperties=$additionalProperties}" + } + + class S3Urls + @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 [S3Urls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3Urls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3Urls: S3Urls) = apply { + additionalProperties = s3Urls.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 [S3Urls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): S3Urls = S3Urls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): S3Urls = 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 S3Urls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "S3Urls{additionalProperties=$additionalProperties}" + } + + class Serialized + @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 [Serialized]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Serialized]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serialized: Serialized) = apply { + additionalProperties = serialized.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 [Serialized]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Serialized = Serialized(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Serialized = 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 Serialized && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Serialized{additionalProperties=$additionalProperties}" + } + + 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 RunSchema && + id == other.id && + appPath == other.appPath && + dottedOrder == other.dottedOrder && + name == other.name && + runType == other.runType && + sessionId == other.sessionId && + status == other.status && + traceId == other.traceId && + childRunIds == other.childRunIds && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + directChildRunIds == other.directChildRunIds && + endTime == other.endTime && + error == other.error && + events == other.events && + executionOrder == other.executionOrder && + extra == other.extra && + feedbackStats == other.feedbackStats && + firstTokenTime == other.firstTokenTime && + inDataset == other.inDataset && + inputs == other.inputs && + inputsPreview == other.inputsPreview && + inputsS3Urls == other.inputsS3Urls && + lastQueuedAt == other.lastQueuedAt && + manifestId == other.manifestId && + manifestS3Id == other.manifestS3Id && + messages == other.messages && + outputs == other.outputs && + outputsPreview == other.outputsPreview && + outputsS3Urls == other.outputsS3Urls && + parentRunId == other.parentRunId && + parentRunIds == other.parentRunIds && + priceModelId == other.priceModelId && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + referenceDatasetId == other.referenceDatasetId && + referenceExampleId == other.referenceExampleId && + s3Urls == other.s3Urls && + serialized == other.serialized && + shareToken == other.shareToken && + startTime == other.startTime && + tags == other.tags && + threadId == other.threadId && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + traceFirstReceivedAt == other.traceFirstReceivedAt && + traceMaxStartTime == other.traceMaxStartTime && + traceMinStartTime == other.traceMinStartTime && + traceTier == other.traceTier && + traceUpgrade == other.traceUpgrade && + ttlSeconds == other.ttlSeconds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + appPath, + dottedOrder, + name, + runType, + sessionId, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + manifestId, + manifestS3Id, + messages, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + tags, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunSchema{id=$id, appPath=$appPath, dottedOrder=$dottedOrder, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inDataset=$inDataset, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, lastQueuedAt=$lastQueuedAt, manifestId=$manifestId, manifestS3Id=$manifestS3Id, messages=$messages, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, shareToken=$shareToken, startTime=$startTime, tags=$tags, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceFirstReceivedAt=$traceFirstReceivedAt, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, traceTier=$traceTier, traceUpgrade=$traceUpgrade, ttlSeconds=$ttlSeconds, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsParams.kt new file mode 100644 index 000000000..0e0a6a500 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsParams.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import java.util.Objects + +/** Get all runs by query in body payload. */ +class RunStatsParams +private constructor( + private val runStatsQueryParams: RunStatsQueryParams, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Query params for run stats. */ + fun runStatsQueryParams(): RunStatsQueryParams = runStatsQueryParams + + fun _additionalBodyProperties(): Map = + runStatsQueryParams._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunStatsParams]. + * + * The following fields are required: + * ```java + * .runStatsQueryParams() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStatsParams]. */ + class Builder internal constructor() { + + private var runStatsQueryParams: RunStatsQueryParams? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runStatsParams: RunStatsParams) = apply { + runStatsQueryParams = runStatsParams.runStatsQueryParams + additionalHeaders = runStatsParams.additionalHeaders.toBuilder() + additionalQueryParams = runStatsParams.additionalQueryParams.toBuilder() + } + + /** Query params for run stats. */ + fun runStatsQueryParams(runStatsQueryParams: RunStatsQueryParams) = apply { + this.runStatsQueryParams = runStatsQueryParams + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunStatsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runStatsQueryParams() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunStatsParams = + RunStatsParams( + checkRequired("runStatsQueryParams", runStatsQueryParams), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): RunStatsQueryParams = runStatsQueryParams + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStatsParams && + runStatsQueryParams == other.runStatsQueryParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(runStatsQueryParams, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunStatsParams{runStatsQueryParams=$runStatsQueryParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsQueryParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsQueryParams.kt new file mode 100644 index 000000000..d362636fe --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsQueryParams.kt @@ -0,0 +1,1428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.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.checkKnown +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import com.langchain.smith.models.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Query params for run stats. */ +class RunStatsQueryParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField>, + private val dataSourceType: JsonField, + private val endTime: JsonField, + private val error: JsonField, + private val executionOrder: JsonField, + private val filter: JsonField, + private val groupBy: JsonField, + private val groups: JsonField>, + private val isRoot: JsonField, + private val parentRun: JsonField, + private val query: JsonField, + private val referenceExample: JsonField>, + private val runType: JsonField, + private val searchFilter: JsonField, + private val select: JsonField>, + private val session: JsonField>, + private val skipPagination: JsonField, + private val startTime: JsonField, + private val trace: JsonField, + private val traceFilter: JsonField, + private val treeFilter: JsonField, + private val useExperimentalSearch: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField> = JsonMissing.of(), + @JsonProperty("data_source_type") + @ExcludeMissing + dataSourceType: JsonField = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + @JsonProperty("group_by") + @ExcludeMissing + groupBy: JsonField = JsonMissing.of(), + @JsonProperty("groups") @ExcludeMissing groups: JsonField> = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing isRoot: JsonField = JsonMissing.of(), + @JsonProperty("parent_run") @ExcludeMissing parentRun: JsonField = JsonMissing.of(), + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("reference_example") + @ExcludeMissing + referenceExample: JsonField> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField = JsonMissing.of(), + @JsonProperty("search_filter") + @ExcludeMissing + searchFilter: JsonField = JsonMissing.of(), + @JsonProperty("select") @ExcludeMissing select: JsonField> = JsonMissing.of(), + @JsonProperty("session") + @ExcludeMissing + session: JsonField> = JsonMissing.of(), + @JsonProperty("skip_pagination") + @ExcludeMissing + skipPagination: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("trace") @ExcludeMissing trace: JsonField = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField = JsonMissing.of(), + @JsonProperty("use_experimental_search") + @ExcludeMissing + useExperimentalSearch: JsonField = JsonMissing.of(), + ) : this( + id, + dataSourceType, + endTime, + error, + executionOrder, + filter, + groupBy, + groups, + isRoot, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional> = id.getOptional("id") + + /** + * Enum for run data source types. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dataSourceType(): Optional = + dataSourceType.getOptional("data_source_type") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun executionOrder(): Optional = executionOrder.getOptional("execution_order") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * Group by param for run stats. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupBy(): Optional = groupBy.getOptional("group_by") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groups(): Optional> = groups.getOptional("groups") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isRoot(): Optional = isRoot.getOptional("is_root") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parentRun(): Optional = parentRun.getOptional("parent_run") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun query(): Optional = query.getOptional("query") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceExample(): Optional> = + referenceExample.getOptional("reference_example") + + /** + * Enum for run types. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun runType(): Optional = runType.getOptional("run_type") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun searchFilter(): Optional = searchFilter.getOptional("search_filter") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun select(): Optional> = select.getOptional("select") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun session(): Optional> = session.getOptional("session") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun skipPagination(): Optional = skipPagination.getOptional("skip_pagination") + + /** + * @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 trace(): Optional = trace.getOptional("trace") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun traceFilter(): Optional = traceFilter.getOptional("trace_filter") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun treeFilter(): Optional = treeFilter.getOptional("tree_filter") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useExperimentalSearch(): Optional = + useExperimentalSearch.getOptional("use_experimental_search") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField> = id + + /** + * Returns the raw JSON value of [dataSourceType]. + * + * Unlike [dataSourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_source_type") + @ExcludeMissing + fun _dataSourceType(): JsonField = dataSourceType + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField = executionOrder + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField = groupBy + + /** + * Returns the raw JSON value of [groups]. + * + * Unlike [groups], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("groups") @ExcludeMissing fun _groups(): JsonField> = groups + + /** + * Returns the raw JSON value of [isRoot]. + * + * Unlike [isRoot], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + + /** + * Returns the raw JSON value of [parentRun]. + * + * Unlike [parentRun], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run") @ExcludeMissing fun _parentRun(): JsonField = parentRun + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [referenceExample]. + * + * Unlike [referenceExample], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example") + @ExcludeMissing + fun _referenceExample(): JsonField> = referenceExample + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType + + /** + * Returns the raw JSON value of [searchFilter]. + * + * Unlike [searchFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("search_filter") + @ExcludeMissing + fun _searchFilter(): JsonField = searchFilter + + /** + * Returns the raw JSON value of [select]. + * + * Unlike [select], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("select") @ExcludeMissing fun _select(): JsonField> = select + + /** + * Returns the raw JSON value of [session]. + * + * Unlike [session], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session") @ExcludeMissing fun _session(): JsonField> = session + + /** + * Returns the raw JSON value of [skipPagination]. + * + * Unlike [skipPagination], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("skip_pagination") + @ExcludeMissing + fun _skipPagination(): JsonField = skipPagination + + /** + * 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 [trace]. + * + * Unlike [trace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace") @ExcludeMissing fun _trace(): JsonField = trace + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField = traceFilter + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") @ExcludeMissing fun _treeFilter(): JsonField = treeFilter + + /** + * Returns the raw JSON value of [useExperimentalSearch]. + * + * Unlike [useExperimentalSearch], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_experimental_search") + @ExcludeMissing + fun _useExperimentalSearch(): JsonField = useExperimentalSearch + + @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 [RunStatsQueryParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStatsQueryParams]. */ + class Builder internal constructor() { + + private var id: JsonField>? = null + private var dataSourceType: JsonField = JsonMissing.of() + private var endTime: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() + private var executionOrder: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var groupBy: JsonField = JsonMissing.of() + private var groups: JsonField>? = null + private var isRoot: JsonField = JsonMissing.of() + private var parentRun: JsonField = JsonMissing.of() + private var query: JsonField = JsonMissing.of() + private var referenceExample: JsonField>? = null + private var runType: JsonField = JsonMissing.of() + private var searchFilter: JsonField = JsonMissing.of() + private var select: JsonField>? = null + private var session: JsonField>? = null + private var skipPagination: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var trace: JsonField = JsonMissing.of() + private var traceFilter: JsonField = JsonMissing.of() + private var treeFilter: JsonField = JsonMissing.of() + private var useExperimentalSearch: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runStatsQueryParams: RunStatsQueryParams) = apply { + id = runStatsQueryParams.id.map { it.toMutableList() } + dataSourceType = runStatsQueryParams.dataSourceType + endTime = runStatsQueryParams.endTime + error = runStatsQueryParams.error + executionOrder = runStatsQueryParams.executionOrder + filter = runStatsQueryParams.filter + groupBy = runStatsQueryParams.groupBy + groups = runStatsQueryParams.groups.map { it.toMutableList() } + isRoot = runStatsQueryParams.isRoot + parentRun = runStatsQueryParams.parentRun + query = runStatsQueryParams.query + referenceExample = runStatsQueryParams.referenceExample.map { it.toMutableList() } + runType = runStatsQueryParams.runType + searchFilter = runStatsQueryParams.searchFilter + select = runStatsQueryParams.select.map { it.toMutableList() } + session = runStatsQueryParams.session.map { it.toMutableList() } + skipPagination = runStatsQueryParams.skipPagination + startTime = runStatsQueryParams.startTime + trace = runStatsQueryParams.trace + traceFilter = runStatsQueryParams.traceFilter + treeFilter = runStatsQueryParams.treeFilter + useExperimentalSearch = runStatsQueryParams.useExperimentalSearch + additionalProperties = runStatsQueryParams.additionalProperties.toMutableMap() + } + + fun id(id: List?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField>) = apply { this.id = id.map { it.toMutableList() } } + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { + this.id = + (this.id ?: JsonField.of(mutableListOf())).also { checkKnown("id", it).add(id) } + } + + /** Enum for run data source types. */ + fun dataSourceType(dataSourceType: RunsFilterDataSourceTypeEnum?) = + dataSourceType(JsonField.ofNullable(dataSourceType)) + + /** Alias for calling [Builder.dataSourceType] with `dataSourceType.orElse(null)`. */ + fun dataSourceType(dataSourceType: Optional) = + dataSourceType(dataSourceType.getOrNull()) + + /** + * Sets [Builder.dataSourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataSourceType] with a well-typed + * [RunsFilterDataSourceTypeEnum] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dataSourceType(dataSourceType: JsonField) = apply { + this.dataSourceType = dataSourceType + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun error(error: Boolean?) = error(JsonField.ofNullable(error)) + + /** + * Alias for [Builder.error]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun error(error: Boolean) = error(error as Boolean?) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun executionOrder(executionOrder: Long?) = + executionOrder(JsonField.ofNullable(executionOrder)) + + /** + * Alias for [Builder.executionOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionOrder(executionOrder: Long) = executionOrder(executionOrder as Long?) + + /** Alias for calling [Builder.executionOrder] with `executionOrder.orElse(null)`. */ + fun executionOrder(executionOrder: Optional) = + executionOrder(executionOrder.getOrNull()) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField) = apply { + this.executionOrder = executionOrder + } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** Group by param for run stats. */ + fun groupBy(groupBy: RunStatsGroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [RunStatsGroupBy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupBy(groupBy: JsonField) = apply { this.groupBy = groupBy } + + fun groups(groups: List?) = groups(JsonField.ofNullable(groups)) + + /** Alias for calling [Builder.groups] with `groups.orElse(null)`. */ + fun groups(groups: Optional>) = groups(groups.getOrNull()) + + /** + * Sets [Builder.groups] to an arbitrary JSON value. + * + * You should usually call [Builder.groups] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groups(groups: JsonField>) = apply { + this.groups = groups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroup(group: String) = apply { + groups = + (groups ?: JsonField.of(mutableListOf())).also { + checkKnown("groups", it).add(group) + } + } + + fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) + + /** + * Alias for [Builder.isRoot]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) + + /** Alias for calling [Builder.isRoot] with `isRoot.orElse(null)`. */ + fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) + + /** + * Sets [Builder.isRoot] to an arbitrary JSON value. + * + * You should usually call [Builder.isRoot] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + + fun parentRun(parentRun: String?) = parentRun(JsonField.ofNullable(parentRun)) + + /** Alias for calling [Builder.parentRun] with `parentRun.orElse(null)`. */ + fun parentRun(parentRun: Optional) = parentRun(parentRun.getOrNull()) + + /** + * Sets [Builder.parentRun] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRun] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRun(parentRun: JsonField) = apply { this.parentRun = parentRun } + + fun query(query: String?) = query(JsonField.ofNullable(query)) + + /** Alias for calling [Builder.query] with `query.orElse(null)`. */ + fun query(query: Optional) = query(query.getOrNull()) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + fun referenceExample(referenceExample: List?) = + referenceExample(JsonField.ofNullable(referenceExample)) + + /** Alias for calling [Builder.referenceExample] with `referenceExample.orElse(null)`. */ + fun referenceExample(referenceExample: Optional>) = + referenceExample(referenceExample.getOrNull()) + + /** + * Sets [Builder.referenceExample] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExample] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExample(referenceExample: JsonField>) = apply { + this.referenceExample = referenceExample.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.referenceExample]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addReferenceExample(referenceExample: String) = apply { + this.referenceExample = + (this.referenceExample ?: JsonField.of(mutableListOf())).also { + checkKnown("referenceExample", it).add(referenceExample) + } + } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum?) = runType(JsonField.ofNullable(runType)) + + /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ + fun runType(runType: Optional) = runType(runType.getOrNull()) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField) = apply { this.runType = runType } + + fun searchFilter(searchFilter: String?) = searchFilter(JsonField.ofNullable(searchFilter)) + + /** Alias for calling [Builder.searchFilter] with `searchFilter.orElse(null)`. */ + fun searchFilter(searchFilter: Optional) = searchFilter(searchFilter.getOrNull()) + + /** + * Sets [Builder.searchFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.searchFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun searchFilter(searchFilter: JsonField) = apply { + this.searchFilter = searchFilter + } + + fun select(select: List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun select(select: JsonField>) = apply { + this.select = select.map { it.toMutableList() } + } + + /** + * Adds a single [Select] to [Builder.select]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelect(select: Select) = apply { + this.select = + (this.select ?: JsonField.of(mutableListOf())).also { + checkKnown("select", it).add(select) + } + } + + fun session(session: List?) = session(JsonField.ofNullable(session)) + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional>) = session(session.getOrNull()) + + /** + * Sets [Builder.session] to an arbitrary JSON value. + * + * You should usually call [Builder.session] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun session(session: JsonField>) = apply { + this.session = session.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = + (this.session ?: JsonField.of(mutableListOf())).also { + checkKnown("session", it).add(session) + } + } + + fun skipPagination(skipPagination: Boolean?) = + skipPagination(JsonField.ofNullable(skipPagination)) + + /** + * Alias for [Builder.skipPagination]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun skipPagination(skipPagination: Boolean) = skipPagination(skipPagination as Boolean?) + + /** Alias for calling [Builder.skipPagination] with `skipPagination.orElse(null)`. */ + fun skipPagination(skipPagination: Optional) = + skipPagination(skipPagination.getOrNull()) + + /** + * Sets [Builder.skipPagination] to an arbitrary JSON value. + * + * You should usually call [Builder.skipPagination] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipPagination(skipPagination: JsonField) = apply { + this.skipPagination = skipPagination + } + + 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 trace(trace: String?) = trace(JsonField.ofNullable(trace)) + + /** Alias for calling [Builder.trace] with `trace.orElse(null)`. */ + fun trace(trace: Optional) = trace(trace.getOrNull()) + + /** + * Sets [Builder.trace] to an arbitrary JSON value. + * + * You should usually call [Builder.trace] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun trace(trace: JsonField) = apply { this.trace = trace } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField) = apply { this.traceFilter = traceFilter } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField) = apply { this.treeFilter = treeFilter } + + fun useExperimentalSearch(useExperimentalSearch: Boolean) = + useExperimentalSearch(JsonField.of(useExperimentalSearch)) + + /** + * Sets [Builder.useExperimentalSearch] to an arbitrary JSON value. + * + * You should usually call [Builder.useExperimentalSearch] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useExperimentalSearch(useExperimentalSearch: JsonField) = apply { + this.useExperimentalSearch = useExperimentalSearch + } + + 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 [RunStatsQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunStatsQueryParams = + RunStatsQueryParams( + (id ?: JsonMissing.of()).map { it.toImmutable() }, + dataSourceType, + endTime, + error, + executionOrder, + filter, + groupBy, + (groups ?: JsonMissing.of()).map { it.toImmutable() }, + isRoot, + parentRun, + query, + (referenceExample ?: JsonMissing.of()).map { it.toImmutable() }, + runType, + searchFilter, + (select ?: JsonMissing.of()).map { it.toImmutable() }, + (session ?: JsonMissing.of()).map { it.toImmutable() }, + skipPagination, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunStatsQueryParams = apply { + if (validated) { + return@apply + } + + id() + dataSourceType().ifPresent { it.validate() } + endTime() + error() + executionOrder() + filter() + groupBy().ifPresent { it.validate() } + groups() + isRoot() + parentRun() + query() + referenceExample() + runType().ifPresent { it.validate() } + searchFilter() + select().ifPresent { it.forEach { it.validate() } } + session() + skipPagination() + startTime() + trace() + traceFilter() + treeFilter() + useExperimentalSearch() + 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 = + (id.asKnown().getOrNull()?.size ?: 0) + + (dataSourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (groups.asKnown().getOrNull()?.sumOf { (if (it == null) 0 else 1).toInt() } ?: 0) + + (if (isRoot.asKnown().isPresent) 1 else 0) + + (if (parentRun.asKnown().isPresent) 1 else 0) + + (if (query.asKnown().isPresent) 1 else 0) + + (referenceExample.asKnown().getOrNull()?.size ?: 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (searchFilter.asKnown().isPresent) 1 else 0) + + (select.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (session.asKnown().getOrNull()?.size ?: 0) + + (if (skipPagination.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (trace.asKnown().isPresent) 1 else 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + (if (useExperimentalSearch.asKnown().isPresent) 1 else 0) + + /** Metrics you can select from run stats endpoint. */ + class Select @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 RUN_COUNT = of("run_count") + + @JvmField val LATENCY_P50 = of("latency_p50") + + @JvmField val LATENCY_P99 = of("latency_p99") + + @JvmField val LATENCY_AVG = of("latency_avg") + + @JvmField val FIRST_TOKEN_P50 = of("first_token_p50") + + @JvmField val FIRST_TOKEN_P99 = of("first_token_p99") + + @JvmField val TOTAL_TOKENS = of("total_tokens") + + @JvmField val PROMPT_TOKENS = of("prompt_tokens") + + @JvmField val COMPLETION_TOKENS = of("completion_tokens") + + @JvmField val MEDIAN_TOKENS = of("median_tokens") + + @JvmField val COMPLETION_TOKENS_P50 = of("completion_tokens_p50") + + @JvmField val PROMPT_TOKENS_P50 = of("prompt_tokens_p50") + + @JvmField val TOKENS_P99 = of("tokens_p99") + + @JvmField val COMPLETION_TOKENS_P99 = of("completion_tokens_p99") + + @JvmField val PROMPT_TOKENS_P99 = of("prompt_tokens_p99") + + @JvmField val LAST_RUN_START_TIME = of("last_run_start_time") + + @JvmField val FEEDBACK_STATS = of("feedback_stats") + + @JvmField val THREAD_FEEDBACK_STATS = of("thread_feedback_stats") + + @JvmField val RUN_FACETS = of("run_facets") + + @JvmField val ERROR_RATE = of("error_rate") + + @JvmField val STREAMING_RATE = of("streaming_rate") + + @JvmField val TOTAL_COST = of("total_cost") + + @JvmField val PROMPT_COST = of("prompt_cost") + + @JvmField val COMPLETION_COST = of("completion_cost") + + @JvmField val COST_P50 = of("cost_p50") + + @JvmField val COST_P99 = of("cost_p99") + + @JvmField val SESSION_FEEDBACK_STATS = of("session_feedback_stats") + + @JvmField val ALL_RUN_STATS = of("all_run_stats") + + @JvmField val ALL_TOKEN_STATS = of("all_token_stats") + + @JvmField val PROMPT_TOKEN_DETAILS = of("prompt_token_details") + + @JvmField val COMPLETION_TOKEN_DETAILS = of("completion_token_details") + + @JvmField val PROMPT_COST_DETAILS = of("prompt_cost_details") + + @JvmField val COMPLETION_COST_DETAILS = of("completion_cost_details") + + @JvmStatic fun of(value: String) = Select(JsonField.of(value)) + } + + /** An enum containing [Select]'s known values. */ + enum class Known { + RUN_COUNT, + LATENCY_P50, + LATENCY_P99, + LATENCY_AVG, + FIRST_TOKEN_P50, + FIRST_TOKEN_P99, + TOTAL_TOKENS, + PROMPT_TOKENS, + COMPLETION_TOKENS, + MEDIAN_TOKENS, + COMPLETION_TOKENS_P50, + PROMPT_TOKENS_P50, + TOKENS_P99, + COMPLETION_TOKENS_P99, + PROMPT_TOKENS_P99, + LAST_RUN_START_TIME, + FEEDBACK_STATS, + THREAD_FEEDBACK_STATS, + RUN_FACETS, + ERROR_RATE, + STREAMING_RATE, + TOTAL_COST, + PROMPT_COST, + COMPLETION_COST, + COST_P50, + COST_P99, + SESSION_FEEDBACK_STATS, + ALL_RUN_STATS, + ALL_TOKEN_STATS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKEN_DETAILS, + PROMPT_COST_DETAILS, + COMPLETION_COST_DETAILS, + } + + /** + * An enum containing [Select]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Select] 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 { + RUN_COUNT, + LATENCY_P50, + LATENCY_P99, + LATENCY_AVG, + FIRST_TOKEN_P50, + FIRST_TOKEN_P99, + TOTAL_TOKENS, + PROMPT_TOKENS, + COMPLETION_TOKENS, + MEDIAN_TOKENS, + COMPLETION_TOKENS_P50, + PROMPT_TOKENS_P50, + TOKENS_P99, + COMPLETION_TOKENS_P99, + PROMPT_TOKENS_P99, + LAST_RUN_START_TIME, + FEEDBACK_STATS, + THREAD_FEEDBACK_STATS, + RUN_FACETS, + ERROR_RATE, + STREAMING_RATE, + TOTAL_COST, + PROMPT_COST, + COMPLETION_COST, + COST_P50, + COST_P99, + SESSION_FEEDBACK_STATS, + ALL_RUN_STATS, + ALL_TOKEN_STATS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKEN_DETAILS, + PROMPT_COST_DETAILS, + COMPLETION_COST_DETAILS, + /** An enum member indicating that [Select] 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) { + RUN_COUNT -> Value.RUN_COUNT + LATENCY_P50 -> Value.LATENCY_P50 + LATENCY_P99 -> Value.LATENCY_P99 + LATENCY_AVG -> Value.LATENCY_AVG + FIRST_TOKEN_P50 -> Value.FIRST_TOKEN_P50 + FIRST_TOKEN_P99 -> Value.FIRST_TOKEN_P99 + TOTAL_TOKENS -> Value.TOTAL_TOKENS + PROMPT_TOKENS -> Value.PROMPT_TOKENS + COMPLETION_TOKENS -> Value.COMPLETION_TOKENS + MEDIAN_TOKENS -> Value.MEDIAN_TOKENS + COMPLETION_TOKENS_P50 -> Value.COMPLETION_TOKENS_P50 + PROMPT_TOKENS_P50 -> Value.PROMPT_TOKENS_P50 + TOKENS_P99 -> Value.TOKENS_P99 + COMPLETION_TOKENS_P99 -> Value.COMPLETION_TOKENS_P99 + PROMPT_TOKENS_P99 -> Value.PROMPT_TOKENS_P99 + LAST_RUN_START_TIME -> Value.LAST_RUN_START_TIME + FEEDBACK_STATS -> Value.FEEDBACK_STATS + THREAD_FEEDBACK_STATS -> Value.THREAD_FEEDBACK_STATS + RUN_FACETS -> Value.RUN_FACETS + ERROR_RATE -> Value.ERROR_RATE + STREAMING_RATE -> Value.STREAMING_RATE + TOTAL_COST -> Value.TOTAL_COST + PROMPT_COST -> Value.PROMPT_COST + COMPLETION_COST -> Value.COMPLETION_COST + COST_P50 -> Value.COST_P50 + COST_P99 -> Value.COST_P99 + SESSION_FEEDBACK_STATS -> Value.SESSION_FEEDBACK_STATS + ALL_RUN_STATS -> Value.ALL_RUN_STATS + ALL_TOKEN_STATS -> Value.ALL_TOKEN_STATS + PROMPT_TOKEN_DETAILS -> Value.PROMPT_TOKEN_DETAILS + COMPLETION_TOKEN_DETAILS -> Value.COMPLETION_TOKEN_DETAILS + PROMPT_COST_DETAILS -> Value.PROMPT_COST_DETAILS + COMPLETION_COST_DETAILS -> Value.COMPLETION_COST_DETAILS + 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) { + RUN_COUNT -> Known.RUN_COUNT + LATENCY_P50 -> Known.LATENCY_P50 + LATENCY_P99 -> Known.LATENCY_P99 + LATENCY_AVG -> Known.LATENCY_AVG + FIRST_TOKEN_P50 -> Known.FIRST_TOKEN_P50 + FIRST_TOKEN_P99 -> Known.FIRST_TOKEN_P99 + TOTAL_TOKENS -> Known.TOTAL_TOKENS + PROMPT_TOKENS -> Known.PROMPT_TOKENS + COMPLETION_TOKENS -> Known.COMPLETION_TOKENS + MEDIAN_TOKENS -> Known.MEDIAN_TOKENS + COMPLETION_TOKENS_P50 -> Known.COMPLETION_TOKENS_P50 + PROMPT_TOKENS_P50 -> Known.PROMPT_TOKENS_P50 + TOKENS_P99 -> Known.TOKENS_P99 + COMPLETION_TOKENS_P99 -> Known.COMPLETION_TOKENS_P99 + PROMPT_TOKENS_P99 -> Known.PROMPT_TOKENS_P99 + LAST_RUN_START_TIME -> Known.LAST_RUN_START_TIME + FEEDBACK_STATS -> Known.FEEDBACK_STATS + THREAD_FEEDBACK_STATS -> Known.THREAD_FEEDBACK_STATS + RUN_FACETS -> Known.RUN_FACETS + ERROR_RATE -> Known.ERROR_RATE + STREAMING_RATE -> Known.STREAMING_RATE + TOTAL_COST -> Known.TOTAL_COST + PROMPT_COST -> Known.PROMPT_COST + COMPLETION_COST -> Known.COMPLETION_COST + COST_P50 -> Known.COST_P50 + COST_P99 -> Known.COST_P99 + SESSION_FEEDBACK_STATS -> Known.SESSION_FEEDBACK_STATS + ALL_RUN_STATS -> Known.ALL_RUN_STATS + ALL_TOKEN_STATS -> Known.ALL_TOKEN_STATS + PROMPT_TOKEN_DETAILS -> Known.PROMPT_TOKEN_DETAILS + COMPLETION_TOKEN_DETAILS -> Known.COMPLETION_TOKEN_DETAILS + PROMPT_COST_DETAILS -> Known.PROMPT_COST_DETAILS + COMPLETION_COST_DETAILS -> Known.COMPLETION_COST_DETAILS + else -> throw LangChainInvalidDataException("Unknown Select: $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(): Select = 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 Select && 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 RunStatsQueryParams && + id == other.id && + dataSourceType == other.dataSourceType && + endTime == other.endTime && + error == other.error && + executionOrder == other.executionOrder && + filter == other.filter && + groupBy == other.groupBy && + groups == other.groups && + isRoot == other.isRoot && + parentRun == other.parentRun && + query == other.query && + referenceExample == other.referenceExample && + runType == other.runType && + searchFilter == other.searchFilter && + select == other.select && + session == other.session && + skipPagination == other.skipPagination && + startTime == other.startTime && + trace == other.trace && + traceFilter == other.traceFilter && + treeFilter == other.treeFilter && + useExperimentalSearch == other.useExperimentalSearch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + dataSourceType, + endTime, + error, + executionOrder, + filter, + groupBy, + groups, + isRoot, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunStatsQueryParams{id=$id, dataSourceType=$dataSourceType, endTime=$endTime, error=$error, executionOrder=$executionOrder, filter=$filter, groupBy=$groupBy, groups=$groups, isRoot=$isRoot, parentRun=$parentRun, query=$query, referenceExample=$referenceExample, runType=$runType, searchFilter=$searchFilter, select=$select, session=$session, skipPagination=$skipPagination, startTime=$startTime, trace=$trace, traceFilter=$traceFilter, treeFilter=$treeFilter, useExperimentalSearch=$useExperimentalSearch, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsResponse.kt new file mode 100644 index 000000000..f91bbd24e --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunStatsResponse.kt @@ -0,0 +1,2429 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.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.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.allMaxBy +import com.langchain.smith.core.checkKnown +import com.langchain.smith.core.getOrThrow +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 + +@JsonDeserialize(using = RunStatsResponse.Deserializer::class) +@JsonSerialize(using = RunStatsResponse.Serializer::class) +class RunStatsResponse +private constructor( + private val runStats: RunStats? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, +) { + + fun runStats(): Optional = Optional.ofNullable(runStats) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isRunStats(): Boolean = runStats != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asRunStats(): RunStats = runStats.getOrThrow("runStats") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + runStats != null -> visitor.visitRunStats(runStats) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): RunStatsResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRunStats(runStats: RunStats) { + runStats.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.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 visitRunStats(runStats: RunStats) = runStats.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStatsResponse && + runStats == other.runStats && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(runStats, unionMember1) + + override fun toString(): String = + when { + runStats != null -> "RunStatsResponse{runStats=$runStats}" + unionMember1 != null -> "RunStatsResponse{unionMember1=$unionMember1}" + _json != null -> "RunStatsResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RunStatsResponse") + } + + companion object { + + @JvmStatic fun ofRunStats(runStats: RunStats) = RunStatsResponse(runStats = runStats) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + RunStatsResponse(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [RunStatsResponse] to a value of type + * [T]. + */ + interface Visitor { + + fun visitRunStats(runStats: RunStats): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [RunStatsResponse] to a value of type [T]. + * + * An instance of [RunStatsResponse] 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 RunStatsResponse: $json") + } + } + + internal class Deserializer : BaseDeserializer(RunStatsResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RunStatsResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + RunStatsResponse(runStats = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + RunStatsResponse(unionMember1 = 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 -> RunStatsResponse(_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(RunStatsResponse::class) { + + override fun serialize( + value: RunStatsResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.runStats != null -> generator.writeObject(value.runStats) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RunStatsResponse") + } + } + } + + class RunStats + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val completionCost: JsonField, + private val completionCostDetails: JsonField, + private val completionTokenDetails: JsonField, + private val completionTokens: JsonField, + private val completionTokensP50: JsonField, + private val completionTokensP99: JsonField, + private val costP50: JsonField, + private val costP99: JsonField, + private val errorRate: JsonField, + private val feedbackStats: JsonField, + private val firstTokenP50: JsonField, + private val firstTokenP99: JsonField, + private val lastRunStartTime: JsonField, + private val latencyP50: JsonField, + private val latencyP99: JsonField, + private val medianTokens: JsonField, + private val promptCost: JsonField, + private val promptCostDetails: JsonField, + private val promptTokenDetails: JsonField, + private val promptTokens: JsonField, + private val promptTokensP50: JsonField, + private val promptTokensP99: JsonField, + private val runCount: JsonField, + private val runFacets: JsonField>, + private val streamingRate: JsonField, + private val tokensP99: JsonField, + private val totalCost: JsonField, + private val totalTokens: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonField = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField = JsonMissing.of(), + @JsonProperty("completion_tokens_p50") + @ExcludeMissing + completionTokensP50: JsonField = JsonMissing.of(), + @JsonProperty("completion_tokens_p99") + @ExcludeMissing + completionTokensP99: JsonField = JsonMissing.of(), + @JsonProperty("cost_p50") @ExcludeMissing costP50: JsonField = JsonMissing.of(), + @JsonProperty("cost_p99") @ExcludeMissing costP99: JsonField = JsonMissing.of(), + @JsonProperty("error_rate") + @ExcludeMissing + errorRate: JsonField = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField = JsonMissing.of(), + @JsonProperty("first_token_p50") + @ExcludeMissing + firstTokenP50: JsonField = JsonMissing.of(), + @JsonProperty("first_token_p99") + @ExcludeMissing + firstTokenP99: JsonField = JsonMissing.of(), + @JsonProperty("last_run_start_time") + @ExcludeMissing + lastRunStartTime: JsonField = JsonMissing.of(), + @JsonProperty("latency_p50") + @ExcludeMissing + latencyP50: JsonField = JsonMissing.of(), + @JsonProperty("latency_p99") + @ExcludeMissing + latencyP99: JsonField = JsonMissing.of(), + @JsonProperty("median_tokens") + @ExcludeMissing + medianTokens: JsonField = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens_p50") + @ExcludeMissing + promptTokensP50: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens_p99") + @ExcludeMissing + promptTokensP99: JsonField = JsonMissing.of(), + @JsonProperty("run_count") @ExcludeMissing runCount: JsonField = JsonMissing.of(), + @JsonProperty("run_facets") + @ExcludeMissing + runFacets: JsonField> = JsonMissing.of(), + @JsonProperty("streaming_rate") + @ExcludeMissing + streamingRate: JsonField = JsonMissing.of(), + @JsonProperty("tokens_p99") + @ExcludeMissing + tokensP99: JsonField = JsonMissing.of(), + @JsonProperty("total_cost") + @ExcludeMissing + totalCost: JsonField = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField = JsonMissing.of(), + ) : this( + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + runFacets, + streamingRate, + tokensP99, + totalCost, + totalTokens, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional = completionCost.getOptional("completion_cost") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokenDetails(): Optional = + completionTokenDetails.getOptional("completion_token_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokensP50(): Optional = + completionTokensP50.getOptional("completion_tokens_p50") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokensP99(): Optional = + completionTokensP99.getOptional("completion_tokens_p99") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun costP50(): Optional = costP50.getOptional("cost_p50") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun costP99(): Optional = costP99.getOptional("cost_p99") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun errorRate(): Optional = errorRate.getOptional("error_rate") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP50(): Optional = firstTokenP50.getOptional("first_token_p50") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP99(): Optional = firstTokenP99.getOptional("first_token_p99") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRunStartTime(): Optional = + lastRunStartTime.getOptional("last_run_start_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP50(): Optional = latencyP50.getOptional("latency_p50") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP99(): Optional = latencyP99.getOptional("latency_p99") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun medianTokens(): Optional = medianTokens.getOptional("median_tokens") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional = promptCost.getOptional("prompt_cost") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokenDetails(): Optional = + promptTokenDetails.getOptional("prompt_token_details") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokensP50(): Optional = promptTokensP50.getOptional("prompt_tokens_p50") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokensP99(): Optional = promptTokensP99.getOptional("prompt_tokens_p99") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runCount(): Optional = runCount.getOptional("run_count") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runFacets(): Optional> = runFacets.getOptional("run_facets") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun streamingRate(): Optional = streamingRate.getOptional("streaming_rate") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tokensP99(): Optional = tokensP99.getOptional("tokens_p99") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional = totalCost.getOptional("total_cost") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField = completionCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField = completionCostDetails + + /** + * Returns the raw JSON value of [completionTokenDetails]. + * + * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonField = completionTokenDetails + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField = completionTokens + + /** + * Returns the raw JSON value of [completionTokensP50]. + * + * Unlike [completionTokensP50], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_tokens_p50") + @ExcludeMissing + fun _completionTokensP50(): JsonField = completionTokensP50 + + /** + * Returns the raw JSON value of [completionTokensP99]. + * + * Unlike [completionTokensP99], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_tokens_p99") + @ExcludeMissing + fun _completionTokensP99(): JsonField = completionTokensP99 + + /** + * Returns the raw JSON value of [costP50]. + * + * Unlike [costP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_p50") @ExcludeMissing fun _costP50(): JsonField = costP50 + + /** + * Returns the raw JSON value of [costP99]. + * + * Unlike [costP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_p99") @ExcludeMissing fun _costP99(): JsonField = costP99 + + /** + * Returns the raw JSON value of [errorRate]. + * + * Unlike [errorRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error_rate") @ExcludeMissing fun _errorRate(): JsonField = errorRate + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + + /** + * Returns the raw JSON value of [firstTokenP50]. + * + * Unlike [firstTokenP50], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_token_p50") + @ExcludeMissing + fun _firstTokenP50(): JsonField = firstTokenP50 + + /** + * Returns the raw JSON value of [firstTokenP99]. + * + * Unlike [firstTokenP99], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_token_p99") + @ExcludeMissing + fun _firstTokenP99(): JsonField = firstTokenP99 + + /** + * Returns the raw JSON value of [lastRunStartTime]. + * + * Unlike [lastRunStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_run_start_time") + @ExcludeMissing + fun _lastRunStartTime(): JsonField = lastRunStartTime + + /** + * Returns the raw JSON value of [latencyP50]. + * + * Unlike [latencyP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p50") + @ExcludeMissing + fun _latencyP50(): JsonField = latencyP50 + + /** + * Returns the raw JSON value of [latencyP99]. + * + * Unlike [latencyP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p99") + @ExcludeMissing + fun _latencyP99(): JsonField = latencyP99 + + /** + * Returns the raw JSON value of [medianTokens]. + * + * Unlike [medianTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("median_tokens") + @ExcludeMissing + fun _medianTokens(): JsonField = medianTokens + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") + @ExcludeMissing + fun _promptCost(): JsonField = promptCost + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField = promptCostDetails + + /** + * Returns the raw JSON value of [promptTokenDetails]. + * + * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonField = promptTokenDetails + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField = promptTokens + + /** + * Returns the raw JSON value of [promptTokensP50]. + * + * Unlike [promptTokensP50], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_tokens_p50") + @ExcludeMissing + fun _promptTokensP50(): JsonField = promptTokensP50 + + /** + * Returns the raw JSON value of [promptTokensP99]. + * + * Unlike [promptTokensP99], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_tokens_p99") + @ExcludeMissing + fun _promptTokensP99(): JsonField = promptTokensP99 + + /** + * Returns the raw JSON value of [runCount]. + * + * Unlike [runCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_count") @ExcludeMissing fun _runCount(): JsonField = runCount + + /** + * Returns the raw JSON value of [runFacets]. + * + * Unlike [runFacets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_facets") + @ExcludeMissing + fun _runFacets(): JsonField> = runFacets + + /** + * Returns the raw JSON value of [streamingRate]. + * + * Unlike [streamingRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("streaming_rate") + @ExcludeMissing + fun _streamingRate(): JsonField = streamingRate + + /** + * Returns the raw JSON value of [tokensP99]. + * + * Unlike [tokensP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tokens_p99") @ExcludeMissing fun _tokensP99(): JsonField = tokensP99 + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") + @ExcludeMissing + fun _totalTokens(): JsonField = totalTokens + + @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 [RunStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStats]. */ + class Builder internal constructor() { + + private var completionCost: JsonField = JsonMissing.of() + private var completionCostDetails: JsonField = JsonMissing.of() + private var completionTokenDetails: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var completionTokensP50: JsonField = JsonMissing.of() + private var completionTokensP99: JsonField = JsonMissing.of() + private var costP50: JsonField = JsonMissing.of() + private var costP99: JsonField = JsonMissing.of() + private var errorRate: JsonField = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() + private var firstTokenP50: JsonField = JsonMissing.of() + private var firstTokenP99: JsonField = JsonMissing.of() + private var lastRunStartTime: JsonField = JsonMissing.of() + private var latencyP50: JsonField = JsonMissing.of() + private var latencyP99: JsonField = JsonMissing.of() + private var medianTokens: JsonField = JsonMissing.of() + private var promptCost: JsonField = JsonMissing.of() + private var promptCostDetails: JsonField = JsonMissing.of() + private var promptTokenDetails: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var promptTokensP50: JsonField = JsonMissing.of() + private var promptTokensP99: JsonField = JsonMissing.of() + private var runCount: JsonField = JsonMissing.of() + private var runFacets: JsonField>? = null + private var streamingRate: JsonField = JsonMissing.of() + private var tokensP99: JsonField = JsonMissing.of() + private var totalCost: JsonField = JsonMissing.of() + private var totalTokens: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runStats: RunStats) = apply { + completionCost = runStats.completionCost + completionCostDetails = runStats.completionCostDetails + completionTokenDetails = runStats.completionTokenDetails + completionTokens = runStats.completionTokens + completionTokensP50 = runStats.completionTokensP50 + completionTokensP99 = runStats.completionTokensP99 + costP50 = runStats.costP50 + costP99 = runStats.costP99 + errorRate = runStats.errorRate + feedbackStats = runStats.feedbackStats + firstTokenP50 = runStats.firstTokenP50 + firstTokenP99 = runStats.firstTokenP99 + lastRunStartTime = runStats.lastRunStartTime + latencyP50 = runStats.latencyP50 + latencyP99 = runStats.latencyP99 + medianTokens = runStats.medianTokens + promptCost = runStats.promptCost + promptCostDetails = runStats.promptCostDetails + promptTokenDetails = runStats.promptTokenDetails + promptTokens = runStats.promptTokens + promptTokensP50 = runStats.promptTokensP50 + promptTokensP99 = runStats.promptTokensP99 + runCount = runStats.runCount + runFacets = runStats.runFacets.map { it.toMutableList() } + streamingRate = runStats.streamingRate + tokensP99 = runStats.tokensP99 + totalCost = runStats.totalCost + totalTokens = runStats.totalTokens + additionalProperties = runStats.additionalProperties.toMutableMap() + } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField) = + apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = + completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) + + /** + * Alias for calling [Builder.completionTokenDetails] with + * `completionTokenDetails.orElse(null)`. + */ + fun completionTokenDetails(completionTokenDetails: Optional) = + completionTokenDetails(completionTokenDetails.getOrNull()) + + /** + * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokenDetails] with a well-typed + * [CompletionTokenDetails] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun completionTokenDetails(completionTokenDetails: JsonField) = + apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) + + /** + * Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. + */ + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.getOrNull()) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + fun completionTokensP50(completionTokensP50: Long?) = + completionTokensP50(JsonField.ofNullable(completionTokensP50)) + + /** + * Alias for [Builder.completionTokensP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokensP50(completionTokensP50: Long) = + completionTokensP50(completionTokensP50 as Long?) + + /** + * Alias for calling [Builder.completionTokensP50] with + * `completionTokensP50.orElse(null)`. + */ + fun completionTokensP50(completionTokensP50: Optional) = + completionTokensP50(completionTokensP50.getOrNull()) + + /** + * Sets [Builder.completionTokensP50] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokensP50] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokensP50(completionTokensP50: JsonField) = apply { + this.completionTokensP50 = completionTokensP50 + } + + fun completionTokensP99(completionTokensP99: Long?) = + completionTokensP99(JsonField.ofNullable(completionTokensP99)) + + /** + * Alias for [Builder.completionTokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokensP99(completionTokensP99: Long) = + completionTokensP99(completionTokensP99 as Long?) + + /** + * Alias for calling [Builder.completionTokensP99] with + * `completionTokensP99.orElse(null)`. + */ + fun completionTokensP99(completionTokensP99: Optional) = + completionTokensP99(completionTokensP99.getOrNull()) + + /** + * Sets [Builder.completionTokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokensP99] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokensP99(completionTokensP99: JsonField) = apply { + this.completionTokensP99 = completionTokensP99 + } + + fun costP50(costP50: String?) = costP50(JsonField.ofNullable(costP50)) + + /** Alias for calling [Builder.costP50] with `costP50.orElse(null)`. */ + fun costP50(costP50: Optional) = costP50(costP50.getOrNull()) + + /** + * Sets [Builder.costP50] to an arbitrary JSON value. + * + * You should usually call [Builder.costP50] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun costP50(costP50: JsonField) = apply { this.costP50 = costP50 } + + fun costP99(costP99: String?) = costP99(JsonField.ofNullable(costP99)) + + /** Alias for calling [Builder.costP99] with `costP99.orElse(null)`. */ + fun costP99(costP99: Optional) = costP99(costP99.getOrNull()) + + /** + * Sets [Builder.costP99] to an arbitrary JSON value. + * + * You should usually call [Builder.costP99] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun costP99(costP99: JsonField) = apply { this.costP99 = costP99 } + + fun errorRate(errorRate: Double?) = errorRate(JsonField.ofNullable(errorRate)) + + /** + * Alias for [Builder.errorRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun errorRate(errorRate: Double) = errorRate(errorRate as Double?) + + /** Alias for calling [Builder.errorRate] with `errorRate.orElse(null)`. */ + fun errorRate(errorRate: Optional) = errorRate(errorRate.getOrNull()) + + /** + * Sets [Builder.errorRate] to an arbitrary JSON value. + * + * You should usually call [Builder.errorRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun errorRate(errorRate: JsonField) = apply { this.errorRate = errorRate } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { + this.feedbackStats = feedbackStats + } + + fun firstTokenP50(firstTokenP50: Double?) = + firstTokenP50(JsonField.ofNullable(firstTokenP50)) + + /** + * Alias for [Builder.firstTokenP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP50(firstTokenP50: Double) = firstTokenP50(firstTokenP50 as Double?) + + /** Alias for calling [Builder.firstTokenP50] with `firstTokenP50.orElse(null)`. */ + fun firstTokenP50(firstTokenP50: Optional) = + firstTokenP50(firstTokenP50.getOrNull()) + + /** + * Sets [Builder.firstTokenP50] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP50] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstTokenP50(firstTokenP50: JsonField) = apply { + this.firstTokenP50 = firstTokenP50 + } + + fun firstTokenP99(firstTokenP99: Double?) = + firstTokenP99(JsonField.ofNullable(firstTokenP99)) + + /** + * Alias for [Builder.firstTokenP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP99(firstTokenP99: Double) = firstTokenP99(firstTokenP99 as Double?) + + /** Alias for calling [Builder.firstTokenP99] with `firstTokenP99.orElse(null)`. */ + fun firstTokenP99(firstTokenP99: Optional) = + firstTokenP99(firstTokenP99.getOrNull()) + + /** + * Sets [Builder.firstTokenP99] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP99] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstTokenP99(firstTokenP99: JsonField) = apply { + this.firstTokenP99 = firstTokenP99 + } + + fun lastRunStartTime(lastRunStartTime: OffsetDateTime?) = + lastRunStartTime(JsonField.ofNullable(lastRunStartTime)) + + /** + * Alias for calling [Builder.lastRunStartTime] with `lastRunStartTime.orElse(null)`. + */ + fun lastRunStartTime(lastRunStartTime: Optional) = + lastRunStartTime(lastRunStartTime.getOrNull()) + + /** + * Sets [Builder.lastRunStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lastRunStartTime(lastRunStartTime: JsonField) = apply { + this.lastRunStartTime = lastRunStartTime + } + + fun latencyP50(latencyP50: Double?) = latencyP50(JsonField.ofNullable(latencyP50)) + + /** + * Alias for [Builder.latencyP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP50(latencyP50: Double) = latencyP50(latencyP50 as Double?) + + /** Alias for calling [Builder.latencyP50] with `latencyP50.orElse(null)`. */ + fun latencyP50(latencyP50: Optional) = latencyP50(latencyP50.getOrNull()) + + /** + * Sets [Builder.latencyP50] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP50] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latencyP50(latencyP50: JsonField) = apply { this.latencyP50 = latencyP50 } + + fun latencyP99(latencyP99: Double?) = latencyP99(JsonField.ofNullable(latencyP99)) + + /** + * Alias for [Builder.latencyP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP99(latencyP99: Double) = latencyP99(latencyP99 as Double?) + + /** Alias for calling [Builder.latencyP99] with `latencyP99.orElse(null)`. */ + fun latencyP99(latencyP99: Optional) = latencyP99(latencyP99.getOrNull()) + + /** + * Sets [Builder.latencyP99] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP99] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latencyP99(latencyP99: JsonField) = apply { this.latencyP99 = latencyP99 } + + fun medianTokens(medianTokens: Long?) = medianTokens(JsonField.ofNullable(medianTokens)) + + /** + * Alias for [Builder.medianTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun medianTokens(medianTokens: Long) = medianTokens(medianTokens as Long?) + + /** Alias for calling [Builder.medianTokens] with `medianTokens.orElse(null)`. */ + fun medianTokens(medianTokens: Optional) = medianTokens(medianTokens.getOrNull()) + + /** + * Sets [Builder.medianTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.medianTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun medianTokens(medianTokens: JsonField) = apply { + this.medianTokens = medianTokens + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptCost(promptCost: JsonField) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** + * Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. + */ + fun promptCostDetails(promptCostDetails: Optional) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed + * [PromptCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = + promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) + + /** + * Alias for calling [Builder.promptTokenDetails] with + * `promptTokenDetails.orElse(null)`. + */ + fun promptTokenDetails(promptTokenDetails: Optional) = + promptTokenDetails(promptTokenDetails.getOrNull()) + + /** + * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokenDetails] with a well-typed + * [PromptTokenDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun promptTokenDetails(promptTokenDetails: JsonField) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ + fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } + + fun promptTokensP50(promptTokensP50: Long?) = + promptTokensP50(JsonField.ofNullable(promptTokensP50)) + + /** + * Alias for [Builder.promptTokensP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokensP50(promptTokensP50: Long) = promptTokensP50(promptTokensP50 as Long?) + + /** Alias for calling [Builder.promptTokensP50] with `promptTokensP50.orElse(null)`. */ + fun promptTokensP50(promptTokensP50: Optional) = + promptTokensP50(promptTokensP50.getOrNull()) + + /** + * Sets [Builder.promptTokensP50] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokensP50] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptTokensP50(promptTokensP50: JsonField) = apply { + this.promptTokensP50 = promptTokensP50 + } + + fun promptTokensP99(promptTokensP99: Long?) = + promptTokensP99(JsonField.ofNullable(promptTokensP99)) + + /** + * Alias for [Builder.promptTokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokensP99(promptTokensP99: Long) = promptTokensP99(promptTokensP99 as Long?) + + /** Alias for calling [Builder.promptTokensP99] with `promptTokensP99.orElse(null)`. */ + fun promptTokensP99(promptTokensP99: Optional) = + promptTokensP99(promptTokensP99.getOrNull()) + + /** + * Sets [Builder.promptTokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokensP99] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptTokensP99(promptTokensP99: JsonField) = apply { + this.promptTokensP99 = promptTokensP99 + } + + fun runCount(runCount: Long?) = runCount(JsonField.ofNullable(runCount)) + + /** + * Alias for [Builder.runCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun runCount(runCount: Long) = runCount(runCount as Long?) + + /** Alias for calling [Builder.runCount] with `runCount.orElse(null)`. */ + fun runCount(runCount: Optional) = runCount(runCount.getOrNull()) + + /** + * Sets [Builder.runCount] to an arbitrary JSON value. + * + * You should usually call [Builder.runCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runCount(runCount: JsonField) = apply { this.runCount = runCount } + + fun runFacets(runFacets: List?) = runFacets(JsonField.ofNullable(runFacets)) + + /** Alias for calling [Builder.runFacets] with `runFacets.orElse(null)`. */ + fun runFacets(runFacets: Optional>) = runFacets(runFacets.getOrNull()) + + /** + * Sets [Builder.runFacets] to an arbitrary JSON value. + * + * You should usually call [Builder.runFacets] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runFacets(runFacets: JsonField>) = apply { + this.runFacets = runFacets.map { it.toMutableList() } + } + + /** + * Adds a single [RunFacet] to [runFacets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRunFacet(runFacet: RunFacet) = apply { + runFacets = + (runFacets ?: JsonField.of(mutableListOf())).also { + checkKnown("runFacets", it).add(runFacet) + } + } + + fun streamingRate(streamingRate: Double?) = + streamingRate(JsonField.ofNullable(streamingRate)) + + /** + * Alias for [Builder.streamingRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun streamingRate(streamingRate: Double) = streamingRate(streamingRate as Double?) + + /** Alias for calling [Builder.streamingRate] with `streamingRate.orElse(null)`. */ + fun streamingRate(streamingRate: Optional) = + streamingRate(streamingRate.getOrNull()) + + /** + * Sets [Builder.streamingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.streamingRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun streamingRate(streamingRate: JsonField) = apply { + this.streamingRate = streamingRate + } + + fun tokensP99(tokensP99: Long?) = tokensP99(JsonField.ofNullable(tokensP99)) + + /** + * Alias for [Builder.tokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun tokensP99(tokensP99: Long) = tokensP99(tokensP99 as Long?) + + /** Alias for calling [Builder.tokensP99] with `tokensP99.orElse(null)`. */ + fun tokensP99(tokensP99: Optional) = tokensP99(tokensP99.getOrNull()) + + /** + * Sets [Builder.tokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.tokensP99] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokensP99(tokensP99: JsonField) = apply { this.tokensP99 = tokensP99 } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalCost(totalCost: JsonField) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long?) = totalTokens(JsonField.ofNullable(totalTokens)) + + /** + * Alias for [Builder.totalTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalTokens(totalTokens: Long) = totalTokens(totalTokens as Long?) + + /** Alias for calling [Builder.totalTokens] with `totalTokens.orElse(null)`. */ + fun totalTokens(totalTokens: Optional) = totalTokens(totalTokens.getOrNull()) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalTokens(totalTokens: JsonField) = apply { this.totalTokens = totalTokens } + + 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 [RunStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunStats = + RunStats( + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + (runFacets ?: JsonMissing.of()).map { it.toImmutable() }, + streamingRate, + tokensP99, + totalCost, + totalTokens, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunStats = apply { + if (validated) { + return@apply + } + + completionCost() + completionCostDetails().ifPresent { it.validate() } + completionTokenDetails().ifPresent { it.validate() } + completionTokens() + completionTokensP50() + completionTokensP99() + costP50() + costP99() + errorRate() + feedbackStats().ifPresent { it.validate() } + firstTokenP50() + firstTokenP99() + lastRunStartTime() + latencyP50() + latencyP99() + medianTokens() + promptCost() + promptCostDetails().ifPresent { it.validate() } + promptTokenDetails().ifPresent { it.validate() } + promptTokens() + promptTokensP50() + promptTokensP99() + runCount() + runFacets().ifPresent { it.forEach { it.validate() } } + streamingRate() + tokensP99() + totalCost() + totalTokens() + 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 (completionCost.asKnown().isPresent) 1 else 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (if (completionTokensP50.asKnown().isPresent) 1 else 0) + + (if (completionTokensP99.asKnown().isPresent) 1 else 0) + + (if (costP50.asKnown().isPresent) 1 else 0) + + (if (costP99.asKnown().isPresent) 1 else 0) + + (if (errorRate.asKnown().isPresent) 1 else 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (if (firstTokenP50.asKnown().isPresent) 1 else 0) + + (if (firstTokenP99.asKnown().isPresent) 1 else 0) + + (if (lastRunStartTime.asKnown().isPresent) 1 else 0) + + (if (latencyP50.asKnown().isPresent) 1 else 0) + + (if (latencyP99.asKnown().isPresent) 1 else 0) + + (if (medianTokens.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (promptTokensP50.asKnown().isPresent) 1 else 0) + + (if (promptTokensP99.asKnown().isPresent) 1 else 0) + + (if (runCount.asKnown().isPresent) 1 else 0) + + (runFacets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (streamingRate.asKnown().isPresent) 1 else 0) + + (if (tokensP99.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + class CompletionCostDetails + @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 + * [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.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 [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = 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 CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class CompletionTokenDetails + @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 + * [CompletionTokenDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { + additionalProperties = + completionTokenDetails.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 [CompletionTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionTokenDetails = + CompletionTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionTokenDetails = 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 CompletionTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionTokenDetails{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @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 [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.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 [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = 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 FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @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 [PromptCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.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 [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = + PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = 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 PromptCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptTokenDetails + @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 [PromptTokenDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(promptTokenDetails: PromptTokenDetails) = apply { + additionalProperties = promptTokenDetails.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 [PromptTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptTokenDetails = + PromptTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptTokenDetails = 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 PromptTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptTokenDetails{additionalProperties=$additionalProperties}" + } + + class RunFacet + @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 [RunFacet]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunFacet]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runFacet: RunFacet) = apply { + additionalProperties = runFacet.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 [RunFacet]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunFacet = RunFacet(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunFacet = 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 RunFacet && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunFacet{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStats && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + completionTokensP50 == other.completionTokensP50 && + completionTokensP99 == other.completionTokensP99 && + costP50 == other.costP50 && + costP99 == other.costP99 && + errorRate == other.errorRate && + feedbackStats == other.feedbackStats && + firstTokenP50 == other.firstTokenP50 && + firstTokenP99 == other.firstTokenP99 && + lastRunStartTime == other.lastRunStartTime && + latencyP50 == other.latencyP50 && + latencyP99 == other.latencyP99 && + medianTokens == other.medianTokens && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + promptTokensP50 == other.promptTokensP50 && + promptTokensP99 == other.promptTokensP99 && + runCount == other.runCount && + runFacets == other.runFacets && + streamingRate == other.streamingRate && + tokensP99 == other.tokensP99 && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + runFacets, + streamingRate, + tokensP99, + totalCost, + totalTokens, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunStats{completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, completionTokensP50=$completionTokensP50, completionTokensP99=$completionTokensP99, costP50=$costP50, costP99=$costP99, errorRate=$errorRate, feedbackStats=$feedbackStats, firstTokenP50=$firstTokenP50, firstTokenP99=$firstTokenP99, lastRunStartTime=$lastRunStartTime, latencyP50=$latencyP50, latencyP99=$latencyP99, medianTokens=$medianTokens, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, promptTokensP50=$promptTokensP50, promptTokensP99=$promptTokensP99, runCount=$runCount, runFacets=$runFacets, streamingRate=$streamingRate, tokensP99=$tokensP99, totalCost=$totalCost, totalTokens=$totalTokens, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @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 [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.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 [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = 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 UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunTypeEnum.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunTypeEnum.kt new file mode 100644 index 000000000..776a1f11c --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunTypeEnum.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langchain.smith.core.Enum +import com.langchain.smith.core.JsonField +import com.langchain.smith.errors.LangChainInvalidDataException + +/** Enum for run types. */ +class RunTypeEnum @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 TOOL = of("tool") + + @JvmField val CHAIN = of("chain") + + @JvmField val LLM = of("llm") + + @JvmField val RETRIEVER = of("retriever") + + @JvmField val EMBEDDING = of("embedding") + + @JvmField val PROMPT = of("prompt") + + @JvmField val PARSER = of("parser") + + @JvmStatic fun of(value: String) = RunTypeEnum(JsonField.of(value)) + } + + /** An enum containing [RunTypeEnum]'s known values. */ + enum class Known { + TOOL, + CHAIN, + LLM, + RETRIEVER, + EMBEDDING, + PROMPT, + PARSER, + } + + /** + * An enum containing [RunTypeEnum]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RunTypeEnum] 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 { + TOOL, + CHAIN, + LLM, + RETRIEVER, + EMBEDDING, + PROMPT, + PARSER, + /** An enum member indicating that [RunTypeEnum] 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) { + TOOL -> Value.TOOL + CHAIN -> Value.CHAIN + LLM -> Value.LLM + RETRIEVER -> Value.RETRIEVER + EMBEDDING -> Value.EMBEDDING + PROMPT -> Value.PROMPT + PARSER -> Value.PARSER + 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) { + TOOL -> Known.TOOL + CHAIN -> Known.CHAIN + LLM -> Known.LLM + RETRIEVER -> Known.RETRIEVER + EMBEDDING -> Known.EMBEDDING + PROMPT -> Known.PROMPT + PARSER -> Known.PARSER + else -> throw LangChainInvalidDataException("Unknown RunTypeEnum: $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(): RunTypeEnum = 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 RunTypeEnum && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexSyncParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdate2Params.kt similarity index 81% rename from langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexSyncParams.kt rename to langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdate2Params.kt index c264366fa..7f4158210 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexSyncParams.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdate2Params.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.langchain.smith.models.datasets.index +package com.langchain.smith.models.runs import com.langchain.smith.core.JsonValue import com.langchain.smith.core.Params @@ -11,16 +11,16 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Sync an index for a dataset. */ -class IndexSyncParams +/** Update a run. */ +class RunUpdate2Params private constructor( - private val datasetId: String?, + private val runId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun datasetId(): Optional = Optional.ofNullable(datasetId) + fun runId(): Optional = Optional.ofNullable(runId) /** Additional body properties to send with the request. */ fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -35,32 +35,32 @@ private constructor( companion object { - @JvmStatic fun none(): IndexSyncParams = builder().build() + @JvmStatic fun none(): RunUpdate2Params = builder().build() - /** Returns a mutable builder for constructing an instance of [IndexSyncParams]. */ + /** Returns a mutable builder for constructing an instance of [RunUpdate2Params]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [IndexSyncParams]. */ + /** A builder for [RunUpdate2Params]. */ class Builder internal constructor() { - private var datasetId: String? = null + private var runId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(indexSyncParams: IndexSyncParams) = apply { - datasetId = indexSyncParams.datasetId - additionalHeaders = indexSyncParams.additionalHeaders.toBuilder() - additionalQueryParams = indexSyncParams.additionalQueryParams.toBuilder() - additionalBodyProperties = indexSyncParams.additionalBodyProperties.toMutableMap() + internal fun from(runUpdate2Params: RunUpdate2Params) = apply { + runId = runUpdate2Params.runId + additionalHeaders = runUpdate2Params.additionalHeaders.toBuilder() + additionalQueryParams = runUpdate2Params.additionalQueryParams.toBuilder() + additionalBodyProperties = runUpdate2Params.additionalBodyProperties.toMutableMap() } - fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + fun runId(runId: String?) = apply { this.runId = runId } - /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional) = runId(runId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -183,13 +183,13 @@ private constructor( } /** - * Returns an immutable instance of [IndexSyncParams]. + * Returns an immutable instance of [RunUpdate2Params]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): IndexSyncParams = - IndexSyncParams( - datasetId, + fun build(): RunUpdate2Params = + RunUpdate2Params( + runId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -201,7 +201,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> datasetId ?: "" + 0 -> runId ?: "" else -> "" } @@ -214,16 +214,16 @@ private constructor( return true } - return other is IndexSyncParams && - datasetId == other.datasetId && + return other is RunUpdate2Params && + runId == other.runId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int = - Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash(runId, additionalHeaders, additionalQueryParams, additionalBodyProperties) override fun toString() = - "IndexSyncParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "RunUpdate2Params{runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexSyncResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdate2Response.kt similarity index 80% rename from langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexSyncResponse.kt rename to langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdate2Response.kt index 9ef25afe3..1e2652cf2 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/datasets/index/IndexSyncResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdate2Response.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.langchain.smith.models.datasets.index +package com.langchain.smith.models.runs import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -11,7 +11,7 @@ import com.langchain.smith.errors.LangChainInvalidDataException import java.util.Collections import java.util.Objects -class IndexSyncResponse +class RunUpdate2Response @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @@ -31,18 +31,18 @@ private constructor(private val additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(indexSyncResponse: IndexSyncResponse) = apply { - additionalProperties = indexSyncResponse.additionalProperties.toMutableMap() + internal fun from(runUpdate2Response: RunUpdate2Response) = apply { + additionalProperties = runUpdate2Response.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -65,16 +65,16 @@ private constructor(private val additionalProperties: MutableMap = Optional.ofNullable(runId) + + fun run(): Run = run + + fun _additionalBodyProperties(): Map = run._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunUpdateParams]. + * + * The following fields are required: + * ```java + * .run() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var run: Run? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runUpdateParams: RunUpdateParams) = apply { + runId = runUpdateParams.runId + run = runUpdateParams.run + additionalHeaders = runUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = runUpdateParams.additionalQueryParams.toBuilder() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional) = runId(runId.getOrNull()) + + fun run(run: Run) = apply { this.run = run } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .run() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunUpdateParams = + RunUpdateParams( + runId, + checkRequired("run", run), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Run = run + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunUpdateParams && + runId == other.runId && + run == other.run && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(runId, run, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunUpdateParams{runId=$runId, run=$run, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdateResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdateResponse.kt new file mode 100644 index 000000000..e52fc9f44 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunUpdateResponse.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Objects + +class RunUpdateResponse +@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 [RunUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runUpdateResponse: RunUpdateResponse) = apply { + additionalProperties = runUpdateResponse.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 [RunUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunUpdateResponse = RunUpdateResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunUpdateResponse = 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 RunUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunsFilterDataSourceTypeEnum.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunsFilterDataSourceTypeEnum.kt new file mode 100644 index 000000000..7e71d104c --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/runs/RunsFilterDataSourceTypeEnum.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langchain.smith.core.Enum +import com.langchain.smith.core.JsonField +import com.langchain.smith.errors.LangChainInvalidDataException + +/** Enum for run data source types. */ +class RunsFilterDataSourceTypeEnum +@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 CURRENT = of("current") + + @JvmField val HISTORICAL = of("historical") + + @JvmField val LITE = of("lite") + + @JvmField val ROOT_LITE = of("root_lite") + + @JvmField val RUNS_FEEDBACKS_RMT_WIDE = of("runs_feedbacks_rmt_wide") + + @JvmStatic fun of(value: String) = RunsFilterDataSourceTypeEnum(JsonField.of(value)) + } + + /** An enum containing [RunsFilterDataSourceTypeEnum]'s known values. */ + enum class Known { + CURRENT, + HISTORICAL, + LITE, + ROOT_LITE, + RUNS_FEEDBACKS_RMT_WIDE, + } + + /** + * An enum containing [RunsFilterDataSourceTypeEnum]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RunsFilterDataSourceTypeEnum] 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 { + CURRENT, + HISTORICAL, + LITE, + ROOT_LITE, + RUNS_FEEDBACKS_RMT_WIDE, + /** + * An enum member indicating that [RunsFilterDataSourceTypeEnum] 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) { + CURRENT -> Value.CURRENT + HISTORICAL -> Value.HISTORICAL + LITE -> Value.LITE + ROOT_LITE -> Value.ROOT_LITE + RUNS_FEEDBACKS_RMT_WIDE -> Value.RUNS_FEEDBACKS_RMT_WIDE + 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) { + CURRENT -> Known.CURRENT + HISTORICAL -> Known.HISTORICAL + LITE -> Known.LITE + ROOT_LITE -> Known.ROOT_LITE + RUNS_FEEDBACKS_RMT_WIDE -> Known.RUNS_FEEDBACKS_RMT_WIDE + else -> + throw LangChainInvalidDataException("Unknown RunsFilterDataSourceTypeEnum: $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(): RunsFilterDataSourceTypeEnum = 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 RunsFilterDataSourceTypeEnum && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt index 1c007a262..f4c7ac5e7 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequest.kt @@ -30,6 +30,7 @@ private constructor( private val endTime: JsonField, private val filter: JsonField, private val hierarchy: JsonField>, + private val isScheduled: JsonField, private val lastNHours: JsonField, private val model: JsonField, private val name: JsonField, @@ -59,6 +60,9 @@ private constructor( @JsonProperty("hierarchy") @ExcludeMissing hierarchy: JsonField> = JsonMissing.of(), + @JsonProperty("is_scheduled") + @ExcludeMissing + isScheduled: JsonField = JsonMissing.of(), @JsonProperty("last_n_hours") @ExcludeMissing lastNHours: JsonField = JsonMissing.of(), @@ -90,6 +94,7 @@ private constructor( endTime, filter, hierarchy, + isScheduled, lastNHours, model, name, @@ -140,6 +145,12 @@ private constructor( */ fun hierarchy(): Optional> = hierarchy.getOptional("hierarchy") + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isScheduled(): Optional = isScheduled.getOptional("is_scheduled") + /** * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -248,6 +259,15 @@ private constructor( */ @JsonProperty("hierarchy") @ExcludeMissing fun _hierarchy(): JsonField> = hierarchy + /** + * Returns the raw JSON value of [isScheduled]. + * + * Unlike [isScheduled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_scheduled") + @ExcludeMissing + fun _isScheduled(): JsonField = isScheduled + /** * Returns the raw JSON value of [lastNHours]. * @@ -361,6 +381,7 @@ private constructor( private var endTime: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var hierarchy: JsonField>? = null + private var isScheduled: JsonField = JsonMissing.of() private var lastNHours: JsonField = JsonMissing.of() private var model: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() @@ -381,6 +402,7 @@ private constructor( endTime = createRunClusteringJobRequest.endTime filter = createRunClusteringJobRequest.filter hierarchy = createRunClusteringJobRequest.hierarchy.map { it.toMutableList() } + isScheduled = createRunClusteringJobRequest.isScheduled lastNHours = createRunClusteringJobRequest.lastNHours model = createRunClusteringJobRequest.model name = createRunClusteringJobRequest.name @@ -496,6 +518,17 @@ private constructor( } } + fun isScheduled(isScheduled: Boolean) = isScheduled(JsonField.of(isScheduled)) + + /** + * Sets [Builder.isScheduled] to an arbitrary JSON value. + * + * You should usually call [Builder.isScheduled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isScheduled(isScheduled: JsonField) = apply { this.isScheduled = isScheduled } + fun lastNHours(lastNHours: Long?) = lastNHours(JsonField.ofNullable(lastNHours)) /** @@ -683,6 +716,7 @@ private constructor( endTime, filter, (hierarchy ?: JsonMissing.of()).map { it.toImmutable() }, + isScheduled, lastNHours, model, name, @@ -710,6 +744,7 @@ private constructor( endTime() filter() hierarchy() + isScheduled() lastNHours() model().ifPresent { it.validate() } name() @@ -744,6 +779,7 @@ private constructor( (if (endTime.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + (hierarchy.asKnown().getOrNull()?.size ?: 0) + + (if (isScheduled.asKnown().isPresent) 1 else 0) + (if (lastNHours.asKnown().isPresent) 1 else 0) + (model.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + @@ -1191,6 +1227,7 @@ private constructor( endTime == other.endTime && filter == other.filter && hierarchy == other.hierarchy && + isScheduled == other.isScheduled && lastNHours == other.lastNHours && model == other.model && name == other.name && @@ -1212,6 +1249,7 @@ private constructor( endTime, filter, hierarchy, + isScheduled, lastNHours, model, name, @@ -1229,5 +1267,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreateRunClusteringJobRequest{attributeSchemas=$attributeSchemas, clusterModel=$clusterModel, configId=$configId, endTime=$endTime, filter=$filter, hierarchy=$hierarchy, lastNHours=$lastNHours, model=$model, name=$name, partitions=$partitions, sample=$sample, startTime=$startTime, summaryModel=$summaryModel, summaryPrompt=$summaryPrompt, userContext=$userContext, validateModelSecrets=$validateModelSecrets, additionalProperties=$additionalProperties}" + "CreateRunClusteringJobRequest{attributeSchemas=$attributeSchemas, clusterModel=$clusterModel, configId=$configId, endTime=$endTime, filter=$filter, hierarchy=$hierarchy, isScheduled=$isScheduled, lastNHours=$lastNHours, model=$model, name=$name, partitions=$partitions, sample=$sample, startTime=$startTime, summaryModel=$summaryModel, summaryPrompt=$summaryPrompt, userContext=$userContext, validateModelSecrets=$validateModelSecrets, additionalProperties=$additionalProperties}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt index 921c9def3..2aefb9aeb 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponse.kt @@ -26,6 +26,7 @@ class InsightRetrieveJobResponse private constructor( private val id: JsonField, private val clusters: JsonField>, + private val createdAt: JsonField, private val name: JsonField, private val status: JsonField, private val configId: JsonField, @@ -44,6 +45,9 @@ private constructor( @JsonProperty("clusters") @ExcludeMissing clusters: JsonField> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("config_id") @ExcludeMissing configId: JsonField = JsonMissing.of(), @@ -60,6 +64,7 @@ private constructor( ) : this( id, clusters, + createdAt, name, status, configId, @@ -84,6 +89,12 @@ private constructor( */ fun clusters(): List = clusters.getRequired("clusters") + /** + * @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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + /** * @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). @@ -154,6 +165,15 @@ private constructor( */ @JsonProperty("clusters") @ExcludeMissing fun _clusters(): JsonField> = clusters + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + /** * Returns the raw JSON value of [name]. * @@ -240,6 +260,7 @@ private constructor( * ```java * .id() * .clusters() + * .createdAt() * .name() * .status() * ``` @@ -252,6 +273,7 @@ private constructor( private var id: JsonField? = null private var clusters: JsonField>? = null + private var createdAt: JsonField? = null private var name: JsonField? = null private var status: JsonField? = null private var configId: JsonField = JsonMissing.of() @@ -267,6 +289,7 @@ private constructor( internal fun from(insightRetrieveJobResponse: InsightRetrieveJobResponse) = apply { id = insightRetrieveJobResponse.id clusters = insightRetrieveJobResponse.clusters.map { it.toMutableList() } + createdAt = insightRetrieveJobResponse.createdAt name = insightRetrieveJobResponse.name status = insightRetrieveJobResponse.status configId = insightRetrieveJobResponse.configId @@ -314,6 +337,17 @@ private constructor( } } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + fun name(name: String) = name(JsonField.of(name)) /** @@ -457,6 +491,7 @@ private constructor( * ```java * .id() * .clusters() + * .createdAt() * .name() * .status() * ``` @@ -467,6 +502,7 @@ private constructor( InsightRetrieveJobResponse( checkRequired("id", id), checkRequired("clusters", clusters).map { it.toImmutable() }, + checkRequired("createdAt", createdAt), checkRequired("name", name), checkRequired("status", status), configId, @@ -489,6 +525,7 @@ private constructor( id() clusters().forEach { it.validate() } + createdAt() name() status() configId() @@ -518,6 +555,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (clusters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + (if (configId.asKnown().isPresent) 1 else 0) + @@ -1928,6 +1966,7 @@ private constructor( return other is InsightRetrieveJobResponse && id == other.id && clusters == other.clusters && + createdAt == other.createdAt && name == other.name && status == other.status && configId == other.configId && @@ -1944,6 +1983,7 @@ private constructor( Objects.hash( id, clusters, + createdAt, name, status, configId, @@ -1960,5 +2000,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InsightRetrieveJobResponse{id=$id, clusters=$clusters, name=$name, status=$status, configId=$configId, endTime=$endTime, error=$error, metadata=$metadata, report=$report, shape=$shape, startTime=$startTime, additionalProperties=$additionalProperties}" + "InsightRetrieveJobResponse{id=$id, clusters=$clusters, createdAt=$createdAt, name=$name, status=$status, configId=$configId, endTime=$endTime, error=$error, metadata=$metadata, report=$report, shape=$shape, startTime=$startTime, additionalProperties=$additionalProperties}" } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsync.kt index f214d4986..362ac2f5f 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsync.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsync.kt @@ -31,7 +31,6 @@ import com.langchain.smith.models.datasets.DatasetVersion import com.langchain.smith.services.async.datasets.ComparativeServiceAsync import com.langchain.smith.services.async.datasets.ExperimentServiceAsync import com.langchain.smith.services.async.datasets.GroupServiceAsync -import com.langchain.smith.services.async.datasets.IndexServiceAsync import com.langchain.smith.services.async.datasets.PlaygroundExperimentServiceAsync import com.langchain.smith.services.async.datasets.RunServiceAsync import com.langchain.smith.services.async.datasets.ShareServiceAsync @@ -68,8 +67,6 @@ interface DatasetServiceAsync { fun splits(): SplitServiceAsync - fun index(): IndexServiceAsync - fun playgroundExperiment(): PlaygroundExperimentServiceAsync /** Create a new dataset. */ @@ -460,8 +457,6 @@ interface DatasetServiceAsync { fun splits(): SplitServiceAsync.WithRawResponse - fun index(): IndexServiceAsync.WithRawResponse - fun playgroundExperiment(): PlaygroundExperimentServiceAsync.WithRawResponse /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncImpl.kt index ea990d239..b005019c7 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/DatasetServiceAsyncImpl.kt @@ -46,8 +46,6 @@ import com.langchain.smith.services.async.datasets.ExperimentServiceAsync import com.langchain.smith.services.async.datasets.ExperimentServiceAsyncImpl import com.langchain.smith.services.async.datasets.GroupServiceAsync import com.langchain.smith.services.async.datasets.GroupServiceAsyncImpl -import com.langchain.smith.services.async.datasets.IndexServiceAsync -import com.langchain.smith.services.async.datasets.IndexServiceAsyncImpl import com.langchain.smith.services.async.datasets.PlaygroundExperimentServiceAsync import com.langchain.smith.services.async.datasets.PlaygroundExperimentServiceAsyncImpl import com.langchain.smith.services.async.datasets.RunServiceAsync @@ -87,8 +85,6 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl private val splits: SplitServiceAsync by lazy { SplitServiceAsyncImpl(clientOptions) } - private val index: IndexServiceAsync by lazy { IndexServiceAsyncImpl(clientOptions) } - private val playgroundExperiment: PlaygroundExperimentServiceAsync by lazy { PlaygroundExperimentServiceAsyncImpl(clientOptions) } @@ -112,8 +108,6 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun splits(): SplitServiceAsync = splits - override fun index(): IndexServiceAsync = index - override fun playgroundExperiment(): PlaygroundExperimentServiceAsync = playgroundExperiment override fun create( @@ -241,10 +235,6 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl SplitServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val index: IndexServiceAsync.WithRawResponse by lazy { - IndexServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - private val playgroundExperiment: PlaygroundExperimentServiceAsync.WithRawResponse by lazy { PlaygroundExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -270,8 +260,6 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun splits(): SplitServiceAsync.WithRawResponse = splits - override fun index(): IndexServiceAsync.WithRawResponse = index - override fun playgroundExperiment(): PlaygroundExperimentServiceAsync.WithRawResponse = playgroundExperiment diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsync.kt index 9cd5f8793..a3e60cb38 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsync.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsync.kt @@ -5,10 +5,23 @@ package com.langchain.smith.services.async import com.langchain.smith.core.ClientOptions import com.langchain.smith.core.RequestOptions import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.models.runs.Run +import com.langchain.smith.models.runs.RunCreateParams +import com.langchain.smith.models.runs.RunCreateResponse import com.langchain.smith.models.runs.RunIngestBatchParams import com.langchain.smith.models.runs.RunIngestBatchResponse import com.langchain.smith.models.runs.RunQueryParams import com.langchain.smith.models.runs.RunQueryResponse +import com.langchain.smith.models.runs.RunRetrieveParams +import com.langchain.smith.models.runs.RunSchema +import com.langchain.smith.models.runs.RunStatsParams +import com.langchain.smith.models.runs.RunStatsQueryParams +import com.langchain.smith.models.runs.RunStatsResponse +import com.langchain.smith.models.runs.RunUpdate2Params +import com.langchain.smith.models.runs.RunUpdate2Response +import com.langchain.smith.models.runs.RunUpdateParams +import com.langchain.smith.models.runs.RunUpdateResponse +import com.langchain.smith.services.async.runs.RuleServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -26,6 +39,88 @@ interface RunServiceAsync { */ fun withOptions(modifier: Consumer): RunServiceAsync + fun rules(): RuleServiceAsync + + /** + * Queues a single run for ingestion. The request body must be a JSON-encoded run object that + * follows the Run schema. + */ + fun create(params: RunCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + fun create(run: Run): CompletableFuture = create(run, RequestOptions.none()) + + /** Get a specific run. */ + fun retrieve(runId: String): CompletableFuture = + retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + ): CompletableFuture = retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(runId: String, requestOptions: RequestOptions): CompletableFuture = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** + * Updates a run identified by its ID. The body should contain only the fields to be changed; + * unknown fields are ignored. + */ + fun update(runId: String, params: RunUpdateParams): CompletableFuture = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** * Ingests a batch of runs in a single JSON payload. The payload must have `post` and/or `patch` * arrays containing run objects. Prefer this endpoint over single‑run ingestion when submitting @@ -67,6 +162,65 @@ interface RunServiceAsync { fun query(requestOptions: RequestOptions): CompletableFuture = query(RunQueryParams.none(), requestOptions) + /** Get all runs by query in body payload. */ + fun stats(params: RunStatsParams): CompletableFuture = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + fun stats(runStatsQueryParams: RunStatsQueryParams): CompletableFuture = + stats(runStatsQueryParams, RequestOptions.none()) + + /** Update a run. */ + fun update2(runId: String): CompletableFuture = + update2(runId, RunUpdate2Params.none()) + + /** @see update2 */ + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update2(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update2 */ + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + ): CompletableFuture = update2(runId, params, RequestOptions.none()) + + /** @see update2 */ + fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update2 */ + fun update2(params: RunUpdate2Params): CompletableFuture = + update2(params, RequestOptions.none()) + + /** @see update2 */ + fun update2( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update2(runId, RunUpdate2Params.none(), requestOptions) + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -77,6 +231,99 @@ interface RunServiceAsync { */ fun withOptions(modifier: Consumer): RunServiceAsync.WithRawResponse + fun rules(): RuleServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /runs`, but is otherwise the same as + * [RunServiceAsync.create]. + */ + fun create(params: RunCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + fun create(run: Run): CompletableFuture> = + create(run, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/{run_id}`, but is otherwise the same as + * [RunServiceAsync.retrieve]. + */ + fun retrieve(runId: String): CompletableFuture> = + retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + ): CompletableFuture> = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /runs/{run_id}`, but is otherwise the same as + * [RunServiceAsync.update]. + */ + fun update( + runId: String, + params: RunUpdateParams, + ): CompletableFuture> = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `post /runs/batch`, but is otherwise the same as * [RunServiceAsync.ingestBatch]. @@ -126,5 +373,75 @@ interface RunServiceAsync { requestOptions: RequestOptions ): CompletableFuture> = query(RunQueryParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/stats`, but is otherwise the same as + * [RunServiceAsync.stats]. + */ + fun stats(params: RunStatsParams): CompletableFuture> = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams + ): CompletableFuture> = + stats(runStatsQueryParams, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/runs/{run_id}`, but is otherwise the same + * as [RunServiceAsync.update2]. + */ + fun update2(runId: String): CompletableFuture> = + update2(runId, RunUpdate2Params.none()) + + /** @see update2 */ + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update2(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update2 */ + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + ): CompletableFuture> = + update2(runId, params, RequestOptions.none()) + + /** @see update2 */ + fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update2 */ + fun update2( + params: RunUpdate2Params + ): CompletableFuture> = + update2(params, RequestOptions.none()) + + /** @see update2 */ + fun update2( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update2(runId, RunUpdate2Params.none(), requestOptions) } } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsyncImpl.kt index 86237497d..aee752d1f 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsyncImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/RunServiceAsyncImpl.kt @@ -4,6 +4,7 @@ package com.langchain.smith.services.async import com.langchain.smith.core.ClientOptions import com.langchain.smith.core.RequestOptions +import com.langchain.smith.core.checkRequired import com.langchain.smith.core.handlers.errorBodyHandler import com.langchain.smith.core.handlers.errorHandler import com.langchain.smith.core.handlers.jsonHandler @@ -15,12 +16,25 @@ import com.langchain.smith.core.http.HttpResponseFor import com.langchain.smith.core.http.json import com.langchain.smith.core.http.parseable import com.langchain.smith.core.prepareAsync +import com.langchain.smith.models.runs.RunCreateParams +import com.langchain.smith.models.runs.RunCreateResponse import com.langchain.smith.models.runs.RunIngestBatchParams import com.langchain.smith.models.runs.RunIngestBatchResponse import com.langchain.smith.models.runs.RunQueryParams import com.langchain.smith.models.runs.RunQueryResponse +import com.langchain.smith.models.runs.RunRetrieveParams +import com.langchain.smith.models.runs.RunSchema +import com.langchain.smith.models.runs.RunStatsParams +import com.langchain.smith.models.runs.RunStatsResponse +import com.langchain.smith.models.runs.RunUpdate2Params +import com.langchain.smith.models.runs.RunUpdate2Response +import com.langchain.smith.models.runs.RunUpdateParams +import com.langchain.smith.models.runs.RunUpdateResponse +import com.langchain.smith.services.async.runs.RuleServiceAsync +import com.langchain.smith.services.async.runs.RuleServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RunServiceAsync { @@ -29,11 +43,36 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client WithRawResponseImpl(clientOptions) } + private val rules: RuleServiceAsync by lazy { RuleServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): RunServiceAsync = RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun rules(): RuleServiceAsync = rules + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /runs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /runs/{run_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + override fun ingestBatch( params: RunIngestBatchParams, requestOptions: RequestOptions, @@ -48,12 +87,30 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client // post /api/v1/runs/query withRawResponse().query(params, requestOptions).thenApply { it.parse() } + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/runs/stats + withRawResponse().stats(params, requestOptions).thenApply { it.parse() } + + override fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /api/v1/runs/{run_id} + withRawResponse().update2(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RunServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val rules: RuleServiceAsync.WithRawResponse by lazy { + RuleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): RunServiceAsync.WithRawResponse = @@ -61,6 +118,106 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) + override fun rules(): RuleServiceAsync.WithRawResponse = rules + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val ingestBatchHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -122,5 +279,70 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client } } } + + private val statsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "stats") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val update2Handler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { update2Handler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsync.kt index 17b4d18ed..e10cb0a84 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsync.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsync.kt @@ -9,8 +9,6 @@ import com.langchain.smith.models.datasets.comparative.ComparativeCreateParams import com.langchain.smith.models.datasets.comparative.ComparativeCreateResponse import com.langchain.smith.models.datasets.comparative.ComparativeDeleteParams import com.langchain.smith.models.datasets.comparative.ComparativeDeleteResponse -import com.langchain.smith.models.datasets.comparative.ComparativeListPageAsync -import com.langchain.smith.models.datasets.comparative.ComparativeListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -38,41 +36,6 @@ interface ComparativeServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Get all comparative experiments for a given dataset. */ - fun list(datasetId: String): CompletableFuture = - list(datasetId, ComparativeListParams.none()) - - /** @see list */ - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - list(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see list */ - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - ): CompletableFuture = list(datasetId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: ComparativeListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list(params: ComparativeListParams): CompletableFuture = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - datasetId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - list(datasetId, ComparativeListParams.none(), requestOptions) - /** Delete a specific comparative experiment. */ fun delete(comparativeExperimentId: String): CompletableFuture = delete(comparativeExperimentId, ComparativeDeleteParams.none()) @@ -142,47 +105,6 @@ interface ComparativeServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/comparative`, but is - * otherwise the same as [ComparativeServiceAsync.list]. - */ - fun list(datasetId: String): CompletableFuture> = - list(datasetId, ComparativeListParams.none()) - - /** @see list */ - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - list(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see list */ - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - ): CompletableFuture> = - list(datasetId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: ComparativeListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: ComparativeListParams - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - datasetId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - list(datasetId, ComparativeListParams.none(), requestOptions) - /** * Returns a raw HTTP response for `delete * /api/v1/datasets/comparative/{comparative_experiment_id}`, but is otherwise the same as diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncImpl.kt index 93160b233..c8b46a49c 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncImpl.kt @@ -20,9 +20,6 @@ import com.langchain.smith.models.datasets.comparative.ComparativeCreateParams import com.langchain.smith.models.datasets.comparative.ComparativeCreateResponse import com.langchain.smith.models.datasets.comparative.ComparativeDeleteParams import com.langchain.smith.models.datasets.comparative.ComparativeDeleteResponse -import com.langchain.smith.models.datasets.comparative.ComparativeListPageAsync -import com.langchain.smith.models.datasets.comparative.ComparativeListParams -import com.langchain.smith.models.datasets.comparative.ComparativeListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -46,13 +43,6 @@ class ComparativeServiceAsyncImpl internal constructor(private val clientOptions // post /api/v1/datasets/comparative withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ComparativeListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v1/datasets/{dataset_id}/comparative - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( params: ComparativeDeleteParams, requestOptions: RequestOptions, @@ -104,47 +94,6 @@ class ComparativeServiceAsyncImpl internal constructor(private val clientOptions } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - - override fun list( - params: ComparativeListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("datasetId", params.datasetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "datasets", params._pathParam(0), "comparative") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } - } - } - .let { - ComparativeListPageAsync.builder() - .service(ComparativeServiceAsyncImpl(clientOptions)) - .streamHandlerExecutor(clientOptions.streamHandlerExecutor) - .params(params) - .items(it) - .build() - } - } - } - } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsync.kt deleted file mode 100644 index 527663876..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsync.kt +++ /dev/null @@ -1,191 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.services.async.datasets - -import com.langchain.smith.core.ClientOptions -import com.langchain.smith.core.RequestOptions -import com.langchain.smith.core.http.HttpResponseFor -import com.langchain.smith.models.datasets.index.IndexCreateParams -import com.langchain.smith.models.datasets.index.IndexCreateResponse -import com.langchain.smith.models.datasets.index.IndexSyncParams -import com.langchain.smith.models.datasets.index.IndexSyncResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface IndexServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): IndexServiceAsync - - /** Index a dataset. */ - fun create(datasetId: String): CompletableFuture = - create(datasetId, IndexCreateParams.none()) - - /** @see create */ - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - create(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see create */ - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - ): CompletableFuture = create(datasetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - params: IndexCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see create */ - fun create(params: IndexCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - datasetId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - create(datasetId, IndexCreateParams.none(), requestOptions) - - /** Sync an index for a dataset. */ - fun sync(datasetId: String): CompletableFuture = - sync(datasetId, IndexSyncParams.none()) - - /** @see sync */ - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see sync */ - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - ): CompletableFuture = sync(datasetId, params, RequestOptions.none()) - - /** @see sync */ - fun sync( - params: IndexSyncParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see sync */ - fun sync(params: IndexSyncParams): CompletableFuture = - sync(params, RequestOptions.none()) - - /** @see sync */ - fun sync( - datasetId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - sync(datasetId, IndexSyncParams.none(), requestOptions) - - /** A view of [IndexServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): IndexServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index`, but is - * otherwise the same as [IndexServiceAsync.create]. - */ - fun create(datasetId: String): CompletableFuture> = - create(datasetId, IndexCreateParams.none()) - - /** @see create */ - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - create(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see create */ - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - ): CompletableFuture> = - create(datasetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - params: IndexCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see create */ - fun create( - params: IndexCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - datasetId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - create(datasetId, IndexCreateParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index/sync`, but is - * otherwise the same as [IndexServiceAsync.sync]. - */ - fun sync(datasetId: String): CompletableFuture> = - sync(datasetId, IndexSyncParams.none()) - - /** @see sync */ - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see sync */ - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - ): CompletableFuture> = - sync(datasetId, params, RequestOptions.none()) - - /** @see sync */ - fun sync( - params: IndexSyncParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see sync */ - fun sync(params: IndexSyncParams): CompletableFuture> = - sync(params, RequestOptions.none()) - - /** @see sync */ - fun sync( - datasetId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - sync(datasetId, IndexSyncParams.none(), requestOptions) - } -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsyncImpl.kt deleted file mode 100644 index 0929a5675..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsyncImpl.kt +++ /dev/null @@ -1,134 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.services.async.datasets - -import com.langchain.smith.core.ClientOptions -import com.langchain.smith.core.RequestOptions -import com.langchain.smith.core.checkRequired -import com.langchain.smith.core.handlers.errorBodyHandler -import com.langchain.smith.core.handlers.errorHandler -import com.langchain.smith.core.handlers.jsonHandler -import com.langchain.smith.core.http.HttpMethod -import com.langchain.smith.core.http.HttpRequest -import com.langchain.smith.core.http.HttpResponse -import com.langchain.smith.core.http.HttpResponse.Handler -import com.langchain.smith.core.http.HttpResponseFor -import com.langchain.smith.core.http.json -import com.langchain.smith.core.http.parseable -import com.langchain.smith.core.prepareAsync -import com.langchain.smith.models.datasets.index.IndexCreateParams -import com.langchain.smith.models.datasets.index.IndexCreateResponse -import com.langchain.smith.models.datasets.index.IndexSyncParams -import com.langchain.smith.models.datasets.index.IndexSyncResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class IndexServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - IndexServiceAsync { - - private val withRawResponse: IndexServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): IndexServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): IndexServiceAsync = - IndexServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun create( - params: IndexCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /api/v1/datasets/{dataset_id}/index - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun sync( - params: IndexSyncParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /api/v1/datasets/{dataset_id}/index/sync - withRawResponse().sync(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - IndexServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): IndexServiceAsync.WithRawResponse = - IndexServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: IndexCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("datasetId", params.datasetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val syncHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun sync( - params: IndexSyncParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("datasetId", params.datasetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index", "sync") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { syncHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsync.kt index 09f8b983a..4c50fc842 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsync.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsync.kt @@ -5,8 +5,8 @@ package com.langchain.smith.services.async.datasets import com.langchain.smith.core.ClientOptions import com.langchain.smith.core.RequestOptions import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.models.datasets.runs.ExampleWithRunsCh import com.langchain.smith.models.datasets.runs.RunCreateParams -import com.langchain.smith.models.datasets.runs.RunCreateResponse import com.langchain.smith.models.datasets.runs.RunDeltaParams import com.langchain.smith.models.datasets.runs.SessionFeedbackDelta import java.util.Optional @@ -34,7 +34,7 @@ interface RunServiceAsync { fun create( datasetId: String, params: RunCreateParams, - ): CompletableFuture> = + ): CompletableFuture>> = create(datasetId, params, RequestOptions.none()) /** @see create */ @@ -42,18 +42,18 @@ interface RunServiceAsync { datasetId: String, params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture>> = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) /** @see create */ - fun create(params: RunCreateParams): CompletableFuture> = + fun create(params: RunCreateParams): CompletableFuture>> = create(params, RequestOptions.none()) /** @see create */ fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture>> /** * Fetch the number of regressions/improvements for each example in a dataset, between @@ -97,7 +97,7 @@ interface RunServiceAsync { fun create( datasetId: String, params: RunCreateParams, - ): CompletableFuture>> = + ): CompletableFuture>>> = create(datasetId, params, RequestOptions.none()) /** @see create */ @@ -105,20 +105,20 @@ interface RunServiceAsync { datasetId: String, params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> = + ): CompletableFuture>>> = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) /** @see create */ fun create( params: RunCreateParams - ): CompletableFuture>> = + ): CompletableFuture>>> = create(params, RequestOptions.none()) /** @see create */ fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture>>> /** * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/runs/delta`, but is diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncImpl.kt index 2907bd6e2..aed3f59a4 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/datasets/RunServiceAsyncImpl.kt @@ -16,8 +16,8 @@ import com.langchain.smith.core.http.HttpResponseFor import com.langchain.smith.core.http.json import com.langchain.smith.core.http.parseable import com.langchain.smith.core.prepareAsync +import com.langchain.smith.models.datasets.runs.ExampleWithRunsCh import com.langchain.smith.models.datasets.runs.RunCreateParams -import com.langchain.smith.models.datasets.runs.RunCreateResponse import com.langchain.smith.models.datasets.runs.RunDeltaParams import com.langchain.smith.models.datasets.runs.SessionFeedbackDelta import java.util.Optional @@ -40,7 +40,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client override fun create( params: RunCreateParams, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture>> = // post /api/v1/datasets/{dataset_id}/runs withRawResponse().create(params, requestOptions).thenApply { it.parse() } @@ -64,13 +64,13 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val createHandler: Handler>> = + jsonHandler>>(clientOptions.jsonMapper) override fun create( params: RunCreateParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture>>> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("datasetId", params.datasetId().getOrNull()) @@ -91,7 +91,7 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client .use { createHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } + it.ifPresent { it.forEach { it.validate() } } } } } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/runs/RuleServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/runs/RuleServiceAsync.kt new file mode 100644 index 000000000..142fa7b27 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/runs/RuleServiceAsync.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.async.runs + +import com.langchain.smith.core.ClientOptions +import java.util.function.Consumer + +interface RuleServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleServiceAsync + + /** A view of [RuleServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleServiceAsync.WithRawResponse + } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/runs/RuleServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/runs/RuleServiceAsyncImpl.kt new file mode 100644 index 000000000..405278850 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/runs/RuleServiceAsyncImpl.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.async.runs + +import com.langchain.smith.core.ClientOptions +import java.util.function.Consumer + +class RuleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RuleServiceAsync { + + private val withRawResponse: RuleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RuleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RuleServiceAsync = + RuleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RuleServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): RuleServiceAsync.WithRawResponse = + RuleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetService.kt index 3978fa201..111bbec21 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetService.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetService.kt @@ -32,7 +32,6 @@ import com.langchain.smith.models.datasets.DatasetVersion import com.langchain.smith.services.blocking.datasets.ComparativeService import com.langchain.smith.services.blocking.datasets.ExperimentService import com.langchain.smith.services.blocking.datasets.GroupService -import com.langchain.smith.services.blocking.datasets.IndexService import com.langchain.smith.services.blocking.datasets.PlaygroundExperimentService import com.langchain.smith.services.blocking.datasets.RunService import com.langchain.smith.services.blocking.datasets.ShareService @@ -68,8 +67,6 @@ interface DatasetService { fun splits(): SplitService - fun index(): IndexService - fun playgroundExperiment(): PlaygroundExperimentService /** Create a new dataset. */ @@ -424,8 +421,6 @@ interface DatasetService { fun splits(): SplitService.WithRawResponse - fun index(): IndexService.WithRawResponse - fun playgroundExperiment(): PlaygroundExperimentService.WithRawResponse /** diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetServiceImpl.kt index bd6bf3b31..a47ad31cd 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetServiceImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/DatasetServiceImpl.kt @@ -46,8 +46,6 @@ import com.langchain.smith.services.blocking.datasets.ExperimentService import com.langchain.smith.services.blocking.datasets.ExperimentServiceImpl import com.langchain.smith.services.blocking.datasets.GroupService import com.langchain.smith.services.blocking.datasets.GroupServiceImpl -import com.langchain.smith.services.blocking.datasets.IndexService -import com.langchain.smith.services.blocking.datasets.IndexServiceImpl import com.langchain.smith.services.blocking.datasets.PlaygroundExperimentService import com.langchain.smith.services.blocking.datasets.PlaygroundExperimentServiceImpl import com.langchain.smith.services.blocking.datasets.RunService @@ -82,8 +80,6 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO private val splits: SplitService by lazy { SplitServiceImpl(clientOptions) } - private val index: IndexService by lazy { IndexServiceImpl(clientOptions) } - private val playgroundExperiment: PlaygroundExperimentService by lazy { PlaygroundExperimentServiceImpl(clientOptions) } @@ -107,8 +103,6 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO override fun splits(): SplitService = splits - override fun index(): IndexService = index - override fun playgroundExperiment(): PlaygroundExperimentService = playgroundExperiment override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): Dataset = @@ -224,10 +218,6 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO SplitServiceImpl.WithRawResponseImpl(clientOptions) } - private val index: IndexService.WithRawResponse by lazy { - IndexServiceImpl.WithRawResponseImpl(clientOptions) - } - private val playgroundExperiment: PlaygroundExperimentService.WithRawResponse by lazy { PlaygroundExperimentServiceImpl.WithRawResponseImpl(clientOptions) } @@ -253,8 +243,6 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO override fun splits(): SplitService.WithRawResponse = splits - override fun index(): IndexService.WithRawResponse = index - override fun playgroundExperiment(): PlaygroundExperimentService.WithRawResponse = playgroundExperiment diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunService.kt index b40640a9c..65d3cb6c2 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunService.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunService.kt @@ -6,10 +6,23 @@ import com.google.errorprone.annotations.MustBeClosed import com.langchain.smith.core.ClientOptions import com.langchain.smith.core.RequestOptions import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.models.runs.Run +import com.langchain.smith.models.runs.RunCreateParams +import com.langchain.smith.models.runs.RunCreateResponse import com.langchain.smith.models.runs.RunIngestBatchParams import com.langchain.smith.models.runs.RunIngestBatchResponse import com.langchain.smith.models.runs.RunQueryParams import com.langchain.smith.models.runs.RunQueryResponse +import com.langchain.smith.models.runs.RunRetrieveParams +import com.langchain.smith.models.runs.RunSchema +import com.langchain.smith.models.runs.RunStatsParams +import com.langchain.smith.models.runs.RunStatsQueryParams +import com.langchain.smith.models.runs.RunStatsResponse +import com.langchain.smith.models.runs.RunUpdate2Params +import com.langchain.smith.models.runs.RunUpdate2Response +import com.langchain.smith.models.runs.RunUpdateParams +import com.langchain.smith.models.runs.RunUpdateResponse +import com.langchain.smith.services.blocking.runs.RuleService import java.util.function.Consumer interface RunService { @@ -26,6 +39,79 @@ interface RunService { */ fun withOptions(modifier: Consumer): RunService + fun rules(): RuleService + + /** + * Queues a single run for ingestion. The request body must be a JSON-encoded run object that + * follows the Run schema. + */ + fun create(params: RunCreateParams): RunCreateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunCreateResponse + + /** @see create */ + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunCreateResponse = create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + fun create(run: Run): RunCreateResponse = create(run, RequestOptions.none()) + + /** Get a specific run. */ + fun retrieve(runId: String): RunSchema = retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunSchema = retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(runId: String, params: RunRetrieveParams = RunRetrieveParams.none()): RunSchema = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunSchema + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): RunSchema = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(runId: String, requestOptions: RequestOptions): RunSchema = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** + * Updates a run identified by its ID. The body should contain only the fields to be changed; + * unknown fields are ignored. + */ + fun update(runId: String, params: RunUpdateParams): RunUpdateResponse = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse = update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): RunUpdateResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse + /** * Ingests a batch of runs in a single JSON payload. The payload must have `post` and/or `patch` * arrays containing run objects. Prefer this endpoint over single‑run ingestion when submitting @@ -66,6 +152,59 @@ interface RunService { fun query(requestOptions: RequestOptions): RunQueryResponse = query(RunQueryParams.none(), requestOptions) + /** Get all runs by query in body payload. */ + fun stats(params: RunStatsParams): RunStatsResponse = stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunStatsResponse + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunStatsResponse = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + fun stats(runStatsQueryParams: RunStatsQueryParams): RunStatsResponse = + stats(runStatsQueryParams, RequestOptions.none()) + + /** Update a run. */ + fun update2(runId: String): RunUpdate2Response = update2(runId, RunUpdate2Params.none()) + + /** @see update2 */ + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdate2Response = update2(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update2 */ + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + ): RunUpdate2Response = update2(runId, params, RequestOptions.none()) + + /** @see update2 */ + fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdate2Response + + /** @see update2 */ + fun update2(params: RunUpdate2Params): RunUpdate2Response = + update2(params, RequestOptions.none()) + + /** @see update2 */ + fun update2(runId: String, requestOptions: RequestOptions): RunUpdate2Response = + update2(runId, RunUpdate2Params.none(), requestOptions) + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -76,6 +215,106 @@ interface RunService { */ fun withOptions(modifier: Consumer): RunService.WithRawResponse + fun rules(): RuleService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /runs`, but is otherwise the same as + * [RunService.create]. + */ + @MustBeClosed + fun create(params: RunCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(run: Run): HttpResponseFor = + create(run, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/{run_id}`, but is otherwise the same as + * [RunService.retrieve]. + */ + @MustBeClosed + fun retrieve(runId: String): HttpResponseFor = + retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + ): HttpResponseFor = retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: RunRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(runId: String, requestOptions: RequestOptions): HttpResponseFor = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /runs/{run_id}`, but is otherwise the same as + * [RunService.update]. + */ + @MustBeClosed + fun update(runId: String, params: RunUpdateParams): HttpResponseFor = + update(runId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + runId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: RunUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `post /runs/batch`, but is otherwise the same as * [RunService.ingestBatch]. @@ -125,5 +364,80 @@ interface RunService { @MustBeClosed fun query(requestOptions: RequestOptions): HttpResponseFor = query(RunQueryParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/stats`, but is otherwise the same as + * [RunService.stats]. + */ + @MustBeClosed + fun stats(params: RunStatsParams): HttpResponseFor = + stats(params, RequestOptions.none()) + + /** @see stats */ + @MustBeClosed + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see stats */ + @MustBeClosed + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + @MustBeClosed + fun stats(runStatsQueryParams: RunStatsQueryParams): HttpResponseFor = + stats(runStatsQueryParams, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/runs/{run_id}`, but is otherwise the same + * as [RunService.update2]. + */ + @MustBeClosed + fun update2(runId: String): HttpResponseFor = + update2(runId, RunUpdate2Params.none()) + + /** @see update2 */ + @MustBeClosed + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update2(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update2 */ + @MustBeClosed + fun update2( + runId: String, + params: RunUpdate2Params = RunUpdate2Params.none(), + ): HttpResponseFor = update2(runId, params, RequestOptions.none()) + + /** @see update2 */ + @MustBeClosed + fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update2 */ + @MustBeClosed + fun update2(params: RunUpdate2Params): HttpResponseFor = + update2(params, RequestOptions.none()) + + /** @see update2 */ + @MustBeClosed + fun update2( + runId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update2(runId, RunUpdate2Params.none(), requestOptions) } } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunServiceImpl.kt index 4656be03e..e7f46c62c 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunServiceImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/RunServiceImpl.kt @@ -4,6 +4,7 @@ package com.langchain.smith.services.blocking import com.langchain.smith.core.ClientOptions import com.langchain.smith.core.RequestOptions +import com.langchain.smith.core.checkRequired import com.langchain.smith.core.handlers.errorBodyHandler import com.langchain.smith.core.handlers.errorHandler import com.langchain.smith.core.handlers.jsonHandler @@ -15,11 +16,24 @@ import com.langchain.smith.core.http.HttpResponseFor import com.langchain.smith.core.http.json import com.langchain.smith.core.http.parseable import com.langchain.smith.core.prepare +import com.langchain.smith.models.runs.RunCreateParams +import com.langchain.smith.models.runs.RunCreateResponse import com.langchain.smith.models.runs.RunIngestBatchParams import com.langchain.smith.models.runs.RunIngestBatchResponse import com.langchain.smith.models.runs.RunQueryParams import com.langchain.smith.models.runs.RunQueryResponse +import com.langchain.smith.models.runs.RunRetrieveParams +import com.langchain.smith.models.runs.RunSchema +import com.langchain.smith.models.runs.RunStatsParams +import com.langchain.smith.models.runs.RunStatsResponse +import com.langchain.smith.models.runs.RunUpdate2Params +import com.langchain.smith.models.runs.RunUpdate2Response +import com.langchain.smith.models.runs.RunUpdateParams +import com.langchain.smith.models.runs.RunUpdateResponse +import com.langchain.smith.services.blocking.runs.RuleService +import com.langchain.smith.services.blocking.runs.RuleServiceImpl import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { @@ -27,11 +41,33 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio WithRawResponseImpl(clientOptions) } + private val rules: RuleService by lazy { RuleServiceImpl(clientOptions) } + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): RunService = RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun rules(): RuleService = rules + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): RunCreateResponse = + // post /runs + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: RunRetrieveParams, requestOptions: RequestOptions): RunSchema = + // get /api/v1/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): RunUpdateResponse = + // patch /runs/{run_id} + withRawResponse().update(params, requestOptions).parse() + override fun ingestBatch( params: RunIngestBatchParams, requestOptions: RequestOptions, @@ -43,12 +79,27 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio // post /api/v1/runs/query withRawResponse().query(params, requestOptions).parse() + override fun stats(params: RunStatsParams, requestOptions: RequestOptions): RunStatsResponse = + // post /api/v1/runs/stats + withRawResponse().stats(params, requestOptions).parse() + + override fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions, + ): RunUpdate2Response = + // patch /api/v1/runs/{run_id} + withRawResponse().update2(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RunService.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val rules: RuleService.WithRawResponse by lazy { + RuleServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): RunService.WithRawResponse = @@ -56,6 +107,97 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio clientOptions.toBuilder().apply(modifier::accept).build() ) + override fun rules(): RuleService.WithRawResponse = rules + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val ingestBatchHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -111,5 +253,64 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio } } } + + private val statsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "stats") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val update2Handler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update2( + params: RunUpdate2Params, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { update2Handler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeService.kt index a0aa46df0..153b8b1ed 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeService.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeService.kt @@ -10,8 +10,6 @@ import com.langchain.smith.models.datasets.comparative.ComparativeCreateParams import com.langchain.smith.models.datasets.comparative.ComparativeCreateResponse import com.langchain.smith.models.datasets.comparative.ComparativeDeleteParams import com.langchain.smith.models.datasets.comparative.ComparativeDeleteResponse -import com.langchain.smith.models.datasets.comparative.ComparativeListPage -import com.langchain.smith.models.datasets.comparative.ComparativeListParams import java.util.function.Consumer interface ComparativeService { @@ -38,36 +36,6 @@ interface ComparativeService { requestOptions: RequestOptions = RequestOptions.none(), ): ComparativeCreateResponse - /** Get all comparative experiments for a given dataset. */ - fun list(datasetId: String): ComparativeListPage = list(datasetId, ComparativeListParams.none()) - - /** @see list */ - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ComparativeListPage = list(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see list */ - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - ): ComparativeListPage = list(datasetId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: ComparativeListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ComparativeListPage - - /** @see list */ - fun list(params: ComparativeListParams): ComparativeListPage = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(datasetId: String, requestOptions: RequestOptions): ComparativeListPage = - list(datasetId, ComparativeListParams.none(), requestOptions) - /** Delete a specific comparative experiment. */ fun delete(comparativeExperimentId: String): ComparativeDeleteResponse = delete(comparativeExperimentId, ComparativeDeleteParams.none()) @@ -135,50 +103,6 @@ interface ComparativeService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/comparative`, but is - * otherwise the same as [ComparativeService.list]. - */ - @MustBeClosed - fun list(datasetId: String): HttpResponseFor = - list(datasetId, ComparativeListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - list(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see list */ - @MustBeClosed - fun list( - datasetId: String, - params: ComparativeListParams = ComparativeListParams.none(), - ): HttpResponseFor = list(datasetId, params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: ComparativeListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list(params: ComparativeListParams): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - datasetId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - list(datasetId, ComparativeListParams.none(), requestOptions) - /** * Returns a raw HTTP response for `delete * /api/v1/datasets/comparative/{comparative_experiment_id}`, but is otherwise the same as diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceImpl.kt index 5242ffb8d..fa9fefba9 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceImpl.kt @@ -20,9 +20,6 @@ import com.langchain.smith.models.datasets.comparative.ComparativeCreateParams import com.langchain.smith.models.datasets.comparative.ComparativeCreateResponse import com.langchain.smith.models.datasets.comparative.ComparativeDeleteParams import com.langchain.smith.models.datasets.comparative.ComparativeDeleteResponse -import com.langchain.smith.models.datasets.comparative.ComparativeListPage -import com.langchain.smith.models.datasets.comparative.ComparativeListParams -import com.langchain.smith.models.datasets.comparative.ComparativeListResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -45,13 +42,6 @@ class ComparativeServiceImpl internal constructor(private val clientOptions: Cli // post /api/v1/datasets/comparative withRawResponse().create(params, requestOptions).parse() - override fun list( - params: ComparativeListParams, - requestOptions: RequestOptions, - ): ComparativeListPage = - // get /api/v1/datasets/{dataset_id}/comparative - withRawResponse().list(params, requestOptions).parse() - override fun delete( params: ComparativeDeleteParams, requestOptions: RequestOptions, @@ -100,43 +90,6 @@ class ComparativeServiceImpl internal constructor(private val clientOptions: Cli } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - - override fun list( - params: ComparativeListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("datasetId", params.datasetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "datasets", params._pathParam(0), "comparative") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } - } - } - .let { - ComparativeListPage.builder() - .service(ComparativeServiceImpl(clientOptions)) - .params(params) - .items(it) - .build() - } - } - } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/IndexService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/IndexService.kt deleted file mode 100644 index 0b4391575..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/IndexService.kt +++ /dev/null @@ -1,186 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.services.blocking.datasets - -import com.google.errorprone.annotations.MustBeClosed -import com.langchain.smith.core.ClientOptions -import com.langchain.smith.core.RequestOptions -import com.langchain.smith.core.http.HttpResponseFor -import com.langchain.smith.models.datasets.index.IndexCreateParams -import com.langchain.smith.models.datasets.index.IndexCreateResponse -import com.langchain.smith.models.datasets.index.IndexSyncParams -import com.langchain.smith.models.datasets.index.IndexSyncResponse -import java.util.function.Consumer - -interface IndexService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): IndexService - - /** Index a dataset. */ - fun create(datasetId: String): IndexCreateResponse = create(datasetId, IndexCreateParams.none()) - - /** @see create */ - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): IndexCreateResponse = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see create */ - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - ): IndexCreateResponse = create(datasetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - params: IndexCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): IndexCreateResponse - - /** @see create */ - fun create(params: IndexCreateParams): IndexCreateResponse = - create(params, RequestOptions.none()) - - /** @see create */ - fun create(datasetId: String, requestOptions: RequestOptions): IndexCreateResponse = - create(datasetId, IndexCreateParams.none(), requestOptions) - - /** Sync an index for a dataset. */ - fun sync(datasetId: String): IndexSyncResponse = sync(datasetId, IndexSyncParams.none()) - - /** @see sync */ - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): IndexSyncResponse = sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see sync */ - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - ): IndexSyncResponse = sync(datasetId, params, RequestOptions.none()) - - /** @see sync */ - fun sync( - params: IndexSyncParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): IndexSyncResponse - - /** @see sync */ - fun sync(params: IndexSyncParams): IndexSyncResponse = sync(params, RequestOptions.none()) - - /** @see sync */ - fun sync(datasetId: String, requestOptions: RequestOptions): IndexSyncResponse = - sync(datasetId, IndexSyncParams.none(), requestOptions) - - /** A view of [IndexService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): IndexService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index`, but is - * otherwise the same as [IndexService.create]. - */ - @MustBeClosed - fun create(datasetId: String): HttpResponseFor = - create(datasetId, IndexCreateParams.none()) - - /** @see create */ - @MustBeClosed - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - create(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see create */ - @MustBeClosed - fun create( - datasetId: String, - params: IndexCreateParams = IndexCreateParams.none(), - ): HttpResponseFor = create(datasetId, params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: IndexCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see create */ - @MustBeClosed - fun create(params: IndexCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - datasetId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - create(datasetId, IndexCreateParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index/sync`, but is - * otherwise the same as [IndexService.sync]. - */ - @MustBeClosed - fun sync(datasetId: String): HttpResponseFor = - sync(datasetId, IndexSyncParams.none()) - - /** @see sync */ - @MustBeClosed - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) - - /** @see sync */ - @MustBeClosed - fun sync( - datasetId: String, - params: IndexSyncParams = IndexSyncParams.none(), - ): HttpResponseFor = sync(datasetId, params, RequestOptions.none()) - - /** @see sync */ - @MustBeClosed - fun sync( - params: IndexSyncParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see sync */ - @MustBeClosed - fun sync(params: IndexSyncParams): HttpResponseFor = - sync(params, RequestOptions.none()) - - /** @see sync */ - @MustBeClosed - fun sync( - datasetId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - sync(datasetId, IndexSyncParams.none(), requestOptions) - } -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/IndexServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/IndexServiceImpl.kt deleted file mode 100644 index bc346f23d..000000000 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/IndexServiceImpl.kt +++ /dev/null @@ -1,124 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.services.blocking.datasets - -import com.langchain.smith.core.ClientOptions -import com.langchain.smith.core.RequestOptions -import com.langchain.smith.core.checkRequired -import com.langchain.smith.core.handlers.errorBodyHandler -import com.langchain.smith.core.handlers.errorHandler -import com.langchain.smith.core.handlers.jsonHandler -import com.langchain.smith.core.http.HttpMethod -import com.langchain.smith.core.http.HttpRequest -import com.langchain.smith.core.http.HttpResponse -import com.langchain.smith.core.http.HttpResponse.Handler -import com.langchain.smith.core.http.HttpResponseFor -import com.langchain.smith.core.http.json -import com.langchain.smith.core.http.parseable -import com.langchain.smith.core.prepare -import com.langchain.smith.models.datasets.index.IndexCreateParams -import com.langchain.smith.models.datasets.index.IndexCreateResponse -import com.langchain.smith.models.datasets.index.IndexSyncParams -import com.langchain.smith.models.datasets.index.IndexSyncResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class IndexServiceImpl internal constructor(private val clientOptions: ClientOptions) : - IndexService { - - private val withRawResponse: IndexService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): IndexService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): IndexService = - IndexServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun create( - params: IndexCreateParams, - requestOptions: RequestOptions, - ): IndexCreateResponse = - // post /api/v1/datasets/{dataset_id}/index - withRawResponse().create(params, requestOptions).parse() - - override fun sync(params: IndexSyncParams, requestOptions: RequestOptions): IndexSyncResponse = - // post /api/v1/datasets/{dataset_id}/index/sync - withRawResponse().sync(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - IndexService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): IndexService.WithRawResponse = - IndexServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: IndexCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("datasetId", params.datasetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val syncHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun sync( - params: IndexSyncParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("datasetId", params.datasetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index", "sync") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { syncHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunService.kt index e1a462fbf..9c96e7879 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunService.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunService.kt @@ -6,8 +6,8 @@ import com.google.errorprone.annotations.MustBeClosed import com.langchain.smith.core.ClientOptions import com.langchain.smith.core.RequestOptions import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.models.datasets.runs.ExampleWithRunsCh import com.langchain.smith.models.datasets.runs.RunCreateParams -import com.langchain.smith.models.datasets.runs.RunCreateResponse import com.langchain.smith.models.datasets.runs.RunDeltaParams import com.langchain.smith.models.datasets.runs.SessionFeedbackDelta import java.util.Optional @@ -31,7 +31,7 @@ interface RunService { * Fetch examples for a dataset, and fetch the runs for each example if they are associated with * the given session_ids. */ - fun create(datasetId: String, params: RunCreateParams): Optional = + fun create(datasetId: String, params: RunCreateParams): Optional> = create(datasetId, params, RequestOptions.none()) /** @see create */ @@ -39,18 +39,18 @@ interface RunService { datasetId: String, params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Optional = + ): Optional> = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) /** @see create */ - fun create(params: RunCreateParams): Optional = + fun create(params: RunCreateParams): Optional> = create(params, RequestOptions.none()) /** @see create */ fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Optional + ): Optional> /** * Fetch the number of regressions/improvements for each example in a dataset, between @@ -93,7 +93,7 @@ interface RunService { fun create( datasetId: String, params: RunCreateParams, - ): HttpResponseFor> = + ): HttpResponseFor>> = create(datasetId, params, RequestOptions.none()) /** @see create */ @@ -102,12 +102,12 @@ interface RunService { datasetId: String, params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> = + ): HttpResponseFor>> = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) /** @see create */ @MustBeClosed - fun create(params: RunCreateParams): HttpResponseFor> = + fun create(params: RunCreateParams): HttpResponseFor>> = create(params, RequestOptions.none()) /** @see create */ @@ -115,7 +115,7 @@ interface RunService { fun create( params: RunCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor>> /** * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/runs/delta`, but is diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceImpl.kt index 142e6b11e..4a2f886dd 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/datasets/RunServiceImpl.kt @@ -16,8 +16,8 @@ import com.langchain.smith.core.http.HttpResponseFor import com.langchain.smith.core.http.json import com.langchain.smith.core.http.parseable import com.langchain.smith.core.prepare +import com.langchain.smith.models.datasets.runs.ExampleWithRunsCh import com.langchain.smith.models.datasets.runs.RunCreateParams -import com.langchain.smith.models.datasets.runs.RunCreateResponse import com.langchain.smith.models.datasets.runs.RunDeltaParams import com.langchain.smith.models.datasets.runs.SessionFeedbackDelta import java.util.Optional @@ -38,7 +38,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio override fun create( params: RunCreateParams, requestOptions: RequestOptions, - ): Optional = + ): Optional> = // post /api/v1/datasets/{dataset_id}/runs withRawResponse().create(params, requestOptions).parse() @@ -62,13 +62,13 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val createHandler: Handler>> = + jsonHandler>>(clientOptions.jsonMapper) override fun create( params: RunCreateParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor>> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("datasetId", params.datasetId().getOrNull()) @@ -87,7 +87,7 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio .use { createHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } + it.ifPresent { it.forEach { it.validate() } } } } } diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/runs/RuleService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/runs/RuleService.kt new file mode 100644 index 000000000..2695fcb0f --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/runs/RuleService.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.blocking.runs + +import com.langchain.smith.core.ClientOptions +import java.util.function.Consumer + +interface RuleService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleService + + /** A view of [RuleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleService.WithRawResponse + } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/runs/RuleServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/runs/RuleServiceImpl.kt new file mode 100644 index 000000000..1d01f91fc --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/runs/RuleServiceImpl.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.blocking.runs + +import com.langchain.smith.core.ClientOptions +import java.util.function.Consumer + +class RuleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RuleService { + + private val withRawResponse: RuleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RuleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RuleService = + RuleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RuleService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): RuleService.WithRawResponse = + RuleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/ClientOptionsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/ClientOptionsTest.kt index f3853599a..9b96db862 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/ClientOptionsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/ClientOptionsTest.kt @@ -16,6 +16,35 @@ internal class ClientOptionsTest { private val httpClient = mock() + @Test + fun putHeader_canOverwriteDefaultHeader() { + val clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .putHeader("User-Agent", "My User Agent") + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + + assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") + } + + @Test + fun toBuilder_apiKeyCanBeUpdated() { + var clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + + clientOptions = clientOptions.toBuilder().apiKey("another My API Key").build() + + assertThat(clientOptions.headers.values("X-API-Key")).containsExactly("another My API Key") + } + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/HttpRequestBodiesTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/HttpRequestBodiesTest.kt new file mode 100644 index 000000000..5c3f7a668 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/HttpRequestBodiesTest.kt @@ -0,0 +1,729 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.core.http + +import com.langchain.smith.core.MultipartField +import com.langchain.smith.core.jsonMapper +import java.io.ByteArrayOutputStream +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HttpRequestBodiesTest { + + @Test + fun multipartFormData_serializesFieldWithFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "file" to + MultipartField.builder() + .value("hello") + .filename("hello.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = body.contentType()!!.substringAfter("multipart/form-data; boundary=") + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="file"; filename="hello.txt" + |Content-Type: text/plain + | + |hello + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesFieldWithoutFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("value") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStream() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "stream content".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |stream content + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesByteArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "binary" to + MultipartField.builder() + .value("abc".toByteArray()) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="binary" + |Content-Type: application/octet-stream + | + |abc + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesBooleanValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "flag" to + MultipartField.builder() + .value(true) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="flag" + |Content-Type: text/plain + | + |true + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNumberValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "count" to + MultipartField.builder().value(42).contentType("text/plain").build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="count" + |Content-Type: text/plain + | + |42 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNullValueAsNoParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "present" to + MultipartField.builder() + .value("yes") + .contentType("text/plain") + .build(), + "absent" to + MultipartField.builder() + .value(null as String?) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="present" + |Content-Type: text/plain + | + |yes + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "items" to + MultipartField.builder>() + .value(listOf("alpha", "beta", "gamma")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="items" + |Content-Type: text/plain + | + |alpha,beta,gamma + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesObjectAsNestedParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "meta" to + MultipartField.builder>() + .value(mapOf("key1" to "val1", "key2" to "val2")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="meta[key1]" + |Content-Type: text/plain + | + |val1 + |--$boundary + |Content-Disposition: form-data; name="meta[key2]" + |Content-Type: text/plain + | + |val2 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesMultipleFields() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "name" to + MultipartField.builder() + .value("Alice") + .contentType("text/plain") + .build(), + "age" to + MultipartField.builder().value(30).contentType("text/plain").build(), + "file" to + MultipartField.builder() + .value("file contents") + .filename("doc.txt") + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="name" + |Content-Type: text/plain + | + |Alice + |--$boundary + |Content-Disposition: form-data; name="age" + |Content-Type: text/plain + | + |30 + |--$boundary + |Content-Disposition: form-data; name="file"; filename="doc.txt" + |Content-Type: text/plain + | + |file contents + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_quotesSpecialCharactersInNameAndFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field\nname" to + MultipartField.builder() + .value("value") + .filename("file\r\"name.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field%0Aname"; filename="file%0D%22name.txt" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_writeIsRepeatable() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("repeatable") + .contentType("text/plain") + .build() + ), + ) + + val output1 = ByteArrayOutputStream() + body.writeTo(output1) + val output2 = ByteArrayOutputStream() + body.writeTo(output2) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output1.size().toLong()) + val boundary = boundary(body) + val expected = + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |repeatable + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + assertThat(output1.toString("UTF-8")).isEqualTo(expected) + assertThat(output2.toString("UTF-8")).isEqualTo(expected) + } + + @Test + fun multipartFormData_serializesByteArrayInputStream() { + // ByteArrayInputStream is specifically handled as repeatable with known content length. + val inputStream = "byte array stream".byteInputStream() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |byte array stream + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStreamWithFilename() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "file data".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "upload" to + MultipartField.builder() + .value(inputStream) + .filename("upload.bin") + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="upload"; filename="upload.bin" + |Content-Type: application/octet-stream + | + |file data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNestedArrayInObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder>>() + .value(mapOf("tags" to listOf("a", "b"))) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data[tags]" + |Content-Type: text/plain + | + |a,b + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_contentLengthIsUnknownWhenInputStreamPresent() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "text" to + MultipartField.builder() + .value("hello") + .contentType("text/plain") + .build(), + "stream" to + MultipartField.builder() + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the + // non-repeatable code path. + .value("data".byteInputStream().buffered()) + .contentType("application/octet-stream") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="text" + |Content-Type: text/plain + | + |hello + |--$boundary + |Content-Disposition: form-data; name="stream" + |Content-Type: application/octet-stream + | + |data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "items" to + MultipartField.builder>() + .value(emptyList()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary + |Content-Disposition: form-data; name="items" + |Content-Type: text/plain + | + | + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "meta" to + MultipartField.builder>() + .value(emptyMap()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + private fun boundary(body: HttpRequestBody): String = + body.contentType()!!.substringAfter("multipart/form-data; boundary=") +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/RetryingHttpClientTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/RetryingHttpClientTest.kt index 829e34ee1..de88cd40d 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/RetryingHttpClientTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/core/http/RetryingHttpClientTest.kt @@ -1,6 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package com.langchain.smith.core.http -import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matching +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.resetAllScenarios +import com.github.tomakehurst.wiremock.client.WireMock.serviceUnavailable +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario @@ -9,7 +20,11 @@ import com.langchain.smith.core.RequestOptions import com.langchain.smith.core.Sleeper import com.langchain.smith.errors.LangChainRetryableException import java.io.InputStream +import java.time.Clock import java.time.Duration +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -25,6 +40,21 @@ internal class RetryingHttpClientTest { private lateinit var baseUrl: String private lateinit var httpClient: HttpClient + private class RecordingSleeper : Sleeper { + val durations = mutableListOf() + + override fun sleep(duration: Duration) { + durations.add(duration) + } + + override fun sleepAsync(duration: Duration): CompletableFuture { + durations.add(duration) + return CompletableFuture.completedFuture(null) + } + + override fun close() {} + } + @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { baseUrl = wmRuntimeInfo.httpBaseUrl @@ -75,7 +105,8 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = retryingHttpClientBuilder().build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).build() val response = retryingClient.execute( @@ -89,6 +120,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @@ -100,8 +132,12 @@ internal class RetryingHttpClientTest { .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) + val sleeper = RecordingSleeper() val retryingClient = - retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + retryingHttpClientBuilder(sleeper) + .maxRetries(2) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute( @@ -115,20 +151,20 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withRetryAfterHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) // First we fail with a retry after header given as a date .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -147,7 +183,13 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + // Fix the clock to 5 seconds before the Retry-After date so the date-based backoff is + // deterministic. + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -175,19 +217,20 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertThat(sleeper.durations) + .containsExactly(Duration.ofSeconds(5), Duration.ofMillis(1234)) assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -197,7 +240,11 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -216,6 +263,7 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertThat(sleeper.durations).containsExactly(Duration.ofSeconds(5)) assertNoResponseLeaks() } @@ -236,7 +284,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() val response = retryingClient.execute( @@ -250,6 +299,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(10)) assertNoResponseLeaks() } @@ -290,21 +340,12 @@ internal class RetryingHttpClientTest { override fun close() = httpClient.close() } + val sleeper = RecordingSleeper() val retryingClient = RetryingHttpClient.builder() .httpClient(failingHttpClient) .maxRetries(2) - .sleeper( - object : Sleeper { - - override fun sleep(duration: Duration) {} - - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) - - override fun close() {} - } - ) + .sleeper(sleeper) .build() val response = @@ -328,25 +369,155 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("0")), ) + // Exponential backoff with jitter: 0.5s * jitter where jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoff(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(3).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + // All retries exhausted; the last 503 response is returned. + assertThat(response.statusCode()).isEqualTo(503) + verify(4, postRequestedFor(urlPathEqualTo("/something"))) + // Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 16) * jitter where + // jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(3) + // retries=1: 0.5s * [0.75, 1.0] + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + // retries=2: 1s * [0.75, 1.0] + assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) + // retries=3: 2s * [0.75, 1.0] + assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) assertNoResponseLeaks() } - private fun retryingHttpClientBuilder() = - RetryingHttpClient.builder() - .httpClient(httpClient) - // Use a no-op `Sleeper` to make the test fast. - .sleeper( - object : Sleeper { + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoffCap(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(7).build() - override fun sleep(duration: Duration) {} + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) + assertThat(response.statusCode()).isEqualTo(503) + verify(8, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).hasSize(7) + // retries=6: backoff hits the 16s cap * [0.75, 1.0] + assertThat(sleeper.durations[5]) + .isBetween(Duration.ofMillis(12000), Duration.ofMillis(16000)) + // retries=7: still capped at 16s * [0.75, 1.0] + assertThat(sleeper.durations[6]) + .isBetween(Duration.ofMillis(12000), Duration.ofMillis(16000)) + assertNoResponseLeaks() + } - override fun close() {} - } + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsPriorityOverRetryAfter(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable() + .withHeader("Retry-After-Ms", "50") + .withHeader("Retry-After", "2") + ) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Retry-After-Ms (50ms) takes priority over Retry-After (2s). + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(50)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterUnparseable(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After", "not-a-date-or-number")) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, ) + assertThat(response.statusCode()).isEqualTo(200) + // Unparseable Retry-After falls through to exponential backoff. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder( + sleeper: RecordingSleeper, + clock: Clock = Clock.systemUTC(), + ) = RetryingHttpClient.builder().httpClient(httpClient).sleeper(sleeper).clock(clock) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) executeAsync(request).get() else execute(request) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/errors/ServiceExceptionErrorMessageTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/errors/ServiceExceptionErrorMessageTest.kt new file mode 100644 index 000000000..bfa2a7e05 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/errors/ServiceExceptionErrorMessageTest.kt @@ -0,0 +1,60 @@ +package com.langchain.smith.errors + +import com.langchain.smith.client.okhttp.LangsmithOkHttpClient +import com.langchain.smith.models.runs.Run +import com.langchain.smith.models.runs.RunIngestBatchParams +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy +import org.junit.jupiter.api.Assumptions.assumeTrue +import org.junit.jupiter.api.Test + +/** + * Verifies that service exception error messages contain the actual API error body rather than + * opaque strings like `[object Object]`. + * + * Run with: + * ```bash + * ./gradlew :langsmith-java-core:test --tests "com.langchain.smith.errors.ServiceExceptionErrorMessageTest" + * ``` + */ +internal class ServiceExceptionErrorMessageTest { + + @Test + fun forbiddenErrorContainsDetail() { + val client = LangsmithOkHttpClient.builder().apiKey("ls-invalid-key").build() + + assertThatThrownBy { client.runs().ingestBatch() } + .isInstanceOf(PermissionDeniedException::class.java) + .satisfies({ e -> + val message = e.message ?: "" + assertThat(message).startsWith("403:") + assertThat(message).doesNotContain("[object Object]") + assertThat(message).contains("Forbidden") + }) + } + + @Test + fun badRequestErrorContainsDetail() { + assumeTrue( + !System.getenv("LANGSMITH_API_KEY").isNullOrBlank(), + "Skipping: LANGSMITH_API_KEY must be set", + ) + val client = LangsmithOkHttpClient.fromEnv() + + val params = + RunIngestBatchParams.builder() + .addPost( + Run.builder().id("not-a-uuid").name("test").runType(Run.RunType.CHAIN).build() + ) + .build() + + assertThatThrownBy { client.runs().ingestBatch(params) } + .isInstanceOf(UnprocessableEntityException::class.java) + .satisfies({ e -> + val message = e.message ?: "" + assertThat(message).startsWith("422:") + assertThat(message).doesNotContain("[object Object]") + assertThat(message).contains("error") + }) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParamsTest.kt index 70a5d9aee..da2d4f9bf 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueExportParamsTest.kt @@ -13,6 +13,7 @@ internal class AnnotationQueueExportParamsTest { AnnotationQueueExportParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .includeAnnotatorDetail(true) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() } @@ -35,12 +36,14 @@ internal class AnnotationQueueExportParamsTest { AnnotationQueueExportParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .includeAnnotatorDetail(true) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val body = params._body() assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.includeAnnotatorDetail()).contains(true) assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt index 845fab65b..5f1275635 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt @@ -2,6 +2,7 @@ package com.langchain.smith.models.annotationqueues +import com.langchain.smith.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,6 +12,7 @@ internal class AnnotationQueueRetrieveSizeParamsTest { fun create() { AnnotationQueueRetrieveSizeParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(AnnotationQueueRetrieveSizeParams.Status.NEEDS_MY_REVIEW) .build() } @@ -25,4 +27,30 @@ internal class AnnotationQueueRetrieveSizeParamsTest { // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } + + @Test + fun queryParams() { + val params = + AnnotationQueueRetrieveSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(AnnotationQueueRetrieveSizeParams.Status.NEEDS_MY_REVIEW) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("status", "needs_my_review").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + AnnotationQueueRetrieveSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt index 92fac6898..d0fad5894 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt @@ -5,6 +5,7 @@ package com.langchain.smith.models.annotationqueues import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.langchain.smith.core.JsonValue import com.langchain.smith.core.jsonMapper +import com.langchain.smith.models.runs.RunTypeEnum import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -21,7 +22,7 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .dottedOrder("dotted_order") .name("name") .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .runType(RunSchemaWithAnnotationQueueInfo.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -140,8 +141,7 @@ internal class RunSchemaWithAnnotationQueueInfoTest { assertThat(runSchemaWithAnnotationQueueInfo.name()).isEqualTo("name") assertThat(runSchemaWithAnnotationQueueInfo.queueRunId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(runSchemaWithAnnotationQueueInfo.runType()) - .isEqualTo(RunSchemaWithAnnotationQueueInfo.RunType.TOOL) + assertThat(runSchemaWithAnnotationQueueInfo.runType()).isEqualTo(RunTypeEnum.TOOL) assertThat(runSchemaWithAnnotationQueueInfo.sessionId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(runSchemaWithAnnotationQueueInfo.status()).isEqualTo("status") @@ -300,7 +300,7 @@ internal class RunSchemaWithAnnotationQueueInfoTest { .dottedOrder("dotted_order") .name("name") .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .runType(RunSchemaWithAnnotationQueueInfo.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponseTest.kt index b62bc5e96..083bc5f58 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/info/InfoListResponseTest.kt @@ -32,6 +32,7 @@ internal class InfoListResponseTest { .customerName("customer_name") .build() ) + .gitSha("git_sha") .instanceFlags( InfoListResponse.InstanceFlags.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) @@ -59,6 +60,7 @@ internal class InfoListResponseTest { .customerName("customer_name") .build() ) + assertThat(infoListResponse.gitSha()).contains("git_sha") assertThat(infoListResponse.instanceFlags()) .contains( InfoListResponse.InstanceFlags.builder() @@ -91,6 +93,7 @@ internal class InfoListResponseTest { .customerName("customer_name") .build() ) + .gitSha("git_sha") .instanceFlags( InfoListResponse.InstanceFlags.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParamsTest.kt index d53de77ee..7b0c704ce 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/runs/RunListParamsTest.kt @@ -16,6 +16,7 @@ internal class RunListParamsTest { .includeStats(true) .limit(1L) .offset(0L) + .status(RunListParams.Status.NEEDS_MY_REVIEW) .build() } @@ -37,6 +38,7 @@ internal class RunListParamsTest { .includeStats(true) .limit(1L) .offset(0L) + .status(RunListParams.Status.NEEDS_MY_REVIEW) .build() val queryParams = params._queryParams() @@ -48,6 +50,7 @@ internal class RunListParamsTest { .put("include_stats", "true") .put("limit", "1") .put("offset", "0") + .put("status", "needs_my_review") .build() ) } 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 47ca2d46e..3ef1b4b53 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 @@ -16,6 +16,7 @@ internal class CommitListParamsTest { .includeStats(true) .limit(1L) .offset(0L) + .tag("tag") .build() } @@ -38,6 +39,7 @@ internal class CommitListParamsTest { .includeStats(true) .limit(1L) .offset(0L) + .tag("tag") .build() val queryParams = params._queryParams() @@ -48,6 +50,7 @@ internal class CommitListParamsTest { .put("include_stats", "true") .put("limit", "1") .put("offset", "0") + .put("tag", "tag") .build() ) } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponseTest.kt index fc5c998c5..b1b877fda 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/commits/CommitRetrieveResponseTest.kt @@ -26,6 +26,8 @@ internal class CommitRetrieveResponseTest { .build() ) .manifest(JsonValue.from(mapOf())) + .modelConfig(JsonValue.from(mapOf())) + .modelProvider("model_provider") .build() assertThat(commitRetrieveResponse.commitHash()).contains("commit_hash") @@ -41,6 +43,9 @@ internal class CommitRetrieveResponseTest { ) assertThat(commitRetrieveResponse._manifest()) .isEqualTo(JsonValue.from(mapOf())) + assertThat(commitRetrieveResponse._modelConfig()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(commitRetrieveResponse.modelProvider()).contains("model_provider") } @Test @@ -59,6 +64,8 @@ internal class CommitRetrieveResponseTest { .build() ) .manifest(JsonValue.from(mapOf())) + .modelConfig(JsonValue.from(mapOf())) + .modelProvider("model_provider") .build() val roundtrippedCommitRetrieveResponse = diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUploadParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUploadParamsTest.kt index f9a0a8d46..835e74238 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUploadParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/DatasetUploadParamsTest.kt @@ -12,7 +12,7 @@ internal class DatasetUploadParamsTest { @Test fun create() { DatasetUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .dataType(DataType.KV) .description("description") @@ -32,7 +32,7 @@ internal class DatasetUploadParamsTest { fun body() { val params = DatasetUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .dataType(DataType.KV) .description("description") @@ -59,7 +59,7 @@ internal class DatasetUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "input_keys" to MultipartField.of(listOf("string")), "data_type" to MultipartField.of(DataType.KV), "description" to MultipartField.of("description"), @@ -84,7 +84,7 @@ internal class DatasetUploadParamsTest { fun bodyWithoutOptionalFields() { val params = DatasetUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .build() @@ -100,7 +100,7 @@ internal class DatasetUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "input_keys" to MultipartField.of(listOf("string")), ) .mapValues { (_, field) -> diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListParamsTest.kt deleted file mode 100644 index bab2a8751..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListParamsTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.comparative - -import com.langchain.smith.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ComparativeListParamsTest { - - @Test - fun create() { - ComparativeListParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(1L) - .name("name") - .nameContains("name_contains") - .offset(0L) - .sortBy(SortByComparativeExperimentColumn.NAME) - .sortByDesc(true) - .build() - } - - @Test - fun pathParams() { - val params = - ComparativeListParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - ComparativeListParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(1L) - .name("name") - .nameContains("name_contains") - .offset(0L) - .sortBy(SortByComparativeExperimentColumn.NAME) - .sortByDesc(true) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) - .put("limit", "1") - .put("name", "name") - .put("name_contains", "name_contains") - .put("offset", "0") - .put("sort_by", "name") - .put("sort_by_desc", "true") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = - ComparativeListParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponseTest.kt deleted file mode 100644 index fc337f5f2..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/comparative/ComparativeListResponseTest.kt +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.comparative - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.langchain.smith.core.JsonValue -import com.langchain.smith.core.jsonMapper -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ComparativeListResponseTest { - - @Test - fun create() { - val comparativeListResponse = - ComparativeListResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addExperimentsInfo( - SimpleExperimentInfo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .extra( - ComparativeListResponse.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ComparativeListResponse.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() - - assertThat(comparativeListResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(comparativeListResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(comparativeListResponse.experimentsInfo()) - .containsExactly( - SimpleExperimentInfo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() - ) - assertThat(comparativeListResponse.modifiedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(comparativeListResponse.referenceDatasetId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(comparativeListResponse.tenantId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(comparativeListResponse.description()).contains("description") - assertThat(comparativeListResponse.extra()) - .contains( - ComparativeListResponse.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(comparativeListResponse.feedbackStats()) - .contains( - ComparativeListResponse.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(comparativeListResponse.name()).contains("name") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val comparativeListResponse = - ComparativeListResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addExperimentsInfo( - SimpleExperimentInfo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .extra( - ComparativeListResponse.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ComparativeListResponse.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() - - val roundtrippedComparativeListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(comparativeListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedComparativeListResponse).isEqualTo(comparativeListResponse) - } -} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt index 4e69a4d16..f80d0fe4f 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/group/GroupRunsResponseTest.kt @@ -7,6 +7,7 @@ import com.langchain.smith.core.JsonValue import com.langchain.smith.core.jsonMapper import com.langchain.smith.models.datasets.runs.ExampleWithRunsCh import com.langchain.smith.models.feedback.FeedbackSchema +import com.langchain.smith.models.runs.RunTypeEnum import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -34,7 +35,7 @@ internal class GroupRunsResponseTest { ExampleWithRunsCh.Run.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .runType(ExampleWithRunsCh.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -294,7 +295,7 @@ internal class GroupRunsResponseTest { ExampleWithRunsCh.Run.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .runType(ExampleWithRunsCh.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -552,7 +553,7 @@ internal class GroupRunsResponseTest { ExampleWithRunsCh.Run.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .runType(ExampleWithRunsCh.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexCreateParamsTest.kt deleted file mode 100644 index e856d6f0c..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexCreateParamsTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.index - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class IndexCreateParamsTest { - - @Test - fun create() { - IndexCreateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tag("tag") - .build() - } - - @Test - fun pathParams() { - val params = - IndexCreateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - - assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - IndexCreateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tag("tag") - .build() - - val body = params._body() - - assertThat(body.tag()).contains("tag") - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - IndexCreateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - - val body = params._body() - } -} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexCreateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexCreateResponseTest.kt deleted file mode 100644 index 4c4904632..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexCreateResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.index - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.langchain.smith.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class IndexCreateResponseTest { - - @Test - fun create() { - val indexCreateResponse = IndexCreateResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val indexCreateResponse = IndexCreateResponse.builder().build() - - val roundtrippedIndexCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(indexCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedIndexCreateResponse).isEqualTo(indexCreateResponse) - } -} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexSyncResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexSyncResponseTest.kt deleted file mode 100644 index a864cfd2f..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexSyncResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.index - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.langchain.smith.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class IndexSyncResponseTest { - - @Test - fun create() { - val indexSyncResponse = IndexSyncResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val indexSyncResponse = IndexSyncResponse.builder().build() - - val roundtrippedIndexSyncResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(indexSyncResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedIndexSyncResponse).isEqualTo(indexSyncResponse) - } -} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt index 66ff39f73..dd7b881b2 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsChTest.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.langchain.smith.core.JsonValue import com.langchain.smith.core.jsonMapper import com.langchain.smith.models.feedback.FeedbackSchema +import com.langchain.smith.models.runs.RunTypeEnum import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -28,7 +29,7 @@ internal class ExampleWithRunsChTest { ExampleWithRunsCh.Run.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .runType(ExampleWithRunsCh.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -175,7 +176,7 @@ internal class ExampleWithRunsChTest { ExampleWithRunsCh.Run.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .runType(ExampleWithRunsCh.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -330,7 +331,7 @@ internal class ExampleWithRunsChTest { ExampleWithRunsCh.Run.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .runType(ExampleWithRunsCh.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsTest.kt deleted file mode 100644 index 1f1181823..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/ExampleWithRunsTest.kt +++ /dev/null @@ -1,467 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.runs - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.langchain.smith.core.JsonValue -import com.langchain.smith.core.jsonMapper -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ExampleWithRunsTest { - - @Test - fun create() { - val exampleWithRuns = - ExampleWithRuns.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs( - ExampleWithRuns.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .addRun( - ExampleWithRuns.Run.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .appPath("app_path") - .dottedOrder("dotted_order") - .name("name") - .runType(ExampleWithRuns.Run.RunType.TOOL) - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status("status") - .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .completionCost("completion_cost") - .completionCostDetails( - ExampleWithRuns.Run.CompletionCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .completionTokenDetails( - ExampleWithRuns.Run.CompletionTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .completionTokens(0L) - .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error("error") - .addEvent( - ExampleWithRuns.Run.Event.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .executionOrder(1L) - .extra( - ExampleWithRuns.Run.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inDataset(true) - .inputs( - ExampleWithRuns.Run.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .inputsPreview("inputs_preview") - .inputsS3Urls( - ExampleWithRuns.Run.InputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMessage( - ExampleWithRuns.Run.Message.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputs( - ExampleWithRuns.Run.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputsPreview("outputs_preview") - .outputsS3Urls( - ExampleWithRuns.Run.OutputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .promptCost("prompt_cost") - .promptCostDetails( - ExampleWithRuns.Run.PromptCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .promptTokenDetails( - ExampleWithRuns.Run.PromptTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .promptTokens(0L) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls( - ExampleWithRuns.Run.S3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .serialized( - ExampleWithRuns.Run.Serialized.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addTag("string") - .threadId("thread_id") - .totalCost("total_cost") - .totalTokens(0L) - .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(ExampleWithRuns.Run.TraceTier.LONGLIVED) - .traceUpgrade(true) - .ttlSeconds(0L) - .build() - ) - .attachmentUrls( - ExampleWithRuns.AttachmentUrls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - ExampleWithRuns.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs( - ExampleWithRuns.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(exampleWithRuns.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(exampleWithRuns.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(exampleWithRuns.inputs()) - .isEqualTo( - ExampleWithRuns.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(exampleWithRuns.name()).isEqualTo("name") - assertThat(exampleWithRuns.runs()) - .containsExactly( - ExampleWithRuns.Run.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .appPath("app_path") - .dottedOrder("dotted_order") - .name("name") - .runType(ExampleWithRuns.Run.RunType.TOOL) - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status("status") - .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .completionCost("completion_cost") - .completionCostDetails( - ExampleWithRuns.Run.CompletionCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .completionTokenDetails( - ExampleWithRuns.Run.CompletionTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .completionTokens(0L) - .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error("error") - .addEvent( - ExampleWithRuns.Run.Event.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .executionOrder(1L) - .extra( - ExampleWithRuns.Run.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inDataset(true) - .inputs( - ExampleWithRuns.Run.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .inputsPreview("inputs_preview") - .inputsS3Urls( - ExampleWithRuns.Run.InputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMessage( - ExampleWithRuns.Run.Message.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputs( - ExampleWithRuns.Run.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputsPreview("outputs_preview") - .outputsS3Urls( - ExampleWithRuns.Run.OutputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .promptCost("prompt_cost") - .promptCostDetails( - ExampleWithRuns.Run.PromptCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .promptTokenDetails( - ExampleWithRuns.Run.PromptTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .promptTokens(0L) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls( - ExampleWithRuns.Run.S3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .serialized( - ExampleWithRuns.Run.Serialized.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addTag("string") - .threadId("thread_id") - .totalCost("total_cost") - .totalTokens(0L) - .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(ExampleWithRuns.Run.TraceTier.LONGLIVED) - .traceUpgrade(true) - .ttlSeconds(0L) - .build() - ) - assertThat(exampleWithRuns.attachmentUrls()) - .contains( - ExampleWithRuns.AttachmentUrls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(exampleWithRuns.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(exampleWithRuns.metadata()) - .contains( - ExampleWithRuns.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(exampleWithRuns.modifiedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(exampleWithRuns.outputs()) - .contains( - ExampleWithRuns.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(exampleWithRuns.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val exampleWithRuns = - ExampleWithRuns.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs( - ExampleWithRuns.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .addRun( - ExampleWithRuns.Run.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .appPath("app_path") - .dottedOrder("dotted_order") - .name("name") - .runType(ExampleWithRuns.Run.RunType.TOOL) - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status("status") - .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .completionCost("completion_cost") - .completionCostDetails( - ExampleWithRuns.Run.CompletionCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .completionTokenDetails( - ExampleWithRuns.Run.CompletionTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .completionTokens(0L) - .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error("error") - .addEvent( - ExampleWithRuns.Run.Event.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .executionOrder(1L) - .extra( - ExampleWithRuns.Run.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) - .build() - ) - .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inDataset(true) - .inputs( - ExampleWithRuns.Run.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .inputsPreview("inputs_preview") - .inputsS3Urls( - ExampleWithRuns.Run.InputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMessage( - ExampleWithRuns.Run.Message.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputs( - ExampleWithRuns.Run.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputsPreview("outputs_preview") - .outputsS3Urls( - ExampleWithRuns.Run.OutputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .promptCost("prompt_cost") - .promptCostDetails( - ExampleWithRuns.Run.PromptCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .promptTokenDetails( - ExampleWithRuns.Run.PromptTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .promptTokens(0L) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls( - ExampleWithRuns.Run.S3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .serialized( - ExampleWithRuns.Run.Serialized.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addTag("string") - .threadId("thread_id") - .totalCost("total_cost") - .totalTokens(0L) - .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(ExampleWithRuns.Run.TraceTier.LONGLIVED) - .traceUpgrade(true) - .ttlSeconds(0L) - .build() - ) - .attachmentUrls( - ExampleWithRuns.AttachmentUrls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - ExampleWithRuns.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs( - ExampleWithRuns.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedExampleWithRuns = - jsonMapper.readValue( - jsonMapper.writeValueAsString(exampleWithRuns), - jacksonTypeRef(), - ) - - assertThat(roundtrippedExampleWithRuns).isEqualTo(exampleWithRuns) - } -} 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 102116898..f7108b3aa 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 @@ -23,6 +23,7 @@ internal class QueryExampleSchemaWithRunsTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .includeAnnotatorDetail(true) .limit(1L) .offset(0L) .preview(true) @@ -47,6 +48,7 @@ internal class QueryExampleSchemaWithRunsTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + assertThat(queryExampleSchemaWithRuns.includeAnnotatorDetail()).contains(true) assertThat(queryExampleSchemaWithRuns.limit()).contains(1L) assertThat(queryExampleSchemaWithRuns.offset()).contains(0L) assertThat(queryExampleSchemaWithRuns.preview()).contains(true) @@ -73,6 +75,7 @@ internal class QueryExampleSchemaWithRunsTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .includeAnnotatorDetail(true) .limit(1L) .offset(0L) .preview(true) 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 42553de4e..084f0e1ee 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 @@ -23,6 +23,7 @@ internal class RunCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .includeAnnotatorDetail(true) .limit(1L) .offset(0L) .preview(true) @@ -63,6 +64,7 @@ internal class RunCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .includeAnnotatorDetail(true) .limit(1L) .offset(0L) .preview(true) @@ -107,6 +109,7 @@ internal class RunCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .includeAnnotatorDetail(true) .limit(1L) .offset(0L) .preview(true) @@ -131,6 +134,7 @@ internal class RunCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + assertThat(body.includeAnnotatorDetail()).contains(true) assertThat(body.limit()).contains(1L) assertThat(body.offset()).contains(0L) assertThat(body.preview()).contains(true) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponseTest.kt deleted file mode 100644 index 860e12a81..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/runs/RunCreateResponseTest.kt +++ /dev/null @@ -1,527 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.models.datasets.runs - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.langchain.smith.core.JsonValue -import com.langchain.smith.core.jsonMapper -import com.langchain.smith.errors.LangChainInvalidDataException -import com.langchain.smith.models.feedback.FeedbackSchema -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class RunCreateResponseTest { - - @Test - fun ofExamplesWithRuns() { - val examplesWithRuns = - listOf( - ExampleWithRuns.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs( - ExampleWithRuns.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .addRun( - ExampleWithRuns.Run.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .appPath("app_path") - .dottedOrder("dotted_order") - .name("name") - .runType(ExampleWithRuns.Run.RunType.TOOL) - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status("status") - .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .completionCost("completion_cost") - .completionCostDetails( - ExampleWithRuns.Run.CompletionCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .completionTokenDetails( - ExampleWithRuns.Run.CompletionTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .completionTokens(0L) - .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error("error") - .addEvent( - ExampleWithRuns.Run.Event.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .executionOrder(1L) - .extra( - ExampleWithRuns.Run.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inDataset(true) - .inputs( - ExampleWithRuns.Run.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .inputsPreview("inputs_preview") - .inputsS3Urls( - ExampleWithRuns.Run.InputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMessage( - ExampleWithRuns.Run.Message.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputs( - ExampleWithRuns.Run.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputsPreview("outputs_preview") - .outputsS3Urls( - ExampleWithRuns.Run.OutputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .promptCost("prompt_cost") - .promptCostDetails( - ExampleWithRuns.Run.PromptCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .promptTokenDetails( - ExampleWithRuns.Run.PromptTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .promptTokens(0L) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls( - ExampleWithRuns.Run.S3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .serialized( - ExampleWithRuns.Run.Serialized.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addTag("string") - .threadId("thread_id") - .totalCost("total_cost") - .totalTokens(0L) - .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(ExampleWithRuns.Run.TraceTier.LONGLIVED) - .traceUpgrade(true) - .ttlSeconds(0L) - .build() - ) - .attachmentUrls( - ExampleWithRuns.AttachmentUrls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - ExampleWithRuns.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs( - ExampleWithRuns.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val runCreateResponse = RunCreateResponse.ofExamplesWithRuns(examplesWithRuns) - - assertThat(runCreateResponse.examplesWithRuns()).contains(examplesWithRuns) - assertThat(runCreateResponse.exampleWithRunsChes()).isEmpty - } - - @Test - fun ofExamplesWithRunsRoundtrip() { - val jsonMapper = jsonMapper() - val runCreateResponse = - RunCreateResponse.ofExamplesWithRuns( - listOf( - ExampleWithRuns.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs( - ExampleWithRuns.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .addRun( - ExampleWithRuns.Run.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .appPath("app_path") - .dottedOrder("dotted_order") - .name("name") - .runType(ExampleWithRuns.Run.RunType.TOOL) - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status("status") - .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .completionCost("completion_cost") - .completionCostDetails( - ExampleWithRuns.Run.CompletionCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .completionTokenDetails( - ExampleWithRuns.Run.CompletionTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .completionTokens(0L) - .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error("error") - .addEvent( - ExampleWithRuns.Run.Event.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .executionOrder(1L) - .extra( - ExampleWithRuns.Run.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inDataset(true) - .inputs( - ExampleWithRuns.Run.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .inputsPreview("inputs_preview") - .inputsS3Urls( - ExampleWithRuns.Run.InputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMessage( - ExampleWithRuns.Run.Message.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputs( - ExampleWithRuns.Run.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputsPreview("outputs_preview") - .outputsS3Urls( - ExampleWithRuns.Run.OutputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .promptCost("prompt_cost") - .promptCostDetails( - ExampleWithRuns.Run.PromptCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .promptTokenDetails( - ExampleWithRuns.Run.PromptTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .promptTokens(0L) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls( - ExampleWithRuns.Run.S3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .serialized( - ExampleWithRuns.Run.Serialized.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addTag("string") - .threadId("thread_id") - .totalCost("total_cost") - .totalTokens(0L) - .traceFirstReceivedAt( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(ExampleWithRuns.Run.TraceTier.LONGLIVED) - .traceUpgrade(true) - .ttlSeconds(0L) - .build() - ) - .attachmentUrls( - ExampleWithRuns.AttachmentUrls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - ExampleWithRuns.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs( - ExampleWithRuns.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - - val roundtrippedRunCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(runCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) - } - - @Test - fun ofExampleWithRunsChes() { - val exampleWithRunsChes = - listOf( - ExampleWithRunsCh.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs( - ExampleWithRunsCh.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .addRun( - ExampleWithRunsCh.Run.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .runType(ExampleWithRunsCh.Run.RunType.TOOL) - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status("status") - .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .appPath("app_path") - .completionCost("completion_cost") - .completionTokens(0L) - .dottedOrder("dotted_order") - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error("error") - .addEvent( - ExampleWithRunsCh.Run.Event.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .executionOrder(1L) - .extra( - ExampleWithRunsCh.Run.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ExampleWithRunsCh.Run.FeedbackStats.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .addFeedback( - FeedbackSchema.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .key("key") - .comment("comment") - .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .correction( - FeedbackSchema.Correction.UnionMember0.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .extra( - FeedbackSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedbackSource( - FeedbackSchema.FeedbackSource.builder() - .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - FeedbackSchema.FeedbackSource.Metadata.builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .type("type") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userName("user_name") - .build() - ) - .feedbackThreadId("feedback_thread_id") - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .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() - ) - .inputs( - ExampleWithRunsCh.Run.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .inputsPreview("inputs_preview") - .inputsS3Urls( - ExampleWithRunsCh.Run.InputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .outputs( - ExampleWithRunsCh.Run.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputsPreview("outputs_preview") - .outputsS3Urls( - ExampleWithRunsCh.Run.OutputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .promptCost("prompt_cost") - .promptTokens(0L) - .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls( - ExampleWithRunsCh.Run.S3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .serialized( - ExampleWithRunsCh.Run.Serialized.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addTag("string") - .totalCost("total_cost") - .totalTokens(0L) - .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .attachmentUrls( - ExampleWithRunsCh.AttachmentUrls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - ExampleWithRunsCh.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs( - ExampleWithRunsCh.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val runCreateResponse = RunCreateResponse.ofExampleWithRunsChes(exampleWithRunsChes) - - assertThat(runCreateResponse.examplesWithRuns()).isEmpty - assertThat(runCreateResponse.exampleWithRunsChes()).contains(exampleWithRunsChes) - } - - // Disabled: ofExampleWithRunsChesRoundtrip test removed - // The ExampleWithRunsChes variant deserializes as ExampleWithRuns due to API evolution - // where RunSchema (in ExampleWithRuns) is now preferred over the simpler Run structure - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - OBJECT(JsonValue.from(mapOf("invalid" to "object"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val runCreateResponse = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { runCreateResponse.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUploadFromCsvParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUploadFromCsvParamsTest.kt index c684bba62..4a8dc4ead 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUploadFromCsvParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/examples/ExampleUploadFromCsvParamsTest.kt @@ -13,7 +13,7 @@ internal class ExampleUploadFromCsvParamsTest { fun create() { ExampleUploadFromCsvParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .addMetadataKey("string") .addOutputKey("string") @@ -25,7 +25,7 @@ internal class ExampleUploadFromCsvParamsTest { val params = ExampleUploadFromCsvParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .build() @@ -39,7 +39,7 @@ internal class ExampleUploadFromCsvParamsTest { val params = ExampleUploadFromCsvParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .addMetadataKey("string") .addOutputKey("string") @@ -57,7 +57,7 @@ internal class ExampleUploadFromCsvParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "input_keys" to MultipartField.of(listOf("string")), "metadata_keys" to MultipartField.of(listOf("string")), "output_keys" to MultipartField.of(listOf("string")), @@ -73,7 +73,7 @@ internal class ExampleUploadFromCsvParamsTest { val params = ExampleUploadFromCsvParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .build() @@ -89,7 +89,7 @@ internal class ExampleUploadFromCsvParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "input_keys" to MultipartField.of(listOf("string")), ) .mapValues { (_, field) -> 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 8d5eb3adc..45d8f906e 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 @@ -25,11 +25,6 @@ internal class FeedbackCreateParamsTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) - .extra( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) @@ -83,11 +78,6 @@ internal class FeedbackCreateParamsTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) - .extra( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) @@ -139,11 +129,6 @@ internal class FeedbackCreateParamsTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) - .extra( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) 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 e99461ee5..53d2815d8 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 @@ -26,11 +26,6 @@ internal class FeedbackCreateSchemaTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) - .extra( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) @@ -80,12 +75,6 @@ internal class FeedbackCreateSchemaTest { assertThat(feedbackCreateSchema.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(feedbackCreateSchema.error()).contains(true) - assertThat(feedbackCreateSchema.extra()) - .contains( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) assertThat(feedbackCreateSchema.feedbackConfig()) .contains( FeedbackCreateSchema.FeedbackConfig.builder() @@ -143,11 +132,6 @@ internal class FeedbackCreateSchemaTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) - .extra( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt index 24b9c7a33..a2011f3ad 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/CreateRepoResponseTest.kt @@ -29,6 +29,7 @@ internal class CreateRepoResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -67,6 +68,7 @@ internal class CreateRepoResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -87,6 +89,7 @@ internal class CreateRepoResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -125,6 +128,7 @@ internal class CreateRepoResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -149,6 +153,7 @@ internal class CreateRepoResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -187,6 +192,7 @@ internal class CreateRepoResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt index ba236f300..79a23ca26 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/GetRepoResponseTest.kt @@ -29,6 +29,7 @@ internal class GetRepoResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -67,6 +68,7 @@ internal class GetRepoResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -87,6 +89,7 @@ internal class GetRepoResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -125,6 +128,7 @@ internal class GetRepoResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -149,6 +153,7 @@ internal class GetRepoResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -187,6 +192,7 @@ internal class GetRepoResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoCreateParamsTest.kt index e44a4787f..a0a4779c9 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoCreateParamsTest.kt @@ -15,6 +15,8 @@ internal class RepoCreateParamsTest { .repoHandle("repo_handle") .description("description") .readme("readme") + .repoType(RepoCreateParams.RepoType.PROMPT) + .restrictedMode(true) .addTag("string") .build() } @@ -27,6 +29,8 @@ internal class RepoCreateParamsTest { .repoHandle("repo_handle") .description("description") .readme("readme") + .repoType(RepoCreateParams.RepoType.PROMPT) + .restrictedMode(true) .addTag("string") .build() @@ -36,6 +40,8 @@ internal class RepoCreateParamsTest { assertThat(body.repoHandle()).isEqualTo("repo_handle") assertThat(body.description()).contains("description") assertThat(body.readme()).contains("readme") + assertThat(body.repoType()).contains(RepoCreateParams.RepoType.PROMPT) + assertThat(body.restrictedMode()).contains(true) assertThat(body.tags().getOrNull()).containsExactly("string") } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt index 69f20eddb..79813a2be 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListPageResponseTest.kt @@ -29,6 +29,7 @@ internal class RepoListPageResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -67,6 +68,7 @@ internal class RepoListPageResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -88,6 +90,7 @@ internal class RepoListPageResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -126,6 +129,7 @@ internal class RepoListPageResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -151,6 +155,7 @@ internal class RepoListPageResponseTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -189,6 +194,7 @@ internal class RepoListPageResponseTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListParamsTest.kt index 9be6400d0..61399d4d7 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoListParamsTest.kt @@ -17,6 +17,7 @@ internal class RepoListParamsTest { .limit(1L) .offset(0L) .query("query") + .repoType(RepoListParams.RepoType.PROMPT) .sortDirection(RepoListParams.SortDirection.ASC) .sortField(RepoListParams.SortField.NUM_LIKES) .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -39,6 +40,7 @@ internal class RepoListParamsTest { .limit(1L) .offset(0L) .query("query") + .repoType(RepoListParams.RepoType.PROMPT) .sortDirection(RepoListParams.SortDirection.ASC) .sortField(RepoListParams.SortField.NUM_LIKES) .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -61,6 +63,7 @@ internal class RepoListParamsTest { .put("limit", "1") .put("offset", "0") .put("query", "query") + .put("repo_type", "prompt") .put("sort_direction", "asc") .put("sort_field", "num_likes") .put( diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoUpdateParamsTest.kt index c4701c918..005017f1b 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoUpdateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoUpdateParamsTest.kt @@ -17,6 +17,7 @@ internal class RepoUpdateParamsTest { .isArchived(true) .isPublic(true) .readme("readme") + .restrictedMode(true) .addTag("string") .build() } @@ -41,6 +42,7 @@ internal class RepoUpdateParamsTest { .isArchived(true) .isPublic(true) .readme("readme") + .restrictedMode(true) .addTag("string") .build() @@ -50,6 +52,7 @@ internal class RepoUpdateParamsTest { assertThat(body.isArchived()).contains(true) assertThat(body.isPublic()).contains(true) assertThat(body.readme()).contains("readme") + assertThat(body.restrictedMode()).contains(true) assertThat(body.tags().getOrNull()).containsExactly("string") } diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt index 287657d34..df2364138 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/repos/RepoWithLookupsTest.kt @@ -28,6 +28,7 @@ internal class RepoWithLookupsTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -66,6 +67,7 @@ internal class RepoWithLookupsTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -82,6 +84,7 @@ internal class RepoWithLookupsTest { assertThat(repoWithLookups.numViews()).isEqualTo(0L) assertThat(repoWithLookups.owner()).contains("owner") assertThat(repoWithLookups.repoHandle()).isEqualTo("repo_handle") + assertThat(repoWithLookups.repoType()).isEqualTo(RepoWithLookups.RepoType.PROMPT) assertThat(repoWithLookups.tags()).containsExactly("string") assertThat(repoWithLookups.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(repoWithLookups.updatedAt()) @@ -123,6 +126,7 @@ internal class RepoWithLookupsTest { assertThat(repoWithLookups.originalRepoId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(repoWithLookups.readme()).contains("readme") + assertThat(repoWithLookups.restrictedMode()).contains(true) assertThat(repoWithLookups.upstreamRepoFullName()).contains("upstream_repo_full_name") assertThat(repoWithLookups.upstreamRepoId()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -144,6 +148,7 @@ internal class RepoWithLookupsTest { .numViews(0L) .owner("owner") .repoHandle("repo_handle") + .repoType(RepoWithLookups.RepoType.PROMPT) .addTag("string") .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -182,6 +187,7 @@ internal class RepoWithLookupsTest { .originalRepoFullName("original_repo_full_name") .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .readme("readme") + .restrictedMode(true) .upstreamRepoFullName("upstream_repo_full_name") .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/BodyParamsForRunSchemaTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/BodyParamsForRunSchemaTest.kt new file mode 100644 index 000000000..7ac6c7c48 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/BodyParamsForRunSchemaTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BodyParamsForRunSchemaTest { + + @Test + fun create() { + val bodyParamsForRunSchema = + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + assertThat(bodyParamsForRunSchema.id().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.cursor()).contains("cursor") + assertThat(bodyParamsForRunSchema.dataSourceType()) + .contains(RunsFilterDataSourceTypeEnum.CURRENT) + assertThat(bodyParamsForRunSchema.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bodyParamsForRunSchema.error()).contains(true) + assertThat(bodyParamsForRunSchema.executionOrder()).contains(1L) + assertThat(bodyParamsForRunSchema.filter()).contains("filter") + assertThat(bodyParamsForRunSchema.isRoot()).contains(true) + assertThat(bodyParamsForRunSchema.limit()).contains(1L) + assertThat(bodyParamsForRunSchema.order()).contains(BodyParamsForRunSchema.Order.ASC) + assertThat(bodyParamsForRunSchema.parentRun()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.query()).contains("query") + assertThat(bodyParamsForRunSchema.referenceExample().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.runType()).contains(RunTypeEnum.TOOL) + assertThat(bodyParamsForRunSchema.searchFilter()).contains("search_filter") + assertThat(bodyParamsForRunSchema.select().getOrNull()) + .containsExactly(BodyParamsForRunSchema.Select.ID) + assertThat(bodyParamsForRunSchema.session().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.skipPagination()).contains(true) + assertThat(bodyParamsForRunSchema.skipPrevCursor()).contains(true) + assertThat(bodyParamsForRunSchema.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bodyParamsForRunSchema.trace()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.traceFilter()).contains("trace_filter") + assertThat(bodyParamsForRunSchema.treeFilter()).contains("tree_filter") + assertThat(bodyParamsForRunSchema.useExperimentalSearch()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bodyParamsForRunSchema = + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + val roundtrippedBodyParamsForRunSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bodyParamsForRunSchema), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBodyParamsForRunSchema).isEqualTo(bodyParamsForRunSchema) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RequestBodyForRunsGenerateQueryTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RequestBodyForRunsGenerateQueryTest.kt new file mode 100644 index 000000000..4082a4da4 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RequestBodyForRunsGenerateQueryTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RequestBodyForRunsGenerateQueryTest { + + @Test + fun create() { + val requestBodyForRunsGenerateQuery = + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + + assertThat(requestBodyForRunsGenerateQuery.query()).isEqualTo("query") + assertThat(requestBodyForRunsGenerateQuery.feedbackKeys().getOrNull()) + .containsExactly(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val requestBodyForRunsGenerateQuery = + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + + val roundtrippedRequestBodyForRunsGenerateQuery = + jsonMapper.readValue( + jsonMapper.writeValueAsString(requestBodyForRunsGenerateQuery), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRequestBodyForRunsGenerateQuery) + .isEqualTo(requestBodyForRunsGenerateQuery) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/ResponseBodyForRunsGenerateQueryTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/ResponseBodyForRunsGenerateQueryTest.kt new file mode 100644 index 000000000..a18019e4e --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/ResponseBodyForRunsGenerateQueryTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResponseBodyForRunsGenerateQueryTest { + + @Test + fun create() { + val responseBodyForRunsGenerateQuery = + ResponseBodyForRunsGenerateQuery.builder() + .feedbackUrls( + ResponseBodyForRunsGenerateQuery.FeedbackUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .filter("filter") + .build() + + assertThat(responseBodyForRunsGenerateQuery.feedbackUrls()) + .isEqualTo( + ResponseBodyForRunsGenerateQuery.FeedbackUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(responseBodyForRunsGenerateQuery.filter()).isEqualTo("filter") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseBodyForRunsGenerateQuery = + ResponseBodyForRunsGenerateQuery.builder() + .feedbackUrls( + ResponseBodyForRunsGenerateQuery.FeedbackUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .filter("filter") + .build() + + val roundtrippedResponseBodyForRunsGenerateQuery = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseBodyForRunsGenerateQuery), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponseBodyForRunsGenerateQuery) + .isEqualTo(responseBodyForRunsGenerateQuery) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunCreateParamsTest.kt new file mode 100644 index 000000000..cef3882a5 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunCreateParamsTest.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.langchain.smith.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunCreateParamsTest { + + @Test + fun create() { + RunCreateParams.builder() + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RunCreateParams.builder() + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RunCreateParams.builder().run(Run.builder().build()).build() + + val body = params._body() + + assertThat(body).isEqualTo(Run.builder().build()) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunCreateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunCreateResponseTest.kt new file mode 100644 index 000000000..ae2b1281e --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunCreateResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunCreateResponseTest { + + @Test + fun create() { + val runCreateResponse = + RunCreateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runCreateResponse = + RunCreateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedRunCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryParamsTest.kt index d2044cb0f..4b60b42cb 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryParamsTest.kt @@ -14,7 +14,7 @@ internal class RunQueryParamsTest { RunQueryParams.builder() .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .dataSourceType(RunQueryParams.DataSourceType.CURRENT) + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .executionOrder(1L) @@ -25,7 +25,7 @@ internal class RunQueryParamsTest { .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .query("query") .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .runType(RunQueryParams.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .searchFilter("search_filter") .addSelect(RunQueryParams.Select.ID) .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -45,7 +45,7 @@ internal class RunQueryParamsTest { RunQueryParams.builder() .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .dataSourceType(RunQueryParams.DataSourceType.CURRENT) + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .executionOrder(1L) @@ -56,7 +56,7 @@ internal class RunQueryParamsTest { .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .query("query") .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .runType(RunQueryParams.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .searchFilter("search_filter") .addSelect(RunQueryParams.Select.ID) .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -73,7 +73,7 @@ internal class RunQueryParamsTest { assertThat(body.id().getOrNull()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.cursor()).contains("cursor") - assertThat(body.dataSourceType()).contains(RunQueryParams.DataSourceType.CURRENT) + assertThat(body.dataSourceType()).contains(RunsFilterDataSourceTypeEnum.CURRENT) assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.error()).contains(true) assertThat(body.executionOrder()).contains(1L) @@ -85,7 +85,7 @@ internal class RunQueryParamsTest { assertThat(body.query()).contains("query") assertThat(body.referenceExample().getOrNull()) .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.runType()).contains(RunQueryParams.RunType.TOOL) + assertThat(body.runType()).contains(RunTypeEnum.TOOL) assertThat(body.searchFilter()).contains("search_filter") assertThat(body.select().getOrNull()).containsExactly(RunQueryParams.Select.ID) assertThat(body.session().getOrNull()) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt index 023db6958..2d02e9ff7 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunQueryResponseTest.kt @@ -21,24 +21,24 @@ internal class RunQueryResponseTest { .build() ) .addRun( - RunQueryResponse.Run.builder() + RunSchema.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .appPath("app_path") .dottedOrder("dotted_order") .name("name") - .runType(RunQueryResponse.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .completionCost("completion_cost") .completionCostDetails( - RunQueryResponse.Run.CompletionCostDetails.builder() + RunSchema.CompletionCostDetails.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .completionTokenDetails( - RunQueryResponse.Run.CompletionTokenDetails.builder() + RunSchema.CompletionTokenDetails.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) @@ -47,31 +47,31 @@ internal class RunQueryResponseTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") .addEvent( - RunQueryResponse.Run.Event.builder() + RunSchema.Event.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .executionOrder(1L) .extra( - RunQueryResponse.Run.Extra.builder() + RunSchema.Extra.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .feedbackStats( - RunQueryResponse.Run.FeedbackStats.builder() + RunSchema.FeedbackStats.builder() .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) .inputs( - RunQueryResponse.Run.Inputs.builder() + RunSchema.Inputs.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .inputsPreview("inputs_preview") .inputsS3Urls( - RunQueryResponse.Run.InputsS3Urls.builder() + RunSchema.InputsS3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -79,18 +79,18 @@ internal class RunQueryResponseTest { .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addMessage( - RunQueryResponse.Run.Message.builder() + RunSchema.Message.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .outputs( - RunQueryResponse.Run.Outputs.builder() + RunSchema.Outputs.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .outputsPreview("outputs_preview") .outputsS3Urls( - RunQueryResponse.Run.OutputsS3Urls.builder() + RunSchema.OutputsS3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -99,12 +99,12 @@ internal class RunQueryResponseTest { .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptCostDetails( - RunQueryResponse.Run.PromptCostDetails.builder() + RunSchema.PromptCostDetails.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .promptTokenDetails( - RunQueryResponse.Run.PromptTokenDetails.builder() + RunSchema.PromptTokenDetails.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) @@ -112,12 +112,12 @@ internal class RunQueryResponseTest { .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .s3Urls( - RunQueryResponse.Run.S3Urls.builder() + RunSchema.S3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .serialized( - RunQueryResponse.Run.Serialized.builder() + RunSchema.Serialized.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -130,7 +130,7 @@ internal class RunQueryResponseTest { .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(RunQueryResponse.Run.TraceTier.LONGLIVED) + .traceTier(RunSchema.TraceTier.LONGLIVED) .traceUpgrade(true) .ttlSeconds(0L) .build() @@ -151,24 +151,24 @@ internal class RunQueryResponseTest { ) assertThat(runQueryResponse.runs()) .containsExactly( - RunQueryResponse.Run.builder() + RunSchema.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .appPath("app_path") .dottedOrder("dotted_order") .name("name") - .runType(RunQueryResponse.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .completionCost("completion_cost") .completionCostDetails( - RunQueryResponse.Run.CompletionCostDetails.builder() + RunSchema.CompletionCostDetails.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .completionTokenDetails( - RunQueryResponse.Run.CompletionTokenDetails.builder() + RunSchema.CompletionTokenDetails.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) @@ -177,31 +177,31 @@ internal class RunQueryResponseTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") .addEvent( - RunQueryResponse.Run.Event.builder() + RunSchema.Event.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .executionOrder(1L) .extra( - RunQueryResponse.Run.Extra.builder() + RunSchema.Extra.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .feedbackStats( - RunQueryResponse.Run.FeedbackStats.builder() + RunSchema.FeedbackStats.builder() .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) .inputs( - RunQueryResponse.Run.Inputs.builder() + RunSchema.Inputs.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .inputsPreview("inputs_preview") .inputsS3Urls( - RunQueryResponse.Run.InputsS3Urls.builder() + RunSchema.InputsS3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -209,18 +209,18 @@ internal class RunQueryResponseTest { .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addMessage( - RunQueryResponse.Run.Message.builder() + RunSchema.Message.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .outputs( - RunQueryResponse.Run.Outputs.builder() + RunSchema.Outputs.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .outputsPreview("outputs_preview") .outputsS3Urls( - RunQueryResponse.Run.OutputsS3Urls.builder() + RunSchema.OutputsS3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -229,12 +229,12 @@ internal class RunQueryResponseTest { .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptCostDetails( - RunQueryResponse.Run.PromptCostDetails.builder() + RunSchema.PromptCostDetails.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .promptTokenDetails( - RunQueryResponse.Run.PromptTokenDetails.builder() + RunSchema.PromptTokenDetails.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) @@ -242,12 +242,12 @@ internal class RunQueryResponseTest { .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .s3Urls( - RunQueryResponse.Run.S3Urls.builder() + RunSchema.S3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .serialized( - RunQueryResponse.Run.Serialized.builder() + RunSchema.Serialized.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -260,7 +260,7 @@ internal class RunQueryResponseTest { .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(RunQueryResponse.Run.TraceTier.LONGLIVED) + .traceTier(RunSchema.TraceTier.LONGLIVED) .traceUpgrade(true) .ttlSeconds(0L) .build() @@ -285,24 +285,24 @@ internal class RunQueryResponseTest { .build() ) .addRun( - RunQueryResponse.Run.builder() + RunSchema.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .appPath("app_path") .dottedOrder("dotted_order") .name("name") - .runType(RunQueryResponse.Run.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status("status") .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .completionCost("completion_cost") .completionCostDetails( - RunQueryResponse.Run.CompletionCostDetails.builder() + RunSchema.CompletionCostDetails.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .completionTokenDetails( - RunQueryResponse.Run.CompletionTokenDetails.builder() + RunSchema.CompletionTokenDetails.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) @@ -311,31 +311,31 @@ internal class RunQueryResponseTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error("error") .addEvent( - RunQueryResponse.Run.Event.builder() + RunSchema.Event.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .executionOrder(1L) .extra( - RunQueryResponse.Run.Extra.builder() + RunSchema.Extra.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .feedbackStats( - RunQueryResponse.Run.FeedbackStats.builder() + RunSchema.FeedbackStats.builder() .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) .build() ) .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .inDataset(true) .inputs( - RunQueryResponse.Run.Inputs.builder() + RunSchema.Inputs.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .inputsPreview("inputs_preview") .inputsS3Urls( - RunQueryResponse.Run.InputsS3Urls.builder() + RunSchema.InputsS3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -343,18 +343,18 @@ internal class RunQueryResponseTest { .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addMessage( - RunQueryResponse.Run.Message.builder() + RunSchema.Message.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .outputs( - RunQueryResponse.Run.Outputs.builder() + RunSchema.Outputs.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .outputsPreview("outputs_preview") .outputsS3Urls( - RunQueryResponse.Run.OutputsS3Urls.builder() + RunSchema.OutputsS3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -363,12 +363,12 @@ internal class RunQueryResponseTest { .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .promptCost("prompt_cost") .promptCostDetails( - RunQueryResponse.Run.PromptCostDetails.builder() + RunSchema.PromptCostDetails.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .promptTokenDetails( - RunQueryResponse.Run.PromptTokenDetails.builder() + RunSchema.PromptTokenDetails.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) @@ -376,12 +376,12 @@ internal class RunQueryResponseTest { .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .s3Urls( - RunQueryResponse.Run.S3Urls.builder() + RunSchema.S3Urls.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .serialized( - RunQueryResponse.Run.Serialized.builder() + RunSchema.Serialized.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -394,7 +394,7 @@ internal class RunQueryResponseTest { .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(RunQueryResponse.Run.TraceTier.LONGLIVED) + .traceTier(RunSchema.TraceTier.LONGLIVED) .traceUpgrade(true) .ttlSeconds(0L) .build() diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunRetrieveParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunRetrieveParamsTest.kt new file mode 100644 index 000000000..98fd9204a --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunRetrieveParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.langchain.smith.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRetrieveParamsTest { + + @Test + fun create() { + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .includeMessages(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + RunRetrieveParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .includeMessages(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("exclude_s3_stored_attributes", "true") + .put("exclude_serialized", "true") + .put("include_messages", "true") + .put("session_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("start_time", "2019-12-27T18:11:19.117Z") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RunRetrieveParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunSchemaTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunSchemaTest.kt new file mode 100644 index 000000000..494ea2f1a --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunSchemaTest.kt @@ -0,0 +1,393 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunSchemaTest { + + @Test + fun create() { + val runSchema = + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent( + RunSchema.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .executionOrder(1L) + .extra( + RunSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs( + RunSchema.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputsPreview("inputs_preview") + .inputsS3Urls( + RunSchema.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMessage( + RunSchema.Message.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + RunSchema.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsPreview("outputs_preview") + .outputsS3Urls( + RunSchema.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls( + RunSchema.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + RunSchema.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(RunSchema.TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + + assertThat(runSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.appPath()).isEqualTo("app_path") + assertThat(runSchema.dottedOrder()).isEqualTo("dotted_order") + assertThat(runSchema.name()).isEqualTo("name") + assertThat(runSchema.runType()).isEqualTo(RunTypeEnum.TOOL) + assertThat(runSchema.sessionId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.status()).isEqualTo("status") + assertThat(runSchema.traceId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.childRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.completionCost()).contains("completion_cost") + assertThat(runSchema.completionCostDetails()) + .contains( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runSchema.completionTokenDetails()) + .contains( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runSchema.completionTokens()).contains(0L) + assertThat(runSchema.directChildRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.error()).contains("error") + assertThat(runSchema.events().getOrNull()) + .containsExactly( + RunSchema.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.executionOrder()).contains(1L) + assertThat(runSchema.extra()) + .contains( + RunSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.feedbackStats()) + .contains( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) + .build() + ) + assertThat(runSchema.firstTokenTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.inDataset()).contains(true) + assertThat(runSchema.inputs()) + .contains( + RunSchema.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.inputsPreview()).contains("inputs_preview") + assertThat(runSchema.inputsS3Urls()) + .contains( + RunSchema.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.lastQueuedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.manifestId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.manifestS3Id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.messages().getOrNull()) + .containsExactly( + RunSchema.Message.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.outputs()) + .contains( + RunSchema.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.outputsPreview()).contains("outputs_preview") + assertThat(runSchema.outputsS3Urls()) + .contains( + RunSchema.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.parentRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.parentRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.priceModelId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.promptCost()).contains("prompt_cost") + assertThat(runSchema.promptCostDetails()) + .contains( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runSchema.promptTokenDetails()) + .contains( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runSchema.promptTokens()).contains(0L) + assertThat(runSchema.referenceDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.referenceExampleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.s3Urls()) + .contains( + RunSchema.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.serialized()) + .contains( + RunSchema.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(runSchema.shareToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.tags().getOrNull()).containsExactly("string") + assertThat(runSchema.threadId()).contains("thread_id") + assertThat(runSchema.totalCost()).contains("total_cost") + assertThat(runSchema.totalTokens()).contains(0L) + assertThat(runSchema.traceFirstReceivedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.traceMaxStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.traceMinStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.traceTier()).contains(RunSchema.TraceTier.LONGLIVED) + assertThat(runSchema.traceUpgrade()).contains(true) + assertThat(runSchema.ttlSeconds()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runSchema = + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent( + RunSchema.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .executionOrder(1L) + .extra( + RunSchema.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("foo" to "bar"))) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs( + RunSchema.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputsPreview("inputs_preview") + .inputsS3Urls( + RunSchema.InputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMessage( + RunSchema.Message.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + RunSchema.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputsPreview("outputs_preview") + .outputsS3Urls( + RunSchema.OutputsS3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls( + RunSchema.S3Urls.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .serialized( + RunSchema.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(RunSchema.TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + + val roundtrippedRunSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runSchema), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunSchema).isEqualTo(runSchema) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsParamsTest.kt new file mode 100644 index 000000000..859360606 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsParamsTest.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.langchain.smith.models.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunStatsParamsTest { + + @Test + fun create() { + RunStatsParams.builder() + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RunStatsParams.builder() + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunStatsParams.builder() + .runStatsQueryParams(RunStatsQueryParams.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(RunStatsQueryParams.builder().build()) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsQueryParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsQueryParamsTest.kt new file mode 100644 index 000000000..5298f3211 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsQueryParamsTest.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import com.langchain.smith.models.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunStatsQueryParamsTest { + + @Test + fun create() { + val runStatsQueryParams = + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + assertThat(runStatsQueryParams.id().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.dataSourceType()) + .contains(RunsFilterDataSourceTypeEnum.CURRENT) + assertThat(runStatsQueryParams.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runStatsQueryParams.error()).contains(true) + assertThat(runStatsQueryParams.executionOrder()).contains(1L) + assertThat(runStatsQueryParams.filter()).contains("filter") + assertThat(runStatsQueryParams.groupBy()) + .contains( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + assertThat(runStatsQueryParams.groups().getOrNull()).containsExactly("string") + assertThat(runStatsQueryParams.isRoot()).contains(true) + assertThat(runStatsQueryParams.parentRun()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.query()).contains("query") + assertThat(runStatsQueryParams.referenceExample().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.runType()).contains(RunTypeEnum.TOOL) + assertThat(runStatsQueryParams.searchFilter()).contains("search_filter") + assertThat(runStatsQueryParams.select().getOrNull()) + .containsExactly(RunStatsQueryParams.Select.RUN_COUNT) + assertThat(runStatsQueryParams.session().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.skipPagination()).contains(true) + assertThat(runStatsQueryParams.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runStatsQueryParams.trace()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.traceFilter()).contains("trace_filter") + assertThat(runStatsQueryParams.treeFilter()).contains("tree_filter") + assertThat(runStatsQueryParams.useExperimentalSearch()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runStatsQueryParams = + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + val roundtrippedRunStatsQueryParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStatsQueryParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunStatsQueryParams).isEqualTo(runStatsQueryParams) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsResponseTest.kt new file mode 100644 index 000000000..2557e7c2a --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunStatsResponseTest.kt @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.jsonMapper +import com.langchain.smith.errors.LangChainInvalidDataException +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class RunStatsResponseTest { + + @Test + fun ofRunStats() { + val runStats = + RunStatsResponse.RunStats.builder() + .completionCost("completion_cost") + .completionCostDetails( + RunStatsResponse.RunStats.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .completionTokenDetails( + RunStatsResponse.RunStats.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats( + RunStatsResponse.RunStats.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails( + RunStatsResponse.RunStats.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .promptTokenDetails( + RunStatsResponse.RunStats.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet( + RunStatsResponse.RunStats.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + + val runStatsResponse = RunStatsResponse.ofRunStats(runStats) + + assertThat(runStatsResponse.runStats()).contains(runStats) + assertThat(runStatsResponse.unionMember1()).isEmpty + } + + @Test + fun ofRunStatsRoundtrip() { + val jsonMapper = jsonMapper() + val runStatsResponse = + RunStatsResponse.ofRunStats( + RunStatsResponse.RunStats.builder() + .completionCost("completion_cost") + .completionCostDetails( + RunStatsResponse.RunStats.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .completionTokenDetails( + RunStatsResponse.RunStats.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats( + RunStatsResponse.RunStats.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails( + RunStatsResponse.RunStats.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .promptTokenDetails( + RunStatsResponse.RunStats.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet( + RunStatsResponse.RunStats.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + ) + + val roundtrippedRunStatsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStatsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunStatsResponse).isEqualTo(runStatsResponse) + } + + @Test + fun ofUnionMember1() { + val unionMember1 = + RunStatsResponse.UnionMember1.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "completion_cost" to "completion_cost", + "completion_cost_details" to mapOf("foo" to "bar"), + "completion_token_details" to mapOf("foo" to "bar"), + "completion_tokens" to 0, + "completion_tokens_p50" to 0, + "completion_tokens_p99" to 0, + "cost_p50" to "cost_p50", + "cost_p99" to "cost_p99", + "error_rate" to 0, + "feedback_stats" to mapOf("foo" to "bar"), + "first_token_p50" to 0, + "first_token_p99" to 0, + "last_run_start_time" to "2019-12-27T18:11:19.117Z", + "latency_p50" to 0, + "latency_p99" to 0, + "median_tokens" to 0, + "prompt_cost" to "prompt_cost", + "prompt_cost_details" to mapOf("foo" to "bar"), + "prompt_token_details" to mapOf("foo" to "bar"), + "prompt_tokens" to 0, + "prompt_tokens_p50" to 0, + "prompt_tokens_p99" to 0, + "run_count" to 0, + "run_facets" to listOf(mapOf("foo" to "bar")), + "streaming_rate" to 0, + "tokens_p99" to 0, + "total_cost" to "total_cost", + "total_tokens" to 0, + ) + ), + ) + .build() + + val runStatsResponse = RunStatsResponse.ofUnionMember1(unionMember1) + + assertThat(runStatsResponse.runStats()).isEmpty + assertThat(runStatsResponse.unionMember1()).contains(unionMember1) + } + + @Test + fun ofUnionMember1Roundtrip() { + val jsonMapper = jsonMapper() + val runStatsResponse = + RunStatsResponse.ofUnionMember1( + RunStatsResponse.UnionMember1.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "completion_cost" to "completion_cost", + "completion_cost_details" to mapOf("foo" to "bar"), + "completion_token_details" to mapOf("foo" to "bar"), + "completion_tokens" to 0, + "completion_tokens_p50" to 0, + "completion_tokens_p99" to 0, + "cost_p50" to "cost_p50", + "cost_p99" to "cost_p99", + "error_rate" to 0, + "feedback_stats" to mapOf("foo" to "bar"), + "first_token_p50" to 0, + "first_token_p99" to 0, + "last_run_start_time" to "2019-12-27T18:11:19.117Z", + "latency_p50" to 0, + "latency_p99" to 0, + "median_tokens" to 0, + "prompt_cost" to "prompt_cost", + "prompt_cost_details" to mapOf("foo" to "bar"), + "prompt_token_details" to mapOf("foo" to "bar"), + "prompt_tokens" to 0, + "prompt_tokens_p50" to 0, + "prompt_tokens_p99" to 0, + "run_count" to 0, + "run_facets" to listOf(mapOf("foo" to "bar")), + "streaming_rate" to 0, + "tokens_p99" to 0, + "total_cost" to "total_cost", + "total_tokens" to 0, + ) + ), + ) + .build() + ) + + val roundtrippedRunStatsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStatsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunStatsResponse).isEqualTo(runStatsResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val runStatsResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { runStatsResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexSyncParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdate2ParamsTest.kt similarity index 60% rename from langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexSyncParamsTest.kt rename to langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdate2ParamsTest.kt index 9f274d6a3..38239a0a2 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/datasets/index/IndexSyncParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdate2ParamsTest.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package com.langchain.smith.models.datasets.index +package com.langchain.smith.models.runs import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class IndexSyncParamsTest { +internal class RunUpdate2ParamsTest { @Test fun create() { - IndexSyncParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + RunUpdate2Params.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun pathParams() { val params = - IndexSyncParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + RunUpdate2Params.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") // out-of-bound path param diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdate2ResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdate2ResponseTest.kt new file mode 100644 index 000000000..a528fd29e --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdate2ResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdate2ResponseTest { + + @Test + fun create() { + val runUpdate2Response = RunUpdate2Response.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runUpdate2Response = RunUpdate2Response.builder().build() + + val roundtrippedRunUpdate2Response = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runUpdate2Response), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunUpdate2Response).isEqualTo(runUpdate2Response) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdateParamsTest.kt new file mode 100644 index 000000000..08164f565 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdateParamsTest.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.langchain.smith.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateParamsTest { + + @Test + fun create() { + RunUpdateParams.builder() + .runId("run_id") + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = RunUpdateParams.builder().runId("run_id").run(Run.builder().build()).build() + + assertThat(params._pathParam(0)).isEqualTo("run_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunUpdateParams.builder() + .runId("run_id") + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RunUpdateParams.builder().runId("run_id").run(Run.builder().build()).build() + + val body = params._body() + + assertThat(body).isEqualTo(Run.builder().build()) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdateResponseTest.kt new file mode 100644 index 000000000..b3c7fe1a2 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/runs/RunUpdateResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateResponseTest { + + @Test + fun create() { + val runUpdateResponse = + RunUpdateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runUpdateResponse = + RunUpdateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedRunUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRunUpdateResponse).isEqualTo(runUpdateResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt index 2b0b17bd0..9ac15a9c9 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/CreateRunClusteringJobRequestTest.kt @@ -26,6 +26,7 @@ internal class CreateRunClusteringJobRequestTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) + .isScheduled(true) .lastNHours(0L) .model(CreateRunClusteringJobRequest.Model.OPENAI) .name("name") @@ -59,6 +60,7 @@ internal class CreateRunClusteringJobRequestTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(createRunClusteringJobRequest.filter()).contains("filter") assertThat(createRunClusteringJobRequest.hierarchy().getOrNull()).containsExactly(0L) + assertThat(createRunClusteringJobRequest.isScheduled()).contains(true) assertThat(createRunClusteringJobRequest.lastNHours()).contains(0L) assertThat(createRunClusteringJobRequest.model()) .contains(CreateRunClusteringJobRequest.Model.OPENAI) @@ -98,6 +100,7 @@ internal class CreateRunClusteringJobRequestTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) + .isScheduled(true) .lastNHours(0L) .model(CreateRunClusteringJobRequest.Model.OPENAI) .name("name") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt index 3be1b26b0..31e601603 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightCreateParamsTest.kt @@ -25,6 +25,7 @@ internal class InsightCreateParamsTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) + .isScheduled(true) .lastNHours(0L) .model(CreateRunClusteringJobRequest.Model.OPENAI) .name("name") @@ -78,6 +79,7 @@ internal class InsightCreateParamsTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) + .isScheduled(true) .lastNHours(0L) .model(CreateRunClusteringJobRequest.Model.OPENAI) .name("name") @@ -115,6 +117,7 @@ internal class InsightCreateParamsTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) + .isScheduled(true) .lastNHours(0L) .model(CreateRunClusteringJobRequest.Model.OPENAI) .name("name") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt index 5e3abde3c..801b5abe0 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/sessions/insights/InsightRetrieveJobResponseTest.kt @@ -32,6 +32,7 @@ internal class InsightRetrieveJobResponseTest { .parentName("parent_name") .build() ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .status("status") .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -86,6 +87,8 @@ internal class InsightRetrieveJobResponseTest { .parentName("parent_name") .build() ) + assertThat(insightRetrieveJobResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(insightRetrieveJobResponse.name()).isEqualTo("name") assertThat(insightRetrieveJobResponse.status()).isEqualTo("status") assertThat(insightRetrieveJobResponse.configId()) @@ -149,6 +152,7 @@ internal class InsightRetrieveJobResponseTest { .parentName("parent_name") .build() ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .status("status") .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/prompts/PromptClientTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/prompts/PromptClientTest.kt index 023a329b6..74e2b0f97 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/prompts/PromptClientTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/prompts/PromptClientTest.kt @@ -8,12 +8,7 @@ import org.junit.jupiter.params.provider.MethodSource internal class PromptClientTest { - data class Case( - val identifier: String, - val owner: String, - val repo: String, - val commit: String, - ) + data class Case(val identifier: String, val owner: String, val repo: String, val commit: String) data class ErrorCase(val identifier: String, val expectedMessage: String) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt index b791ccd70..9acda2e5f 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncTest.kt @@ -9,6 +9,7 @@ import com.langchain.smith.models.annotationqueues.AnnotationQueueCreateRunStatu import com.langchain.smith.models.annotationqueues.AnnotationQueueExportParams import com.langchain.smith.models.annotationqueues.AnnotationQueuePopulateParams import com.langchain.smith.models.annotationqueues.AnnotationQueueRetrieveRunParams +import com.langchain.smith.models.annotationqueues.AnnotationQueueRetrieveSizeParams import com.langchain.smith.models.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams import com.langchain.smith.models.annotationqueues.AnnotationQueueRubricItemSchema import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateParams @@ -199,6 +200,7 @@ internal class AnnotationQueueServiceAsyncTest { AnnotationQueueExportParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .includeAnnotatorDetail(true) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -301,7 +303,12 @@ internal class AnnotationQueueServiceAsyncTest { val annotationQueueServiceAsync = client.annotationQueues() val annotationQueueSizeSchemaFuture = - annotationQueueServiceAsync.retrieveSize("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + annotationQueueServiceAsync.retrieveSize( + AnnotationQueueRetrieveSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(AnnotationQueueRetrieveSizeParams.Status.NEEDS_MY_REVIEW) + .build() + ) val annotationQueueSizeSchema = annotationQueueSizeSchemaFuture.get() annotationQueueSizeSchema.validate() 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 2fe23396a..20b1c6e81 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 @@ -376,7 +376,7 @@ internal class DatasetServiceAsyncTest { val datasetFuture = datasetServiceAsync.upload( DatasetUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .dataType(DataType.KV) .description("description") 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 d984aa968..0ec0d2a72 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 @@ -233,7 +233,7 @@ internal class ExampleServiceAsyncTest { exampleServiceAsync.uploadFromCsv( ExampleUploadFromCsvParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .addMetadataKey("string") .addOutputKey("string") 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 35be3c846..347d2d953 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 @@ -39,11 +39,6 @@ internal class FeedbackServiceAsyncTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) - .extra( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RepoServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RepoServiceAsyncTest.kt index da4888ac6..5739e99a1 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RepoServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RepoServiceAsyncTest.kt @@ -30,6 +30,8 @@ internal class RepoServiceAsyncTest { .repoHandle("repo_handle") .description("description") .readme("readme") + .repoType(RepoCreateParams.RepoType.PROMPT) + .restrictedMode(true) .addTag("string") .build() ) @@ -78,6 +80,7 @@ internal class RepoServiceAsyncTest { .isArchived(true) .isPublic(true) .readme("readme") + .restrictedMode(true) .addTag("string") .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RunServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RunServiceAsyncTest.kt index 5fe518800..0d63b35a7 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RunServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/RunServiceAsyncTest.kt @@ -7,12 +7,190 @@ import com.langchain.smith.core.JsonValue import com.langchain.smith.models.runs.Run import com.langchain.smith.models.runs.RunIngestBatchParams import com.langchain.smith.models.runs.RunQueryParams +import com.langchain.smith.models.runs.RunRetrieveParams +import com.langchain.smith.models.runs.RunStatsQueryParams +import com.langchain.smith.models.runs.RunTypeEnum +import com.langchain.smith.models.runs.RunUpdateParams +import com.langchain.smith.models.runs.RunsFilterDataSourceTypeEnum +import com.langchain.smith.models.sessions.RunStatsGroupBy import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RunServiceAsyncTest { + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val runFuture = + runServiceAsync.create( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + + val run = runFuture.get() + run.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val runSchemaFuture = + runServiceAsync.retrieve( + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .includeMessages(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val runSchema = runSchemaFuture.get() + runSchema.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val runFuture = + runServiceAsync.update( + RunUpdateParams.builder() + .runId("run_id") + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + ) + + val run = runFuture.get() + run.validate() + } + @Disabled("Mock server tests are disabled") @Test fun ingestBatch() { @@ -156,7 +334,7 @@ internal class RunServiceAsyncTest { RunQueryParams.builder() .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .dataSourceType(RunQueryParams.DataSourceType.CURRENT) + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .executionOrder(1L) @@ -167,7 +345,7 @@ internal class RunServiceAsyncTest { .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .query("query") .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .runType(RunQueryParams.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .searchFilter("search_filter") .addSelect(RunQueryParams.Select.ID) .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -184,4 +362,70 @@ internal class RunServiceAsyncTest { val response = responseFuture.get() response.validate() } + + @Disabled("Mock server tests are disabled") + @Test + fun stats() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val responseFuture = + runServiceAsync.stats( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update2() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val responseFuture = runServiceAsync.update2("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } } 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 97825b450..e6b1e3073 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 @@ -81,6 +81,7 @@ internal class RunServiceAsyncTest { .includeStats(true) .limit(1L) .offset(0L) + .status(RunListParams.Status.NEEDS_MY_REVIEW) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt index f9591523c..750d2d15e 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/ComparativeServiceAsyncTest.kt @@ -44,23 +44,6 @@ internal class ComparativeServiceAsyncTest { comparative.validate() } - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = - LangsmithOkHttpClientAsync.builder() - .apiKey("My API Key") - .tenantId("My Tenant ID") - .organizationId("My Organization ID") - .build() - val comparativeServiceAsync = client.datasets().comparative() - - val pageFuture = comparativeServiceAsync.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - - val page = pageFuture.get() - page.items().forEach { it.validate() } - } - @Disabled("Mock server tests are disabled") @Test fun delete() { diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsyncTest.kt deleted file mode 100644 index 80dbd3e75..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/datasets/IndexServiceAsyncTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.services.async.datasets - -import com.langchain.smith.client.okhttp.LangsmithOkHttpClientAsync -import com.langchain.smith.models.datasets.index.IndexCreateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class IndexServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - LangsmithOkHttpClientAsync.builder() - .apiKey("My API Key") - .tenantId("My Tenant ID") - .organizationId("My Organization ID") - .build() - val indexServiceAsync = client.datasets().index() - - val indexFuture = - indexServiceAsync.create( - IndexCreateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tag("tag") - .build() - ) - - val index = indexFuture.get() - index.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun sync() { - val client = - LangsmithOkHttpClientAsync.builder() - .apiKey("My API Key") - .tenantId("My Tenant ID") - .organizationId("My Organization ID") - .build() - val indexServiceAsync = client.datasets().index() - - val responseFuture = indexServiceAsync.sync("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - - val response = responseFuture.get() - response.validate() - } -} 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 19c0917c2..de91c8e94 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 @@ -25,7 +25,7 @@ internal class RunServiceAsyncTest { .build() val runServiceAsync = client.datasets().runs() - val runFuture = + val exampleWithRunsChesFuture = runServiceAsync.create( RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -38,6 +38,7 @@ internal class RunServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .includeAnnotatorDetail(true) .limit(1L) .offset(0L) .preview(true) @@ -51,9 +52,9 @@ internal class RunServiceAsyncTest { .build() ) - val run = runFuture.get() - val unwrappedRun = run.getOrNull() - unwrappedRun?.validate() + val exampleWithRunsChes = exampleWithRunsChesFuture.get() + val unwrappedExampleWithRunsChes = exampleWithRunsChes.getOrNull() + unwrappedExampleWithRunsChes?.forEach { it.validate() } } @Disabled("Mock server tests are disabled") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt index 4136620b4..24df9c0e8 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/sessions/InsightServiceAsyncTest.kt @@ -43,6 +43,7 @@ internal class InsightServiceAsyncTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) + .isScheduled(true) .lastNHours(0L) .model(CreateRunClusteringJobRequest.Model.OPENAI) .name("name") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt index 2b902d098..a73f83277 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceTest.kt @@ -9,6 +9,7 @@ import com.langchain.smith.models.annotationqueues.AnnotationQueueCreateRunStatu import com.langchain.smith.models.annotationqueues.AnnotationQueueExportParams import com.langchain.smith.models.annotationqueues.AnnotationQueuePopulateParams import com.langchain.smith.models.annotationqueues.AnnotationQueueRetrieveRunParams +import com.langchain.smith.models.annotationqueues.AnnotationQueueRetrieveSizeParams import com.langchain.smith.models.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams import com.langchain.smith.models.annotationqueues.AnnotationQueueRubricItemSchema import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateParams @@ -193,6 +194,7 @@ internal class AnnotationQueueServiceTest { AnnotationQueueExportParams.builder() .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .includeAnnotatorDetail(true) .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -290,7 +292,12 @@ internal class AnnotationQueueServiceTest { val annotationQueueService = client.annotationQueues() val annotationQueueSizeSchema = - annotationQueueService.retrieveSize("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + annotationQueueService.retrieveSize( + AnnotationQueueRetrieveSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(AnnotationQueueRetrieveSizeParams.Status.NEEDS_MY_REVIEW) + .build() + ) annotationQueueSizeSchema.validate() } 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 288035033..78b0859d4 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 @@ -364,7 +364,7 @@ internal class DatasetServiceTest { val dataset = datasetService.upload( DatasetUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .dataType(DataType.KV) .description("description") 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 3394a727b..309ad2049 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 @@ -224,7 +224,7 @@ internal class ExampleServiceTest { exampleService.uploadFromCsv( ExampleUploadFromCsvParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .addInputKey("string") .addMetadataKey("string") .addOutputKey("string") 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 b2e5b255f..5d5b1e640 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 @@ -39,11 +39,6 @@ internal class FeedbackServiceTest { ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) - .extra( - FeedbackCreateSchema.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .feedbackConfig( FeedbackCreateSchema.FeedbackConfig.builder() .type(FeedbackCreateSchema.FeedbackConfig.Type.CONTINUOUS) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RepoServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RepoServiceTest.kt index f9866ca2d..0ad830da1 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RepoServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RepoServiceTest.kt @@ -30,6 +30,8 @@ internal class RepoServiceTest { .repoHandle("repo_handle") .description("description") .readme("readme") + .repoType(RepoCreateParams.RepoType.PROMPT) + .restrictedMode(true) .addTag("string") .build() ) @@ -74,6 +76,7 @@ internal class RepoServiceTest { .isArchived(true) .isPublic(true) .readme("readme") + .restrictedMode(true) .addTag("string") .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RunServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RunServiceTest.kt index a5fe5dc8e..c3b1d73b6 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RunServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/RunServiceTest.kt @@ -7,12 +7,187 @@ import com.langchain.smith.core.JsonValue import com.langchain.smith.models.runs.Run import com.langchain.smith.models.runs.RunIngestBatchParams import com.langchain.smith.models.runs.RunQueryParams +import com.langchain.smith.models.runs.RunRetrieveParams +import com.langchain.smith.models.runs.RunStatsQueryParams +import com.langchain.smith.models.runs.RunTypeEnum +import com.langchain.smith.models.runs.RunUpdateParams +import com.langchain.smith.models.runs.RunsFilterDataSourceTypeEnum +import com.langchain.smith.models.sessions.RunStatsGroupBy import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class RunServiceTest { + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = + LangsmithOkHttpClient.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val run = + runService.create( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + + run.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithOkHttpClient.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val runSchema = + runService.retrieve( + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .includeMessages(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + runSchema.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = + LangsmithOkHttpClient.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val run = + runService.update( + RunUpdateParams.builder() + .runId("run_id") + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + ) + + run.validate() + } + @Disabled("Mock server tests are disabled") @Test fun ingestBatch() { @@ -155,7 +330,7 @@ internal class RunServiceTest { RunQueryParams.builder() .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .dataSourceType(RunQueryParams.DataSourceType.CURRENT) + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .error(true) .executionOrder(1L) @@ -166,7 +341,7 @@ internal class RunServiceTest { .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .query("query") .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .runType(RunQueryParams.RunType.TOOL) + .runType(RunTypeEnum.TOOL) .searchFilter("search_filter") .addSelect(RunQueryParams.Select.ID) .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -182,4 +357,68 @@ internal class RunServiceTest { response.validate() } + + @Disabled("Mock server tests are disabled") + @Test + fun stats() { + val client = + LangsmithOkHttpClient.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val response = + runService.stats( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update2() { + val client = + LangsmithOkHttpClient.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val response = runService.update2("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } } 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 c19bf07d3..dc58346e9 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 @@ -79,6 +79,7 @@ internal class RunServiceTest { .includeStats(true) .limit(1L) .offset(0L) + .status(RunListParams.Status.NEEDS_MY_REVIEW) .build() ) diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt index 97735e387..34c4ec550 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/ComparativeServiceTest.kt @@ -43,22 +43,6 @@ internal class ComparativeServiceTest { comparative.validate() } - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = - LangsmithOkHttpClient.builder() - .apiKey("My API Key") - .tenantId("My Tenant ID") - .organizationId("My Organization ID") - .build() - val comparativeService = client.datasets().comparative() - - val page = comparativeService.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - - page.items().forEach { it.validate() } - } - @Disabled("Mock server tests are disabled") @Test fun delete() { diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/IndexServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/IndexServiceTest.kt deleted file mode 100644 index 38c9eda25..000000000 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/datasets/IndexServiceTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.langchain.smith.services.blocking.datasets - -import com.langchain.smith.client.okhttp.LangsmithOkHttpClient -import com.langchain.smith.models.datasets.index.IndexCreateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class IndexServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - LangsmithOkHttpClient.builder() - .apiKey("My API Key") - .tenantId("My Tenant ID") - .organizationId("My Organization ID") - .build() - val indexService = client.datasets().index() - - val index = - indexService.create( - IndexCreateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tag("tag") - .build() - ) - - index.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun sync() { - val client = - LangsmithOkHttpClient.builder() - .apiKey("My API Key") - .tenantId("My Tenant ID") - .organizationId("My Organization ID") - .build() - val indexService = client.datasets().index() - - val response = indexService.sync("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - - response.validate() - } -} 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 82f0cf2d1..e136d93e3 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 @@ -25,7 +25,7 @@ internal class RunServiceTest { .build() val runService = client.datasets().runs() - val run = + val exampleWithRunsChes = runService.create( RunCreateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -38,6 +38,7 @@ internal class RunServiceTest { .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) .build() ) + .includeAnnotatorDetail(true) .limit(1L) .offset(0L) .preview(true) @@ -51,8 +52,8 @@ internal class RunServiceTest { .build() ) - val unwrappedRun = run.getOrNull() - unwrappedRun?.validate() + val unwrappedExampleWithRunsChes = exampleWithRunsChes.getOrNull() + unwrappedExampleWithRunsChes?.forEach { it.validate() } } @Disabled("Mock server tests are disabled") diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt index 6f0ede0d1..16166a607 100644 --- a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/sessions/InsightServiceTest.kt @@ -43,6 +43,7 @@ internal class InsightServiceTest { .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addHierarchy(0L) + .isScheduled(true) .lastNHours(0L) .model(CreateRunClusteringJobRequest.Model.OPENAI) .name("name") diff --git a/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt b/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt index aad827181..1fe8a8203 100644 --- a/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt +++ b/langsmith-java-proguard-test/src/test/kotlin/com/langchain/smith/proguard/ProGuardCompatibilityTest.kt @@ -6,8 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.langchain.smith.client.okhttp.LangsmithOkHttpClient import com.langchain.smith.core.JsonValue import com.langchain.smith.core.jsonMapper -import com.langchain.smith.models.datasets.runs.ExampleWithRuns -import com.langchain.smith.models.datasets.runs.RunCreateResponse +import com.langchain.smith.models.runs.RunStatsResponse import com.langchain.smith.models.sessions.CustomChartsSection import com.langchain.smith.models.sessions.SessionSortableColumns import java.time.OffsetDateTime @@ -236,169 +235,73 @@ internal class ProGuardCompatibilityTest { } @Test - fun runCreateResponseRoundtrip() { + fun runStatsResponseRoundtrip() { val jsonMapper = jsonMapper() - val runCreateResponse = - RunCreateResponse.ofExamplesWithRuns( - listOf( - ExampleWithRuns.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inputs( - ExampleWithRuns.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .addRun( - ExampleWithRuns.Run.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .appPath("app_path") - .dottedOrder("dotted_order") - .name("name") - .runType(ExampleWithRuns.Run.RunType.TOOL) - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status("status") - .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .completionCost("completion_cost") - .completionCostDetails( - ExampleWithRuns.Run.CompletionCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .completionTokenDetails( - ExampleWithRuns.Run.CompletionTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .completionTokens(0L) - .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error("error") - .addEvent( - ExampleWithRuns.Run.Event.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .executionOrder(1L) - .extra( - ExampleWithRuns.Run.Extra.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .feedbackStats( - ExampleWithRuns.Run.FeedbackStats.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("foo" to "bar")), - ) - .build() - ) - .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inDataset(true) - .inputs( - ExampleWithRuns.Run.Inputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .inputsPreview("inputs_preview") - .inputsS3Urls( - ExampleWithRuns.Run.InputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMessage( - ExampleWithRuns.Run.Message.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputs( - ExampleWithRuns.Run.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .outputsPreview("outputs_preview") - .outputsS3Urls( - ExampleWithRuns.Run.OutputsS3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .promptCost("prompt_cost") - .promptCostDetails( - ExampleWithRuns.Run.PromptCostDetails.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .promptTokenDetails( - ExampleWithRuns.Run.PromptTokenDetails.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .promptTokens(0L) - .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .s3Urls( - ExampleWithRuns.Run.S3Urls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .serialized( - ExampleWithRuns.Run.Serialized.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addTag("string") - .threadId("thread_id") - .totalCost("total_cost") - .totalTokens(0L) - .traceFirstReceivedAt( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .traceTier(ExampleWithRuns.Run.TraceTier.LONGLIVED) - .traceUpgrade(true) - .ttlSeconds(0L) - .build() - ) - .attachmentUrls( - ExampleWithRuns.AttachmentUrls.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - ExampleWithRuns.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .outputs( - ExampleWithRuns.Outputs.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val runStatsResponse = + RunStatsResponse.ofRunStats( + RunStatsResponse.RunStats.builder() + .completionCost("completion_cost") + .completionCostDetails( + RunStatsResponse.RunStats.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .completionTokenDetails( + RunStatsResponse.RunStats.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats( + RunStatsResponse.RunStats.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails( + RunStatsResponse.RunStats.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .promptTokenDetails( + RunStatsResponse.RunStats.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet( + RunStatsResponse.RunStats.RunFacet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() ) - val roundtrippedRunCreateResponse = + val roundtrippedRunStatsResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(runCreateResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(runStatsResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + assertThat(roundtrippedRunStatsResponse).isEqualTo(runStatsResponse) } @Test diff --git a/scripts/fast-format b/scripts/fast-format index 1b3bc473a..35a1dee25 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -24,8 +24,8 @@ if [ ! -f "$FILE_LIST" ]; then exit 1 fi -if ! command -v ktfmt-fast-format &> /dev/null; then - echo "Error: ktfmt-fast-format not found" +if ! command -v ktfmt &> /dev/null; then + echo "Error: ktfmt not found" exit 1 fi @@ -36,7 +36,7 @@ echo "==> Done looking for Kotlin files" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" - echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt --kotlinlang-style "$@" else echo "No Kotlin files to format -- expected outcome during incremental formatting" fi