-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): general availability updates (#21)
The following APIs are now GA and have been moved out of the beta namespace: - Prompt caching - Token counting - PDF Support - The Batch API This commit also adds new endpoints for listing available models. https://docs.anthropic.com/en/release-notes/api
- Loading branch information
1 parent
1714add
commit 4ec22eb
Showing
153 changed files
with
12,267 additions
and
4,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
configured_endpoints: 9 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-73443ebfebee64b8ec0ebbacd2521d6b6aa900e9526ec97abdcbcff0c0955d9b.yml | ||
configured_endpoints: 17 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-be055148d227480fcacc9086c37ac8009dcb487731069ada51af35044f65bee4.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
anthropic-java-core/src/main/kotlin/com/anthropic/models/ApiErrorObject.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
// File generated from our OpenAPI spec by Stainless. | ||
|
||
package com.anthropic.models | ||
|
||
import com.anthropic.core.Enum | ||
import com.anthropic.core.ExcludeMissing | ||
import com.anthropic.core.JsonField | ||
import com.anthropic.core.JsonMissing | ||
import com.anthropic.core.JsonValue | ||
import com.anthropic.core.NoAutoDetect | ||
import com.anthropic.core.toImmutable | ||
import com.anthropic.errors.AnthropicInvalidDataException | ||
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.databind.annotation.JsonDeserialize | ||
import java.util.Objects | ||
|
||
@JsonDeserialize(builder = ApiErrorObject.Builder::class) | ||
@NoAutoDetect | ||
class ApiErrorObject | ||
private constructor( | ||
private val type: JsonField<Type>, | ||
private val message: JsonField<String>, | ||
private val additionalProperties: Map<String, JsonValue>, | ||
) { | ||
|
||
private var validated: Boolean = false | ||
|
||
fun type(): Type = type.getRequired("type") | ||
|
||
fun message(): String = message.getRequired("message") | ||
|
||
@JsonProperty("type") @ExcludeMissing fun _type() = type | ||
|
||
@JsonProperty("message") @ExcludeMissing fun _message() = message | ||
|
||
@JsonAnyGetter | ||
@ExcludeMissing | ||
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties | ||
|
||
fun validate(): ApiErrorObject = apply { | ||
if (!validated) { | ||
type() | ||
message() | ||
validated = true | ||
} | ||
} | ||
|
||
fun toBuilder() = Builder().from(this) | ||
|
||
companion object { | ||
|
||
@JvmStatic fun builder() = Builder() | ||
} | ||
|
||
class Builder { | ||
|
||
private var type: JsonField<Type> = JsonMissing.of() | ||
private var message: JsonField<String> = JsonMissing.of() | ||
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() | ||
|
||
@JvmSynthetic | ||
internal fun from(apiErrorObject: ApiErrorObject) = apply { | ||
this.type = apiErrorObject.type | ||
this.message = apiErrorObject.message | ||
additionalProperties(apiErrorObject.additionalProperties) | ||
} | ||
|
||
fun type(type: Type) = type(JsonField.of(type)) | ||
|
||
@JsonProperty("type") | ||
@ExcludeMissing | ||
fun type(type: JsonField<Type>) = apply { this.type = type } | ||
|
||
fun message(message: String) = message(JsonField.of(message)) | ||
|
||
@JsonProperty("message") | ||
@ExcludeMissing | ||
fun message(message: JsonField<String>) = apply { this.message = message } | ||
|
||
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { | ||
this.additionalProperties.clear() | ||
this.additionalProperties.putAll(additionalProperties) | ||
} | ||
|
||
@JsonAnySetter | ||
fun putAdditionalProperty(key: String, value: JsonValue) = apply { | ||
this.additionalProperties.put(key, value) | ||
} | ||
|
||
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { | ||
this.additionalProperties.putAll(additionalProperties) | ||
} | ||
|
||
fun build(): ApiErrorObject = | ||
ApiErrorObject( | ||
type, | ||
message, | ||
additionalProperties.toImmutable(), | ||
) | ||
} | ||
|
||
class Type | ||
@JsonCreator | ||
private constructor( | ||
private val value: JsonField<String>, | ||
) : Enum { | ||
|
||
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value | ||
|
||
companion object { | ||
|
||
@JvmField val API_ERROR = of("api_error") | ||
|
||
@JvmStatic fun of(value: String) = Type(JsonField.of(value)) | ||
} | ||
|
||
enum class Known { | ||
API_ERROR, | ||
} | ||
|
||
enum class Value { | ||
API_ERROR, | ||
_UNKNOWN, | ||
} | ||
|
||
fun value(): Value = | ||
when (this) { | ||
API_ERROR -> Value.API_ERROR | ||
else -> Value._UNKNOWN | ||
} | ||
|
||
fun known(): Known = | ||
when (this) { | ||
API_ERROR -> Known.API_ERROR | ||
else -> throw AnthropicInvalidDataException("Unknown Type: $value") | ||
} | ||
|
||
fun asString(): String = _value().asStringOrThrow() | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) { | ||
return true | ||
} | ||
|
||
return /* spotless:off */ other is Type && 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 | ||
} | ||
|
||
return /* spotless:off */ other is ApiErrorObject && type == other.type && message == other.message && additionalProperties == other.additionalProperties /* spotless:on */ | ||
} | ||
|
||
/* spotless:off */ | ||
private val hashCode: Int by lazy { Objects.hash(type, message, additionalProperties) } | ||
/* spotless:on */ | ||
|
||
override fun hashCode(): Int = hashCode | ||
|
||
override fun toString() = | ||
"ApiErrorObject{type=$type, message=$message, additionalProperties=$additionalProperties}" | ||
} |
Oops, something went wrong.