Skip to content

Commit f86f8ee

Browse files
feat(api): update enum values, comments, examples, and constants (#149)
1 parent 7246cf9 commit f86f8ee

File tree

217 files changed

+2583
-13266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+2583
-13266
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 60
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3904ef6b29a89c98f93a9b7da19879695f3c440564be6384db7af1b734611ede.yml

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ import com.openai.models.ChatModel;
9696

9797
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
9898
.addMessage(ChatCompletionUserMessageParam.builder()
99-
.role(ChatCompletionUserMessageParam.Role.USER)
10099
.content("Say this is a test")
101100
.build())
102101
.model(ChatModel.O1)

openai-java-core/src/main/kotlin/com/openai/models/Assistant.kt

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
66
import com.fasterxml.jackson.annotation.JsonAnySetter
77
import com.fasterxml.jackson.annotation.JsonCreator
88
import com.fasterxml.jackson.annotation.JsonProperty
9-
import com.openai.core.Enum
109
import com.openai.core.ExcludeMissing
1110
import com.openai.core.JsonField
1211
import com.openai.core.JsonMissing
@@ -37,9 +36,7 @@ private constructor(
3736
@JsonProperty("metadata") @ExcludeMissing private val metadata: JsonValue = JsonMissing.of(),
3837
@JsonProperty("model") @ExcludeMissing private val model: JsonField<String> = JsonMissing.of(),
3938
@JsonProperty("name") @ExcludeMissing private val name: JsonField<String> = JsonMissing.of(),
40-
@JsonProperty("object")
41-
@ExcludeMissing
42-
private val object_: JsonField<Object> = JsonMissing.of(),
39+
@JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(),
4340
@JsonProperty("tools")
4441
@ExcludeMissing
4542
private val tools: JsonField<List<AssistantTool>> = JsonMissing.of(),
@@ -91,7 +88,7 @@ private constructor(
9188
fun name(): Optional<String> = Optional.ofNullable(name.getNullable("name"))
9289

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

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

176-
/** The object type, which is always `assistant`. */
177-
@JsonProperty("object") @ExcludeMissing fun _object_(): JsonField<Object> = object_
178-
179173
/**
180174
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant.
181175
* Tools can be of types `code_interpreter`, `file_search`, or `function`.
@@ -247,7 +241,11 @@ private constructor(
247241
instructions()
248242
model()
249243
name()
250-
object_()
244+
_object_().let {
245+
if (it != JsonValue.from("assistant")) {
246+
throw OpenAIInvalidDataException("'object_' is invalid, received $it")
247+
}
248+
}
251249
tools().forEach { it.validate() }
252250
responseFormat().ifPresent { it.validate() }
253251
temperature()
@@ -272,7 +270,7 @@ private constructor(
272270
private var metadata: JsonValue? = null
273271
private var model: JsonField<String>? = null
274272
private var name: JsonField<String>? = null
275-
private var object_: JsonField<Object>? = null
273+
private var object_: JsonValue = JsonValue.from("assistant")
276274
private var tools: JsonField<MutableList<AssistantTool>>? = null
277275
private var responseFormat: JsonField<AssistantResponseFormatOption> = JsonMissing.of()
278276
private var temperature: JsonField<Double> = JsonMissing.of()
@@ -372,10 +370,7 @@ private constructor(
372370
fun name(name: JsonField<String>) = apply { this.name = name }
373371

374372
/** The object type, which is always `assistant`. */
375-
fun object_(object_: Object) = object_(JsonField.of(object_))
376-
377-
/** The object type, which is always `assistant`. */
378-
fun object_(object_: JsonField<Object>) = apply { this.object_ = object_ }
373+
fun object_(object_: JsonValue) = apply { this.object_ = object_ }
379374

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

502497
/** `auto` is the default value */
503-
fun responseFormat(behavior: AssistantResponseFormatOption.Behavior) =
504-
responseFormat(AssistantResponseFormatOption.ofBehavior(behavior))
498+
fun responseFormatAuto() = responseFormat(AssistantResponseFormatOption.ofAuto())
505499

506500
/**
507501
* Specifies the format that the model must output. Compatible with
@@ -696,7 +690,7 @@ private constructor(
696690
checkRequired("metadata", metadata),
697691
checkRequired("model", model),
698692
checkRequired("name", name),
699-
checkRequired("object_", object_),
693+
object_,
700694
checkRequired("tools", tools).map { it.toImmutable() },
701695
responseFormat,
702696
temperature,
@@ -706,58 +700,6 @@ private constructor(
706700
)
707701
}
708702

709-
/** The object type, which is always `assistant`. */
710-
class Object
711-
@JsonCreator
712-
private constructor(
713-
private val value: JsonField<String>,
714-
) : Enum {
715-
716-
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
717-
718-
companion object {
719-
720-
@JvmField val ASSISTANT = of("assistant")
721-
722-
@JvmStatic fun of(value: String) = Object(JsonField.of(value))
723-
}
724-
725-
enum class Known {
726-
ASSISTANT,
727-
}
728-
729-
enum class Value {
730-
ASSISTANT,
731-
_UNKNOWN,
732-
}
733-
734-
fun value(): Value =
735-
when (this) {
736-
ASSISTANT -> Value.ASSISTANT
737-
else -> Value._UNKNOWN
738-
}
739-
740-
fun known(): Known =
741-
when (this) {
742-
ASSISTANT -> Known.ASSISTANT
743-
else -> throw OpenAIInvalidDataException("Unknown Object: $value")
744-
}
745-
746-
fun asString(): String = _value().asStringOrThrow()
747-
748-
override fun equals(other: Any?): Boolean {
749-
if (this === other) {
750-
return true
751-
}
752-
753-
return /* spotless:off */ other is Object && value == other.value /* spotless:on */
754-
}
755-
756-
override fun hashCode() = value.hashCode()
757-
758-
override fun toString() = value.toString()
759-
}
760-
761703
/**
762704
* A set of resources that are used by the assistant's tools. The resources are specific to the
763705
* type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the

openai-java-core/src/main/kotlin/com/openai/models/AssistantDeleted.kt

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
66
import com.fasterxml.jackson.annotation.JsonAnySetter
77
import com.fasterxml.jackson.annotation.JsonCreator
88
import com.fasterxml.jackson.annotation.JsonProperty
9-
import com.openai.core.Enum
109
import com.openai.core.ExcludeMissing
1110
import com.openai.core.JsonField
1211
import com.openai.core.JsonMissing
@@ -26,24 +25,20 @@ private constructor(
2625
@JsonProperty("deleted")
2726
@ExcludeMissing
2827
private val deleted: JsonField<Boolean> = JsonMissing.of(),
29-
@JsonProperty("object")
30-
@ExcludeMissing
31-
private val object_: JsonField<Object> = JsonMissing.of(),
28+
@JsonProperty("object") @ExcludeMissing private val object_: JsonValue = JsonMissing.of(),
3229
@JsonAnySetter private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
3330
) {
3431

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

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

39-
fun object_(): Object = object_.getRequired("object")
36+
@JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_
4037

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

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

45-
@JsonProperty("object") @ExcludeMissing fun _object_(): JsonField<Object> = object_
46-
4742
@JsonAnyGetter
4843
@ExcludeMissing
4944
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
@@ -57,7 +52,11 @@ private constructor(
5752

5853
id()
5954
deleted()
60-
object_()
55+
_object_().let {
56+
if (it != JsonValue.from("assistant.deleted")) {
57+
throw OpenAIInvalidDataException("'object_' is invalid, received $it")
58+
}
59+
}
6160
validated = true
6261
}
6362

@@ -72,7 +71,7 @@ private constructor(
7271

7372
private var id: JsonField<String>? = null
7473
private var deleted: JsonField<Boolean>? = null
75-
private var object_: JsonField<Object>? = null
74+
private var object_: JsonValue = JsonValue.from("assistant.deleted")
7675
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
7776

7877
@JvmSynthetic
@@ -91,9 +90,7 @@ private constructor(
9190

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

94-
fun object_(object_: Object) = object_(JsonField.of(object_))
95-
96-
fun object_(object_: JsonField<Object>) = apply { this.object_ = object_ }
93+
fun object_(object_: JsonValue) = apply { this.object_ = object_ }
9794

9895
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
9996
this.additionalProperties.clear()
@@ -118,62 +115,11 @@ private constructor(
118115
AssistantDeleted(
119116
checkRequired("id", id),
120117
checkRequired("deleted", deleted),
121-
checkRequired("object_", object_),
118+
object_,
122119
additionalProperties.toImmutable(),
123120
)
124121
}
125122

126-
class Object
127-
@JsonCreator
128-
private constructor(
129-
private val value: JsonField<String>,
130-
) : Enum {
131-
132-
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
133-
134-
companion object {
135-
136-
@JvmField val ASSISTANT_DELETED = of("assistant.deleted")
137-
138-
@JvmStatic fun of(value: String) = Object(JsonField.of(value))
139-
}
140-
141-
enum class Known {
142-
ASSISTANT_DELETED,
143-
}
144-
145-
enum class Value {
146-
ASSISTANT_DELETED,
147-
_UNKNOWN,
148-
}
149-
150-
fun value(): Value =
151-
when (this) {
152-
ASSISTANT_DELETED -> Value.ASSISTANT_DELETED
153-
else -> Value._UNKNOWN
154-
}
155-
156-
fun known(): Known =
157-
when (this) {
158-
ASSISTANT_DELETED -> Known.ASSISTANT_DELETED
159-
else -> throw OpenAIInvalidDataException("Unknown Object: $value")
160-
}
161-
162-
fun asString(): String = _value().asStringOrThrow()
163-
164-
override fun equals(other: Any?): Boolean {
165-
if (this === other) {
166-
return true
167-
}
168-
169-
return /* spotless:off */ other is Object && value == other.value /* spotless:on */
170-
}
171-
172-
override fun hashCode() = value.hashCode()
173-
174-
override fun toString() = value.toString()
175-
}
176-
177123
override fun equals(other: Any?): Boolean {
178124
if (this === other) {
179125
return true

0 commit comments

Comments
 (0)