release: 0.1.0-alpha.20 (#85)

* feat(api): api update

* codegen metadata

* codegen metadata

* feat(api): api update

* feat(api): api update

* feat(api): api update

* codegen metadata

* feat(api): api update

* feat(api): api update

* codegen metadata

* codegen metadata

* codegen metadata

* feat(api): api update

* codegen metadata

* codegen metadata

* feat(client): add `HttpRequest#url()` method

* codegen metadata

* codegen metadata

* codegen metadata

* codegen metadata

* feat(client): allow configuring dispatcher executor service

* codegen metadata

* codegen metadata

* codegen metadata

* codegen metadata

* release: 0.1.0-alpha.20

---------

Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
This commit is contained in:
stainless-app[bot]
2026-01-14 14:43:32 -05:00
committed by GitHub
parent 5572d09902
commit ded153ef51
40 changed files with 2475 additions and 216 deletions
@@ -507,9 +507,9 @@ private constructor(
headers.put("X-API-Key", it)
}
}
tenantId?.let {
organizationId?.let {
if (!it.isEmpty()) {
headers.put("X-Tenant-Id", it)
headers.put("X-Organization-Id", it)
}
}
bearerToken?.let {
@@ -517,9 +517,9 @@ private constructor(
headers.put("Authorization", "Bearer $it")
}
}
organizationId?.let {
tenantId?.let {
if (!it.isEmpty()) {
headers.put("X-Organization-Id", it)
headers.put("X-Tenant-Id", it)
}
}
headers.replaceAll(this.headers.build())
@@ -2,6 +2,7 @@ package com.langchain.smith.core.http
import com.langchain.smith.core.checkRequired
import com.langchain.smith.core.toImmutable
import java.net.URLEncoder
class HttpRequest
private constructor(
@@ -13,6 +14,35 @@ private constructor(
@get:JvmName("body") val body: HttpRequestBody?,
) {
fun url(): String = buildString {
append(baseUrl)
pathSegments.forEach { segment ->
if (!endsWith("/")) {
append("/")
}
append(URLEncoder.encode(segment, "UTF-8"))
}
if (queryParams.isEmpty()) {
return@buildString
}
append("?")
var isFirst = true
queryParams.keys().forEach { key ->
queryParams.values(key).forEach { value ->
if (!isFirst) {
append("&")
}
append(URLEncoder.encode(key, "UTF-8"))
append("=")
append(URLEncoder.encode(value, "UTF-8"))
isFirst = false
}
}
}
fun toBuilder(): Builder = Builder().from(this)
override fun toString(): String =
@@ -2,11 +2,34 @@
package com.langchain.smith.models.annotationqueues.runs
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.ObjectCodec
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.langchain.smith.core.BaseDeserializer
import com.langchain.smith.core.BaseSerializer
import com.langchain.smith.core.Enum
import com.langchain.smith.core.ExcludeMissing
import com.langchain.smith.core.JsonField
import com.langchain.smith.core.JsonMissing
import com.langchain.smith.core.JsonValue
import com.langchain.smith.core.Params
import com.langchain.smith.core.allMaxBy
import com.langchain.smith.core.checkRequired
import com.langchain.smith.core.getOrThrow
import com.langchain.smith.core.http.Headers
import com.langchain.smith.core.http.QueryParams
import com.langchain.smith.core.toImmutable
import com.langchain.smith.errors.LangChainInvalidDataException
import java.time.OffsetDateTime
import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -15,14 +38,14 @@ import kotlin.jvm.optionals.getOrNull
class RunCreateParams
private constructor(
private val queueId: String?,
private val body: List<String>,
private val body: Body,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) : Params {
fun queueId(): Optional<String> = Optional.ofNullable(queueId)
fun body(): List<String> = body
fun body(): Body = body
/** Additional headers to send with the request. */
fun _additionalHeaders(): Headers = additionalHeaders
@@ -49,14 +72,14 @@ private constructor(
class Builder internal constructor() {
private var queueId: String? = null
private var body: MutableList<String>? = null
private var body: Body? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@JvmSynthetic
internal fun from(runCreateParams: RunCreateParams) = apply {
queueId = runCreateParams.queueId
body = runCreateParams.body.toMutableList()
body = runCreateParams.body
additionalHeaders = runCreateParams.additionalHeaders.toBuilder()
additionalQueryParams = runCreateParams.additionalQueryParams.toBuilder()
}
@@ -66,16 +89,18 @@ private constructor(
/** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */
fun queueId(queueId: Optional<String>) = queueId(queueId.getOrNull())
fun body(body: List<String>) = apply { this.body = body.toMutableList() }
fun body(body: Body) = apply { this.body = body }
/** Alias for calling [body] with `Body.ofStrings(strings)`. */
fun bodyOfStrings(strings: List<String>) = body(Body.ofStrings(strings))
/**
* Adds a single [String] to [Builder.body].
*
* @throws IllegalStateException if the field was previously set to a non-list.
* Alias for calling [body] with
* `Body.ofAnnotationQueueRunAddSchemas(annotationQueueRunAddSchemas)`.
*/
fun addBody(body: String) = apply {
this.body = (this.body ?: mutableListOf()).apply { add(body) }
}
fun bodyOfAnnotationQueueRunAddSchemas(
annotationQueueRunAddSchemas: List<Body.AnnotationQueueRunAddSchema>
) = body(Body.ofAnnotationQueueRunAddSchemas(annotationQueueRunAddSchemas))
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
@@ -190,13 +215,13 @@ private constructor(
fun build(): RunCreateParams =
RunCreateParams(
queueId,
checkRequired("body", body).toImmutable(),
checkRequired("body", body),
additionalHeaders.build(),
additionalQueryParams.build(),
)
}
fun _body(): List<String> = body
fun _body(): Body = body
fun _pathParam(index: Int): String =
when (index) {
@@ -208,6 +233,706 @@ private constructor(
override fun _queryParams(): QueryParams = additionalQueryParams
@JsonDeserialize(using = Body.Deserializer::class)
@JsonSerialize(using = Body.Serializer::class)
class Body
private constructor(
private val strings: List<String>? = null,
private val annotationQueueRunAddSchemas: List<AnnotationQueueRunAddSchema>? = null,
private val _json: JsonValue? = null,
) {
fun strings(): Optional<List<String>> = Optional.ofNullable(strings)
fun annotationQueueRunAddSchemas(): Optional<List<AnnotationQueueRunAddSchema>> =
Optional.ofNullable(annotationQueueRunAddSchemas)
fun isStrings(): Boolean = strings != null
fun isAnnotationQueueRunAddSchemas(): Boolean = annotationQueueRunAddSchemas != null
fun asStrings(): List<String> = strings.getOrThrow("strings")
fun asAnnotationQueueRunAddSchemas(): List<AnnotationQueueRunAddSchema> =
annotationQueueRunAddSchemas.getOrThrow("annotationQueueRunAddSchemas")
fun _json(): Optional<JsonValue> = Optional.ofNullable(_json)
fun <T> accept(visitor: Visitor<T>): T =
when {
strings != null -> visitor.visitStrings(strings)
annotationQueueRunAddSchemas != null ->
visitor.visitAnnotationQueueRunAddSchemas(annotationQueueRunAddSchemas)
else -> visitor.unknown(_json)
}
private var validated: Boolean = false
fun validate(): Body = apply {
if (validated) {
return@apply
}
accept(
object : Visitor<Unit> {
override fun visitStrings(strings: List<String>) {}
override fun visitAnnotationQueueRunAddSchemas(
annotationQueueRunAddSchemas: List<AnnotationQueueRunAddSchema>
) {
annotationQueueRunAddSchemas.forEach { it.validate() }
}
}
)
validated = true
}
fun isValid(): Boolean =
try {
validate()
true
} catch (e: LangChainInvalidDataException) {
false
}
/**
* Returns a score indicating how many valid values are contained in this object
* recursively.
*
* Used for best match union deserialization.
*/
@JvmSynthetic
internal fun validity(): Int =
accept(
object : Visitor<Int> {
override fun visitStrings(strings: List<String>) = strings.size
override fun visitAnnotationQueueRunAddSchemas(
annotationQueueRunAddSchemas: List<AnnotationQueueRunAddSchema>
) = annotationQueueRunAddSchemas.sumOf { it.validity().toInt() }
override fun unknown(json: JsonValue?) = 0
}
)
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is Body &&
strings == other.strings &&
annotationQueueRunAddSchemas == other.annotationQueueRunAddSchemas
}
override fun hashCode(): Int = Objects.hash(strings, annotationQueueRunAddSchemas)
override fun toString(): String =
when {
strings != null -> "Body{strings=$strings}"
annotationQueueRunAddSchemas != null ->
"Body{annotationQueueRunAddSchemas=$annotationQueueRunAddSchemas}"
_json != null -> "Body{_unknown=$_json}"
else -> throw IllegalStateException("Invalid Body")
}
companion object {
@JvmStatic fun ofStrings(strings: List<String>) = Body(strings = strings.toImmutable())
@JvmStatic
fun ofAnnotationQueueRunAddSchemas(
annotationQueueRunAddSchemas: List<AnnotationQueueRunAddSchema>
) = Body(annotationQueueRunAddSchemas = annotationQueueRunAddSchemas.toImmutable())
}
/** An interface that defines how to map each variant of [Body] to a value of type [T]. */
interface Visitor<out T> {
fun visitStrings(strings: List<String>): T
fun visitAnnotationQueueRunAddSchemas(
annotationQueueRunAddSchemas: List<AnnotationQueueRunAddSchema>
): T
/**
* Maps an unknown variant of [Body] to a value of type [T].
*
* An instance of [Body] can contain an unknown variant if it was deserialized from data
* that doesn't match any known variant. For example, if the SDK is on an older version
* than the API, then the API may respond with new variants that the SDK is unaware of.
*
* @throws LangChainInvalidDataException in the default implementation.
*/
fun unknown(json: JsonValue?): T {
throw LangChainInvalidDataException("Unknown Body: $json")
}
}
internal class Deserializer : BaseDeserializer<Body>(Body::class) {
override fun ObjectCodec.deserialize(node: JsonNode): Body {
val json = JsonValue.fromJsonNode(node)
val bestMatches =
sequenceOf(
tryDeserialize(node, jacksonTypeRef<List<String>>())?.let {
Body(strings = it, _json = json)
},
tryDeserialize(
node,
jacksonTypeRef<List<AnnotationQueueRunAddSchema>>(),
)
?.let { Body(annotationQueueRunAddSchemas = it, _json = json) },
)
.filterNotNull()
.allMaxBy { it.validity() }
.toList()
return when (bestMatches.size) {
// This can happen if what we're deserializing is completely incompatible with
// all the possible variants (e.g. deserializing from boolean).
0 -> Body(_json = json)
1 -> bestMatches.single()
// If there's more than one match with the highest validity, then use the first
// completely valid match, or simply the first match if none are completely
// valid.
else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first()
}
}
}
internal class Serializer : BaseSerializer<Body>(Body::class) {
override fun serialize(
value: Body,
generator: JsonGenerator,
provider: SerializerProvider,
) {
when {
value.strings != null -> generator.writeObject(value.strings)
value.annotationQueueRunAddSchemas != null ->
generator.writeObject(value.annotationQueueRunAddSchemas)
value._json != null -> generator.writeObject(value._json)
else -> throw IllegalStateException("Invalid Body")
}
}
}
/** Schema for adding a run to an annotation queue with optional metadata. */
class AnnotationQueueRunAddSchema
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val runId: JsonField<String>,
private val parentRunId: JsonField<String>,
private val sessionId: JsonField<String>,
private val startTime: JsonField<OffsetDateTime>,
private val traceId: JsonField<String>,
private val traceTier: JsonField<TraceTier>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {
@JsonCreator
private constructor(
@JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(),
@JsonProperty("parent_run_id")
@ExcludeMissing
parentRunId: JsonField<String> = JsonMissing.of(),
@JsonProperty("session_id")
@ExcludeMissing
sessionId: JsonField<String> = JsonMissing.of(),
@JsonProperty("start_time")
@ExcludeMissing
startTime: JsonField<OffsetDateTime> = JsonMissing.of(),
@JsonProperty("trace_id")
@ExcludeMissing
traceId: JsonField<String> = JsonMissing.of(),
@JsonProperty("trace_tier")
@ExcludeMissing
traceTier: JsonField<TraceTier> = JsonMissing.of(),
) : this(runId, parentRunId, sessionId, startTime, traceId, traceTier, mutableMapOf())
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected
* value).
*/
fun runId(): String = runId.getRequired("run_id")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g.
* if the server responded with an unexpected value).
*/
fun parentRunId(): Optional<String> = parentRunId.getOptional("parent_run_id")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g.
* if the server responded with an unexpected value).
*/
fun sessionId(): Optional<String> = sessionId.getOptional("session_id")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g.
* if the server responded with an unexpected value).
*/
fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g.
* if the server responded with an unexpected value).
*/
fun traceId(): Optional<String> = traceId.getOptional("trace_id")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g.
* if the server responded with an unexpected value).
*/
fun traceTier(): Optional<TraceTier> = traceTier.getOptional("trace_tier")
/**
* Returns the raw JSON value of [runId].
*
* Unlike [runId], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId
/**
* Returns the raw JSON value of [parentRunId].
*
* Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected
* type.
*/
@JsonProperty("parent_run_id")
@ExcludeMissing
fun _parentRunId(): JsonField<String> = parentRunId
/**
* Returns the raw JSON value of [sessionId].
*
* Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected
* type.
*/
@JsonProperty("session_id")
@ExcludeMissing
fun _sessionId(): JsonField<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 [traceId].
*
* Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId
/**
* Returns the raw JSON value of [traceTier].
*
* Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected
* type.
*/
@JsonProperty("trace_tier")
@ExcludeMissing
fun _traceTier(): JsonField<TraceTier> = traceTier
@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
* [AnnotationQueueRunAddSchema].
*
* The following fields are required:
* ```java
* .runId()
* ```
*/
@JvmStatic fun builder() = Builder()
}
/** A builder for [AnnotationQueueRunAddSchema]. */
class Builder internal constructor() {
private var runId: JsonField<String>? = null
private var parentRunId: JsonField<String> = JsonMissing.of()
private var sessionId: JsonField<String> = JsonMissing.of()
private var startTime: JsonField<OffsetDateTime> = JsonMissing.of()
private var traceId: JsonField<String> = JsonMissing.of()
private var traceTier: JsonField<TraceTier> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
internal fun from(annotationQueueRunAddSchema: AnnotationQueueRunAddSchema) =
apply {
runId = annotationQueueRunAddSchema.runId
parentRunId = annotationQueueRunAddSchema.parentRunId
sessionId = annotationQueueRunAddSchema.sessionId
startTime = annotationQueueRunAddSchema.startTime
traceId = annotationQueueRunAddSchema.traceId
traceTier = annotationQueueRunAddSchema.traceTier
additionalProperties =
annotationQueueRunAddSchema.additionalProperties.toMutableMap()
}
fun runId(runId: String) = runId(JsonField.of(runId))
/**
* Sets [Builder.runId] to an arbitrary JSON value.
*
* You should usually call [Builder.runId] with a well-typed [String] value instead.
* This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
fun runId(runId: JsonField<String>) = apply { this.runId = runId }
fun parentRunId(parentRunId: String?) =
parentRunId(JsonField.ofNullable(parentRunId))
/** Alias for calling [Builder.parentRunId] with `parentRunId.orElse(null)`. */
fun parentRunId(parentRunId: Optional<String>) =
parentRunId(parentRunId.getOrNull())
/**
* Sets [Builder.parentRunId] to an arbitrary JSON value.
*
* You should usually call [Builder.parentRunId] with a well-typed [String] value
* instead. This method is primarily for setting the field to an undocumented or not
* yet supported value.
*/
fun parentRunId(parentRunId: JsonField<String>) = apply {
this.parentRunId = parentRunId
}
fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId))
/** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */
fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull())
/**
* Sets [Builder.sessionId] to an arbitrary JSON value.
*
* You should usually call [Builder.sessionId] with a well-typed [String] value
* instead. This method is primarily for setting the field to an undocumented or not
* yet supported value.
*/
fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId }
fun startTime(startTime: OffsetDateTime?) =
startTime(JsonField.ofNullable(startTime))
/** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */
fun startTime(startTime: Optional<OffsetDateTime>) =
startTime(startTime.getOrNull())
/**
* Sets [Builder.startTime] to an arbitrary JSON value.
*
* You should usually call [Builder.startTime] with a well-typed [OffsetDateTime]
* value instead. This method is primarily for setting the field to an undocumented
* or not yet supported value.
*/
fun startTime(startTime: JsonField<OffsetDateTime>) = apply {
this.startTime = startTime
}
fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId))
/** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */
fun traceId(traceId: Optional<String>) = traceId(traceId.getOrNull())
/**
* Sets [Builder.traceId] to an arbitrary JSON value.
*
* You should usually call [Builder.traceId] with a well-typed [String] value
* instead. This method is primarily for setting the field to an undocumented or not
* yet supported value.
*/
fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId }
fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier))
/** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */
fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull())
/**
* Sets [Builder.traceTier] to an arbitrary JSON value.
*
* You should usually call [Builder.traceTier] with a well-typed [TraceTier] value
* instead. This method is primarily for setting the field to an undocumented or not
* yet supported value.
*/
fun traceTier(traceTier: JsonField<TraceTier>) = apply {
this.traceTier = traceTier
}
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 [AnnotationQueueRunAddSchema].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
* .runId()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
fun build(): AnnotationQueueRunAddSchema =
AnnotationQueueRunAddSchema(
checkRequired("runId", runId),
parentRunId,
sessionId,
startTime,
traceId,
traceTier,
additionalProperties.toMutableMap(),
)
}
private var validated: Boolean = false
fun validate(): AnnotationQueueRunAddSchema = apply {
if (validated) {
return@apply
}
runId()
parentRunId()
sessionId()
startTime()
traceId()
traceTier().ifPresent { it.validate() }
validated = true
}
fun isValid(): Boolean =
try {
validate()
true
} catch (e: LangChainInvalidDataException) {
false
}
/**
* Returns a score indicating how many valid values are contained in this object
* recursively.
*
* Used for best match union deserialization.
*/
@JvmSynthetic
internal fun validity(): Int =
(if (runId.asKnown().isPresent) 1 else 0) +
(if (parentRunId.asKnown().isPresent) 1 else 0) +
(if (sessionId.asKnown().isPresent) 1 else 0) +
(if (startTime.asKnown().isPresent) 1 else 0) +
(if (traceId.asKnown().isPresent) 1 else 0) +
(traceTier.asKnown().getOrNull()?.validity() ?: 0)
class TraceTier @JsonCreator private constructor(private val value: JsonField<String>) :
Enum {
/**
* Returns this class instance's raw value.
*
* This is usually only useful if this instance was deserialized from data that
* doesn't match any known member, and you want to know that value. For example, if
* the SDK is on an older version than the API, then the API may respond with new
* members that the SDK is unaware of.
*/
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
companion object {
@JvmField val LONGLIVED = of("longlived")
@JvmField val SHORTLIVED = of("shortlived")
@JvmStatic fun of(value: String) = TraceTier(JsonField.of(value))
}
/** An enum containing [TraceTier]'s known values. */
enum class Known {
LONGLIVED,
SHORTLIVED,
}
/**
* An enum containing [TraceTier]'s known values, as well as an [_UNKNOWN] member.
*
* An instance of [TraceTier] can contain an unknown value in a couple of cases:
* - It was deserialized from data that doesn't match any known member. For example,
* if the SDK is on an older version than the API, then the API may respond with
* new members that the SDK is unaware of.
* - It was constructed with an arbitrary value using the [of] method.
*/
enum class Value {
LONGLIVED,
SHORTLIVED,
/**
* An enum member indicating that [TraceTier] was instantiated with an unknown
* value.
*/
_UNKNOWN,
}
/**
* Returns an enum member corresponding to this class instance's value, or
* [Value._UNKNOWN] if the class was instantiated with an unknown value.
*
* Use the [known] method instead if you're certain the value is always known or if
* you want to throw for the unknown case.
*/
fun value(): Value =
when (this) {
LONGLIVED -> Value.LONGLIVED
SHORTLIVED -> Value.SHORTLIVED
else -> Value._UNKNOWN
}
/**
* Returns an enum member corresponding to this class instance's value.
*
* Use the [value] method instead if you're uncertain the value is always known and
* don't want to throw for the unknown case.
*
* @throws LangChainInvalidDataException if this class instance's value is a not a
* known member.
*/
fun known(): Known =
when (this) {
LONGLIVED -> Known.LONGLIVED
SHORTLIVED -> Known.SHORTLIVED
else -> throw LangChainInvalidDataException("Unknown TraceTier: $value")
}
/**
* Returns this class instance's primitive wire representation.
*
* This differs from the [toString] method because that method is primarily for
* debugging and generally doesn't throw.
*
* @throws LangChainInvalidDataException if this class instance's value does not
* have the expected primitive type.
*/
fun asString(): String =
_value().asString().orElseThrow {
LangChainInvalidDataException("Value is not a String")
}
private var validated: Boolean = false
fun validate(): TraceTier = apply {
if (validated) {
return@apply
}
known()
validated = true
}
fun isValid(): Boolean =
try {
validate()
true
} catch (e: LangChainInvalidDataException) {
false
}
/**
* Returns a score indicating how many valid values are contained in this object
* recursively.
*
* Used for best match union deserialization.
*/
@JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is TraceTier && value == other.value
}
override fun hashCode() = value.hashCode()
override fun toString() = value.toString()
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is AnnotationQueueRunAddSchema &&
runId == other.runId &&
parentRunId == other.parentRunId &&
sessionId == other.sessionId &&
startTime == other.startTime &&
traceId == other.traceId &&
traceTier == other.traceTier &&
additionalProperties == other.additionalProperties
}
private val hashCode: Int by lazy {
Objects.hash(
runId,
parentRunId,
sessionId,
startTime,
traceId,
traceTier,
additionalProperties,
)
}
override fun hashCode(): Int = hashCode
override fun toString() =
"AnnotationQueueRunAddSchema{runId=$runId, parentRunId=$parentRunId, sessionId=$sessionId, startTime=$startTime, traceId=$traceId, traceTier=$traceTier, additionalProperties=$additionalProperties}"
}
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -14,12 +14,14 @@ import kotlin.jvm.optionals.getOrNull
/**
* Lists all commits for a repository with pagination support. This endpoint supports both
* authenticated and unauthenticated access. Authenticated users can access private repos, while
* unauthenticated users can only access public repos.
* unauthenticated users can only access public repos. The include_stats parameter controls whether
* download and view statistics are computed (defaults to true).
*/
class CommitListParams
private constructor(
private val owner: JsonValue,
private val repo: JsonValue?,
private val includeStats: Boolean?,
private val limit: Long?,
private val offset: Long?,
private val additionalHeaders: Headers,
@@ -30,6 +32,9 @@ private constructor(
fun repo(): Optional<JsonValue> = Optional.ofNullable(repo)
/** IncludeStats determines whether to compute num_downloads and num_views */
fun includeStats(): Optional<Boolean> = Optional.ofNullable(includeStats)
/** Limit is the pagination limit */
fun limit(): Optional<Long> = Optional.ofNullable(limit)
@@ -62,6 +67,7 @@ private constructor(
private var owner: JsonValue? = null
private var repo: JsonValue? = null
private var includeStats: Boolean? = null
private var limit: Long? = null
private var offset: Long? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
@@ -71,6 +77,7 @@ private constructor(
internal fun from(commitListParams: CommitListParams) = apply {
owner = commitListParams.owner
repo = commitListParams.repo
includeStats = commitListParams.includeStats
limit = commitListParams.limit
offset = commitListParams.offset
additionalHeaders = commitListParams.additionalHeaders.toBuilder()
@@ -84,6 +91,19 @@ private constructor(
/** Alias for calling [Builder.repo] with `repo.orElse(null)`. */
fun repo(repo: Optional<JsonValue>) = repo(repo.getOrNull())
/** IncludeStats determines whether to compute num_downloads and num_views */
fun includeStats(includeStats: Boolean?) = apply { this.includeStats = includeStats }
/**
* Alias for [Builder.includeStats].
*
* This unboxed primitive overload exists for backwards compatibility.
*/
fun includeStats(includeStats: Boolean) = includeStats(includeStats as Boolean?)
/** Alias for calling [Builder.includeStats] with `includeStats.orElse(null)`. */
fun includeStats(includeStats: Optional<Boolean>) = includeStats(includeStats.getOrNull())
/** Limit is the pagination limit */
fun limit(limit: Long?) = apply { this.limit = limit }
@@ -224,6 +244,7 @@ private constructor(
CommitListParams(
checkRequired("owner", owner),
repo,
includeStats,
limit,
offset,
additionalHeaders.build(),
@@ -243,6 +264,7 @@ private constructor(
override fun _queryParams(): QueryParams =
QueryParams.builder()
.apply {
includeStats?.let { put("include_stats", it.toString()) }
limit?.let { put("limit", it.toString()) }
offset?.let { put("offset", it.toString()) }
putAll(additionalQueryParams)
@@ -257,6 +279,7 @@ private constructor(
return other is CommitListParams &&
owner == other.owner &&
repo == other.repo &&
includeStats == other.includeStats &&
limit == other.limit &&
offset == other.offset &&
additionalHeaders == other.additionalHeaders &&
@@ -264,8 +287,16 @@ private constructor(
}
override fun hashCode(): Int =
Objects.hash(owner, repo, limit, offset, additionalHeaders, additionalQueryParams)
Objects.hash(
owner,
repo,
includeStats,
limit,
offset,
additionalHeaders,
additionalQueryParams,
)
override fun toString() =
"CommitListParams{owner=$owner, repo=$repo, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
"CommitListParams{owner=$owner, repo=$repo, includeStats=$includeStats, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
@@ -69,6 +69,12 @@ private constructor(
*/
fun examples(): Optional<List<String>> = body.examples()
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun split(): Optional<Split> = body.split()
/**
* Returns the raw JSON value of [sourceDatasetId].
*
@@ -97,6 +103,13 @@ private constructor(
*/
fun _examples(): JsonField<List<String>> = body._examples()
/**
* Returns the raw JSON value of [split].
*
* Unlike [split], this method doesn't throw if the JSON field has an unexpected type.
*/
fun _split(): JsonField<Split> = body._split()
fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties()
/** Additional headers to send with the request. */
@@ -144,6 +157,8 @@ private constructor(
* - [targetDatasetId]
* - [asOf]
* - [examples]
* - [split]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }
@@ -218,6 +233,25 @@ private constructor(
*/
fun addExample(example: String) = apply { body.addExample(example) }
fun split(split: Split?) = apply { body.split(split) }
/** Alias for calling [Builder.split] with `split.orElse(null)`. */
fun split(split: Optional<Split>) = split(split.getOrNull())
/**
* Sets [Builder.split] to an arbitrary JSON value.
*
* You should usually call [Builder.split] with a well-typed [Split] value instead. This
* method is primarily for setting the field to an undocumented or not yet supported value.
*/
fun split(split: JsonField<Split>) = apply { body.split(split) }
/** Alias for calling [split] with `Split.ofString(string)`. */
fun split(string: String) = apply { body.split(string) }
/** Alias for calling [split] with `Split.ofStrings(strings)`. */
fun splitOfStrings(strings: List<String>) = apply { body.splitOfStrings(strings) }
fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply {
body.additionalProperties(additionalBodyProperties)
}
@@ -369,6 +403,7 @@ private constructor(
private val targetDatasetId: JsonField<String>,
private val asOf: JsonField<AsOf>,
private val examples: JsonField<List<String>>,
private val split: JsonField<Split>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {
@@ -384,7 +419,8 @@ private constructor(
@JsonProperty("examples")
@ExcludeMissing
examples: JsonField<List<String>> = JsonMissing.of(),
) : this(sourceDatasetId, targetDatasetId, asOf, examples, mutableMapOf())
@JsonProperty("split") @ExcludeMissing split: JsonField<Split> = JsonMissing.of(),
) : this(sourceDatasetId, targetDatasetId, asOf, examples, split, mutableMapOf())
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type or is
@@ -413,6 +449,12 @@ private constructor(
*/
fun examples(): Optional<List<String>> = examples.getOptional("examples")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if
* the server responded with an unexpected value).
*/
fun split(): Optional<Split> = split.getOptional("split")
/**
* Returns the raw JSON value of [sourceDatasetId].
*
@@ -449,6 +491,13 @@ private constructor(
@ExcludeMissing
fun _examples(): JsonField<List<String>> = examples
/**
* Returns the raw JSON value of [split].
*
* Unlike [split], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("split") @ExcludeMissing fun _split(): JsonField<Split> = split
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -482,6 +531,7 @@ private constructor(
private var targetDatasetId: JsonField<String>? = null
private var asOf: JsonField<AsOf> = JsonMissing.of()
private var examples: JsonField<MutableList<String>>? = null
private var split: JsonField<Split> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
@@ -490,6 +540,7 @@ private constructor(
targetDatasetId = body.targetDatasetId
asOf = body.asOf
examples = body.examples.map { it.toMutableList() }
split = body.split
additionalProperties = body.additionalProperties.toMutableMap()
}
@@ -570,6 +621,26 @@ private constructor(
}
}
fun split(split: Split?) = split(JsonField.ofNullable(split))
/** Alias for calling [Builder.split] with `split.orElse(null)`. */
fun split(split: Optional<Split>) = split(split.getOrNull())
/**
* Sets [Builder.split] to an arbitrary JSON value.
*
* You should usually call [Builder.split] with a well-typed [Split] value instead. This
* method is primarily for setting the field to an undocumented or not yet supported
* value.
*/
fun split(split: JsonField<Split>) = apply { this.split = split }
/** Alias for calling [split] with `Split.ofString(string)`. */
fun split(string: String) = split(Split.ofString(string))
/** Alias for calling [split] with `Split.ofStrings(strings)`. */
fun splitOfStrings(strings: List<String>) = split(Split.ofStrings(strings))
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -608,6 +679,7 @@ private constructor(
checkRequired("targetDatasetId", targetDatasetId),
asOf,
(examples ?: JsonMissing.of()).map { it.toImmutable() },
split,
additionalProperties.toMutableMap(),
)
}
@@ -623,6 +695,7 @@ private constructor(
targetDatasetId()
asOf().ifPresent { it.validate() }
examples()
split().ifPresent { it.validate() }
validated = true
}
@@ -645,7 +718,8 @@ private constructor(
(if (sourceDatasetId.asKnown().isPresent) 1 else 0) +
(if (targetDatasetId.asKnown().isPresent) 1 else 0) +
(asOf.asKnown().getOrNull()?.validity() ?: 0) +
(examples.asKnown().getOrNull()?.size ?: 0)
(examples.asKnown().getOrNull()?.size ?: 0) +
(split.asKnown().getOrNull()?.validity() ?: 0)
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -657,17 +731,25 @@ private constructor(
targetDatasetId == other.targetDatasetId &&
asOf == other.asOf &&
examples == other.examples &&
split == other.split &&
additionalProperties == other.additionalProperties
}
private val hashCode: Int by lazy {
Objects.hash(sourceDatasetId, targetDatasetId, asOf, examples, additionalProperties)
Objects.hash(
sourceDatasetId,
targetDatasetId,
asOf,
examples,
split,
additionalProperties,
)
}
override fun hashCode(): Int = hashCode
override fun toString() =
"Body{sourceDatasetId=$sourceDatasetId, targetDatasetId=$targetDatasetId, asOf=$asOf, examples=$examples, additionalProperties=$additionalProperties}"
"Body{sourceDatasetId=$sourceDatasetId, targetDatasetId=$targetDatasetId, asOf=$asOf, examples=$examples, split=$split, additionalProperties=$additionalProperties}"
}
/**
@@ -842,6 +924,173 @@ private constructor(
}
}
@JsonDeserialize(using = Split.Deserializer::class)
@JsonSerialize(using = Split.Serializer::class)
class Split
private constructor(
private val string: String? = null,
private val strings: List<String>? = null,
private val _json: JsonValue? = null,
) {
fun string(): Optional<String> = Optional.ofNullable(string)
fun strings(): Optional<List<String>> = Optional.ofNullable(strings)
fun isString(): Boolean = string != null
fun isStrings(): Boolean = strings != null
fun asString(): String = string.getOrThrow("string")
fun asStrings(): List<String> = strings.getOrThrow("strings")
fun _json(): Optional<JsonValue> = Optional.ofNullable(_json)
fun <T> accept(visitor: Visitor<T>): T =
when {
string != null -> visitor.visitString(string)
strings != null -> visitor.visitStrings(strings)
else -> visitor.unknown(_json)
}
private var validated: Boolean = false
fun validate(): Split = apply {
if (validated) {
return@apply
}
accept(
object : Visitor<Unit> {
override fun visitString(string: String) {}
override fun visitStrings(strings: List<String>) {}
}
)
validated = true
}
fun isValid(): Boolean =
try {
validate()
true
} catch (e: LangChainInvalidDataException) {
false
}
/**
* Returns a score indicating how many valid values are contained in this object
* recursively.
*
* Used for best match union deserialization.
*/
@JvmSynthetic
internal fun validity(): Int =
accept(
object : Visitor<Int> {
override fun visitString(string: String) = 1
override fun visitStrings(strings: List<String>) = strings.size
override fun unknown(json: JsonValue?) = 0
}
)
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is Split && string == other.string && strings == other.strings
}
override fun hashCode(): Int = Objects.hash(string, strings)
override fun toString(): String =
when {
string != null -> "Split{string=$string}"
strings != null -> "Split{strings=$strings}"
_json != null -> "Split{_unknown=$_json}"
else -> throw IllegalStateException("Invalid Split")
}
companion object {
@JvmStatic fun ofString(string: String) = Split(string = string)
@JvmStatic fun ofStrings(strings: List<String>) = Split(strings = strings.toImmutable())
}
/** An interface that defines how to map each variant of [Split] to a value of type [T]. */
interface Visitor<out T> {
fun visitString(string: String): T
fun visitStrings(strings: List<String>): T
/**
* Maps an unknown variant of [Split] to a value of type [T].
*
* An instance of [Split] can contain an unknown variant if it was deserialized from
* data that doesn't match any known variant. For example, if the SDK is on an older
* version than the API, then the API may respond with new variants that the SDK is
* unaware of.
*
* @throws LangChainInvalidDataException in the default implementation.
*/
fun unknown(json: JsonValue?): T {
throw LangChainInvalidDataException("Unknown Split: $json")
}
}
internal class Deserializer : BaseDeserializer<Split>(Split::class) {
override fun ObjectCodec.deserialize(node: JsonNode): Split {
val json = JsonValue.fromJsonNode(node)
val bestMatches =
sequenceOf(
tryDeserialize(node, jacksonTypeRef<String>())?.let {
Split(string = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<List<String>>())?.let {
Split(strings = it, _json = json)
},
)
.filterNotNull()
.allMaxBy { it.validity() }
.toList()
return when (bestMatches.size) {
// This can happen if what we're deserializing is completely incompatible with
// all the possible variants (e.g. deserializing from object).
0 -> Split(_json = json)
1 -> bestMatches.single()
// If there's more than one match with the highest validity, then use the first
// completely valid match, or simply the first match if none are completely
// valid.
else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first()
}
}
}
internal class Serializer : BaseSerializer<Split>(Split::class) {
override fun serialize(
value: Split,
generator: JsonGenerator,
provider: SerializerProvider,
) {
when {
value.string != null -> generator.writeObject(value.string)
value.strings != null -> generator.writeObject(value.strings)
value._json != null -> generator.writeObject(value._json)
else -> throw IllegalStateException("Invalid Split")
}
}
}
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -29,6 +29,7 @@ private constructor(
private val offset: JsonField<Long>,
private val preview: JsonField<Boolean>,
private val sortParams: JsonField<SortParamsForRunsComparisonView>,
private val stream: JsonField<Boolean>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {
@@ -47,6 +48,7 @@ private constructor(
@JsonProperty("sort_params")
@ExcludeMissing
sortParams: JsonField<SortParamsForRunsComparisonView> = JsonMissing.of(),
@JsonProperty("stream") @ExcludeMissing stream: JsonField<Boolean> = JsonMissing.of(),
) : this(
sessionIds,
comparativeExperimentId,
@@ -55,6 +57,7 @@ private constructor(
offset,
preview,
sortParams,
stream,
mutableMapOf(),
)
@@ -102,6 +105,12 @@ private constructor(
fun sortParams(): Optional<SortParamsForRunsComparisonView> =
sortParams.getOptional("sort_params")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun stream(): Optional<Boolean> = stream.getOptional("stream")
/**
* Returns the raw JSON value of [sessionIds].
*
@@ -158,6 +167,13 @@ private constructor(
@ExcludeMissing
fun _sortParams(): JsonField<SortParamsForRunsComparisonView> = sortParams
/**
* Returns the raw JSON value of [stream].
*
* Unlike [stream], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField<Boolean> = stream
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
@@ -193,6 +209,7 @@ private constructor(
private var offset: JsonField<Long> = JsonMissing.of()
private var preview: JsonField<Boolean> = JsonMissing.of()
private var sortParams: JsonField<SortParamsForRunsComparisonView> = JsonMissing.of()
private var stream: JsonField<Boolean> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@JvmSynthetic
@@ -204,6 +221,7 @@ private constructor(
offset = queryExampleSchemaWithRuns.offset
preview = queryExampleSchemaWithRuns.preview
sortParams = queryExampleSchemaWithRuns.sortParams
stream = queryExampleSchemaWithRuns.stream
additionalProperties = queryExampleSchemaWithRuns.additionalProperties.toMutableMap()
}
@@ -314,6 +332,16 @@ private constructor(
this.sortParams = sortParams
}
fun stream(stream: Boolean) = stream(JsonField.of(stream))
/**
* Sets [Builder.stream] to an arbitrary JSON value.
*
* You should usually call [Builder.stream] with a well-typed [Boolean] value instead. This
* method is primarily for setting the field to an undocumented or not yet supported value.
*/
fun stream(stream: JsonField<Boolean>) = apply { this.stream = stream }
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -354,6 +382,7 @@ private constructor(
offset,
preview,
sortParams,
stream,
additionalProperties.toMutableMap(),
)
}
@@ -372,6 +401,7 @@ private constructor(
offset()
preview()
sortParams().ifPresent { it.validate() }
stream()
validated = true
}
@@ -396,7 +426,8 @@ private constructor(
(if (limit.asKnown().isPresent) 1 else 0) +
(if (offset.asKnown().isPresent) 1 else 0) +
(if (preview.asKnown().isPresent) 1 else 0) +
(sortParams.asKnown().getOrNull()?.validity() ?: 0)
(sortParams.asKnown().getOrNull()?.validity() ?: 0) +
(if (stream.asKnown().isPresent) 1 else 0)
class Filters
@JsonCreator
@@ -510,6 +541,7 @@ private constructor(
offset == other.offset &&
preview == other.preview &&
sortParams == other.sortParams &&
stream == other.stream &&
additionalProperties == other.additionalProperties
}
@@ -522,6 +554,7 @@ private constructor(
offset,
preview,
sortParams,
stream,
additionalProperties,
)
}
@@ -529,5 +562,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
"QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, additionalProperties=$additionalProperties}"
"QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, filters=$filters, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, stream=$stream, additionalProperties=$additionalProperties}"
}
@@ -17,6 +17,7 @@ class ExampleRetrieveParams
private constructor(
private val exampleId: String?,
private val asOf: AsOf?,
private val dataset: String?,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) : Params {
@@ -29,6 +30,8 @@ private constructor(
*/
fun asOf(): Optional<AsOf> = Optional.ofNullable(asOf)
fun dataset(): Optional<String> = Optional.ofNullable(dataset)
/** Additional headers to send with the request. */
fun _additionalHeaders(): Headers = additionalHeaders
@@ -50,6 +53,7 @@ private constructor(
private var exampleId: String? = null
private var asOf: AsOf? = null
private var dataset: String? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@@ -57,6 +61,7 @@ private constructor(
internal fun from(exampleRetrieveParams: ExampleRetrieveParams) = apply {
exampleId = exampleRetrieveParams.exampleId
asOf = exampleRetrieveParams.asOf
dataset = exampleRetrieveParams.dataset
additionalHeaders = exampleRetrieveParams.additionalHeaders.toBuilder()
additionalQueryParams = exampleRetrieveParams.additionalQueryParams.toBuilder()
}
@@ -81,6 +86,11 @@ private constructor(
/** Alias for calling [asOf] with `AsOf.ofString(string)`. */
fun asOf(string: String) = asOf(AsOf.ofString(string))
fun dataset(dataset: String?) = apply { this.dataset = dataset }
/** Alias for calling [Builder.dataset] with `dataset.orElse(null)`. */
fun dataset(dataset: Optional<String>) = dataset(dataset.getOrNull())
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -188,6 +198,7 @@ private constructor(
ExampleRetrieveParams(
exampleId,
asOf,
dataset,
additionalHeaders.build(),
additionalQueryParams.build(),
)
@@ -218,6 +229,7 @@ private constructor(
}
}
)
dataset?.let { put("dataset", it) }
putAll(additionalQueryParams)
}
.build()
@@ -294,13 +306,14 @@ private constructor(
return other is ExampleRetrieveParams &&
exampleId == other.exampleId &&
asOf == other.asOf &&
dataset == other.dataset &&
additionalHeaders == other.additionalHeaders &&
additionalQueryParams == other.additionalQueryParams
}
override fun hashCode(): Int =
Objects.hash(exampleId, asOf, additionalHeaders, additionalQueryParams)
Objects.hash(exampleId, asOf, dataset, additionalHeaders, additionalQueryParams)
override fun toString() =
"ExampleRetrieveParams{exampleId=$exampleId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
"ExampleRetrieveParams{exampleId=$exampleId, asOf=$asOf, dataset=$dataset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
@@ -50,6 +50,7 @@ private constructor(
private val runId: JsonField<String>,
private val score: JsonField<Score>,
private val sessionId: JsonField<String>,
private val startTime: JsonField<OffsetDateTime>,
private val traceId: JsonField<String>,
private val value: JsonField<Value>,
private val additionalProperties: MutableMap<String, JsonValue>,
@@ -85,6 +86,9 @@ private constructor(
@JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(),
@JsonProperty("score") @ExcludeMissing score: JsonField<Score> = JsonMissing.of(),
@JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(),
@JsonProperty("start_time")
@ExcludeMissing
startTime: JsonField<OffsetDateTime> = JsonMissing.of(),
@JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(),
@JsonProperty("value") @ExcludeMissing value: JsonField<Value> = JsonMissing.of(),
) : this(
@@ -102,6 +106,7 @@ private constructor(
runId,
score,
sessionId,
startTime,
traceId,
value,
mutableMapOf(),
@@ -194,6 +199,12 @@ private constructor(
*/
fun sessionId(): Optional<String> = sessionId.getOptional("session_id")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time")
/**
* @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -319,6 +330,15 @@ private constructor(
*/
@JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<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 [traceId].
*
@@ -375,6 +395,7 @@ private constructor(
private var runId: JsonField<String> = JsonMissing.of()
private var score: JsonField<Score> = JsonMissing.of()
private var sessionId: JsonField<String> = JsonMissing.of()
private var startTime: JsonField<OffsetDateTime> = JsonMissing.of()
private var traceId: JsonField<String> = JsonMissing.of()
private var value: JsonField<Value> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@@ -395,6 +416,7 @@ private constructor(
runId = feedbackCreateSchema.runId
score = feedbackCreateSchema.score
sessionId = feedbackCreateSchema.sessionId
startTime = feedbackCreateSchema.startTime
traceId = feedbackCreateSchema.traceId
value = feedbackCreateSchema.value
additionalProperties = feedbackCreateSchema.additionalProperties.toMutableMap()
@@ -634,6 +656,20 @@ private constructor(
*/
fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId }
fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime))
/** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */
fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull())
/**
* Sets [Builder.startTime] to an arbitrary JSON value.
*
* You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value
* instead. This method is primarily for setting the field to an undocumented or not yet
* supported value.
*/
fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime }
fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId))
/** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */
@@ -719,6 +755,7 @@ private constructor(
runId,
score,
sessionId,
startTime,
traceId,
value,
additionalProperties.toMutableMap(),
@@ -746,6 +783,7 @@ private constructor(
runId()
score().ifPresent { it.validate() }
sessionId()
startTime()
traceId()
value().ifPresent { it.validate() }
validated = true
@@ -780,6 +818,7 @@ private constructor(
(if (runId.asKnown().isPresent) 1 else 0) +
(score.asKnown().getOrNull()?.validity() ?: 0) +
(if (sessionId.asKnown().isPresent) 1 else 0) +
(if (startTime.asKnown().isPresent) 1 else 0) +
(if (traceId.asKnown().isPresent) 1 else 0) +
(value.asKnown().getOrNull()?.validity() ?: 0)
@@ -2440,6 +2479,7 @@ private constructor(
runId == other.runId &&
score == other.score &&
sessionId == other.sessionId &&
startTime == other.startTime &&
traceId == other.traceId &&
value == other.value &&
additionalProperties == other.additionalProperties
@@ -2461,6 +2501,7 @@ private constructor(
runId,
score,
sessionId,
startTime,
traceId,
value,
additionalProperties,
@@ -2470,5 +2511,5 @@ private constructor(
override fun hashCode(): Int = hashCode
override fun toString() =
"FeedbackCreateSchema{key=$key, id=$id, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, error=$error, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}"
"FeedbackCreateSchema{key=$key, id=$id, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, error=$error, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, startTime=$startTime, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}"
}
@@ -2667,6 +2667,8 @@ private constructor(
@JvmField val MESSAGES = of("messages")
@JvmField val INSERTED_AT = of("inserted_at")
@JvmStatic fun of(value: String) = Select(JsonField.of(value))
}
@@ -2731,6 +2733,7 @@ private constructor(
THREAD_ID,
TRACE_MIN_MAX_START_TIME,
MESSAGES,
INSERTED_AT,
}
/**
@@ -2802,6 +2805,7 @@ private constructor(
THREAD_ID,
TRACE_MIN_MAX_START_TIME,
MESSAGES,
INSERTED_AT,
/** An enum member indicating that [Select] was instantiated with an unknown value. */
_UNKNOWN,
}
@@ -2874,6 +2878,7 @@ private constructor(
THREAD_ID -> Value.THREAD_ID
TRACE_MIN_MAX_START_TIME -> Value.TRACE_MIN_MAX_START_TIME
MESSAGES -> Value.MESSAGES
INSERTED_AT -> Value.INSERTED_AT
else -> Value._UNKNOWN
}
@@ -2947,6 +2952,7 @@ private constructor(
THREAD_ID -> Known.THREAD_ID
TRACE_MIN_MAX_START_TIME -> Known.TRACE_MIN_MAX_START_TIME
MESSAGES -> Known.MESSAGES
INSERTED_AT -> Known.INSERTED_AT
else -> throw LangChainInvalidDataException("Unknown Select: $value")
}
@@ -91,7 +91,8 @@ interface CommitServiceAsync {
/**
* Lists all commits for a repository with pagination support. This endpoint supports both
* authenticated and unauthenticated access. Authenticated users can access private repos, while
* unauthenticated users can only access public repos.
* unauthenticated users can only access public repos. The include_stats parameter controls
* whether download and view statistics are computed (defaults to true).
*/
fun list(repo: JsonValue, params: CommitListParams): CompletableFuture<CommitListPageAsync> =
list(repo, params, RequestOptions.none())
@@ -85,7 +85,8 @@ interface CommitService {
/**
* Lists all commits for a repository with pagination support. This endpoint supports both
* authenticated and unauthenticated access. Authenticated users can access private repos, while
* unauthenticated users can only access public repos.
* unauthenticated users can only access public repos. The include_stats parameter controls
* whether download and view statistics are computed (defaults to true).
*/
fun list(repo: JsonValue, params: CommitListParams): CommitListPage =
list(repo, params, RequestOptions.none())
@@ -0,0 +1,110 @@
package com.langchain.smith.core.http
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.EnumSource
internal class HttpRequestTest {
enum class UrlTestCase(val request: HttpRequest, val expectedUrl: String) {
BASE_URL_ONLY(
HttpRequest.builder().method(HttpMethod.GET).baseUrl("https://api.example.com").build(),
expectedUrl = "https://api.example.com",
),
BASE_URL_WITH_TRAILING_SLASH(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com/")
.build(),
expectedUrl = "https://api.example.com/",
),
SINGLE_PATH_SEGMENT(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com")
.addPathSegment("users")
.build(),
expectedUrl = "https://api.example.com/users",
),
MULTIPLE_PATH_SEGMENTS(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com")
.addPathSegments("users", "123", "profile")
.build(),
expectedUrl = "https://api.example.com/users/123/profile",
),
PATH_SEGMENT_WITH_SPECIAL_CHARS(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com")
.addPathSegment("user name")
.build(),
expectedUrl = "https://api.example.com/user+name",
),
SINGLE_QUERY_PARAM(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com")
.addPathSegment("users")
.putQueryParam("limit", "10")
.build(),
expectedUrl = "https://api.example.com/users?limit=10",
),
MULTIPLE_QUERY_PARAMS(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com")
.addPathSegment("users")
.putQueryParam("limit", "10")
.putQueryParam("offset", "20")
.build(),
expectedUrl = "https://api.example.com/users?limit=10&offset=20",
),
QUERY_PARAM_WITH_SPECIAL_CHARS(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com")
.addPathSegment("search")
.putQueryParam("q", "hello world")
.build(),
expectedUrl = "https://api.example.com/search?q=hello+world",
),
MULTIPLE_VALUES_SAME_PARAM(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com")
.addPathSegment("users")
.putQueryParams("tags", listOf("admin", "user"))
.build(),
expectedUrl = "https://api.example.com/users?tags=admin&tags=user",
),
BASE_URL_WITH_TRAILING_SLASH_AND_PATH(
HttpRequest.builder()
.method(HttpMethod.GET)
.baseUrl("https://api.example.com/")
.addPathSegment("users")
.build(),
expectedUrl = "https://api.example.com/users",
),
COMPLEX_URL(
HttpRequest.builder()
.method(HttpMethod.POST)
.baseUrl("https://api.example.com")
.addPathSegments("v1", "users", "123")
.putQueryParams("include", listOf("profile", "settings"))
.putQueryParam("format", "json")
.build(),
expectedUrl =
"https://api.example.com/v1/users/123?include=profile&include=settings&format=json",
),
}
@ParameterizedTest
@EnumSource
fun url(testCase: UrlTestCase) {
val actualUrl = testCase.request.url()
assertThat(actualUrl).isEqualTo(testCase.expectedUrl)
}
}
@@ -11,7 +11,7 @@ internal class RunCreateParamsTest {
fun create() {
RunCreateParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"))
.build()
}
@@ -20,7 +20,7 @@ internal class RunCreateParamsTest {
val params =
RunCreateParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"))
.build()
assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
@@ -33,11 +33,14 @@ internal class RunCreateParamsTest {
val params =
RunCreateParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"))
.build()
val body = params._body()
assertThat(body).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(body)
.isEqualTo(
RunCreateParams.Body.ofStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"))
)
}
}
@@ -14,6 +14,7 @@ internal class CommitListParamsTest {
CommitListParams.builder()
.owner(JsonValue.from(mapOf<String, Any>()))
.repo(JsonValue.from(mapOf<String, Any>()))
.includeStats(true)
.limit(1L)
.offset(0L)
.build()
@@ -39,6 +40,7 @@ internal class CommitListParamsTest {
CommitListParams.builder()
.owner(JsonValue.from(mapOf<String, Any>()))
.repo(JsonValue.from(mapOf<String, Any>()))
.includeStats(true)
.limit(1L)
.offset(0L)
.build()
@@ -46,7 +48,13 @@ internal class CommitListParamsTest {
val queryParams = params._queryParams()
assertThat(queryParams)
.isEqualTo(QueryParams.builder().put("limit", "1").put("offset", "0").build())
.isEqualTo(
QueryParams.builder()
.put("include_stats", "true")
.put("limit", "1")
.put("offset", "0")
.build()
)
}
@Test
@@ -16,6 +16,7 @@ internal class DatasetCloneParamsTest {
.targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.split("string")
.build()
}
@@ -27,6 +28,7 @@ internal class DatasetCloneParamsTest {
.targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.split("string")
.build()
val body = params._body()
@@ -41,6 +43,7 @@ internal class DatasetCloneParamsTest {
)
assertThat(body.examples().getOrNull())
.containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(body.split()).contains(DatasetCloneParams.Split.ofString("string"))
}
@Test
@@ -30,6 +30,7 @@ internal class QueryExampleSchemaWithRunsTest {
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.stream(true)
.build()
assertThat(queryExampleSchemaWithRuns.sessionIds())
@@ -52,6 +53,7 @@ internal class QueryExampleSchemaWithRunsTest {
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
assertThat(queryExampleSchemaWithRuns.stream()).contains(true)
}
@Test
@@ -75,6 +77,7 @@ internal class QueryExampleSchemaWithRunsTest {
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.stream(true)
.build()
val roundtrippedQueryExampleSchemaWithRuns =
@@ -13,27 +13,24 @@ internal class RunCreateParamsTest {
fun create() {
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.format("format")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
QueryExampleSchemaWithRuns.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.format(RunCreateParams.Format.CSV)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
RunCreateParams.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.stream(true)
.build()
}
@@ -42,11 +39,7 @@ internal class RunCreateParamsTest {
val params =
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
@@ -59,32 +52,29 @@ internal class RunCreateParamsTest {
val params =
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.format("format")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
QueryExampleSchemaWithRuns.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.format(RunCreateParams.Format.CSV)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
RunCreateParams.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.stream(true)
.build()
val queryParams = params._queryParams()
assertThat(queryParams).isEqualTo(QueryParams.builder().put("format", "format").build())
assertThat(queryParams).isEqualTo(QueryParams.builder().put("format", "csv").build())
}
@Test
@@ -92,11 +82,7 @@ internal class RunCreateParamsTest {
val params =
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
val queryParams = params._queryParams()
@@ -109,52 +95,47 @@ internal class RunCreateParamsTest {
val params =
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.format("format")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
QueryExampleSchemaWithRuns.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.format(RunCreateParams.Format.CSV)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
RunCreateParams.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.stream(true)
.build()
val body = params._body()
assertThat(body)
.isEqualTo(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
QueryExampleSchemaWithRuns.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
assertThat(body.sessionIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(body.comparativeExperimentId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(body.filters())
.contains(
RunCreateParams.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
assertThat(body.limit()).contains(1L)
assertThat(body.offset()).contains(0L)
assertThat(body.preview()).contains(true)
assertThat(body.sortParams())
.contains(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
assertThat(body.stream()).contains(true)
}
@Test
@@ -162,20 +143,11 @@ internal class RunCreateParamsTest {
val params =
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
val body = params._body()
assertThat(body)
.isEqualTo(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
assertThat(body.sessionIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
}
}
@@ -14,6 +14,7 @@ internal class ExampleRetrieveParamsTest {
ExampleRetrieveParams.builder()
.exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
}
@@ -35,12 +36,18 @@ internal class ExampleRetrieveParamsTest {
ExampleRetrieveParams.builder()
.exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
val queryParams = params._queryParams()
assertThat(queryParams)
.isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build())
.isEqualTo(
QueryParams.builder()
.put("as_of", "2019-12-27T18:11:19.117Z")
.put("dataset", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
}
@Test
@@ -53,6 +53,7 @@ internal class FeedbackCreateParamsTest {
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.score(0.0)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.value(0.0)
.build()
@@ -105,6 +106,7 @@ internal class FeedbackCreateParamsTest {
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.score(0.0)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.value(0.0)
.build()
@@ -155,6 +157,7 @@ internal class FeedbackCreateParamsTest {
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.score(0.0)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.value(0.0)
.build()
@@ -54,6 +54,7 @@ internal class FeedbackCreateSchemaTest {
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.score(0.0)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.value(0.0)
.build()
@@ -109,6 +110,8 @@ internal class FeedbackCreateSchemaTest {
assertThat(feedbackCreateSchema.score()).contains(FeedbackCreateSchema.Score.ofNumber(0.0))
assertThat(feedbackCreateSchema.sessionId())
.contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(feedbackCreateSchema.startTime())
.contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
assertThat(feedbackCreateSchema.traceId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
assertThat(feedbackCreateSchema.value()).contains(FeedbackCreateSchema.Value.ofNumber(0.0))
}
@@ -157,6 +160,7 @@ internal class FeedbackCreateSchemaTest {
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.score(0.0)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.value(0.0)
.build()
@@ -222,6 +222,7 @@ internal class DatasetServiceAsyncTest {
.targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.split("string")
.build()
)
@@ -82,6 +82,7 @@ internal class ExampleServiceAsyncTest {
ExampleRetrieveParams.builder()
.exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
@@ -71,6 +71,7 @@ internal class FeedbackServiceAsyncTest {
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.score(0.0)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.value(0.0)
.build()
@@ -33,7 +33,7 @@ internal class RunServiceAsyncTest {
runServiceAsync.create(
RunCreateParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"))
.build()
)
@@ -5,7 +5,6 @@ package com.langchain.smith.services.async.datasets
import com.langchain.smith.TestServerExtension
import com.langchain.smith.client.okhttp.LangsmithOkHttpClientAsync
import com.langchain.smith.core.JsonValue
import com.langchain.smith.models.datasets.runs.QueryExampleSchemaWithRuns
import com.langchain.smith.models.datasets.runs.QueryFeedbackDelta
import com.langchain.smith.models.datasets.runs.RunCreateParams
import com.langchain.smith.models.datasets.runs.RunDeltaParams
@@ -34,27 +33,24 @@ internal class RunServiceAsyncTest {
runServiceAsync.create(
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.format("format")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
QueryExampleSchemaWithRuns.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.format(RunCreateParams.Format.CSV)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
RunCreateParams.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.stream(true)
.build()
)
@@ -217,6 +217,7 @@ internal class DatasetServiceTest {
.targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.split("string")
.build()
)
@@ -81,6 +81,7 @@ internal class ExampleServiceTest {
ExampleRetrieveParams.builder()
.exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.build()
)
@@ -71,6 +71,7 @@ internal class FeedbackServiceTest {
.runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.score(0.0)
.sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
.traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.value(0.0)
.build()
@@ -33,7 +33,7 @@ internal class RunServiceTest {
runService.create(
RunCreateParams.builder()
.queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.bodyOfStrings(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"))
.build()
)
@@ -5,7 +5,6 @@ package com.langchain.smith.services.blocking.datasets
import com.langchain.smith.TestServerExtension
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient
import com.langchain.smith.core.JsonValue
import com.langchain.smith.models.datasets.runs.QueryExampleSchemaWithRuns
import com.langchain.smith.models.datasets.runs.QueryFeedbackDelta
import com.langchain.smith.models.datasets.runs.RunCreateParams
import com.langchain.smith.models.datasets.runs.RunDeltaParams
@@ -34,27 +33,24 @@ internal class RunServiceTest {
runService.create(
RunCreateParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.format("format")
.queryExampleSchemaWithRuns(
QueryExampleSchemaWithRuns.builder()
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
QueryExampleSchemaWithRuns.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.format(RunCreateParams.Format.CSV)
.addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.filters(
RunCreateParams.Filters.builder()
.putAdditionalProperty("foo", JsonValue.from(listOf("string")))
.build()
)
.limit(1L)
.offset(0L)
.preview(true)
.sortParams(
SortParamsForRunsComparisonView.builder()
.sortBy("sort_by")
.sortOrder(SortParamsForRunsComparisonView.SortOrder.ASC)
.build()
)
.stream(true)
.build()
)