Skip to content

Commit

Permalink
feat(api): update enum values, comments, examples, and constants (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jan 22, 2025
1 parent 7246cf9 commit 4bfa305
Show file tree
Hide file tree
Showing 217 changed files with 2,583 additions and 13,266 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 60
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3904ef6b29a89c98f93a9b7da19879695f3c440564be6384db7af1b734611ede.yml
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ import com.openai.models.ChatModel;

ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.addMessage(ChatCompletionUserMessageParam.builder()
.role(ChatCompletionUserMessageParam.Role.USER)
.content("Say this is a test")
.build())
.model(ChatModel.O1)
Expand Down
80 changes: 11 additions & 69 deletions openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.openai.core.Enum
import com.openai.core.ExcludeMissing
import com.openai.core.JsonField
import com.openai.core.JsonMissing
Expand Down Expand Up @@ -37,9 +36,7 @@ private constructor(
@JsonProperty("metadata") @ExcludeMissing private val metadata: JsonValue = JsonMissing.of(),
@JsonProperty("model") @ExcludeMissing private val model: JsonField<String> = JsonMissing.of(),
@JsonProperty("name") @ExcludeMissing private val name: JsonField<String> = JsonMissing.of(),
@JsonProperty("object")
@ExcludeMissing
private val object_: JsonField<Object> = JsonMissing.of(),
@JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(),
@JsonProperty("tools")
@ExcludeMissing
private val tools: JsonField<List<AssistantTool>> = JsonMissing.of(),
Expand Down Expand Up @@ -91,7 +88,7 @@ private constructor(
fun name(): Optional<String> = Optional.ofNullable(name.getNullable("name"))

/** The object type, which is always `assistant`. */
fun object_(): Object = object_.getRequired("object")
@JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_

/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant.
Expand Down Expand Up @@ -173,9 +170,6 @@ private constructor(
/** The name of the assistant. The maximum length is 256 characters. */
@JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name

/** The object type, which is always `assistant`. */
@JsonProperty("object") @ExcludeMissing fun _object_(): JsonField<Object> = object_

/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant.
* Tools can be of types `code_interpreter`, `file_search`, or `function`.
Expand Down Expand Up @@ -247,7 +241,11 @@ private constructor(
instructions()
model()
name()
object_()
_object_().let {
if (it != JsonValue.from("assistant")) {
throw OpenAIInvalidDataException("'object_' is invalid, received $it")
}
}
tools().forEach { it.validate() }
responseFormat().ifPresent { it.validate() }
temperature()
Expand All @@ -272,7 +270,7 @@ private constructor(
private var metadata: JsonValue? = null
private var model: JsonField<String>? = null
private var name: JsonField<String>? = null
private var object_: JsonField<Object>? = null
private var object_: JsonValue = JsonValue.from("assistant")
private var tools: JsonField<MutableList<AssistantTool>>? = null
private var responseFormat: JsonField<AssistantResponseFormatOption> = JsonMissing.of()
private var temperature: JsonField<Double> = JsonMissing.of()
Expand Down Expand Up @@ -372,10 +370,7 @@ private constructor(
fun name(name: JsonField<String>) = apply { this.name = name }

/** The object type, which is always `assistant`. */
fun object_(object_: Object) = object_(JsonField.of(object_))

/** The object type, which is always `assistant`. */
fun object_(object_: JsonField<Object>) = apply { this.object_ = object_ }
fun object_(object_: JsonValue) = apply { this.object_ = object_ }

/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per
Expand Down Expand Up @@ -500,8 +495,7 @@ private constructor(
}

/** `auto` is the default value */
fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) =
responseFormat(AssistantResponseFormatOption.ofBehavior(behavior))
fun responseFormatAuto() = responseFormat(AssistantResponseFormatOption.ofAuto())

/**
* Specifies the format that the model must output. Compatible with
Expand Down Expand Up @@ -696,7 +690,7 @@ private constructor(
checkRequired("metadata", metadata),
checkRequired("model", model),
checkRequired("name", name),
checkRequired("object_", object_),
object_,
checkRequired("tools", tools).map { it.toImmutable() },
responseFormat,
temperature,
Expand All @@ -706,58 +700,6 @@ private constructor(
)
}

/** The object type, which is always `assistant`. */
class Object
@JsonCreator
private constructor(
private val value: JsonField<String>,
) : Enum {

@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value

companion object {

@JvmField val ASSISTANT = of("assistant")

@JvmStatic fun of(value: String) = Object(JsonField.of(value))
}

enum class Known {
ASSISTANT,
}

enum class Value {
ASSISTANT,
_UNKNOWN,
}

fun value(): Value =
when (this) {
ASSISTANT -> Value.ASSISTANT
else -> Value._UNKNOWN
}

fun known(): Known =
when (this) {
ASSISTANT -> Known.ASSISTANT
else -> throw OpenAIInvalidDataException("Unknown Object: $value")
}

fun asString(): String = _value().asStringOrThrow()

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is Object && value == other.value /* spotless:on */
}

override fun hashCode() = value.hashCode()

override fun toString() = value.toString()
}

/**
* A set of resources that are used by the assistant's tools. The resources are specific to the
* type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.openai.core.Enum
import com.openai.core.ExcludeMissing
import com.openai.core.JsonField
import com.openai.core.JsonMissing
Expand All @@ -26,24 +25,20 @@ private constructor(
@JsonProperty("deleted")
@ExcludeMissing
private val deleted: JsonField<Boolean> = JsonMissing.of(),
@JsonProperty("object")
@ExcludeMissing
private val object_: JsonField<Object> = JsonMissing.of(),
@JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(),
@JsonAnySetter private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

fun id(): String = id.getRequired("id")

fun deleted(): Boolean = deleted.getRequired("deleted")

fun object_(): Object = object_.getRequired("object")
@JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_

@JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id

@JsonProperty("deleted") @ExcludeMissing fun _deleted(): JsonField<Boolean> = deleted

@JsonProperty("object") @ExcludeMissing fun _object_(): JsonField<Object> = object_

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
Expand All @@ -57,7 +52,11 @@ private constructor(

id()
deleted()
object_()
_object_().let {
if (it != JsonValue.from("assistant.deleted")) {
throw OpenAIInvalidDataException("'object_' is invalid, received $it")
}
}
validated = true
}

Expand All @@ -72,7 +71,7 @@ private constructor(

private var id: JsonField<String>? = null
private var deleted: JsonField<Boolean>? = null
private var object_: JsonField<Object>? = null
private var object_: JsonValue = JsonValue.from("assistant.deleted")
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
Expand All @@ -91,9 +90,7 @@ private constructor(

fun deleted(deleted: JsonField<Boolean>) = apply { this.deleted = deleted }

fun object_(object_: Object) = object_(JsonField.of(object_))

fun object_(object_: JsonField<Object>) = apply { this.object_ = object_ }
fun object_(object_: JsonValue) = apply { this.object_ = object_ }

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
Expand All @@ -118,62 +115,11 @@ private constructor(
AssistantDeleted(
checkRequired("id", id),
checkRequired("deleted", deleted),
checkRequired("object_", object_),
object_,
additionalProperties.toImmutable(),
)
}

class Object
@JsonCreator
private constructor(
private val value: JsonField<String>,
) : Enum {

@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value

companion object {

@JvmField val ASSISTANT_DELETED = of("assistant.deleted")

@JvmStatic fun of(value: String) = Object(JsonField.of(value))
}

enum class Known {
ASSISTANT_DELETED,
}

enum class Value {
ASSISTANT_DELETED,
_UNKNOWN,
}

fun value(): Value =
when (this) {
ASSISTANT_DELETED -> Value.ASSISTANT_DELETED
else -> Value._UNKNOWN
}

fun known(): Known =
when (this) {
ASSISTANT_DELETED -> Known.ASSISTANT_DELETED
else -> throw OpenAIInvalidDataException("Unknown Object: $value")
}

fun asString(): String = _value().asStringOrThrow()

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return /* spotless:off */ other is Object && value == other.value /* spotless:on */
}

override fun hashCode() = value.hashCode()

override fun toString() = value.toString()
}

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
Expand Down
Loading

0 comments on commit 4bfa305

Please sign in to comment.