Skip to content

Commit

Permalink
fix(client): naming of some variants
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Oct 22, 2024
1 parent 6beee8a commit 3a764f2
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 187 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: 22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8729aaa35436531ab453224af10e67f89677db8f350f0346bb3537489edea649.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-f9320ebf347140052c7f8b0bc5c7db24f5e367c368c8cb34c3606af4e2b6591b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,8 @@ constructor(
* `none` is the default when no functions are present. `auto` is the default if functions
* are present.
*/
fun functionCall(unionMember0: FunctionCall.UnionMember0) = apply {
this.functionCall = FunctionCall.ofUnionMember0(unionMember0)
fun functionCall(behavior: FunctionCall.Behavior) = apply {
this.functionCall = FunctionCall.ofBehavior(behavior)
}

/**
Expand Down Expand Up @@ -1357,8 +1357,8 @@ constructor(
* `none` is the default when no tools are present. `auto` is the default if tools are
* present.
*/
fun toolChoice(unionMember0: ChatCompletionToolChoiceOption.UnionMember0) = apply {
this.toolChoice = ChatCompletionToolChoiceOption.ofUnionMember0(unionMember0)
fun toolChoice(behavior: ChatCompletionToolChoiceOption.Behavior) = apply {
this.toolChoice = ChatCompletionToolChoiceOption.ofBehavior(behavior)
}

/**
Expand Down Expand Up @@ -1626,7 +1626,7 @@ constructor(
@JsonSerialize(using = FunctionCall.Serializer::class)
class FunctionCall
private constructor(
private val unionMember0: UnionMember0? = null,
private val behavior: Behavior? = null,
private val functionCallOption: ChatCompletionFunctionCallOption? = null,
private val _json: JsonValue? = null,
) {
Expand All @@ -1637,19 +1637,19 @@ constructor(
* `none` means the model will not call a function and instead generates a message. `auto`
* means the model can pick between generating a message or calling a function.
*/
fun unionMember0(): Optional<UnionMember0> = Optional.ofNullable(unionMember0)
fun behavior(): Optional<Behavior> = Optional.ofNullable(behavior)
/**
* Specifying a particular function via `{"name": "my_function"}` forces the model to call
* that function.
*/
fun functionCallOption(): Optional<ChatCompletionFunctionCallOption> =
Optional.ofNullable(functionCallOption)

fun isUnionMember0(): Boolean = unionMember0 != null
fun isBehavior(): Boolean = behavior != null

fun isFunctionCallOption(): Boolean = functionCallOption != null

fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0")
fun asBehavior(): Behavior = behavior.getOrThrow("behavior")

fun asFunctionCallOption(): ChatCompletionFunctionCallOption =
functionCallOption.getOrThrow("functionCallOption")
Expand All @@ -1658,15 +1658,15 @@ constructor(

fun <T> accept(visitor: Visitor<T>): T {
return when {
unionMember0 != null -> visitor.visitUnionMember0(unionMember0)
behavior != null -> visitor.visitBehavior(behavior)
functionCallOption != null -> visitor.visitFunctionCallOption(functionCallOption)
else -> visitor.unknown(_json)
}
}

fun validate(): FunctionCall = apply {
if (!validated) {
if (unionMember0 == null && functionCallOption == null) {
if (behavior == null && functionCallOption == null) {
throw OpenAIInvalidDataException("Unknown FunctionCall: $_json")
}
functionCallOption?.validate()
Expand All @@ -1679,16 +1679,16 @@ constructor(
return true
}

return /* spotless:off */ other is FunctionCall && this.unionMember0 == other.unionMember0 && this.functionCallOption == other.functionCallOption /* spotless:on */
return /* spotless:off */ other is FunctionCall && this.behavior == other.behavior && this.functionCallOption == other.functionCallOption /* spotless:on */
}

override fun hashCode(): Int {
return /* spotless:off */ Objects.hash(unionMember0, functionCallOption) /* spotless:on */
return /* spotless:off */ Objects.hash(behavior, functionCallOption) /* spotless:on */
}

override fun toString(): String {
return when {
unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}"
behavior != null -> "FunctionCall{behavior=$behavior}"
functionCallOption != null -> "FunctionCall{functionCallOption=$functionCallOption}"
_json != null -> "FunctionCall{_unknown=$_json}"
else -> throw IllegalStateException("Invalid FunctionCall")
Expand All @@ -1697,9 +1697,7 @@ constructor(

companion object {

@JvmStatic
fun ofUnionMember0(unionMember0: UnionMember0) =
FunctionCall(unionMember0 = unionMember0)
@JvmStatic fun ofBehavior(behavior: Behavior) = FunctionCall(behavior = behavior)

@JvmStatic
fun ofFunctionCallOption(functionCallOption: ChatCompletionFunctionCallOption) =
Expand All @@ -1708,7 +1706,7 @@ constructor(

interface Visitor<out T> {

fun visitUnionMember0(unionMember0: UnionMember0): T
fun visitBehavior(behavior: Behavior): T

fun visitFunctionCallOption(functionCallOption: ChatCompletionFunctionCallOption): T

Expand All @@ -1722,8 +1720,8 @@ constructor(
override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<UnionMember0>())?.let {
return FunctionCall(unionMember0 = it, _json = json)
tryDeserialize(node, jacksonTypeRef<Behavior>())?.let {
return FunctionCall(behavior = it, _json = json)
}
tryDeserialize(node, jacksonTypeRef<ChatCompletionFunctionCallOption>()) {
it.validate()
Expand All @@ -1744,7 +1742,7 @@ constructor(
provider: SerializerProvider
) {
when {
value.unionMember0 != null -> generator.writeObject(value.unionMember0)
value.behavior != null -> generator.writeObject(value.behavior)
value.functionCallOption != null ->
generator.writeObject(value.functionCallOption)
value._json != null -> generator.writeObject(value._json)
Expand All @@ -1753,7 +1751,7 @@ constructor(
}
}

class UnionMember0
class Behavior
@JsonCreator
private constructor(
private val value: JsonField<String>,
Expand All @@ -1766,7 +1764,7 @@ constructor(
return true
}

return /* spotless:off */ other is UnionMember0 && this.value == other.value /* spotless:on */
return /* spotless:off */ other is Behavior && this.value == other.value /* spotless:on */
}

override fun hashCode() = value.hashCode()
Expand All @@ -1775,11 +1773,11 @@ constructor(

companion object {

@JvmField val NONE = UnionMember0(JsonField.of("none"))
@JvmField val NONE = Behavior(JsonField.of("none"))

@JvmField val AUTO = UnionMember0(JsonField.of("auto"))
@JvmField val AUTO = Behavior(JsonField.of("auto"))

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

enum class Known {
Expand All @@ -1804,7 +1802,7 @@ constructor(
when (this) {
NONE -> Known.NONE
AUTO -> Known.AUTO
else -> throw OpenAIInvalidDataException("Unknown UnionMember0: $value")
else -> throw OpenAIInvalidDataException("Unknown Behavior: $value")
}

fun asString(): String = _value().asStringOrThrow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.Optional
@JsonSerialize(using = ChatCompletionToolChoiceOption.Serializer::class)
class ChatCompletionToolChoiceOption
private constructor(
private val unionMember0: UnionMember0? = null,
private val behavior: Behavior? = null,
private val chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice? = null,
private val _json: JsonValue? = null,
) {
Expand All @@ -36,18 +36,18 @@ private constructor(
* the model can pick between generating a message or calling one or more tools. `required`
* means the model must call one or more tools.
*/
fun unionMember0(): Optional<UnionMember0> = Optional.ofNullable(unionMember0)
fun behavior(): Optional<Behavior> = Optional.ofNullable(behavior)
/**
* Specifies a tool the model should use. Use to force the model to call a specific function.
*/
fun chatCompletionNamedToolChoice(): Optional<ChatCompletionNamedToolChoice> =
Optional.ofNullable(chatCompletionNamedToolChoice)

fun isUnionMember0(): Boolean = unionMember0 != null
fun isBehavior(): Boolean = behavior != null

fun isChatCompletionNamedToolChoice(): Boolean = chatCompletionNamedToolChoice != null

fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0")
fun asBehavior(): Behavior = behavior.getOrThrow("behavior")

fun asChatCompletionNamedToolChoice(): ChatCompletionNamedToolChoice =
chatCompletionNamedToolChoice.getOrThrow("chatCompletionNamedToolChoice")
Expand All @@ -56,7 +56,7 @@ private constructor(

fun <T> accept(visitor: Visitor<T>): T {
return when {
unionMember0 != null -> visitor.visitUnionMember0(unionMember0)
behavior != null -> visitor.visitBehavior(behavior)
chatCompletionNamedToolChoice != null ->
visitor.visitChatCompletionNamedToolChoice(chatCompletionNamedToolChoice)
else -> visitor.unknown(_json)
Expand All @@ -65,7 +65,7 @@ private constructor(

fun validate(): ChatCompletionToolChoiceOption = apply {
if (!validated) {
if (unionMember0 == null && chatCompletionNamedToolChoice == null) {
if (behavior == null && chatCompletionNamedToolChoice == null) {
throw OpenAIInvalidDataException("Unknown ChatCompletionToolChoiceOption: $_json")
}
chatCompletionNamedToolChoice?.validate()
Expand All @@ -78,16 +78,16 @@ private constructor(
return true
}

return /* spotless:off */ other is ChatCompletionToolChoiceOption && this.unionMember0 == other.unionMember0 && this.chatCompletionNamedToolChoice == other.chatCompletionNamedToolChoice /* spotless:on */
return /* spotless:off */ other is ChatCompletionToolChoiceOption && this.behavior == other.behavior && this.chatCompletionNamedToolChoice == other.chatCompletionNamedToolChoice /* spotless:on */
}

override fun hashCode(): Int {
return /* spotless:off */ Objects.hash(unionMember0, chatCompletionNamedToolChoice) /* spotless:on */
return /* spotless:off */ Objects.hash(behavior, chatCompletionNamedToolChoice) /* spotless:on */
}

override fun toString(): String {
return when {
unionMember0 != null -> "ChatCompletionToolChoiceOption{unionMember0=$unionMember0}"
behavior != null -> "ChatCompletionToolChoiceOption{behavior=$behavior}"
chatCompletionNamedToolChoice != null ->
"ChatCompletionToolChoiceOption{chatCompletionNamedToolChoice=$chatCompletionNamedToolChoice}"
_json != null -> "ChatCompletionToolChoiceOption{_unknown=$_json}"
Expand All @@ -98,8 +98,7 @@ private constructor(
companion object {

@JvmStatic
fun ofUnionMember0(unionMember0: UnionMember0) =
ChatCompletionToolChoiceOption(unionMember0 = unionMember0)
fun ofBehavior(behavior: Behavior) = ChatCompletionToolChoiceOption(behavior = behavior)

@JvmStatic
fun ofChatCompletionNamedToolChoice(
Expand All @@ -112,7 +111,7 @@ private constructor(

interface Visitor<out T> {

fun visitUnionMember0(unionMember0: UnionMember0): T
fun visitBehavior(behavior: Behavior): T

fun visitChatCompletionNamedToolChoice(
chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice
Expand All @@ -129,8 +128,8 @@ private constructor(
override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionToolChoiceOption {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<UnionMember0>())?.let {
return ChatCompletionToolChoiceOption(unionMember0 = it, _json = json)
tryDeserialize(node, jacksonTypeRef<Behavior>())?.let {
return ChatCompletionToolChoiceOption(behavior = it, _json = json)
}
tryDeserialize(node, jacksonTypeRef<ChatCompletionNamedToolChoice>()) { it.validate() }
?.let {
Expand All @@ -153,7 +152,7 @@ private constructor(
provider: SerializerProvider
) {
when {
value.unionMember0 != null -> generator.writeObject(value.unionMember0)
value.behavior != null -> generator.writeObject(value.behavior)
value.chatCompletionNamedToolChoice != null ->
generator.writeObject(value.chatCompletionNamedToolChoice)
value._json != null -> generator.writeObject(value._json)
Expand All @@ -162,7 +161,7 @@ private constructor(
}
}

class UnionMember0
class Behavior
@JsonCreator
private constructor(
private val value: JsonField<String>,
Expand All @@ -175,7 +174,7 @@ private constructor(
return true
}

return /* spotless:off */ other is UnionMember0 && this.value == other.value /* spotless:on */
return /* spotless:off */ other is Behavior && this.value == other.value /* spotless:on */
}

override fun hashCode() = value.hashCode()
Expand All @@ -184,13 +183,13 @@ private constructor(

companion object {

@JvmField val NONE = UnionMember0(JsonField.of("none"))
@JvmField val NONE = Behavior(JsonField.of("none"))

@JvmField val AUTO = UnionMember0(JsonField.of("auto"))
@JvmField val AUTO = Behavior(JsonField.of("auto"))

@JvmField val REQUIRED = UnionMember0(JsonField.of("required"))
@JvmField val REQUIRED = Behavior(JsonField.of("required"))

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

enum class Known {
Expand Down Expand Up @@ -219,7 +218,7 @@ private constructor(
NONE -> Known.NONE
AUTO -> Known.AUTO
REQUIRED -> Known.REQUIRED
else -> throw OpenAIInvalidDataException("Unknown UnionMember0: $value")
else -> throw OpenAIInvalidDataException("Unknown Behavior: $value")
}

fun asString(): String = _value().asStringOrThrow()
Expand Down
Loading

0 comments on commit 3a764f2

Please sign in to comment.