Release SDK updates (#183)

This commit is contained in:
KiewanVillatel
2026-07-14 11:30:12 +02:00
committed by GitHub
53 changed files with 13032 additions and 391 deletions
+1 -1
View File
@@ -1 +1 @@
configured_endpoints: 143
configured_endpoints: 144
+7 -7
View File
@@ -19,7 +19,7 @@ sourceSets.main {
resources.srcDir(generateVersionProperties)
}
val jacksonVersion = "2.22.0"
val jacksonVersion = "2.22.1"
val jacksonAnnotationsVersion = "2.22"
configurations.matching { it.name in setOf("testCompileClasspath", "testRuntimeClasspath") }.configureEach {
@@ -83,14 +83,14 @@ dependencies {
testImplementation("org.eclipse.jetty.http2:http2-common") { version { require("12.1.10") } }
testImplementation("org.eclipse.jetty.http2:http2-hpack") { version { require("12.1.10") } }
testImplementation("org.eclipse.jetty.http2:http2-server") { version { require("12.1.10") } }
testImplementation("org.bouncycastle:bcpg-jdk18on") { version { require("1.84") } }
testImplementation("org.bouncycastle:bcpkix-jdk18on") { version { require("1.84") } }
testImplementation("org.bouncycastle:bcprov-jdk18on") { version { require("1.84") } }
testImplementation("org.apache.logging.log4j:log4j-core") { version { require("2.25.4") } }
testImplementation("org.bouncycastle:bcpg-jdk18on:1.84")
testImplementation("org.bouncycastle:bcpkix-jdk18on:1.84")
testImplementation("org.bouncycastle:bcprov-jdk18on:1.84")
testImplementation("org.apache.logging.log4j:log4j-core:2.25.4")
testImplementation("org.apache.opennlp:opennlp-tools") { version { require("2.5.9") } }
testImplementation("com.github.jknack:handlebars") { version { require("4.5.2") } }
testImplementation("org.codehaus.plexus:plexus-utils") { version { require("4.0.3") } }
testImplementation("org.apache.commons:commons-lang3") { version { require("3.20.0") } }
testImplementation("org.codehaus.plexus:plexus-utils:4.0.3")
testImplementation("org.apache.commons:commons-lang3:3.18.0")
testImplementation("org.apache.commons:commons-compress") { version { require("1.28.0") } }
testImplementation("commons-fileupload:commons-fileupload") { version { require("1.6.0") } }
testImplementation("commons-io:commons-io") { version { require("2.22.0") } }
@@ -0,0 +1,565 @@
// File generated from our OpenAPI spec by Stainless.
package com.langchain.smith.models.annotationqueues.runs
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.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.checkRequired
import com.langchain.smith.core.http.Headers
import com.langchain.smith.core.http.QueryParams
import com.langchain.smith.core.toImmutable
import com.langchain.smith.errors.LangChainInvalidDataException
import java.time.OffsetDateTime
import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
/** Add Runs To Annotation Queue By Key */
class RunCreateByKeyParams
private constructor(
private val queueId: String?,
private val extendTraceRetention: Boolean?,
private val body: List<Body>,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) : Params {
fun queueId(): Optional<String> = Optional.ofNullable(queueId)
fun extendTraceRetention(): Optional<Boolean> = Optional.ofNullable(extendTraceRetention)
fun body(): List<Body> = body
/** 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 [RunCreateByKeyParams].
*
* The following fields are required:
* ```java
* .body()
* ```
*/
@JvmStatic fun builder() = Builder()
}
/** A builder for [RunCreateByKeyParams]. */
class Builder internal constructor() {
private var queueId: String? = null
private var extendTraceRetention: Boolean? = null
private var body: MutableList<Body>? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@JvmSynthetic
internal fun from(runCreateByKeyParams: RunCreateByKeyParams) = apply {
queueId = runCreateByKeyParams.queueId
extendTraceRetention = runCreateByKeyParams.extendTraceRetention
body = runCreateByKeyParams.body.toMutableList()
additionalHeaders = runCreateByKeyParams.additionalHeaders.toBuilder()
additionalQueryParams = runCreateByKeyParams.additionalQueryParams.toBuilder()
}
fun queueId(queueId: String?) = apply { this.queueId = queueId }
/** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */
fun queueId(queueId: Optional<String>) = queueId(queueId.getOrNull())
fun extendTraceRetention(extendTraceRetention: Boolean?) = apply {
this.extendTraceRetention = extendTraceRetention
}
/**
* Alias for [Builder.extendTraceRetention].
*
* This unboxed primitive overload exists for backwards compatibility.
*/
fun extendTraceRetention(extendTraceRetention: Boolean) =
extendTraceRetention(extendTraceRetention as Boolean?)
/**
* Alias for calling [Builder.extendTraceRetention] with
* `extendTraceRetention.orElse(null)`.
*/
fun extendTraceRetention(extendTraceRetention: Optional<Boolean>) =
extendTraceRetention(extendTraceRetention.getOrNull())
fun body(body: List<Body>) = apply { this.body = body.toMutableList() }
/**
* Adds a single [Body] to [Builder.body].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
fun addBody(body: Body) = apply {
this.body = (this.body ?: mutableListOf()).apply { add(body) }
}
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
}
fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
}
fun putAdditionalHeader(name: String, value: String) = apply {
additionalHeaders.put(name, value)
}
fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply {
additionalHeaders.put(name, values)
}
fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.putAll(additionalHeaders)
}
fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply {
this.additionalHeaders.putAll(additionalHeaders)
}
fun replaceAdditionalHeaders(name: String, value: String) = apply {
additionalHeaders.replace(name, value)
}
fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply {
additionalHeaders.replace(name, values)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.replaceAll(additionalHeaders)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply {
this.additionalHeaders.replaceAll(additionalHeaders)
}
fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
fun removeAllAdditionalHeaders(names: Set<String>) = apply {
additionalHeaders.removeAll(names)
}
fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
this.additionalQueryParams.clear()
putAllAdditionalQueryParams(additionalQueryParams)
}
fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply {
this.additionalQueryParams.clear()
putAllAdditionalQueryParams(additionalQueryParams)
}
fun putAdditionalQueryParam(key: String, value: String) = apply {
additionalQueryParams.put(key, value)
}
fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply {
additionalQueryParams.put(key, values)
}
fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
this.additionalQueryParams.putAll(additionalQueryParams)
}
fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) =
apply {
this.additionalQueryParams.putAll(additionalQueryParams)
}
fun replaceAdditionalQueryParams(key: String, value: String) = apply {
additionalQueryParams.replace(key, value)
}
fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply {
additionalQueryParams.replace(key, values)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) =
apply {
this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
fun removeAllAdditionalQueryParams(keys: Set<String>) = apply {
additionalQueryParams.removeAll(keys)
}
/**
* Returns an immutable instance of [RunCreateByKeyParams].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
* .body()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
fun build(): RunCreateByKeyParams =
RunCreateByKeyParams(
queueId,
extendTraceRetention,
checkRequired("body", body).toImmutable(),
additionalHeaders.build(),
additionalQueryParams.build(),
)
}
fun _body(): List<Body> = body
fun _pathParam(index: Int): String =
when (index) {
0 -> queueId ?: ""
else -> ""
}
override fun _headers(): Headers = additionalHeaders
override fun _queryParams(): QueryParams =
QueryParams.builder()
.apply {
extendTraceRetention?.let { put("extend_trace_retention", it.toString()) }
putAll(additionalQueryParams)
}
.build()
/** Add run to AQ by SmithDB key. is_root derived server-side (LSAQ-141). */
class Body
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val runId: JsonField<String>,
private val sessionId: JsonField<String>,
private val startTime: JsonField<OffsetDateTime>,
private val sourceProposedExampleId: JsonField<String>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {
@JsonCreator
private constructor(
@JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(),
@JsonProperty("session_id")
@ExcludeMissing
sessionId: JsonField<String> = JsonMissing.of(),
@JsonProperty("start_time")
@ExcludeMissing
startTime: JsonField<OffsetDateTime> = JsonMissing.of(),
@JsonProperty("source_proposed_example_id")
@ExcludeMissing
sourceProposedExampleId: JsonField<String> = JsonMissing.of(),
) : this(runId, sessionId, startTime, sourceProposedExampleId, mutableMapOf())
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
fun runId(): String = runId.getRequired("run_id")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type 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 startTime(): OffsetDateTime = startTime.getRequired("start_time")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
*/
fun sourceProposedExampleId(): Optional<String> =
sourceProposedExampleId.getOptional("source_proposed_example_id")
/**
* Returns the raw JSON value of [runId].
*
* Unlike [runId], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId
/**
* 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<String> = sessionId
/**
* Returns the raw JSON value of [startTime].
*
* Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("start_time")
@ExcludeMissing
fun _startTime(): JsonField<OffsetDateTime> = startTime
/**
* Returns the raw JSON value of [sourceProposedExampleId].
*
* Unlike [sourceProposedExampleId], this method doesn't throw if the JSON field has an
* unexpected type.
*/
@JsonProperty("source_proposed_example_id")
@ExcludeMissing
fun _sourceProposedExampleId(): JsonField<String> = sourceProposedExampleId
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
}
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> =
Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
companion object {
/**
* Returns a mutable builder for constructing an instance of [Body].
*
* The following fields are required:
* ```java
* .runId()
* .sessionId()
* .startTime()
* ```
*/
@JvmStatic fun builder() = Builder()
}
/** A builder for [Body]. */
class Builder internal constructor() {
private var runId: JsonField<String>? = null
private var sessionId: JsonField<String>? = null
private var startTime: JsonField<OffsetDateTime>? = null
private var sourceProposedExampleId: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
internal fun from(body: Body) = apply {
runId = body.runId
sessionId = body.sessionId
startTime = body.startTime
sourceProposedExampleId = body.sourceProposedExampleId
additionalProperties = body.additionalProperties.toMutableMap()
}
fun runId(runId: String) = runId(JsonField.of(runId))
/**
* Sets [Builder.runId] to an arbitrary JSON value.
*
* You should usually call [Builder.runId] with a well-typed [String] value instead.
* This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
fun runId(runId: JsonField<String>) = apply { this.runId = runId }
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<String>) = apply { this.sessionId = sessionId }
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<OffsetDateTime>) = apply {
this.startTime = startTime
}
fun sourceProposedExampleId(sourceProposedExampleId: String?) =
sourceProposedExampleId(JsonField.ofNullable(sourceProposedExampleId))
/**
* Alias for calling [Builder.sourceProposedExampleId] with
* `sourceProposedExampleId.orElse(null)`.
*/
fun sourceProposedExampleId(sourceProposedExampleId: Optional<String>) =
sourceProposedExampleId(sourceProposedExampleId.getOrNull())
/**
* Sets [Builder.sourceProposedExampleId] to an arbitrary JSON value.
*
* You should usually call [Builder.sourceProposedExampleId] with a well-typed [String]
* value instead. This method is primarily for setting the field to an undocumented or
* not yet supported value.
*/
fun sourceProposedExampleId(sourceProposedExampleId: JsonField<String>) = apply {
this.sourceProposedExampleId = sourceProposedExampleId
}
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
}
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
additionalProperties.put(key, value)
}
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.putAll(additionalProperties)
}
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
keys.forEach(::removeAdditionalProperty)
}
/**
* Returns an immutable instance of [Body].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
* .runId()
* .sessionId()
* .startTime()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
fun build(): Body =
Body(
checkRequired("runId", runId),
checkRequired("sessionId", sessionId),
checkRequired("startTime", startTime),
sourceProposedExampleId,
additionalProperties.toMutableMap(),
)
}
private var validated: Boolean = false
/**
* Validates that the types of all values in this object match their expected types
* recursively.
*
* This method is _not_ forwards compatible with new types from the API for existing fields.
*
* @throws LangChainInvalidDataException if any value type in this object doesn't match its
* expected type.
*/
fun validate(): Body = apply {
if (validated) {
return@apply
}
runId()
sessionId()
startTime()
sourceProposedExampleId()
validated = true
}
fun isValid(): Boolean =
try {
validate()
true
} catch (e: LangChainInvalidDataException) {
false
}
/**
* Returns a score indicating how many valid values are contained in this object
* recursively.
*
* Used for best match union deserialization.
*/
@JvmSynthetic
internal fun validity(): Int =
(if (runId.asKnown().isPresent) 1 else 0) +
(if (sessionId.asKnown().isPresent) 1 else 0) +
(if (startTime.asKnown().isPresent) 1 else 0) +
(if (sourceProposedExampleId.asKnown().isPresent) 1 else 0)
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is Body &&
runId == other.runId &&
sessionId == other.sessionId &&
startTime == other.startTime &&
sourceProposedExampleId == other.sourceProposedExampleId &&
additionalProperties == other.additionalProperties
}
private val hashCode: Int by lazy {
Objects.hash(runId, sessionId, startTime, sourceProposedExampleId, additionalProperties)
}
override fun hashCode(): Int = hashCode
override fun toString() =
"Body{runId=$runId, sessionId=$sessionId, startTime=$startTime, sourceProposedExampleId=$sourceProposedExampleId, additionalProperties=$additionalProperties}"
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is RunCreateByKeyParams &&
queueId == other.queueId &&
extendTraceRetention == other.extendTraceRetention &&
body == other.body &&
additionalHeaders == other.additionalHeaders &&
additionalQueryParams == other.additionalQueryParams
}
override fun hashCode(): Int =
Objects.hash(queueId, extendTraceRetention, body, additionalHeaders, additionalQueryParams)
override fun toString() =
"RunCreateByKeyParams{queueId=$queueId, extendTraceRetention=$extendTraceRetention, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
@@ -0,0 +1,386 @@
// File generated from our OpenAPI spec by Stainless.
package com.langchain.smith.models.annotationqueues.runs
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.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.errors.LangChainInvalidDataException
import java.time.OffsetDateTime
import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class RunCreateByKeyResponse
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val id: JsonField<String>,
private val queueId: JsonField<String>,
private val runId: JsonField<String>,
private val addedAt: JsonField<OffsetDateTime>,
private val lastReviewedTime: JsonField<OffsetDateTime>,
private val sourceProposedExampleId: JsonField<String>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {
@JsonCreator
private constructor(
@JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(),
@JsonProperty("queue_id") @ExcludeMissing queueId: JsonField<String> = JsonMissing.of(),
@JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(),
@JsonProperty("added_at")
@ExcludeMissing
addedAt: JsonField<OffsetDateTime> = JsonMissing.of(),
@JsonProperty("last_reviewed_time")
@ExcludeMissing
lastReviewedTime: JsonField<OffsetDateTime> = JsonMissing.of(),
@JsonProperty("source_proposed_example_id")
@ExcludeMissing
sourceProposedExampleId: JsonField<String> = JsonMissing.of(),
) : this(id, queueId, runId, addedAt, lastReviewedTime, sourceProposedExampleId, 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 queueId(): String = queueId.getRequired("queue_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 runId(): String = runId.getRequired("run_id")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun addedAt(): Optional<OffsetDateTime> = addedAt.getOptional("added_at")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun lastReviewedTime(): Optional<OffsetDateTime> =
lastReviewedTime.getOptional("last_reviewed_time")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun sourceProposedExampleId(): Optional<String> =
sourceProposedExampleId.getOptional("source_proposed_example_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<String> = id
/**
* Returns the raw JSON value of [queueId].
*
* Unlike [queueId], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("queue_id") @ExcludeMissing fun _queueId(): JsonField<String> = queueId
/**
* Returns the raw JSON value of [runId].
*
* Unlike [runId], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId
/**
* Returns the raw JSON value of [addedAt].
*
* Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField<OffsetDateTime> = addedAt
/**
* Returns the raw JSON value of [lastReviewedTime].
*
* Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected
* type.
*/
@JsonProperty("last_reviewed_time")
@ExcludeMissing
fun _lastReviewedTime(): JsonField<OffsetDateTime> = lastReviewedTime
/**
* Returns the raw JSON value of [sourceProposedExampleId].
*
* Unlike [sourceProposedExampleId], this method doesn't throw if the JSON field has an
* unexpected type.
*/
@JsonProperty("source_proposed_example_id")
@ExcludeMissing
fun _sourceProposedExampleId(): JsonField<String> = sourceProposedExampleId
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
}
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> =
Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
companion object {
/**
* Returns a mutable builder for constructing an instance of [RunCreateByKeyResponse].
*
* The following fields are required:
* ```java
* .id()
* .queueId()
* .runId()
* ```
*/
@JvmStatic fun builder() = Builder()
}
/** A builder for [RunCreateByKeyResponse]. */
class Builder internal constructor() {
private var id: JsonField<String>? = null
private var queueId: JsonField<String>? = null
private var runId: JsonField<String>? = null
private var addedAt: JsonField<OffsetDateTime> = JsonMissing.of()
private var lastReviewedTime: JsonField<OffsetDateTime> = JsonMissing.of()
private var sourceProposedExampleId: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
internal fun from(runCreateByKeyResponse: RunCreateByKeyResponse) = apply {
id = runCreateByKeyResponse.id
queueId = runCreateByKeyResponse.queueId
runId = runCreateByKeyResponse.runId
addedAt = runCreateByKeyResponse.addedAt
lastReviewedTime = runCreateByKeyResponse.lastReviewedTime
sourceProposedExampleId = runCreateByKeyResponse.sourceProposedExampleId
additionalProperties = runCreateByKeyResponse.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<String>) = apply { this.id = id }
fun queueId(queueId: String) = queueId(JsonField.of(queueId))
/**
* Sets [Builder.queueId] to an arbitrary JSON value.
*
* You should usually call [Builder.queueId] with a well-typed [String] value instead. This
* method is primarily for setting the field to an undocumented or not yet supported value.
*/
fun queueId(queueId: JsonField<String>) = apply { this.queueId = queueId }
fun runId(runId: String) = runId(JsonField.of(runId))
/**
* Sets [Builder.runId] to an arbitrary JSON value.
*
* You should usually call [Builder.runId] with a well-typed [String] value instead. This
* method is primarily for setting the field to an undocumented or not yet supported value.
*/
fun runId(runId: JsonField<String>) = apply { this.runId = runId }
fun addedAt(addedAt: OffsetDateTime) = addedAt(JsonField.of(addedAt))
/**
* Sets [Builder.addedAt] to an arbitrary JSON value.
*
* You should usually call [Builder.addedAt] with a well-typed [OffsetDateTime] value
* instead. This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
fun addedAt(addedAt: JsonField<OffsetDateTime>) = apply { this.addedAt = addedAt }
fun lastReviewedTime(lastReviewedTime: OffsetDateTime?) =
lastReviewedTime(JsonField.ofNullable(lastReviewedTime))
/** Alias for calling [Builder.lastReviewedTime] with `lastReviewedTime.orElse(null)`. */
fun lastReviewedTime(lastReviewedTime: Optional<OffsetDateTime>) =
lastReviewedTime(lastReviewedTime.getOrNull())
/**
* Sets [Builder.lastReviewedTime] to an arbitrary JSON value.
*
* You should usually call [Builder.lastReviewedTime] with a well-typed [OffsetDateTime]
* value instead. This method is primarily for setting the field to an undocumented or not
* yet supported value.
*/
fun lastReviewedTime(lastReviewedTime: JsonField<OffsetDateTime>) = apply {
this.lastReviewedTime = lastReviewedTime
}
fun sourceProposedExampleId(sourceProposedExampleId: String?) =
sourceProposedExampleId(JsonField.ofNullable(sourceProposedExampleId))
/**
* Alias for calling [Builder.sourceProposedExampleId] with
* `sourceProposedExampleId.orElse(null)`.
*/
fun sourceProposedExampleId(sourceProposedExampleId: Optional<String>) =
sourceProposedExampleId(sourceProposedExampleId.getOrNull())
/**
* Sets [Builder.sourceProposedExampleId] to an arbitrary JSON value.
*
* You should usually call [Builder.sourceProposedExampleId] with a well-typed [String]
* value instead. This method is primarily for setting the field to an undocumented or not
* yet supported value.
*/
fun sourceProposedExampleId(sourceProposedExampleId: JsonField<String>) = apply {
this.sourceProposedExampleId = sourceProposedExampleId
}
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
}
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
additionalProperties.put(key, value)
}
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.putAll(additionalProperties)
}
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
keys.forEach(::removeAdditionalProperty)
}
/**
* Returns an immutable instance of [RunCreateByKeyResponse].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
* .id()
* .queueId()
* .runId()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
fun build(): RunCreateByKeyResponse =
RunCreateByKeyResponse(
checkRequired("id", id),
checkRequired("queueId", queueId),
checkRequired("runId", runId),
addedAt,
lastReviewedTime,
sourceProposedExampleId,
additionalProperties.toMutableMap(),
)
}
private var validated: Boolean = false
/**
* Validates that the types of all values in this object match their expected types recursively.
*
* This method is _not_ forwards compatible with new types from the API for existing fields.
*
* @throws LangChainInvalidDataException if any value type in this object doesn't match its
* expected type.
*/
fun validate(): RunCreateByKeyResponse = apply {
if (validated) {
return@apply
}
id()
queueId()
runId()
addedAt()
lastReviewedTime()
sourceProposedExampleId()
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 (queueId.asKnown().isPresent) 1 else 0) +
(if (runId.asKnown().isPresent) 1 else 0) +
(if (addedAt.asKnown().isPresent) 1 else 0) +
(if (lastReviewedTime.asKnown().isPresent) 1 else 0) +
(if (sourceProposedExampleId.asKnown().isPresent) 1 else 0)
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is RunCreateByKeyResponse &&
id == other.id &&
queueId == other.queueId &&
runId == other.runId &&
addedAt == other.addedAt &&
lastReviewedTime == other.lastReviewedTime &&
sourceProposedExampleId == other.sourceProposedExampleId &&
additionalProperties == other.additionalProperties
}
private val hashCode: Int by lazy {
Objects.hash(
id,
queueId,
runId,
addedAt,
lastReviewedTime,
sourceProposedExampleId,
additionalProperties,
)
}
override fun hashCode(): Int = hashCode
override fun toString() =
"RunCreateByKeyResponse{id=$id, queueId=$queueId, runId=$runId, addedAt=$addedAt, lastReviewedTime=$lastReviewedTime, sourceProposedExampleId=$sourceProposedExampleId, additionalProperties=$additionalProperties}"
}
@@ -26,6 +26,7 @@ private constructor(
private val createdAt: JsonField<String>,
private val createdBy: JsonField<String>,
private val feedbackKeys: JsonField<List<String>>,
private val isManaged: JsonField<Boolean>,
private val llmEvaluator: JsonField<OnlineLlmEvaluator>,
private val name: JsonField<String>,
private val runRules: JsonField<List<OnlineEvaluatorRunRule>>,
@@ -46,6 +47,9 @@ private constructor(
@JsonProperty("feedback_keys")
@ExcludeMissing
feedbackKeys: JsonField<List<String>> = JsonMissing.of(),
@JsonProperty("is_managed")
@ExcludeMissing
isManaged: JsonField<Boolean> = JsonMissing.of(),
@JsonProperty("llm_evaluator")
@ExcludeMissing
llmEvaluator: JsonField<OnlineLlmEvaluator> = JsonMissing.of(),
@@ -64,6 +68,7 @@ private constructor(
createdAt,
createdBy,
feedbackKeys,
isManaged,
llmEvaluator,
name,
runRules,
@@ -103,6 +108,15 @@ private constructor(
*/
fun feedbackKeys(): Optional<List<String>> = feedbackKeys.getOptional("feedback_keys")
/**
* IsManaged marks a LangChain-managed evaluator (currently the managed Perceived Error judge).
* NULL in the DB is read as false via COALESCE.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun isManaged(): Optional<Boolean> = isManaged.getOptional("is_managed")
/**
* Embedded child evaluator (populated based on type)
*
@@ -180,6 +194,13 @@ private constructor(
@ExcludeMissing
fun _feedbackKeys(): JsonField<List<String>> = feedbackKeys
/**
* Returns the raw JSON value of [isManaged].
*
* Unlike [isManaged], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("is_managed") @ExcludeMissing fun _isManaged(): JsonField<Boolean> = isManaged
/**
* Returns the raw JSON value of [llmEvaluator].
*
@@ -252,6 +273,7 @@ private constructor(
private var createdAt: JsonField<String> = JsonMissing.of()
private var createdBy: JsonField<String> = JsonMissing.of()
private var feedbackKeys: JsonField<MutableList<String>>? = null
private var isManaged: JsonField<Boolean> = JsonMissing.of()
private var llmEvaluator: JsonField<OnlineLlmEvaluator> = JsonMissing.of()
private var name: JsonField<String> = JsonMissing.of()
private var runRules: JsonField<MutableList<OnlineEvaluatorRunRule>>? = null
@@ -267,6 +289,7 @@ private constructor(
createdAt = onlineEvaluator.createdAt
createdBy = onlineEvaluator.createdBy
feedbackKeys = onlineEvaluator.feedbackKeys.map { it.toMutableList() }
isManaged = onlineEvaluator.isManaged
llmEvaluator = onlineEvaluator.llmEvaluator
name = onlineEvaluator.name
runRules = onlineEvaluator.runRules.map { it.toMutableList() }
@@ -347,6 +370,21 @@ private constructor(
}
}
/**
* IsManaged marks a LangChain-managed evaluator (currently the managed Perceived Error
* judge). NULL in the DB is read as false via COALESCE.
*/
fun isManaged(isManaged: Boolean) = isManaged(JsonField.of(isManaged))
/**
* Sets [Builder.isManaged] to an arbitrary JSON value.
*
* You should usually call [Builder.isManaged] with a well-typed [Boolean] value instead.
* This method is primarily for setting the field to an undocumented or not yet supported
* value.
*/
fun isManaged(isManaged: JsonField<Boolean>) = apply { this.isManaged = isManaged }
/** Embedded child evaluator (populated based on type) */
fun llmEvaluator(llmEvaluator: OnlineLlmEvaluator) =
llmEvaluator(JsonField.of(llmEvaluator))
@@ -460,6 +498,7 @@ private constructor(
createdAt,
createdBy,
(feedbackKeys ?: JsonMissing.of()).map { it.toImmutable() },
isManaged,
llmEvaluator,
name,
(runRules ?: JsonMissing.of()).map { it.toImmutable() },
@@ -490,6 +529,7 @@ private constructor(
createdAt()
createdBy()
feedbackKeys()
isManaged()
llmEvaluator().ifPresent { it.validate() }
name()
runRules().ifPresent { it.forEach { it.validate() } }
@@ -519,6 +559,7 @@ private constructor(
(if (createdAt.asKnown().isPresent) 1 else 0) +
(if (createdBy.asKnown().isPresent) 1 else 0) +
(feedbackKeys.asKnown().getOrNull()?.size ?: 0) +
(if (isManaged.asKnown().isPresent) 1 else 0) +
(llmEvaluator.asKnown().getOrNull()?.validity() ?: 0) +
(if (name.asKnown().isPresent) 1 else 0) +
(runRules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
@@ -537,6 +578,7 @@ private constructor(
createdAt == other.createdAt &&
createdBy == other.createdBy &&
feedbackKeys == other.feedbackKeys &&
isManaged == other.isManaged &&
llmEvaluator == other.llmEvaluator &&
name == other.name &&
runRules == other.runRules &&
@@ -553,6 +595,7 @@ private constructor(
createdAt,
createdBy,
feedbackKeys,
isManaged,
llmEvaluator,
name,
runRules,
@@ -566,5 +609,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
"OnlineEvaluator{id=$id, codeEvaluator=$codeEvaluator, createdAt=$createdAt, createdBy=$createdBy, feedbackKeys=$feedbackKeys, llmEvaluator=$llmEvaluator, name=$name, runRules=$runRules, tenantId=$tenantId, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}"
"OnlineEvaluator{id=$id, codeEvaluator=$codeEvaluator, createdAt=$createdAt, createdBy=$createdBy, feedbackKeys=$feedbackKeys, isManaged=$isManaged, llmEvaluator=$llmEvaluator, name=$name, runRules=$runRules, tenantId=$tenantId, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}"
}
@@ -82,6 +82,9 @@ private constructor(
fun isRoot(): Optional<Boolean> = body.isRoot()
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the trace are
* returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -158,6 +161,9 @@ private constructor(
fun startTime(): Optional<OffsetDateTime> = body.startTime()
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied — all
* runs in the trace are returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -541,6 +547,10 @@ private constructor(
*/
fun isRoot(isRoot: JsonField<Boolean>) = apply { body.isRoot(isRoot) }
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the trace
* are returned in a single response.
*/
fun limit(limit: Long) = apply { body.limit(limit) }
/**
@@ -738,6 +748,10 @@ private constructor(
*/
fun startTime(startTime: JsonField<OffsetDateTime>) = apply { body.startTime(startTime) }
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied —
* all runs in the trace are returned in a single response.
*/
fun trace(trace: String?) = apply { body.trace(trace) }
/** Alias for calling [Builder.trace] with `trace.orElse(null)`. */
@@ -1093,6 +1107,9 @@ private constructor(
fun isRoot(): Optional<Boolean> = isRoot.getOptional("is_root")
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the trace
* are returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
*/
@@ -1170,6 +1187,9 @@ private constructor(
fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time")
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied —
* all runs in the trace are returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
*/
@@ -1619,6 +1639,10 @@ private constructor(
*/
fun isRoot(isRoot: JsonField<Boolean>) = apply { this.isRoot = isRoot }
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the
* trace are returned in a single response.
*/
fun limit(limit: Long) = limit(JsonField.of(limit))
/**
@@ -1843,6 +1867,10 @@ private constructor(
this.startTime = startTime
}
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied
* — all runs in the trace are returned in a single response.
*/
fun trace(trace: String?) = trace(JsonField.ofNullable(trace))
/** Alias for calling [Builder.trace] with `trace.orElse(null)`. */
@@ -82,6 +82,9 @@ private constructor(
fun isRoot(): Optional<Boolean> = body.isRoot()
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the trace are
* returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -158,6 +161,9 @@ private constructor(
fun startTime(): Optional<OffsetDateTime> = body.startTime()
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied — all
* runs in the trace are returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -541,6 +547,10 @@ private constructor(
*/
fun isRoot(isRoot: JsonField<Boolean>) = apply { body.isRoot(isRoot) }
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the trace
* are returned in a single response.
*/
fun limit(limit: Long) = apply { body.limit(limit) }
/**
@@ -738,6 +748,10 @@ private constructor(
*/
fun startTime(startTime: JsonField<OffsetDateTime>) = apply { body.startTime(startTime) }
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied —
* all runs in the trace are returned in a single response.
*/
fun trace(trace: String?) = apply { body.trace(trace) }
/** Alias for calling [Builder.trace] with `trace.orElse(null)`. */
@@ -1093,6 +1107,9 @@ private constructor(
fun isRoot(): Optional<Boolean> = isRoot.getOptional("is_root")
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the trace
* are returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
*/
@@ -1170,6 +1187,9 @@ private constructor(
fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time")
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied —
* all runs in the trace are returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
*/
@@ -1619,6 +1639,10 @@ private constructor(
*/
fun isRoot(isRoot: JsonField<Boolean>) = apply { this.isRoot = isRoot }
/**
* Maximum number of runs to return. Not applied when trace is set — all runs in the
* trace are returned in a single response.
*/
fun limit(limit: Long) = limit(JsonField.of(limit))
/**
@@ -1843,6 +1867,10 @@ private constructor(
this.startTime = startTime
}
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied
* — all runs in the trace are returned in a single response.
*/
fun trace(trace: String?) = trace(JsonField.ofNullable(trace))
/** Alias for calling [Builder.trace] with `trace.orElse(null)`. */
@@ -254,6 +254,9 @@ private constructor(
fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time")
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied — all
* runs in the trace are returned in a single response.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -906,6 +909,10 @@ private constructor(
*/
fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime }
/**
* Filter runs by trace ID. When set, limit and cursor-based pagination are not applied —
* all runs in the trace are returned in a single response.
*/
fun trace(trace: String?) = trace(JsonField.ofNullable(trace))
/** Alias for calling [Builder.trace] with `trace.orElse(null)`. */
@@ -18,7 +18,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class ThreadListItem
class Thread
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val count: JsonField<Long>,
@@ -459,11 +459,11 @@ private constructor(
companion object {
/** Returns a mutable builder for constructing an instance of [ThreadListItem]. */
/** Returns a mutable builder for constructing an instance of [Thread]. */
@JvmStatic fun builder() = Builder()
}
/** A builder for [ThreadListItem]. */
/** A builder for [Thread]. */
class Builder internal constructor() {
private var count: JsonField<Long> = JsonMissing.of()
@@ -488,27 +488,27 @@ private constructor(
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
internal fun from(threadListItem: ThreadListItem) = apply {
count = threadListItem.count
feedbackStats = threadListItem.feedbackStats
firstInputs = threadListItem.firstInputs
firstTraceId = threadListItem.firstTraceId
lastError = threadListItem.lastError
lastOutputs = threadListItem.lastOutputs
lastTraceId = threadListItem.lastTraceId
latencyP50 = threadListItem.latencyP50
latencyP99 = threadListItem.latencyP99
maxStartTime = threadListItem.maxStartTime
minStartTime = threadListItem.minStartTime
numErroredTurns = threadListItem.numErroredTurns
startTime = threadListItem.startTime
threadId = threadListItem.threadId
totalCost = threadListItem.totalCost
totalCostDetails = threadListItem.totalCostDetails
totalTokenDetails = threadListItem.totalTokenDetails
totalTokens = threadListItem.totalTokens
traceId = threadListItem.traceId
additionalProperties = threadListItem.additionalProperties.toMutableMap()
internal fun from(thread: Thread) = apply {
count = thread.count
feedbackStats = thread.feedbackStats
firstInputs = thread.firstInputs
firstTraceId = thread.firstTraceId
lastError = thread.lastError
lastOutputs = thread.lastOutputs
lastTraceId = thread.lastTraceId
latencyP50 = thread.latencyP50
latencyP99 = thread.latencyP99
maxStartTime = thread.maxStartTime
minStartTime = thread.minStartTime
numErroredTurns = thread.numErroredTurns
startTime = thread.startTime
threadId = thread.threadId
totalCost = thread.totalCost
totalCostDetails = thread.totalCostDetails
totalTokenDetails = thread.totalTokenDetails
totalTokens = thread.totalTokens
traceId = thread.traceId
additionalProperties = thread.additionalProperties.toMutableMap()
}
/**
@@ -822,12 +822,12 @@ private constructor(
}
/**
* Returns an immutable instance of [ThreadListItem].
* Returns an immutable instance of [Thread].
*
* Further updates to this [Builder] will not mutate the returned instance.
*/
fun build(): ThreadListItem =
ThreadListItem(
fun build(): Thread =
Thread(
count,
feedbackStats,
firstInputs,
@@ -861,7 +861,7 @@ private constructor(
* @throws LangChainInvalidDataException if any value type in this object doesn't match its
* expected type.
*/
fun validate(): ThreadListItem = apply {
fun validate(): Thread = apply {
if (validated) {
return@apply
}
@@ -1269,7 +1269,7 @@ private constructor(
return true
}
return other is ThreadListItem &&
return other is Thread &&
count == other.count &&
feedbackStats == other.feedbackStats &&
firstInputs == other.firstInputs &&
@@ -1320,5 +1320,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
"ThreadListItem{count=$count, feedbackStats=$feedbackStats, firstInputs=$firstInputs, firstTraceId=$firstTraceId, lastError=$lastError, lastOutputs=$lastOutputs, lastTraceId=$lastTraceId, latencyP50=$latencyP50, latencyP99=$latencyP99, maxStartTime=$maxStartTime, minStartTime=$minStartTime, numErroredTurns=$numErroredTurns, startTime=$startTime, threadId=$threadId, totalCost=$totalCost, totalCostDetails=$totalCostDetails, totalTokenDetails=$totalTokenDetails, totalTokens=$totalTokens, traceId=$traceId, additionalProperties=$additionalProperties}"
"Thread{count=$count, feedbackStats=$feedbackStats, firstInputs=$firstInputs, firstTraceId=$firstTraceId, lastError=$lastError, lastOutputs=$lastOutputs, lastTraceId=$lastTraceId, latencyP50=$latencyP50, latencyP99=$latencyP99, maxStartTime=$maxStartTime, minStartTime=$minStartTime, numErroredTurns=$numErroredTurns, startTime=$startTime, threadId=$threadId, totalCost=$totalCost, totalCostDetails=$totalCostDetails, totalTokenDetails=$totalTokenDetails, totalTokens=$totalTokens, traceId=$traceId, additionalProperties=$additionalProperties}"
}
@@ -16,14 +16,14 @@ private constructor(
private val service: ThreadService,
private val params: ThreadListTracesParams,
private val response: ThreadListTracesPageResponse,
) : Page<ThreadTraceListItem> {
) : Page<ThreadTrace> {
/**
* Delegates to [ThreadListTracesPageResponse], but gracefully handles missing data.
*
* @see ThreadListTracesPageResponse.items
*/
override fun items(): List<ThreadTraceListItem> =
override fun items(): List<ThreadTrace> =
response._items().getOptional("items").getOrNull() ?: emptyList()
/**
@@ -44,7 +44,7 @@ private constructor(
override fun nextPage(): ThreadListTracesPage = service.listTraces(nextPageParams())
fun autoPager(): AutoPager<ThreadTraceListItem> = AutoPager.from(this)
fun autoPager(): AutoPager<ThreadTrace> = AutoPager.from(this)
/** The parameters that were used to request this page. */
fun params(): ThreadListTracesParams = params
@@ -19,14 +19,14 @@ private constructor(
private val streamHandlerExecutor: Executor,
private val params: ThreadListTracesParams,
private val response: ThreadListTracesPageResponse,
) : PageAsync<ThreadTraceListItem> {
) : PageAsync<ThreadTrace> {
/**
* Delegates to [ThreadListTracesPageResponse], but gracefully handles missing data.
*
* @see ThreadListTracesPageResponse.items
*/
override fun items(): List<ThreadTraceListItem> =
override fun items(): List<ThreadTrace> =
response._items().getOptional("items").getOrNull() ?: emptyList()
/**
@@ -48,8 +48,7 @@ private constructor(
override fun nextPage(): CompletableFuture<ThreadListTracesPageAsync> =
service.listTraces(nextPageParams())
fun autoPager(): AutoPagerAsync<ThreadTraceListItem> =
AutoPagerAsync.from(this, streamHandlerExecutor)
fun autoPager(): AutoPagerAsync<ThreadTrace> = AutoPagerAsync.from(this, streamHandlerExecutor)
/** The parameters that were used to request this page. */
fun params(): ThreadListTracesParams = params
@@ -21,7 +21,7 @@ import kotlin.jvm.optionals.getOrNull
class ThreadListTracesPageResponse
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val items: JsonField<List<ThreadTraceListItem>>,
private val items: JsonField<List<ThreadTrace>>,
private val nextCursor: JsonField<String>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {
@@ -30,7 +30,7 @@ private constructor(
private constructor(
@JsonProperty("items")
@ExcludeMissing
items: JsonField<List<ThreadTraceListItem>> = JsonMissing.of(),
items: JsonField<List<ThreadTrace>> = JsonMissing.of(),
@JsonProperty("next_cursor")
@ExcludeMissing
nextCursor: JsonField<String> = JsonMissing.of(),
@@ -43,7 +43,7 @@ private constructor(
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun items(): Optional<List<ThreadTraceListItem>> = items.getOptional("items")
fun items(): Optional<List<ThreadTrace>> = items.getOptional("items")
/**
* `next_cursor` is the opaque cursor to pass as `cursor` on the next request. Null on the final
@@ -59,9 +59,7 @@ private constructor(
*
* Unlike [items], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("items")
@ExcludeMissing
fun _items(): JsonField<List<ThreadTraceListItem>> = items
@JsonProperty("items") @ExcludeMissing fun _items(): JsonField<List<ThreadTrace>> = items
/**
* Returns the raw JSON value of [nextCursor].
@@ -93,7 +91,7 @@ private constructor(
/** A builder for [ThreadListTracesPageResponse]. */
class Builder internal constructor() {
private var items: JsonField<MutableList<ThreadTraceListItem>>? = null
private var items: JsonField<MutableList<ThreadTrace>>? = null
private var nextCursor: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@@ -108,25 +106,25 @@ private constructor(
* `items` is the page of root traces in this thread. Which properties are populated on each
* trace depends on the `selects` query parameter.
*/
fun items(items: List<ThreadTraceListItem>) = items(JsonField.of(items))
fun items(items: List<ThreadTrace>) = items(JsonField.of(items))
/**
* Sets [Builder.items] to an arbitrary JSON value.
*
* You should usually call [Builder.items] with a well-typed `List<ThreadTraceListItem>`
* value instead. This method is primarily for setting the field to an undocumented or not
* yet supported value.
* You should usually call [Builder.items] with a well-typed `List<ThreadTrace>` value
* instead. This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
fun items(items: JsonField<List<ThreadTraceListItem>>) = apply {
fun items(items: JsonField<List<ThreadTrace>>) = apply {
this.items = items.map { it.toMutableList() }
}
/**
* Adds a single [ThreadTraceListItem] to [items].
* Adds a single [ThreadTrace] to [items].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
fun addItem(item: ThreadTraceListItem) = apply {
fun addItem(item: ThreadTrace) = apply {
items =
(items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) }
}
@@ -16,14 +16,14 @@ private constructor(
private val service: ThreadService,
private val params: ThreadQueryParams,
private val response: ThreadQueryPageResponse,
) : Page<ThreadListItem> {
) : Page<Thread> {
/**
* Delegates to [ThreadQueryPageResponse], but gracefully handles missing data.
*
* @see ThreadQueryPageResponse.items
*/
override fun items(): List<ThreadListItem> =
override fun items(): List<Thread> =
response._items().getOptional("items").getOrNull() ?: emptyList()
/**
@@ -44,7 +44,7 @@ private constructor(
override fun nextPage(): ThreadQueryPage = service.query(nextPageParams())
fun autoPager(): AutoPager<ThreadListItem> = AutoPager.from(this)
fun autoPager(): AutoPager<Thread> = AutoPager.from(this)
/** The parameters that were used to request this page. */
fun params(): ThreadQueryParams = params
@@ -19,14 +19,14 @@ private constructor(
private val streamHandlerExecutor: Executor,
private val params: ThreadQueryParams,
private val response: ThreadQueryPageResponse,
) : PageAsync<ThreadListItem> {
) : PageAsync<Thread> {
/**
* Delegates to [ThreadQueryPageResponse], but gracefully handles missing data.
*
* @see ThreadQueryPageResponse.items
*/
override fun items(): List<ThreadListItem> =
override fun items(): List<Thread> =
response._items().getOptional("items").getOrNull() ?: emptyList()
/**
@@ -48,8 +48,7 @@ private constructor(
override fun nextPage(): CompletableFuture<ThreadQueryPageAsync> =
service.query(nextPageParams())
fun autoPager(): AutoPagerAsync<ThreadListItem> =
AutoPagerAsync.from(this, streamHandlerExecutor)
fun autoPager(): AutoPagerAsync<Thread> = AutoPagerAsync.from(this, streamHandlerExecutor)
/** The parameters that were used to request this page. */
fun params(): ThreadQueryParams = params
@@ -21,16 +21,14 @@ import kotlin.jvm.optionals.getOrNull
class ThreadQueryPageResponse
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val items: JsonField<List<ThreadListItem>>,
private val items: JsonField<List<Thread>>,
private val nextCursor: JsonField<String>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {
@JsonCreator
private constructor(
@JsonProperty("items")
@ExcludeMissing
items: JsonField<List<ThreadListItem>> = JsonMissing.of(),
@JsonProperty("items") @ExcludeMissing items: JsonField<List<Thread>> = JsonMissing.of(),
@JsonProperty("next_cursor")
@ExcludeMissing
nextCursor: JsonField<String> = JsonMissing.of(),
@@ -42,7 +40,7 @@ private constructor(
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun items(): Optional<List<ThreadListItem>> = items.getOptional("items")
fun items(): Optional<List<Thread>> = items.getOptional("items")
/**
* `next_cursor` is the opaque cursor to pass as `cursor` on the next request. Null on the final
@@ -58,7 +56,7 @@ private constructor(
*
* Unlike [items], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("items") @ExcludeMissing fun _items(): JsonField<List<ThreadListItem>> = items
@JsonProperty("items") @ExcludeMissing fun _items(): JsonField<List<Thread>> = items
/**
* Returns the raw JSON value of [nextCursor].
@@ -88,7 +86,7 @@ private constructor(
/** A builder for [ThreadQueryPageResponse]. */
class Builder internal constructor() {
private var items: JsonField<MutableList<ThreadListItem>>? = null
private var items: JsonField<MutableList<Thread>>? = null
private var nextCursor: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@@ -100,25 +98,25 @@ private constructor(
}
/** `items` is the page of thread summaries, sorted by the thread's most recent activity. */
fun items(items: List<ThreadListItem>) = items(JsonField.of(items))
fun items(items: List<Thread>) = items(JsonField.of(items))
/**
* Sets [Builder.items] to an arbitrary JSON value.
*
* You should usually call [Builder.items] with a well-typed `List<ThreadListItem>` value
* instead. This method is primarily for setting the field to an undocumented or not yet
* supported value.
* You should usually call [Builder.items] with a well-typed `List<Thread>` value instead.
* This method is primarily for setting the field to an undocumented or not yet supported
* value.
*/
fun items(items: JsonField<List<ThreadListItem>>) = apply {
fun items(items: JsonField<List<Thread>>) = apply {
this.items = items.map { it.toMutableList() }
}
/**
* Adds a single [ThreadListItem] to [items].
* Adds a single [Thread] to [items].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
fun addItem(item: ThreadListItem) = apply {
fun addItem(item: Thread) = apply {
items =
(items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) }
}
@@ -52,6 +52,7 @@ private constructor(
/**
* `max_start_time` is the exclusive upper bound on thread activity (RFC3339 date-time).
* Defaults to now (UTC) when omitted.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -60,6 +61,7 @@ private constructor(
/**
* `min_start_time` is the inclusive lower bound on thread activity (RFC3339 date-time).
* Defaults to 1 day before now (UTC) when omitted.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -202,7 +204,10 @@ private constructor(
*/
fun filter(filter: JsonField<String>) = apply { body.filter(filter) }
/** `max_start_time` is the exclusive upper bound on thread activity (RFC3339 date-time). */
/**
* `max_start_time` is the exclusive upper bound on thread activity (RFC3339 date-time).
* Defaults to now (UTC) when omitted.
*/
fun maxStartTime(maxStartTime: OffsetDateTime) = apply { body.maxStartTime(maxStartTime) }
/**
@@ -216,7 +221,10 @@ private constructor(
body.maxStartTime(maxStartTime)
}
/** `min_start_time` is the inclusive lower bound on thread activity (RFC3339 date-time). */
/**
* `min_start_time` is the inclusive lower bound on thread activity (RFC3339 date-time).
* Defaults to 1 day before now (UTC) when omitted.
*/
fun minStartTime(minStartTime: OffsetDateTime) = apply { body.minStartTime(minStartTime) }
/**
@@ -443,6 +451,7 @@ private constructor(
/**
* `max_start_time` is the exclusive upper bound on thread activity (RFC3339 date-time).
* Defaults to now (UTC) when omitted.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
@@ -451,6 +460,7 @@ private constructor(
/**
* `min_start_time` is the inclusive lower bound on thread activity (RFC3339 date-time).
* Defaults to 1 day before now (UTC) when omitted.
*
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
@@ -598,6 +608,7 @@ private constructor(
/**
* `max_start_time` is the exclusive upper bound on thread activity (RFC3339 date-time).
* Defaults to now (UTC) when omitted.
*/
fun maxStartTime(maxStartTime: OffsetDateTime) =
maxStartTime(JsonField.of(maxStartTime))
@@ -615,6 +626,7 @@ private constructor(
/**
* `min_start_time` is the inclusive lower bound on thread activity (RFC3339 date-time).
* Defaults to 1 day before now (UTC) when omitted.
*/
fun minStartTime(minStartTime: OffsetDateTime) =
minStartTime(JsonField.of(minStartTime))
@@ -18,7 +18,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class ThreadStatsResponse
class ThreadStats
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val completionCost: JsonField<Double>,
@@ -434,11 +434,11 @@ private constructor(
companion object {
/** Returns a mutable builder for constructing an instance of [ThreadStatsResponse]. */
/** Returns a mutable builder for constructing an instance of [ThreadStats]. */
@JvmStatic fun builder() = Builder()
}
/** A builder for [ThreadStatsResponse]. */
/** A builder for [ThreadStats]. */
class Builder internal constructor() {
private var completionCost: JsonField<Double> = JsonMissing.of()
@@ -461,25 +461,25 @@ private constructor(
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
internal fun from(threadStatsResponse: ThreadStatsResponse) = apply {
completionCost = threadStatsResponse.completionCost
completionCostDetails = threadStatsResponse.completionCostDetails
completionTokenDetails = threadStatsResponse.completionTokenDetails
completionTokens = threadStatsResponse.completionTokens
feedbackStats = threadStatsResponse.feedbackStats
firstStartTime = threadStatsResponse.firstStartTime
lastEndTime = threadStatsResponse.lastEndTime
lastStartTime = threadStatsResponse.lastStartTime
latencyP50Seconds = threadStatsResponse.latencyP50Seconds
latencyP99Seconds = threadStatsResponse.latencyP99Seconds
promptCost = threadStatsResponse.promptCost
promptCostDetails = threadStatsResponse.promptCostDetails
promptTokenDetails = threadStatsResponse.promptTokenDetails
promptTokens = threadStatsResponse.promptTokens
totalCost = threadStatsResponse.totalCost
totalTokens = threadStatsResponse.totalTokens
turns = threadStatsResponse.turns
additionalProperties = threadStatsResponse.additionalProperties.toMutableMap()
internal fun from(threadStats: ThreadStats) = apply {
completionCost = threadStats.completionCost
completionCostDetails = threadStats.completionCostDetails
completionTokenDetails = threadStats.completionTokenDetails
completionTokens = threadStats.completionTokens
feedbackStats = threadStats.feedbackStats
firstStartTime = threadStats.firstStartTime
lastEndTime = threadStats.lastEndTime
lastStartTime = threadStats.lastStartTime
latencyP50Seconds = threadStats.latencyP50Seconds
latencyP99Seconds = threadStats.latencyP99Seconds
promptCost = threadStats.promptCost
promptCostDetails = threadStats.promptCostDetails
promptTokenDetails = threadStats.promptTokenDetails
promptTokens = threadStats.promptTokens
totalCost = threadStats.totalCost
totalTokens = threadStats.totalTokens
turns = threadStats.turns
additionalProperties = threadStats.additionalProperties.toMutableMap()
}
/**
@@ -790,12 +790,12 @@ private constructor(
}
/**
* Returns an immutable instance of [ThreadStatsResponse].
* Returns an immutable instance of [ThreadStats].
*
* Further updates to this [Builder] will not mutate the returned instance.
*/
fun build(): ThreadStatsResponse =
ThreadStatsResponse(
fun build(): ThreadStats =
ThreadStats(
completionCost,
completionCostDetails,
completionTokenDetails,
@@ -827,7 +827,7 @@ private constructor(
* @throws LangChainInvalidDataException if any value type in this object doesn't match its
* expected type.
*/
fun validate(): ThreadStatsResponse = apply {
fun validate(): ThreadStats = apply {
if (validated) {
return@apply
}
@@ -2078,7 +2078,7 @@ private constructor(
return true
}
return other is ThreadStatsResponse &&
return other is ThreadStats &&
completionCost == other.completionCost &&
completionCostDetails == other.completionCostDetails &&
completionTokenDetails == other.completionTokenDetails &&
@@ -2125,5 +2125,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
"ThreadStatsResponse{completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, feedbackStats=$feedbackStats, firstStartTime=$firstStartTime, lastEndTime=$lastEndTime, lastStartTime=$lastStartTime, latencyP50Seconds=$latencyP50Seconds, latencyP99Seconds=$latencyP99Seconds, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, totalCost=$totalCost, totalTokens=$totalTokens, turns=$turns, additionalProperties=$additionalProperties}"
"ThreadStats{completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, feedbackStats=$feedbackStats, firstStartTime=$firstStartTime, lastEndTime=$lastEndTime, lastStartTime=$lastStartTime, latencyP50Seconds=$latencyP50Seconds, latencyP99Seconds=$latencyP99Seconds, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, totalCost=$totalCost, totalTokens=$totalTokens, turns=$turns, additionalProperties=$additionalProperties}"
}
@@ -25,6 +25,7 @@ private constructor(
private val threadId: String?,
private val selects: List<Select>,
private val sessionId: String,
private val filter: String?,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) : Params {
@@ -40,6 +41,14 @@ private constructor(
/** `session_id` is the tracing project (session) UUID (required). */
fun sessionId(): String = sessionId
/**
* `filter` narrows which of the thread's traces are aggregated, using a LangSmith filter
* expression. For example: lt(start_time, "2025-01-01T00:00:00Z") or eq(trace_id,
* "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328"). See
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.
*/
fun filter(): Optional<String> = Optional.ofNullable(filter)
/** Additional headers to send with the request. */
fun _additionalHeaders(): Headers = additionalHeaders
@@ -68,6 +77,7 @@ private constructor(
private var threadId: String? = null
private var selects: MutableList<Select>? = null
private var sessionId: String? = null
private var filter: String? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@@ -76,6 +86,7 @@ private constructor(
threadId = threadStatsParams.threadId
selects = threadStatsParams.selects.toMutableList()
sessionId = threadStatsParams.sessionId
filter = threadStatsParams.filter
additionalHeaders = threadStatsParams.additionalHeaders.toBuilder()
additionalQueryParams = threadStatsParams.additionalQueryParams.toBuilder()
}
@@ -103,6 +114,17 @@ private constructor(
/** `session_id` is the tracing project (session) UUID (required). */
fun sessionId(sessionId: String) = apply { this.sessionId = sessionId }
/**
* `filter` narrows which of the thread's traces are aggregated, using a LangSmith filter
* expression. For example: lt(start_time, "2025-01-01T00:00:00Z") or eq(trace_id,
* "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328"). See
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.
*/
fun filter(filter: String?) = apply { this.filter = filter }
/** Alias for calling [Builder.filter] with `filter.orElse(null)`. */
fun filter(filter: Optional<String>) = filter(filter.getOrNull())
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -219,6 +241,7 @@ private constructor(
threadId,
checkRequired("selects", selects).toImmutable(),
checkRequired("sessionId", sessionId),
filter,
additionalHeaders.build(),
additionalQueryParams.build(),
)
@@ -237,6 +260,7 @@ private constructor(
.apply {
selects.forEach { put("selects", it.toString()) }
put("session_id", sessionId)
filter?.let { put("filter", it) }
putAll(additionalQueryParams)
}
.build()
@@ -476,13 +500,14 @@ private constructor(
threadId == other.threadId &&
selects == other.selects &&
sessionId == other.sessionId &&
filter == other.filter &&
additionalHeaders == other.additionalHeaders &&
additionalQueryParams == other.additionalQueryParams
}
override fun hashCode(): Int =
Objects.hash(threadId, selects, sessionId, additionalHeaders, additionalQueryParams)
Objects.hash(threadId, selects, sessionId, filter, additionalHeaders, additionalQueryParams)
override fun toString() =
"ThreadStatsParams{threadId=$threadId, selects=$selects, sessionId=$sessionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
"ThreadStatsParams{threadId=$threadId, selects=$selects, sessionId=$sessionId, filter=$filter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
@@ -18,7 +18,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class ThreadTraceListItem
class ThreadTrace
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val completionCost: JsonField<Double>,
@@ -502,11 +502,11 @@ private constructor(
companion object {
/** Returns a mutable builder for constructing an instance of [ThreadTraceListItem]. */
/** Returns a mutable builder for constructing an instance of [ThreadTrace]. */
@JvmStatic fun builder() = Builder()
}
/** A builder for [ThreadTraceListItem]. */
/** A builder for [ThreadTrace]. */
class Builder internal constructor() {
private var completionCost: JsonField<Double> = JsonMissing.of()
@@ -533,29 +533,29 @@ private constructor(
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
internal fun from(threadTraceListItem: ThreadTraceListItem) = apply {
completionCost = threadTraceListItem.completionCost
completionCostDetails = threadTraceListItem.completionCostDetails
completionTokenDetails = threadTraceListItem.completionTokenDetails
completionTokens = threadTraceListItem.completionTokens
endTime = threadTraceListItem.endTime
errorPreview = threadTraceListItem.errorPreview
firstTokenTime = threadTraceListItem.firstTokenTime
inputsPreview = threadTraceListItem.inputsPreview
latency = threadTraceListItem.latency
name = threadTraceListItem.name
op = threadTraceListItem.op
outputsPreview = threadTraceListItem.outputsPreview
promptCost = threadTraceListItem.promptCost
promptCostDetails = threadTraceListItem.promptCostDetails
promptTokenDetails = threadTraceListItem.promptTokenDetails
promptTokens = threadTraceListItem.promptTokens
startTime = threadTraceListItem.startTime
threadId = threadTraceListItem.threadId
totalCost = threadTraceListItem.totalCost
totalTokens = threadTraceListItem.totalTokens
traceId = threadTraceListItem.traceId
additionalProperties = threadTraceListItem.additionalProperties.toMutableMap()
internal fun from(threadTrace: ThreadTrace) = apply {
completionCost = threadTrace.completionCost
completionCostDetails = threadTrace.completionCostDetails
completionTokenDetails = threadTrace.completionTokenDetails
completionTokens = threadTrace.completionTokens
endTime = threadTrace.endTime
errorPreview = threadTrace.errorPreview
firstTokenTime = threadTrace.firstTokenTime
inputsPreview = threadTrace.inputsPreview
latency = threadTrace.latency
name = threadTrace.name
op = threadTrace.op
outputsPreview = threadTrace.outputsPreview
promptCost = threadTrace.promptCost
promptCostDetails = threadTrace.promptCostDetails
promptTokenDetails = threadTrace.promptTokenDetails
promptTokens = threadTrace.promptTokens
startTime = threadTrace.startTime
threadId = threadTrace.threadId
totalCost = threadTrace.totalCost
totalTokens = threadTrace.totalTokens
traceId = threadTrace.traceId
additionalProperties = threadTrace.additionalProperties.toMutableMap()
}
/**
@@ -910,12 +910,12 @@ private constructor(
}
/**
* Returns an immutable instance of [ThreadTraceListItem].
* Returns an immutable instance of [ThreadTrace].
*
* Further updates to this [Builder] will not mutate the returned instance.
*/
fun build(): ThreadTraceListItem =
ThreadTraceListItem(
fun build(): ThreadTrace =
ThreadTrace(
completionCost,
completionCostDetails,
completionTokenDetails,
@@ -951,7 +951,7 @@ private constructor(
* @throws LangChainInvalidDataException if any value type in this object doesn't match its
* expected type.
*/
fun validate(): ThreadTraceListItem = apply {
fun validate(): ThreadTrace = apply {
if (validated) {
return@apply
}
@@ -2098,7 +2098,7 @@ private constructor(
return true
}
return other is ThreadTraceListItem &&
return other is ThreadTrace &&
completionCost == other.completionCost &&
completionCostDetails == other.completionCostDetails &&
completionTokenDetails == other.completionTokenDetails &&
@@ -2153,5 +2153,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
"ThreadTraceListItem{completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, endTime=$endTime, errorPreview=$errorPreview, firstTokenTime=$firstTokenTime, inputsPreview=$inputsPreview, latency=$latency, name=$name, op=$op, outputsPreview=$outputsPreview, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, startTime=$startTime, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceId=$traceId, additionalProperties=$additionalProperties}"
"ThreadTrace{completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, endTime=$endTime, errorPreview=$errorPreview, firstTokenTime=$firstTokenTime, inputsPreview=$inputsPreview, latency=$latency, name=$name, op=$op, outputsPreview=$outputsPreview, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, startTime=$startTime, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceId=$traceId, additionalProperties=$additionalProperties}"
}
@@ -9,8 +9,8 @@ import com.langchain.smith.models.threads.ThreadListTracesPageAsync
import com.langchain.smith.models.threads.ThreadListTracesParams
import com.langchain.smith.models.threads.ThreadQueryPageAsync
import com.langchain.smith.models.threads.ThreadQueryParams
import com.langchain.smith.models.threads.ThreadStats
import com.langchain.smith.models.threads.ThreadStatsParams
import com.langchain.smith.models.threads.ThreadStatsResponse
import java.util.concurrent.CompletableFuture
import java.util.function.Consumer
@@ -83,7 +83,7 @@ interface ThreadServiceAsync {
* thread (turn count, latency percentiles, token/cost sums, and detail breakdowns) within a
* project.
*/
fun stats(threadId: String, params: ThreadStatsParams): CompletableFuture<ThreadStatsResponse> =
fun stats(threadId: String, params: ThreadStatsParams): CompletableFuture<ThreadStats> =
stats(threadId, params, RequestOptions.none())
/** @see stats */
@@ -91,18 +91,18 @@ interface ThreadServiceAsync {
threadId: String,
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<ThreadStatsResponse> =
): CompletableFuture<ThreadStats> =
stats(params.toBuilder().threadId(threadId).build(), requestOptions)
/** @see stats */
fun stats(params: ThreadStatsParams): CompletableFuture<ThreadStatsResponse> =
fun stats(params: ThreadStatsParams): CompletableFuture<ThreadStats> =
stats(params, RequestOptions.none())
/** @see stats */
fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<ThreadStatsResponse>
): CompletableFuture<ThreadStats>
/**
* A view of [ThreadServiceAsync] that provides access to raw HTTP responses for each method.
@@ -180,7 +180,7 @@ interface ThreadServiceAsync {
fun stats(
threadId: String,
params: ThreadStatsParams,
): CompletableFuture<HttpResponseFor<ThreadStatsResponse>> =
): CompletableFuture<HttpResponseFor<ThreadStats>> =
stats(threadId, params, RequestOptions.none())
/** @see stats */
@@ -188,19 +188,17 @@ interface ThreadServiceAsync {
threadId: String,
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<HttpResponseFor<ThreadStatsResponse>> =
): CompletableFuture<HttpResponseFor<ThreadStats>> =
stats(params.toBuilder().threadId(threadId).build(), requestOptions)
/** @see stats */
fun stats(
params: ThreadStatsParams
): CompletableFuture<HttpResponseFor<ThreadStatsResponse>> =
fun stats(params: ThreadStatsParams): CompletableFuture<HttpResponseFor<ThreadStats>> =
stats(params, RequestOptions.none())
/** @see stats */
fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<HttpResponseFor<ThreadStatsResponse>>
): CompletableFuture<HttpResponseFor<ThreadStats>>
}
}
@@ -22,8 +22,8 @@ import com.langchain.smith.models.threads.ThreadListTracesParams
import com.langchain.smith.models.threads.ThreadQueryPageAsync
import com.langchain.smith.models.threads.ThreadQueryPageResponse
import com.langchain.smith.models.threads.ThreadQueryParams
import com.langchain.smith.models.threads.ThreadStats
import com.langchain.smith.models.threads.ThreadStatsParams
import com.langchain.smith.models.threads.ThreadStatsResponse
import java.util.concurrent.CompletableFuture
import java.util.function.Consumer
import kotlin.jvm.optionals.getOrNull
@@ -57,7 +57,7 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli
override fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions,
): CompletableFuture<ThreadStatsResponse> =
): CompletableFuture<ThreadStats> =
// get /v2/threads/{thread_id}/stats
withRawResponse().stats(params, requestOptions).thenApply { it.parse() }
@@ -154,13 +154,13 @@ class ThreadServiceAsyncImpl internal constructor(private val clientOptions: Cli
}
}
private val statsHandler: Handler<ThreadStatsResponse> =
jsonHandler<ThreadStatsResponse>(clientOptions.jsonMapper)
private val statsHandler: Handler<ThreadStats> =
jsonHandler<ThreadStats>(clientOptions.jsonMapper)
override fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions,
): CompletableFuture<HttpResponseFor<ThreadStatsResponse>> {
): CompletableFuture<HttpResponseFor<ThreadStats>> {
// We check here instead of in the params builder because this can be specified
// positionally or in the params class.
checkRequired("threadId", params.threadId().getOrNull())
@@ -6,6 +6,8 @@ import com.langchain.smith.core.ClientOptions
import com.langchain.smith.core.RequestOptions
import com.langchain.smith.core.http.HttpResponseFor
import com.langchain.smith.models.annotationqueues.RunSchemaWithAnnotationQueueInfo
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyResponse
import com.langchain.smith.models.annotationqueues.runs.RunCreateParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateResponse
import com.langchain.smith.models.annotationqueues.runs.RunDeleteAllParams
@@ -114,6 +116,31 @@ interface RunServiceAsync {
): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> =
list(queueId, RunListParams.none(), requestOptions)
/** Add Runs To Annotation Queue By Key */
fun createByKey(
queueId: String,
params: RunCreateByKeyParams,
): CompletableFuture<List<RunCreateByKeyResponse>> =
createByKey(queueId, params, RequestOptions.none())
/** @see createByKey */
fun createByKey(
queueId: String,
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<List<RunCreateByKeyResponse>> =
createByKey(params.toBuilder().queueId(queueId).build(), requestOptions)
/** @see createByKey */
fun createByKey(params: RunCreateByKeyParams): CompletableFuture<List<RunCreateByKeyResponse>> =
createByKey(params, RequestOptions.none())
/** @see createByKey */
fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<List<RunCreateByKeyResponse>>
/** Delete Runs From Annotation Queue */
fun deleteAll(queueId: String): CompletableFuture<RunDeleteAllResponse> =
deleteAll(queueId, RunDeleteAllParams.none())
@@ -286,6 +313,36 @@ interface RunServiceAsync {
): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> =
list(queueId, RunListParams.none(), requestOptions)
/**
* Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs/by-key`,
* but is otherwise the same as [RunServiceAsync.createByKey].
*/
fun createByKey(
queueId: String,
params: RunCreateByKeyParams,
): CompletableFuture<HttpResponseFor<List<RunCreateByKeyResponse>>> =
createByKey(queueId, params, RequestOptions.none())
/** @see createByKey */
fun createByKey(
queueId: String,
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<HttpResponseFor<List<RunCreateByKeyResponse>>> =
createByKey(params.toBuilder().queueId(queueId).build(), requestOptions)
/** @see createByKey */
fun createByKey(
params: RunCreateByKeyParams
): CompletableFuture<HttpResponseFor<List<RunCreateByKeyResponse>>> =
createByKey(params, RequestOptions.none())
/** @see createByKey */
fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture<HttpResponseFor<List<RunCreateByKeyResponse>>>
/**
* Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs/delete`,
* but is otherwise the same as [RunServiceAsync.deleteAll].
@@ -17,6 +17,8 @@ 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.annotationqueues.RunSchemaWithAnnotationQueueInfo
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyResponse
import com.langchain.smith.models.annotationqueues.runs.RunCreateParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateResponse
import com.langchain.smith.models.annotationqueues.runs.RunDeleteAllParams
@@ -63,6 +65,13 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client
// get /api/v1/annotation-queues/{queue_id}/runs
withRawResponse().list(params, requestOptions).thenApply { it.parse() }
override fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions,
): CompletableFuture<List<RunCreateByKeyResponse>> =
// post /api/v1/annotation-queues/{queue_id}/runs/by-key
withRawResponse().createByKey(params, requestOptions).thenApply { it.parse() }
override fun deleteAll(
params: RunDeleteAllParams,
requestOptions: RequestOptions,
@@ -198,6 +207,47 @@ class RunServiceAsyncImpl internal constructor(private val clientOptions: Client
}
}
private val createByKeyHandler: Handler<List<RunCreateByKeyResponse>> =
jsonHandler<List<RunCreateByKeyResponse>>(clientOptions.jsonMapper)
override fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions,
): CompletableFuture<HttpResponseFor<List<RunCreateByKeyResponse>>> {
// We check here instead of in the params builder because this can be specified
// positionally or in the params class.
checkRequired("queueId", params.queueId().getOrNull())
val request =
HttpRequest.builder()
.method(HttpMethod.POST)
.baseUrl(clientOptions.baseUrl())
.addPathSegments(
"api",
"v1",
"annotation-queues",
params._pathParam(0),
"runs",
"by-key",
)
.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 { createByKeyHandler.handle(it) }
.also {
if (requestOptions.responseValidation!!) {
it.forEach { it.validate() }
}
}
}
}
}
private val deleteAllHandler: Handler<RunDeleteAllResponse> =
jsonHandler<RunDeleteAllResponse>(clientOptions.jsonMapper)
@@ -10,8 +10,8 @@ import com.langchain.smith.models.threads.ThreadListTracesPage
import com.langchain.smith.models.threads.ThreadListTracesParams
import com.langchain.smith.models.threads.ThreadQueryPage
import com.langchain.smith.models.threads.ThreadQueryParams
import com.langchain.smith.models.threads.ThreadStats
import com.langchain.smith.models.threads.ThreadStatsParams
import com.langchain.smith.models.threads.ThreadStatsResponse
import java.util.function.Consumer
interface ThreadService {
@@ -79,7 +79,7 @@ interface ThreadService {
* thread (turn count, latency percentiles, token/cost sums, and detail breakdowns) within a
* project.
*/
fun stats(threadId: String, params: ThreadStatsParams): ThreadStatsResponse =
fun stats(threadId: String, params: ThreadStatsParams): ThreadStats =
stats(threadId, params, RequestOptions.none())
/** @see stats */
@@ -87,16 +87,16 @@ interface ThreadService {
threadId: String,
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): ThreadStatsResponse = stats(params.toBuilder().threadId(threadId).build(), requestOptions)
): ThreadStats = stats(params.toBuilder().threadId(threadId).build(), requestOptions)
/** @see stats */
fun stats(params: ThreadStatsParams): ThreadStatsResponse = stats(params, RequestOptions.none())
fun stats(params: ThreadStatsParams): ThreadStats = stats(params, RequestOptions.none())
/** @see stats */
fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): ThreadStatsResponse
): ThreadStats
/** A view of [ThreadService] that provides access to raw HTTP responses for each method. */
interface WithRawResponse {
@@ -170,10 +170,8 @@ interface ThreadService {
* same as [ThreadService.stats].
*/
@MustBeClosed
fun stats(
threadId: String,
params: ThreadStatsParams,
): HttpResponseFor<ThreadStatsResponse> = stats(threadId, params, RequestOptions.none())
fun stats(threadId: String, params: ThreadStatsParams): HttpResponseFor<ThreadStats> =
stats(threadId, params, RequestOptions.none())
/** @see stats */
@MustBeClosed
@@ -181,12 +179,12 @@ interface ThreadService {
threadId: String,
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): HttpResponseFor<ThreadStatsResponse> =
): HttpResponseFor<ThreadStats> =
stats(params.toBuilder().threadId(threadId).build(), requestOptions)
/** @see stats */
@MustBeClosed
fun stats(params: ThreadStatsParams): HttpResponseFor<ThreadStatsResponse> =
fun stats(params: ThreadStatsParams): HttpResponseFor<ThreadStats> =
stats(params, RequestOptions.none())
/** @see stats */
@@ -194,6 +192,6 @@ interface ThreadService {
fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions = RequestOptions.none(),
): HttpResponseFor<ThreadStatsResponse>
): HttpResponseFor<ThreadStats>
}
}
@@ -22,8 +22,8 @@ import com.langchain.smith.models.threads.ThreadListTracesParams
import com.langchain.smith.models.threads.ThreadQueryPage
import com.langchain.smith.models.threads.ThreadQueryPageResponse
import com.langchain.smith.models.threads.ThreadQueryParams
import com.langchain.smith.models.threads.ThreadStats
import com.langchain.smith.models.threads.ThreadStatsParams
import com.langchain.smith.models.threads.ThreadStatsResponse
import java.util.function.Consumer
import kotlin.jvm.optionals.getOrNull
@@ -50,10 +50,7 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp
// post /v2/threads/query
withRawResponse().query(params, requestOptions).parse()
override fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions,
): ThreadStatsResponse =
override fun stats(params: ThreadStatsParams, requestOptions: RequestOptions): ThreadStats =
// get /v2/threads/{thread_id}/stats
withRawResponse().stats(params, requestOptions).parse()
@@ -142,13 +139,13 @@ class ThreadServiceImpl internal constructor(private val clientOptions: ClientOp
}
}
private val statsHandler: Handler<ThreadStatsResponse> =
jsonHandler<ThreadStatsResponse>(clientOptions.jsonMapper)
private val statsHandler: Handler<ThreadStats> =
jsonHandler<ThreadStats>(clientOptions.jsonMapper)
override fun stats(
params: ThreadStatsParams,
requestOptions: RequestOptions,
): HttpResponseFor<ThreadStatsResponse> {
): HttpResponseFor<ThreadStats> {
// We check here instead of in the params builder because this can be specified
// positionally or in the params class.
checkRequired("threadId", params.threadId().getOrNull())
@@ -7,6 +7,8 @@ import com.langchain.smith.core.ClientOptions
import com.langchain.smith.core.RequestOptions
import com.langchain.smith.core.http.HttpResponseFor
import com.langchain.smith.models.annotationqueues.RunSchemaWithAnnotationQueueInfo
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyResponse
import com.langchain.smith.models.annotationqueues.runs.RunCreateParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateResponse
import com.langchain.smith.models.annotationqueues.runs.RunDeleteAllParams
@@ -107,6 +109,28 @@ interface RunService {
requestOptions: RequestOptions,
): List<RunSchemaWithAnnotationQueueInfo> = list(queueId, RunListParams.none(), requestOptions)
/** Add Runs To Annotation Queue By Key */
fun createByKey(queueId: String, params: RunCreateByKeyParams): List<RunCreateByKeyResponse> =
createByKey(queueId, params, RequestOptions.none())
/** @see createByKey */
fun createByKey(
queueId: String,
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): List<RunCreateByKeyResponse> =
createByKey(params.toBuilder().queueId(queueId).build(), requestOptions)
/** @see createByKey */
fun createByKey(params: RunCreateByKeyParams): List<RunCreateByKeyResponse> =
createByKey(params, RequestOptions.none())
/** @see createByKey */
fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): List<RunCreateByKeyResponse>
/** Delete Runs From Annotation Queue */
fun deleteAll(queueId: String): RunDeleteAllResponse =
deleteAll(queueId, RunDeleteAllParams.none())
@@ -278,6 +302,40 @@ interface RunService {
): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> =
list(queueId, RunListParams.none(), requestOptions)
/**
* Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs/by-key`,
* but is otherwise the same as [RunService.createByKey].
*/
@MustBeClosed
fun createByKey(
queueId: String,
params: RunCreateByKeyParams,
): HttpResponseFor<List<RunCreateByKeyResponse>> =
createByKey(queueId, params, RequestOptions.none())
/** @see createByKey */
@MustBeClosed
fun createByKey(
queueId: String,
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): HttpResponseFor<List<RunCreateByKeyResponse>> =
createByKey(params.toBuilder().queueId(queueId).build(), requestOptions)
/** @see createByKey */
@MustBeClosed
fun createByKey(
params: RunCreateByKeyParams
): HttpResponseFor<List<RunCreateByKeyResponse>> =
createByKey(params, RequestOptions.none())
/** @see createByKey */
@MustBeClosed
fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions = RequestOptions.none(),
): HttpResponseFor<List<RunCreateByKeyResponse>>
/**
* Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs/delete`,
* but is otherwise the same as [RunService.deleteAll].
@@ -17,6 +17,8 @@ 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.annotationqueues.RunSchemaWithAnnotationQueueInfo
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyResponse
import com.langchain.smith.models.annotationqueues.runs.RunCreateParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateResponse
import com.langchain.smith.models.annotationqueues.runs.RunDeleteAllParams
@@ -61,6 +63,13 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio
// get /api/v1/annotation-queues/{queue_id}/runs
withRawResponse().list(params, requestOptions).parse()
override fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions,
): List<RunCreateByKeyResponse> =
// post /api/v1/annotation-queues/{queue_id}/runs/by-key
withRawResponse().createByKey(params, requestOptions).parse()
override fun deleteAll(
params: RunDeleteAllParams,
requestOptions: RequestOptions,
@@ -187,6 +196,44 @@ class RunServiceImpl internal constructor(private val clientOptions: ClientOptio
}
}
private val createByKeyHandler: Handler<List<RunCreateByKeyResponse>> =
jsonHandler<List<RunCreateByKeyResponse>>(clientOptions.jsonMapper)
override fun createByKey(
params: RunCreateByKeyParams,
requestOptions: RequestOptions,
): HttpResponseFor<List<RunCreateByKeyResponse>> {
// We check here instead of in the params builder because this can be specified
// positionally or in the params class.
checkRequired("queueId", params.queueId().getOrNull())
val request =
HttpRequest.builder()
.method(HttpMethod.POST)
.baseUrl(clientOptions.baseUrl())
.addPathSegments(
"api",
"v1",
"annotation-queues",
params._pathParam(0),
"runs",
"by-key",
)
.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 { createByKeyHandler.handle(it) }
.also {
if (requestOptions.responseValidation!!) {
it.forEach { it.validate() }
}
}
}
}
private val deleteAllHandler: Handler<RunDeleteAllResponse> =
jsonHandler<RunDeleteAllResponse>(clientOptions.jsonMapper)
@@ -0,0 +1,142 @@
// File generated from our OpenAPI spec by Stainless.
package com.langchain.smith.models.annotationqueues.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 RunCreateByKeyParamsTest {
@Test
fun create() {
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.extendTraceRetention(true)
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.build()
}
@Test
fun pathParams() {
val params =
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.build()
)
.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 =
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.extendTraceRetention(true)
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.build()
val queryParams = params._queryParams()
assertThat(queryParams)
.isEqualTo(QueryParams.builder().put("extend_trace_retention", "true").build())
}
@Test
fun queryParamsWithoutOptionalFields() {
val params =
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.build()
)
.build()
val queryParams = params._queryParams()
assertThat(queryParams).isEqualTo(QueryParams.builder().build())
}
@Test
fun body() {
val params =
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.extendTraceRetention(true)
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.build()
val body = params._body()
assertThat(body)
.containsExactly(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
}
@Test
fun bodyWithoutOptionalFields() {
val params =
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.build()
)
.build()
val body = params._body()
assertThat(body)
.containsExactly(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.build()
)
}
}
@@ -0,0 +1,58 @@
// File generated from our OpenAPI spec by Stainless.
package com.langchain.smith.models.annotationqueues.runs
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
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 RunCreateByKeyResponseTest {
@Test
fun create() {
val runCreateByKeyResponse =
RunCreateByKeyResponse.builder()
.id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
assertThat(runCreateByKeyResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(runCreateByKeyResponse.queueId())
.isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(runCreateByKeyResponse.runId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(runCreateByKeyResponse.addedAt())
.contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
assertThat(runCreateByKeyResponse.lastReviewedTime())
.contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
assertThat(runCreateByKeyResponse.sourceProposedExampleId())
.contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
}
@Test
fun roundtrip() {
val jsonMapper = jsonMapper()
val runCreateByKeyResponse =
RunCreateByKeyResponse.builder()
.id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
val roundtrippedRunCreateByKeyResponse =
jsonMapper.readValue(
jsonMapper.writeValueAsString(runCreateByKeyResponse),
jacksonTypeRef<RunCreateByKeyResponse>(),
)
assertThat(roundtrippedRunCreateByKeyResponse).isEqualTo(runCreateByKeyResponse)
}
}
@@ -27,6 +27,7 @@ internal class CreateOnlineEvaluatorResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -84,6 +85,7 @@ internal class CreateOnlineEvaluatorResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -145,6 +147,7 @@ internal class CreateOnlineEvaluatorResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -28,6 +28,7 @@ internal class OnlineEvaluatorListPageResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -86,6 +87,7 @@ internal class OnlineEvaluatorListPageResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -148,6 +150,7 @@ internal class OnlineEvaluatorListPageResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -26,6 +26,7 @@ internal class OnlineEvaluatorTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -79,6 +80,7 @@ internal class OnlineEvaluatorTest {
assertThat(onlineEvaluator.createdAt()).contains("created_at")
assertThat(onlineEvaluator.createdBy()).contains("created_by")
assertThat(onlineEvaluator.feedbackKeys().getOrNull()).containsExactly("string")
assertThat(onlineEvaluator.isManaged()).contains(true)
assertThat(onlineEvaluator.llmEvaluator())
.contains(
OnlineLlmEvaluator.builder()
@@ -138,6 +140,7 @@ internal class OnlineEvaluatorTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -27,6 +27,7 @@ internal class UpdateOnlineEvaluatorResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -84,6 +85,7 @@ internal class UpdateOnlineEvaluatorResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -145,6 +147,7 @@ internal class UpdateOnlineEvaluatorResponseTest {
.createdAt("created_at")
.createdBy("created_by")
.addFeedbackKey("string")
.isManaged(true)
.llmEvaluator(
OnlineLlmEvaluator.builder()
.annotationQueueId("annotation_queue_id")
@@ -113,6 +113,15 @@ internal class SandboxListResponseTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
SandboxResponse.MountConfig.Mount
.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
SandboxResponse.MountConfig.Mount
.SandboxapiS3BucketMountSpec
@@ -368,6 +377,15 @@ internal class SandboxListResponseTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
SandboxResponse.MountConfig.Mount
.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
SandboxResponse.MountConfig.Mount
.SandboxapiS3BucketMountSpec
@@ -625,6 +643,15 @@ internal class SandboxListResponseTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
SandboxResponse.MountConfig.Mount
.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
SandboxResponse.MountConfig.Mount
.SandboxapiS3BucketMountSpec
@@ -101,6 +101,14 @@ internal class SandboxResponseTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
SandboxResponse.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
SandboxResponse.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Gcs
@@ -331,6 +339,14 @@ internal class SandboxResponseTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
SandboxResponse.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
SandboxResponse.MountConfig.Mount.SandboxapiS3BucketMountSpec.Gcs
.builder()
@@ -564,6 +580,14 @@ internal class SandboxResponseTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
SandboxResponse.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
SandboxResponse.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Gcs
@@ -97,6 +97,14 @@ internal class BoxCreateParamsTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
BoxCreateParams.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
BoxCreateParams.MountConfig.Mount.SandboxapiS3BucketMountSpec.Gcs
.builder()
@@ -327,6 +335,14 @@ internal class BoxCreateParamsTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
BoxCreateParams.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
BoxCreateParams.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Gcs
@@ -558,6 +574,14 @@ internal class BoxCreateParamsTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
BoxCreateParams.MountConfig.Mount.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
BoxCreateParams.MountConfig.Mount.SandboxapiS3BucketMountSpec.Gcs
.builder()
@@ -17,21 +17,21 @@ internal class ThreadListTracesPageResponseTest {
val threadListTracesPageResponse =
ThreadListTracesPageResponse.builder()
.addItem(
ThreadTraceListItem.builder()
ThreadTrace.builder()
.completionCost(0.0)
.completionCostDetails(
ThreadTraceListItem.CompletionCostDetails.builder()
ThreadTrace.CompletionCostDetails.builder()
.raw(
ThreadTraceListItem.CompletionCostDetails.Raw.builder()
ThreadTrace.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.completionTokenDetails(
ThreadTraceListItem.CompletionTokenDetails.builder()
ThreadTrace.CompletionTokenDetails.builder()
.raw(
ThreadTraceListItem.CompletionTokenDetails.Raw.builder()
ThreadTrace.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -48,18 +48,18 @@ internal class ThreadListTracesPageResponseTest {
.outputsPreview("outputs_preview")
.promptCost(0.0)
.promptCostDetails(
ThreadTraceListItem.PromptCostDetails.builder()
ThreadTrace.PromptCostDetails.builder()
.raw(
ThreadTraceListItem.PromptCostDetails.Raw.builder()
ThreadTrace.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.promptTokenDetails(
ThreadTraceListItem.PromptTokenDetails.builder()
ThreadTrace.PromptTokenDetails.builder()
.raw(
ThreadTraceListItem.PromptTokenDetails.Raw.builder()
ThreadTrace.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -78,21 +78,21 @@ internal class ThreadListTracesPageResponseTest {
assertThat(threadListTracesPageResponse.items().getOrNull())
.containsExactly(
ThreadTraceListItem.builder()
ThreadTrace.builder()
.completionCost(0.0)
.completionCostDetails(
ThreadTraceListItem.CompletionCostDetails.builder()
ThreadTrace.CompletionCostDetails.builder()
.raw(
ThreadTraceListItem.CompletionCostDetails.Raw.builder()
ThreadTrace.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.completionTokenDetails(
ThreadTraceListItem.CompletionTokenDetails.builder()
ThreadTrace.CompletionTokenDetails.builder()
.raw(
ThreadTraceListItem.CompletionTokenDetails.Raw.builder()
ThreadTrace.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -109,18 +109,18 @@ internal class ThreadListTracesPageResponseTest {
.outputsPreview("outputs_preview")
.promptCost(0.0)
.promptCostDetails(
ThreadTraceListItem.PromptCostDetails.builder()
ThreadTrace.PromptCostDetails.builder()
.raw(
ThreadTraceListItem.PromptCostDetails.Raw.builder()
ThreadTrace.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.promptTokenDetails(
ThreadTraceListItem.PromptTokenDetails.builder()
ThreadTrace.PromptTokenDetails.builder()
.raw(
ThreadTraceListItem.PromptTokenDetails.Raw.builder()
ThreadTrace.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -144,21 +144,21 @@ internal class ThreadListTracesPageResponseTest {
val threadListTracesPageResponse =
ThreadListTracesPageResponse.builder()
.addItem(
ThreadTraceListItem.builder()
ThreadTrace.builder()
.completionCost(0.0)
.completionCostDetails(
ThreadTraceListItem.CompletionCostDetails.builder()
ThreadTrace.CompletionCostDetails.builder()
.raw(
ThreadTraceListItem.CompletionCostDetails.Raw.builder()
ThreadTrace.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.completionTokenDetails(
ThreadTraceListItem.CompletionTokenDetails.builder()
ThreadTrace.CompletionTokenDetails.builder()
.raw(
ThreadTraceListItem.CompletionTokenDetails.Raw.builder()
ThreadTrace.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -175,18 +175,18 @@ internal class ThreadListTracesPageResponseTest {
.outputsPreview("outputs_preview")
.promptCost(0.0)
.promptCostDetails(
ThreadTraceListItem.PromptCostDetails.builder()
ThreadTrace.PromptCostDetails.builder()
.raw(
ThreadTraceListItem.PromptCostDetails.Raw.builder()
ThreadTrace.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.promptTokenDetails(
ThreadTraceListItem.PromptTokenDetails.builder()
ThreadTrace.PromptTokenDetails.builder()
.raw(
ThreadTraceListItem.PromptTokenDetails.Raw.builder()
ThreadTrace.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -17,10 +17,10 @@ internal class ThreadQueryPageResponseTest {
val threadQueryPageResponse =
ThreadQueryPageResponse.builder()
.addItem(
ThreadListItem.builder()
Thread.builder()
.count(3L)
.feedbackStats(
ThreadListItem.FeedbackStats.builder()
Thread.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -54,12 +54,12 @@ internal class ThreadQueryPageResponseTest {
.threadId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
.totalCost(0.045)
.totalCostDetails(
ThreadListItem.TotalCostDetails.builder()
Thread.TotalCostDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.totalTokenDetails(
ThreadListItem.TotalTokenDetails.builder()
Thread.TotalTokenDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -72,10 +72,10 @@ internal class ThreadQueryPageResponseTest {
assertThat(threadQueryPageResponse.items().getOrNull())
.containsExactly(
ThreadListItem.builder()
Thread.builder()
.count(3L)
.feedbackStats(
ThreadListItem.FeedbackStats.builder()
Thread.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -109,12 +109,12 @@ internal class ThreadQueryPageResponseTest {
.threadId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
.totalCost(0.045)
.totalCostDetails(
ThreadListItem.TotalCostDetails.builder()
Thread.TotalCostDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.totalTokenDetails(
ThreadListItem.TotalTokenDetails.builder()
Thread.TotalTokenDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -132,10 +132,10 @@ internal class ThreadQueryPageResponseTest {
val threadQueryPageResponse =
ThreadQueryPageResponse.builder()
.addItem(
ThreadListItem.builder()
Thread.builder()
.count(3L)
.feedbackStats(
ThreadListItem.FeedbackStats.builder()
Thread.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -169,12 +169,12 @@ internal class ThreadQueryPageResponseTest {
.threadId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
.totalCost(0.045)
.totalCostDetails(
ThreadListItem.TotalCostDetails.builder()
Thread.TotalCostDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.totalTokenDetails(
ThreadListItem.TotalTokenDetails.builder()
Thread.TotalTokenDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -14,6 +14,7 @@ internal class ThreadStatsParamsTest {
.threadId("thread_id")
.addSelect(ThreadStatsParams.Select.TURNS)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filter("filter")
.build()
}
@@ -33,6 +34,28 @@ internal class ThreadStatsParamsTest {
@Test
fun queryParams() {
val params =
ThreadStatsParams.builder()
.threadId("thread_id")
.addSelect(ThreadStatsParams.Select.TURNS)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filter("filter")
.build()
val queryParams = params._queryParams()
assertThat(queryParams)
.isEqualTo(
QueryParams.builder()
.put("selects", "TURNS")
.put("session_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.put("filter", "filter")
.build()
)
}
@Test
fun queryParamsWithoutOptionalFields() {
val params =
ThreadStatsParams.builder()
.threadId("thread_id")
@@ -9,26 +9,26 @@ import java.time.OffsetDateTime
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
internal class ThreadStatsResponseTest {
internal class ThreadStatsTest {
@Test
fun create() {
val threadStatsResponse =
ThreadStatsResponse.builder()
val threadStats =
ThreadStats.builder()
.completionCost(0.0)
.completionCostDetails(
ThreadStatsResponse.CompletionCostDetails.builder()
ThreadStats.CompletionCostDetails.builder()
.raw(
ThreadStatsResponse.CompletionCostDetails.Raw.builder()
ThreadStats.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.completionTokenDetails(
ThreadStatsResponse.CompletionTokenDetails.builder()
ThreadStats.CompletionTokenDetails.builder()
.raw(
ThreadStatsResponse.CompletionTokenDetails.Raw.builder()
ThreadStats.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -36,7 +36,7 @@ internal class ThreadStatsResponseTest {
)
.completionTokens(0L)
.feedbackStats(
ThreadStatsResponse.FeedbackStats.builder()
ThreadStats.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -63,18 +63,18 @@ internal class ThreadStatsResponseTest {
.latencyP99Seconds(0.0)
.promptCost(0.0)
.promptCostDetails(
ThreadStatsResponse.PromptCostDetails.builder()
ThreadStats.PromptCostDetails.builder()
.raw(
ThreadStatsResponse.PromptCostDetails.Raw.builder()
ThreadStats.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.promptTokenDetails(
ThreadStatsResponse.PromptTokenDetails.builder()
ThreadStats.PromptTokenDetails.builder()
.raw(
ThreadStatsResponse.PromptTokenDetails.Raw.builder()
ThreadStats.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -86,31 +86,31 @@ internal class ThreadStatsResponseTest {
.turns(0L)
.build()
assertThat(threadStatsResponse.completionCost()).contains(0.0)
assertThat(threadStatsResponse.completionCostDetails())
assertThat(threadStats.completionCost()).contains(0.0)
assertThat(threadStats.completionCostDetails())
.contains(
ThreadStatsResponse.CompletionCostDetails.builder()
ThreadStats.CompletionCostDetails.builder()
.raw(
ThreadStatsResponse.CompletionCostDetails.Raw.builder()
ThreadStats.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadStatsResponse.completionTokenDetails())
assertThat(threadStats.completionTokenDetails())
.contains(
ThreadStatsResponse.CompletionTokenDetails.builder()
ThreadStats.CompletionTokenDetails.builder()
.raw(
ThreadStatsResponse.CompletionTokenDetails.Raw.builder()
ThreadStats.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadStatsResponse.completionTokens()).contains(0L)
assertThat(threadStatsResponse.feedbackStats())
assertThat(threadStats.completionTokens()).contains(0L)
assertThat(threadStats.feedbackStats())
.contains(
ThreadStatsResponse.FeedbackStats.builder()
ThreadStats.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -130,60 +130,60 @@ internal class ThreadStatsResponseTest {
)
.build()
)
assertThat(threadStatsResponse.firstStartTime())
assertThat(threadStats.firstStartTime())
.contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
assertThat(threadStatsResponse.lastEndTime())
assertThat(threadStats.lastEndTime())
.contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
assertThat(threadStatsResponse.lastStartTime())
assertThat(threadStats.lastStartTime())
.contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
assertThat(threadStatsResponse.latencyP50Seconds()).contains(0.0)
assertThat(threadStatsResponse.latencyP99Seconds()).contains(0.0)
assertThat(threadStatsResponse.promptCost()).contains(0.0)
assertThat(threadStatsResponse.promptCostDetails())
assertThat(threadStats.latencyP50Seconds()).contains(0.0)
assertThat(threadStats.latencyP99Seconds()).contains(0.0)
assertThat(threadStats.promptCost()).contains(0.0)
assertThat(threadStats.promptCostDetails())
.contains(
ThreadStatsResponse.PromptCostDetails.builder()
ThreadStats.PromptCostDetails.builder()
.raw(
ThreadStatsResponse.PromptCostDetails.Raw.builder()
ThreadStats.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadStatsResponse.promptTokenDetails())
assertThat(threadStats.promptTokenDetails())
.contains(
ThreadStatsResponse.PromptTokenDetails.builder()
ThreadStats.PromptTokenDetails.builder()
.raw(
ThreadStatsResponse.PromptTokenDetails.Raw.builder()
ThreadStats.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadStatsResponse.promptTokens()).contains(0L)
assertThat(threadStatsResponse.totalCost()).contains(0.0)
assertThat(threadStatsResponse.totalTokens()).contains(0L)
assertThat(threadStatsResponse.turns()).contains(0L)
assertThat(threadStats.promptTokens()).contains(0L)
assertThat(threadStats.totalCost()).contains(0.0)
assertThat(threadStats.totalTokens()).contains(0L)
assertThat(threadStats.turns()).contains(0L)
}
@Test
fun roundtrip() {
val jsonMapper = jsonMapper()
val threadStatsResponse =
ThreadStatsResponse.builder()
val threadStats =
ThreadStats.builder()
.completionCost(0.0)
.completionCostDetails(
ThreadStatsResponse.CompletionCostDetails.builder()
ThreadStats.CompletionCostDetails.builder()
.raw(
ThreadStatsResponse.CompletionCostDetails.Raw.builder()
ThreadStats.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.completionTokenDetails(
ThreadStatsResponse.CompletionTokenDetails.builder()
ThreadStats.CompletionTokenDetails.builder()
.raw(
ThreadStatsResponse.CompletionTokenDetails.Raw.builder()
ThreadStats.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -191,7 +191,7 @@ internal class ThreadStatsResponseTest {
)
.completionTokens(0L)
.feedbackStats(
ThreadStatsResponse.FeedbackStats.builder()
ThreadStats.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -218,18 +218,18 @@ internal class ThreadStatsResponseTest {
.latencyP99Seconds(0.0)
.promptCost(0.0)
.promptCostDetails(
ThreadStatsResponse.PromptCostDetails.builder()
ThreadStats.PromptCostDetails.builder()
.raw(
ThreadStatsResponse.PromptCostDetails.Raw.builder()
ThreadStats.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.promptTokenDetails(
ThreadStatsResponse.PromptTokenDetails.builder()
ThreadStats.PromptTokenDetails.builder()
.raw(
ThreadStatsResponse.PromptTokenDetails.Raw.builder()
ThreadStats.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -241,12 +241,12 @@ internal class ThreadStatsResponseTest {
.turns(0L)
.build()
val roundtrippedThreadStatsResponse =
val roundtrippedThreadStats =
jsonMapper.readValue(
jsonMapper.writeValueAsString(threadStatsResponse),
jacksonTypeRef<ThreadStatsResponse>(),
jsonMapper.writeValueAsString(threadStats),
jacksonTypeRef<ThreadStats>(),
)
assertThat(roundtrippedThreadStatsResponse).isEqualTo(threadStatsResponse)
assertThat(roundtrippedThreadStats).isEqualTo(threadStats)
}
}
@@ -9,15 +9,15 @@ import java.time.OffsetDateTime
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
internal class ThreadListItemTest {
internal class ThreadTest {
@Test
fun create() {
val threadListItem =
ThreadListItem.builder()
val thread =
Thread.builder()
.count(3L)
.feedbackStats(
ThreadListItem.FeedbackStats.builder()
Thread.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -51,12 +51,12 @@ internal class ThreadListItemTest {
.threadId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
.totalCost(0.045)
.totalCostDetails(
ThreadListItem.TotalCostDetails.builder()
Thread.TotalCostDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.totalTokenDetails(
ThreadListItem.TotalTokenDetails.builder()
Thread.TotalTokenDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -64,10 +64,10 @@ internal class ThreadListItemTest {
.traceId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9328")
.build()
assertThat(threadListItem.count()).contains(3L)
assertThat(threadListItem.feedbackStats())
assertThat(thread.count()).contains(3L)
assertThat(thread.feedbackStats())
.contains(
ThreadListItem.FeedbackStats.builder()
Thread.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -87,46 +87,43 @@ internal class ThreadListItemTest {
)
.build()
)
assertThat(threadListItem.firstInputs()).contains("first_inputs")
assertThat(threadListItem.firstTraceId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
assertThat(threadListItem.lastError()).contains("last_error")
assertThat(threadListItem.lastOutputs()).contains("last_outputs")
assertThat(threadListItem.lastTraceId()).contains("0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328")
assertThat(threadListItem.latencyP50()).contains(0.15)
assertThat(threadListItem.latencyP99()).contains(0.42)
assertThat(threadListItem.maxStartTime())
.contains(OffsetDateTime.parse("2025-01-15T12:05:00.000Z"))
assertThat(threadListItem.minStartTime())
.contains(OffsetDateTime.parse("2025-01-15T12:00:00.000Z"))
assertThat(threadListItem.numErroredTurns()).contains(1L)
assertThat(threadListItem.startTime())
.contains(OffsetDateTime.parse("2025-01-15T12:00:00.000Z"))
assertThat(threadListItem.threadId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
assertThat(threadListItem.totalCost()).contains(0.045)
assertThat(threadListItem.totalCostDetails())
assertThat(thread.firstInputs()).contains("first_inputs")
assertThat(thread.firstTraceId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
assertThat(thread.lastError()).contains("last_error")
assertThat(thread.lastOutputs()).contains("last_outputs")
assertThat(thread.lastTraceId()).contains("0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328")
assertThat(thread.latencyP50()).contains(0.15)
assertThat(thread.latencyP99()).contains(0.42)
assertThat(thread.maxStartTime()).contains(OffsetDateTime.parse("2025-01-15T12:05:00.000Z"))
assertThat(thread.minStartTime()).contains(OffsetDateTime.parse("2025-01-15T12:00:00.000Z"))
assertThat(thread.numErroredTurns()).contains(1L)
assertThat(thread.startTime()).contains(OffsetDateTime.parse("2025-01-15T12:00:00.000Z"))
assertThat(thread.threadId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
assertThat(thread.totalCost()).contains(0.045)
assertThat(thread.totalCostDetails())
.contains(
ThreadListItem.TotalCostDetails.builder()
Thread.TotalCostDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
assertThat(threadListItem.totalTokenDetails())
assertThat(thread.totalTokenDetails())
.contains(
ThreadListItem.TotalTokenDetails.builder()
Thread.TotalTokenDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
assertThat(threadListItem.totalTokens()).contains(450L)
assertThat(threadListItem.traceId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9328")
assertThat(thread.totalTokens()).contains(450L)
assertThat(thread.traceId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9328")
}
@Test
fun roundtrip() {
val jsonMapper = jsonMapper()
val threadListItem =
ThreadListItem.builder()
val thread =
Thread.builder()
.count(3L)
.feedbackStats(
ThreadListItem.FeedbackStats.builder()
Thread.FeedbackStats.builder()
.putAdditionalProperty(
"foo",
JsonValue.from(
@@ -160,12 +157,12 @@ internal class ThreadListItemTest {
.threadId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
.totalCost(0.045)
.totalCostDetails(
ThreadListItem.TotalCostDetails.builder()
Thread.TotalCostDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.totalTokenDetails(
ThreadListItem.TotalTokenDetails.builder()
Thread.TotalTokenDetails.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -173,12 +170,9 @@ internal class ThreadListItemTest {
.traceId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9328")
.build()
val roundtrippedThreadListItem =
jsonMapper.readValue(
jsonMapper.writeValueAsString(threadListItem),
jacksonTypeRef<ThreadListItem>(),
)
val roundtrippedThread =
jsonMapper.readValue(jsonMapper.writeValueAsString(thread), jacksonTypeRef<Thread>())
assertThat(roundtrippedThreadListItem).isEqualTo(threadListItem)
assertThat(roundtrippedThread).isEqualTo(thread)
}
}
@@ -9,26 +9,26 @@ import java.time.OffsetDateTime
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
internal class ThreadTraceListItemTest {
internal class ThreadTraceTest {
@Test
fun create() {
val threadTraceListItem =
ThreadTraceListItem.builder()
val threadTrace =
ThreadTrace.builder()
.completionCost(0.0)
.completionCostDetails(
ThreadTraceListItem.CompletionCostDetails.builder()
ThreadTrace.CompletionCostDetails.builder()
.raw(
ThreadTraceListItem.CompletionCostDetails.Raw.builder()
ThreadTrace.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.completionTokenDetails(
ThreadTraceListItem.CompletionTokenDetails.builder()
ThreadTrace.CompletionTokenDetails.builder()
.raw(
ThreadTraceListItem.CompletionTokenDetails.Raw.builder()
ThreadTrace.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -45,18 +45,18 @@ internal class ThreadTraceListItemTest {
.outputsPreview("outputs_preview")
.promptCost(0.0)
.promptCostDetails(
ThreadTraceListItem.PromptCostDetails.builder()
ThreadTrace.PromptCostDetails.builder()
.raw(
ThreadTraceListItem.PromptCostDetails.Raw.builder()
ThreadTrace.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.promptTokenDetails(
ThreadTraceListItem.PromptTokenDetails.builder()
ThreadTrace.PromptTokenDetails.builder()
.raw(
ThreadTraceListItem.PromptTokenDetails.Raw.builder()
ThreadTrace.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -70,87 +70,86 @@ internal class ThreadTraceListItemTest {
.traceId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
.build()
assertThat(threadTraceListItem.completionCost()).contains(0.0)
assertThat(threadTraceListItem.completionCostDetails())
assertThat(threadTrace.completionCost()).contains(0.0)
assertThat(threadTrace.completionCostDetails())
.contains(
ThreadTraceListItem.CompletionCostDetails.builder()
ThreadTrace.CompletionCostDetails.builder()
.raw(
ThreadTraceListItem.CompletionCostDetails.Raw.builder()
ThreadTrace.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadTraceListItem.completionTokenDetails())
assertThat(threadTrace.completionTokenDetails())
.contains(
ThreadTraceListItem.CompletionTokenDetails.builder()
ThreadTrace.CompletionTokenDetails.builder()
.raw(
ThreadTraceListItem.CompletionTokenDetails.Raw.builder()
ThreadTrace.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadTraceListItem.completionTokens()).contains(0L)
assertThat(threadTraceListItem.endTime())
.contains(OffsetDateTime.parse("2025-01-15T12:00:01.500Z"))
assertThat(threadTraceListItem.errorPreview()).contains("error_preview")
assertThat(threadTraceListItem.firstTokenTime())
assertThat(threadTrace.completionTokens()).contains(0L)
assertThat(threadTrace.endTime()).contains(OffsetDateTime.parse("2025-01-15T12:00:01.500Z"))
assertThat(threadTrace.errorPreview()).contains("error_preview")
assertThat(threadTrace.firstTokenTime())
.contains(OffsetDateTime.parse("2024-01-15T10:30:00.312Z"))
assertThat(threadTraceListItem.inputsPreview()).contains("inputs_preview")
assertThat(threadTraceListItem.latency()).contains(0.0)
assertThat(threadTraceListItem.name()).contains("name")
assertThat(threadTraceListItem.op()).contains(0.0)
assertThat(threadTraceListItem.outputsPreview()).contains("outputs_preview")
assertThat(threadTraceListItem.promptCost()).contains(0.0)
assertThat(threadTraceListItem.promptCostDetails())
assertThat(threadTrace.inputsPreview()).contains("inputs_preview")
assertThat(threadTrace.latency()).contains(0.0)
assertThat(threadTrace.name()).contains("name")
assertThat(threadTrace.op()).contains(0.0)
assertThat(threadTrace.outputsPreview()).contains("outputs_preview")
assertThat(threadTrace.promptCost()).contains(0.0)
assertThat(threadTrace.promptCostDetails())
.contains(
ThreadTraceListItem.PromptCostDetails.builder()
ThreadTrace.PromptCostDetails.builder()
.raw(
ThreadTraceListItem.PromptCostDetails.Raw.builder()
ThreadTrace.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadTraceListItem.promptTokenDetails())
assertThat(threadTrace.promptTokenDetails())
.contains(
ThreadTraceListItem.PromptTokenDetails.builder()
ThreadTrace.PromptTokenDetails.builder()
.raw(
ThreadTraceListItem.PromptTokenDetails.Raw.builder()
ThreadTrace.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
assertThat(threadTraceListItem.promptTokens()).contains(0L)
assertThat(threadTraceListItem.startTime())
assertThat(threadTrace.promptTokens()).contains(0L)
assertThat(threadTrace.startTime())
.contains(OffsetDateTime.parse("2025-01-15T12:00:00.000Z"))
assertThat(threadTraceListItem.threadId()).contains("d4e5f6a7-b8c9-4d5e-1f2a-3b4c5d6e7f8a")
assertThat(threadTraceListItem.totalCost()).contains(0.0)
assertThat(threadTraceListItem.totalTokens()).contains(0L)
assertThat(threadTraceListItem.traceId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
assertThat(threadTrace.threadId()).contains("d4e5f6a7-b8c9-4d5e-1f2a-3b4c5d6e7f8a")
assertThat(threadTrace.totalCost()).contains(0.0)
assertThat(threadTrace.totalTokens()).contains(0L)
assertThat(threadTrace.traceId()).contains("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
}
@Test
fun roundtrip() {
val jsonMapper = jsonMapper()
val threadTraceListItem =
ThreadTraceListItem.builder()
val threadTrace =
ThreadTrace.builder()
.completionCost(0.0)
.completionCostDetails(
ThreadTraceListItem.CompletionCostDetails.builder()
ThreadTrace.CompletionCostDetails.builder()
.raw(
ThreadTraceListItem.CompletionCostDetails.Raw.builder()
ThreadTrace.CompletionCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.completionTokenDetails(
ThreadTraceListItem.CompletionTokenDetails.builder()
ThreadTrace.CompletionTokenDetails.builder()
.raw(
ThreadTraceListItem.CompletionTokenDetails.Raw.builder()
ThreadTrace.CompletionTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -167,18 +166,18 @@ internal class ThreadTraceListItemTest {
.outputsPreview("outputs_preview")
.promptCost(0.0)
.promptCostDetails(
ThreadTraceListItem.PromptCostDetails.builder()
ThreadTrace.PromptCostDetails.builder()
.raw(
ThreadTraceListItem.PromptCostDetails.Raw.builder()
ThreadTrace.PromptCostDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
.build()
)
.promptTokenDetails(
ThreadTraceListItem.PromptTokenDetails.builder()
ThreadTrace.PromptTokenDetails.builder()
.raw(
ThreadTraceListItem.PromptTokenDetails.Raw.builder()
ThreadTrace.PromptTokenDetails.Raw.builder()
.putAdditionalProperty("foo", JsonValue.from(0))
.build()
)
@@ -192,12 +191,12 @@ internal class ThreadTraceListItemTest {
.traceId("018e4c7e-a9fb-7ef0-a5b6-6ea3a82e9327")
.build()
val roundtrippedThreadTraceListItem =
val roundtrippedThreadTrace =
jsonMapper.readValue(
jsonMapper.writeValueAsString(threadTraceListItem),
jacksonTypeRef<ThreadTraceListItem>(),
jsonMapper.writeValueAsString(threadTrace),
jacksonTypeRef<ThreadTrace>(),
)
assertThat(roundtrippedThreadTraceListItem).isEqualTo(threadTraceListItem)
assertThat(roundtrippedThreadTrace).isEqualTo(threadTrace)
}
}
@@ -58,16 +58,17 @@ internal class ThreadServiceAsyncTest {
.build()
val threadServiceAsync = client.threads()
val responseFuture =
val threadStatsFuture =
threadServiceAsync.stats(
ThreadStatsParams.builder()
.threadId("thread_id")
.addSelect(ThreadStatsParams.Select.TURNS)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filter("filter")
.build()
)
val response = responseFuture.get()
response.validate()
val threadStats = threadStatsFuture.get()
threadStats.validate()
}
}
@@ -3,6 +3,7 @@
package com.langchain.smith.services.async.annotationqueues
import com.langchain.smith.client.okhttp.LangsmithOkHttpClientAsync
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateParams
import com.langchain.smith.models.annotationqueues.runs.RunDeleteAllParams
import com.langchain.smith.models.annotationqueues.runs.RunDeleteQueueParams
@@ -87,6 +88,36 @@ internal class RunServiceAsyncTest {
runSchemaWithAnnotationQueueInfos.forEach { it.validate() }
}
@Disabled("Mock server tests are disabled")
@Test
fun createByKey() {
val client =
LangsmithOkHttpClientAsync.builder()
.apiKey("My API Key")
.tenantId("My Tenant ID")
.build()
val runServiceAsync = client.annotationQueues().runs()
val responseFuture =
runServiceAsync.createByKey(
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.extendTraceRetention(true)
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.build()
)
val response = responseFuture.get()
response.forEach { it.validate() }
}
@Disabled("Mock server tests are disabled")
@Test
fun deleteAll() {
@@ -123,6 +123,15 @@ internal class BoxServiceAsyncTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
BoxCreateParams.MountConfig.Mount
.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
BoxCreateParams.MountConfig.Mount
.SandboxapiS3BucketMountSpec
@@ -47,15 +47,16 @@ internal class ThreadServiceTest {
LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build()
val threadService = client.threads()
val response =
val threadStats =
threadService.stats(
ThreadStatsParams.builder()
.threadId("thread_id")
.addSelect(ThreadStatsParams.Select.TURNS)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filter("filter")
.build()
)
response.validate()
threadStats.validate()
}
}
@@ -3,6 +3,7 @@
package com.langchain.smith.services.blocking.annotationqueues
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient
import com.langchain.smith.models.annotationqueues.runs.RunCreateByKeyParams
import com.langchain.smith.models.annotationqueues.runs.RunCreateParams
import com.langchain.smith.models.annotationqueues.runs.RunDeleteAllParams
import com.langchain.smith.models.annotationqueues.runs.RunDeleteQueueParams
@@ -75,6 +76,32 @@ internal class RunServiceTest {
runSchemaWithAnnotationQueueInfos.forEach { it.validate() }
}
@Disabled("Mock server tests are disabled")
@Test
fun createByKey() {
val client =
LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build()
val runService = client.annotationQueues().runs()
val response =
runService.createByKey(
RunCreateByKeyParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.extendTraceRetention(true)
.addBody(
RunCreateByKeyParams.Body.builder()
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.sourceProposedExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.build()
)
response.forEach { it.validate() }
}
@Disabled("Mock server tests are disabled")
@Test
fun deleteAll() {
@@ -120,6 +120,15 @@ internal class BoxServiceTest {
.writebackSeconds(0L)
.build()
)
.contexthub(
BoxCreateParams.MountConfig.Mount
.SandboxapiS3BucketMountSpec
.Contexthub
.builder()
.repo("repo")
.initialPullOnly(true)
.build()
)
.gcs(
BoxCreateParams.MountConfig.Mount
.SandboxapiS3BucketMountSpec
+1 -1
View File
@@ -20,7 +20,7 @@ dependencies {
implementation(kotlin("stdlib"))
// Jackson for JSON handling in examples
implementation("com.fasterxml.jackson.core:jackson-databind:2.22.0")
implementation("com.fasterxml.jackson.core:jackson-databind:2.22.1")
// Spring Boot dependencies (optional - only needed for Spring Boot example)
implementation(platform("org.springframework.boot:spring-boot-dependencies:3.5.16"))
@@ -19,7 +19,7 @@ dependencies {
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.22.0")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.22.1")
}
tasks.shadowJar {