diff --git a/README.md b/README.md index aa54131..4c169ca 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,14 @@ automatic retry logic. com.volcengine ark-runtime - 0.3.0 + 0.4.0 ``` ### Gradle ```groovy -implementation 'com.volcengine:ark-runtime:0.3.0' +implementation 'com.volcengine:ark-runtime:0.4.0' ``` ## Usage diff --git a/VERSION b/VERSION index 0d91a54..1d0ba9e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.0 +0.4.0 diff --git a/pom.xml b/pom.xml index 4761e41..d1ca07c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.volcengine ark-runtime - 0.3.0 + 0.4.0 jar ark-runtime diff --git a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeep.java b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeep.java index 99f890f..a5dfe65 100644 --- a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeep.java +++ b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeep.java @@ -13,217 +13,107 @@ * Do not edit the class manually. */ - package com.volcengine.ark.runtime.models.messages; import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.io.IOException; import java.util.Objects; /** - * What context to retain while applying a context-management edit. + * MessagesContextManagementKeep + * + * Naked-union holder generated by gen/java/postprocess.py from the openapi + * anyOf schema (variants: String, MessagesContextManagementKeepParameter). + * + * The Jackson apache-httpclient template openapi-generator runs against + * does not support non-discriminated anyOf/oneOf — it either drops to a + * degenerate empty shell or flattens one variant's fields onto the class, + * losing the others. This postprocess rewrite replaces the parent with a + * @JsonValue holder + typed static factories for write-side, plus a custom + * @JsonDeserialize that dispatches by JsonNode shape on the read-side so + * round-trips preserve variant types (string -> typed primitive/enum, + * object -> typed model, array -> typed List). */ -@JsonPropertyOrder({ - MessagesContextManagementKeep.JSON_PROPERTY_TYPE, - MessagesContextManagementKeep.JSON_PROPERTY_VALUE -}) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.21.0") +@JsonDeserialize(using = MessagesContextManagementKeep.Deserializer.class) public class MessagesContextManagementKeep { - /** - * Gets or Sets type - */ - public enum TypeEnum { - ALL(String.valueOf("all")), - - THINKING_TURNS(String.valueOf("thinking_turns")), - - TOOL_USES(String.valueOf("tool_uses")); - - private String value; - - TypeEnum(String value) { - this.value = value; - } - @JsonValue - public String getValue() { - return value; - } + private final Object value; - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equalsIgnoreCase(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } + @JsonCreator + public MessagesContextManagementKeep(Object value) { + this.value = value; } - public static final String JSON_PROPERTY_TYPE = "type"; - @javax.annotation.Nonnull - private TypeEnum type; - - public static final String JSON_PROPERTY_VALUE = "value"; - @javax.annotation.Nonnull - private Integer value; - public MessagesContextManagementKeep() { + this.value = null; } - public MessagesContextManagementKeep type(@javax.annotation.Nonnull TypeEnum type) { - - this.type = type; - return this; - } - - /** - * Get type - * @return type - */ - @javax.annotation.Nonnull - @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - - public TypeEnum getType() { - return type; - } - - - @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setType(@javax.annotation.Nonnull TypeEnum type) { - this.type = type; + public static MessagesContextManagementKeep ofString(String value) { + return new MessagesContextManagementKeep(value); } - public MessagesContextManagementKeep value(@javax.annotation.Nonnull Integer value) { - - this.value = value; - return this; + public static MessagesContextManagementKeep ofMessagesContextManagementKeepParameter(MessagesContextManagementKeepParameter value) { + return new MessagesContextManagementKeep(value); } - /** - * Get value - * @return value - */ - @javax.annotation.Nonnull - @JsonProperty(value = JSON_PROPERTY_VALUE, required = true) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - - public Integer getValue() { - return value; + @JsonValue + public Object getValue() { + return this.value; } - - @JsonProperty(value = JSON_PROPERTY_VALUE, required = true) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setValue(@javax.annotation.Nonnull Integer value) { - this.value = value; + public static class Deserializer extends JsonDeserializer { + @Override + public MessagesContextManagementKeep deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + ObjectMapper mapper = (ObjectMapper) p.getCodec(); + JsonNode node = mapper.readTree(p); + if (node.isTextual()) { + return new MessagesContextManagementKeep(mapper.treeToValue(node, String.class)); + } + if (node.isObject()) { + return new MessagesContextManagementKeep(mapper.treeToValue(node, MessagesContextManagementKeepParameter.class)); + } + throw ctxt.weirdStringException( + node == null ? "null" : node.toString(), + MessagesContextManagementKeep.class, + "no MessagesContextManagementKeep variant matched JSON node shape"); + } } - @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MessagesContextManagementKeep messagesContextManagementKeep = (MessagesContextManagementKeep) o; - return Objects.equals(this.type, messagesContextManagementKeep.type) && - Objects.equals(this.value, messagesContextManagementKeep.value); + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessagesContextManagementKeep other = (MessagesContextManagementKeep) o; + return Objects.equals(this.value, other.value); } @Override public int hashCode() { - return Objects.hash(type, value); + return Objects.hash(this.value); } @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MessagesContextManagementKeep {\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - return o == null ? "null" : o.toString().replace("\n", "\n "); + return "class MessagesContextManagementKeep {" + Objects.toString(value) + "}"; } public static class Builder { - - private MessagesContextManagementKeep instance; - - public Builder() { - this(new MessagesContextManagementKeep()); - } - - protected Builder(MessagesContextManagementKeep instance) { - this.instance = instance; - } - - public MessagesContextManagementKeep.Builder type(TypeEnum type) { - this.instance.type = type; - return this; - } - public MessagesContextManagementKeep.Builder value(Integer value) { - this.instance.value = value; - return this; - } - - - /** - * returns a built MessagesContextManagementKeep instance. - * - * The builder is not reusable. - */ - public MessagesContextManagementKeep build() { - try { - return this.instance; - } finally { - // ensure that this.instance is not reused - this.instance = null; - } - } - - @Override - public String toString() { - return getClass() + "=(" + instance + ")"; - } + private Object value; + public Builder() {} + public Builder value(Object value) { this.value = value; return this; } + public MessagesContextManagementKeep build() { return new MessagesContextManagementKeep(this.value); } } - /** - * Create a builder with no initialized field. - */ - public static MessagesContextManagementKeep.Builder builder() { - return new MessagesContextManagementKeep.Builder(); - } + public static MessagesContextManagementKeep.Builder builder() { return new MessagesContextManagementKeep.Builder(); } - /** - * Create a builder with a shallow copy of this instance. - */ public MessagesContextManagementKeep.Builder toBuilder() { - return new MessagesContextManagementKeep.Builder() - .type(getType()) - .value(getValue()); + return new MessagesContextManagementKeep.Builder().value(this.value); } - - } diff --git a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepAll.java b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepAll.java index 75c3ebc..0b2bac6 100644 --- a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepAll.java +++ b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepAll.java @@ -16,11 +16,9 @@ package com.volcengine.ark.runtime.models.messages; -import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonValue; import java.util.Objects; /** @@ -30,48 +28,15 @@ MessagesContextManagementKeepAll.JSON_PROPERTY_TYPE }) @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.21.0") -public class MessagesContextManagementKeepAll { - /** - * Gets or Sets type - */ - public enum TypeEnum { - ALL(String.valueOf("all")); - - private String value; - - TypeEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equalsIgnoreCase(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - } - +public class MessagesContextManagementKeepAll implements MessagesContextManagementKeepParameter { public static final String JSON_PROPERTY_TYPE = "type"; @javax.annotation.Nonnull - private TypeEnum type; + private MessagesContextManagementKeepParameterType type = MessagesContextManagementKeepParameterType.ALL; public MessagesContextManagementKeepAll() { } - public MessagesContextManagementKeepAll type(@javax.annotation.Nonnull TypeEnum type) { + public MessagesContextManagementKeepAll type(@javax.annotation.Nonnull MessagesContextManagementKeepParameterType type) { this.type = type; return this; @@ -85,14 +50,14 @@ public MessagesContextManagementKeepAll type(@javax.annotation.Nonnull TypeEnum @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public TypeEnum getType() { + public MessagesContextManagementKeepParameterType getType() { return type; } @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setType(@javax.annotation.Nonnull TypeEnum type) { + public void setType(@javax.annotation.Nonnull MessagesContextManagementKeepParameterType type) { this.type = type; } @@ -143,7 +108,7 @@ protected Builder(MessagesContextManagementKeepAll instance) { this.instance = instance; } - public MessagesContextManagementKeepAll.Builder type(TypeEnum type) { + public MessagesContextManagementKeepAll.Builder type(MessagesContextManagementKeepParameterType type) { this.instance.type = type; return this; } diff --git a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepParameter.java b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepParameter.java new file mode 100644 index 0000000..fb3809d --- /dev/null +++ b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepParameter.java @@ -0,0 +1,32 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +/* + * Ark Messages API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.volcengine.ark.runtime.models.messages; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.21.0") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = MessagesContextManagementKeepAll.class, name = "all"), + @JsonSubTypes.Type(value = MessagesContextManagementKeepThinkingTurns.class, name = "thinking_turns"), + @JsonSubTypes.Type(value = MessagesContextManagementKeepToolUses.class, name = "tool_uses"), +}) + +public interface MessagesContextManagementKeepParameter { + public MessagesContextManagementKeepParameterType getType(); +} diff --git a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepParameterType.java b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepParameterType.java new file mode 100644 index 0000000..d6b1e07 --- /dev/null +++ b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepParameterType.java @@ -0,0 +1,59 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +/* + * Ark Messages API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.volcengine.ark.runtime.models.messages; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets MessagesContextManagementKeepParameterType + */ +public enum MessagesContextManagementKeepParameterType { + + ALL("all"), + + THINKING_TURNS("thinking_turns"), + + TOOL_USES("tool_uses"); + + private String value; + + MessagesContextManagementKeepParameterType(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static MessagesContextManagementKeepParameterType fromValue(String value) { + for (MessagesContextManagementKeepParameterType b : MessagesContextManagementKeepParameterType.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepThinkingTurns.java b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepThinkingTurns.java index ce56ad5..6433a4d 100644 --- a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepThinkingTurns.java +++ b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepThinkingTurns.java @@ -16,11 +16,9 @@ package com.volcengine.ark.runtime.models.messages; -import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonValue; import java.util.Objects; /** @@ -31,43 +29,10 @@ MessagesContextManagementKeepThinkingTurns.JSON_PROPERTY_VALUE }) @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.21.0") -public class MessagesContextManagementKeepThinkingTurns { - /** - * Gets or Sets type - */ - public enum TypeEnum { - THINKING_TURNS(String.valueOf("thinking_turns")); - - private String value; - - TypeEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equalsIgnoreCase(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - } - +public class MessagesContextManagementKeepThinkingTurns implements MessagesContextManagementKeepParameter { public static final String JSON_PROPERTY_TYPE = "type"; @javax.annotation.Nonnull - private TypeEnum type; + private MessagesContextManagementKeepParameterType type = MessagesContextManagementKeepParameterType.THINKING_TURNS; public static final String JSON_PROPERTY_VALUE = "value"; @javax.annotation.Nonnull @@ -76,7 +41,7 @@ public static TypeEnum fromValue(String value) { public MessagesContextManagementKeepThinkingTurns() { } - public MessagesContextManagementKeepThinkingTurns type(@javax.annotation.Nonnull TypeEnum type) { + public MessagesContextManagementKeepThinkingTurns type(@javax.annotation.Nonnull MessagesContextManagementKeepParameterType type) { this.type = type; return this; @@ -90,14 +55,14 @@ public MessagesContextManagementKeepThinkingTurns type(@javax.annotation.Nonnull @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public TypeEnum getType() { + public MessagesContextManagementKeepParameterType getType() { return type; } @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setType(@javax.annotation.Nonnull TypeEnum type) { + public void setType(@javax.annotation.Nonnull MessagesContextManagementKeepParameterType type) { this.type = type; } @@ -175,7 +140,7 @@ protected Builder(MessagesContextManagementKeepThinkingTurns instance) { this.instance = instance; } - public MessagesContextManagementKeepThinkingTurns.Builder type(TypeEnum type) { + public MessagesContextManagementKeepThinkingTurns.Builder type(MessagesContextManagementKeepParameterType type) { this.instance.type = type; return this; } diff --git a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepToolUses.java b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepToolUses.java index de9abdf..64836e9 100644 --- a/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepToolUses.java +++ b/src/main/java/com/volcengine/ark/runtime/models/messages/MessagesContextManagementKeepToolUses.java @@ -16,11 +16,9 @@ package com.volcengine.ark.runtime.models.messages; -import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonValue; import java.util.Objects; /** @@ -31,43 +29,10 @@ MessagesContextManagementKeepToolUses.JSON_PROPERTY_VALUE }) @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.21.0") -public class MessagesContextManagementKeepToolUses { - /** - * Gets or Sets type - */ - public enum TypeEnum { - TOOL_USES(String.valueOf("tool_uses")); - - private String value; - - TypeEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equalsIgnoreCase(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - } - +public class MessagesContextManagementKeepToolUses implements MessagesContextManagementKeepParameter { public static final String JSON_PROPERTY_TYPE = "type"; @javax.annotation.Nonnull - private TypeEnum type; + private MessagesContextManagementKeepParameterType type = MessagesContextManagementKeepParameterType.TOOL_USES; public static final String JSON_PROPERTY_VALUE = "value"; @javax.annotation.Nonnull @@ -76,7 +41,7 @@ public static TypeEnum fromValue(String value) { public MessagesContextManagementKeepToolUses() { } - public MessagesContextManagementKeepToolUses type(@javax.annotation.Nonnull TypeEnum type) { + public MessagesContextManagementKeepToolUses type(@javax.annotation.Nonnull MessagesContextManagementKeepParameterType type) { this.type = type; return this; @@ -90,14 +55,14 @@ public MessagesContextManagementKeepToolUses type(@javax.annotation.Nonnull Type @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public TypeEnum getType() { + public MessagesContextManagementKeepParameterType getType() { return type; } @JsonProperty(value = JSON_PROPERTY_TYPE, required = true) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setType(@javax.annotation.Nonnull TypeEnum type) { + public void setType(@javax.annotation.Nonnull MessagesContextManagementKeepParameterType type) { this.type = type; } @@ -175,7 +140,7 @@ protected Builder(MessagesContextManagementKeepToolUses instance) { this.instance = instance; } - public MessagesContextManagementKeepToolUses.Builder type(TypeEnum type) { + public MessagesContextManagementKeepToolUses.Builder type(MessagesContextManagementKeepParameterType type) { this.instance.type = type; return this; }