From 16f80028849f54f8feab7314e33d557e4a923581 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:33:13 +0000 Subject: [PATCH 1/5] chore(internal): add and tweak check functions (#55) chore(internal): tweak client options nullability handling --- .../main/kotlin/com/anthropic/core/Check.kt | 25 ++++++++++++++++++- .../com/anthropic/core/ClientOptions.kt | 6 ++--- .../main/kotlin/com/anthropic/core/Values.kt | 2 ++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/Check.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/Check.kt index 1c47d92..e9cf878 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/Check.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/Check.kt @@ -4,4 +4,27 @@ package com.anthropic.core @JvmSynthetic internal fun checkRequired(name: String, value: T?): T = - checkNotNull(value) { "`$name` is required but was not set" } + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt index 2cf46c6..31dd1fd 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/ClientOptions.kt @@ -183,7 +183,7 @@ private constructor( } fun build(): ClientOptions { - checkRequired("httpClient", httpClient) + val httpClient = checkRequired("httpClient", httpClient) val headers = Headers.builder() val queryParams = QueryParams.builder() @@ -209,10 +209,10 @@ private constructor( queryParams.replaceAll(this.queryParams.build()) return ClientOptions( - httpClient!!, + httpClient, PhantomReachableClosingHttpClient( RetryingHttpClient.builder() - .httpClient(httpClient!!) + .httpClient(httpClient) .clock(clock) .maxRetries(maxRetries) .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/Values.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/Values.kt index 1d59a4e..41b76c1 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/Values.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/Values.kt @@ -117,6 +117,8 @@ sealed class JsonField { is JsonValue -> this } + @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + fun accept(visitor: Visitor): R = when (this) { is KnownValue -> visitor.visitKnown(value) From b9f114543501938c386f659417e312844900dd56 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 04:54:19 +0000 Subject: [PATCH 2/5] chore: simplify examples involving lists (#57) --- README.md | 8 +- .../BetaMessageBatchCancelParamsTest.kt | 2 +- .../BetaMessageBatchCreateParamsTest.kt | 452 ++++----- .../BetaMessageBatchDeleteParamsTest.kt | 2 +- .../BetaMessageBatchIndividualResponseTest.kt | 28 +- .../models/BetaMessageBatchListParamsTest.kt | 4 +- .../BetaMessageBatchRetrieveParamsTest.kt | 2 +- .../BetaMessageBatchSucceededResultTest.kt | 28 +- .../BetaMessageCountTokensParamsTest.kt | 176 ++-- .../models/BetaMessageCreateParamsTest.kt | 180 ++-- .../com/anthropic/models/BetaMessageTest.kt | 14 +- .../models/BetaRawMessageStartEventTest.kt | 28 +- .../models/CompletionCreateParamsTest.kt | 4 +- .../models/MessageBatchCreateParamsTest.kt | 410 ++++---- .../MessageBatchIndividualResponseTest.kt | 28 +- .../models/MessageBatchSucceededResultTest.kt | 28 +- .../models/MessageCountTokensParamsTest.kt | 164 ++-- .../models/MessageCreateParamsTest.kt | 168 ++-- .../com/anthropic/models/MessageTest.kt | 14 +- .../models/RawMessageStartEventTest.kt | 28 +- .../anthropic/services/ErrorHandlingTest.kt | 872 +++++++++--------- .../anthropic/services/ServiceParamsTest.kt | 92 +- .../blocking/CompletionServiceTest.kt | 4 +- .../services/blocking/MessageServiceTest.kt | 232 +++-- .../blocking/beta/MessageServiceTest.kt | 250 +++-- .../beta/messages/BatchServiceTest.kt | 188 ++-- .../blocking/messages/BatchServiceTest.kt | 168 ++-- 27 files changed, 1660 insertions(+), 1914 deletions(-) diff --git a/README.md b/README.md index 01ec030..cc8e194 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,13 @@ import com.anthropic.models.Message; import com.anthropic.models.MessageCreateParams; import com.anthropic.models.MessageParam; import com.anthropic.models.Model; -import java.util.List; MessageCreateParams params = MessageCreateParams.builder() .maxTokens(1024L) - .messages(List.of(MessageParam.builder() + .addMessage(MessageParam.builder() .role(MessageParam.Role.USER) .content(MessageParam.Content.ofString("Hello, Claude")) - .build())) + .build()) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build(); Message message = client.messages().create(params); @@ -117,13 +116,12 @@ Use the `BetaMessageBatchListParams` builder to set parameters: import com.anthropic.models.AnthropicBeta; import com.anthropic.models.BetaMessageBatchListPage; import com.anthropic.models.BetaMessageBatchListParams; -import java.util.List; BetaMessageBatchListParams params = BetaMessageBatchListParams.builder() .afterId("after_id") .beforeId("before_id") .limit(20L) - .betas(List.of(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build(); BetaMessageBatchListPage page1 = client.beta().messages().batches().list(params); diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCancelParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCancelParamsTest.kt index 98b3900..1d157ec 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCancelParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCancelParamsTest.kt @@ -11,7 +11,7 @@ class BetaMessageBatchCancelParamsTest { fun createBetaMessageBatchCancelParams() { BetaMessageBatchCancelParams.builder() .messageBatchId("message_batch_id") - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt index d611fdc..c6fa157 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt @@ -11,22 +11,115 @@ class BetaMessageBatchCreateParamsTest { @Test fun createBetaMessageBatchCreateParams() { BetaMessageBatchCreateParams.builder() - .requests( - listOf( + .addRequest( + BetaMessageBatchCreateParams.Request.builder() + .customId("my-custom-id-1") + .params( + BetaMessageBatchCreateParams.Request.Params.builder() + .maxTokens(1024L) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .metadata( + BetaMetadata.builder() + .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") + .build() + ) + .addStopSequence("string") + .stream(true) + .system( + BetaMessageBatchCreateParams.Request.Params.System + .ofBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type( + BetaCacheControlEphemeral.Type.EPHEMERAL + ) + .build() + ) + .build() + ) + ) + ) + .temperature(1.0) + .toolChoice( + BetaToolChoice.ofBetaToolChoiceAuto( + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() + ) + ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) + ) + ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() + ) + ) + .topK(5L) + .topP(0.7) + .build() + ) + .build() + ) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun getBody() { + val params = + BetaMessageBatchCreateParams.builder() + .addRequest( BetaMessageBatchCreateParams.Request.builder() .customId("my-custom-id-1") .params( BetaMessageBatchCreateParams.Request.Params.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content( - BetaMessageParam.Content.ofString("Hello, world") - ) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( @@ -34,7 +127,7 @@ class BetaMessageBatchCreateParamsTest { .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") .build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .stream(true) .system( BetaMessageBatchCreateParams.Request.Params.System @@ -64,47 +157,43 @@ class BetaMessageBatchCreateParamsTest { .build() ) ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type.EPHEMERAL - ) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description( + "Get the current weather in a given location" + ) + .type(BetaTool.Type.CUSTOM) + .build() ) ) .topK(5L) @@ -113,122 +202,7 @@ class BetaMessageBatchCreateParamsTest { ) .build() ) - ) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) - .build() - } - - @Test - fun getBody() { - val params = - BetaMessageBatchCreateParams.builder() - .requests( - listOf( - BetaMessageBatchCreateParams.Request.builder() - .customId("my-custom-id-1") - .params( - BetaMessageBatchCreateParams.Request.Params.builder() - .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content( - BetaMessageParam.Content.ofString( - "Hello, world" - ) - ) - .role(BetaMessageParam.Role.USER) - .build() - ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .metadata( - BetaMetadata.builder() - .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") - .build() - ) - .stopSequences(listOf("string")) - .stream(true) - .system( - BetaMessageBatchCreateParams.Request.Params.System - .ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type - .EPHEMERAL - ) - .build() - ) - .build() - ) - ) - ) - .temperature(1.0) - .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) - ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) - ) - ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type - .EPHEMERAL - ) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .type(BetaTool.Type.CUSTOM) - .build() - ) - ) - ) - .topK(5L) - .topP(0.7) - .build() - ) - .build() - ) - ) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() val body = params.getBody() assertThat(body).isNotNull @@ -240,15 +214,11 @@ class BetaMessageBatchCreateParamsTest { .params( BetaMessageBatchCreateParams.Request.Params.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content( - BetaMessageParam.Content.ofString("Hello, world") - ) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( @@ -256,7 +226,7 @@ class BetaMessageBatchCreateParamsTest { .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") .build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .stream(true) .system( BetaMessageBatchCreateParams.Request.Params.System @@ -286,47 +256,43 @@ class BetaMessageBatchCreateParamsTest { .build() ) ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type.EPHEMERAL - ) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description( + "Get the current weather in a given location" + ) + .type(BetaTool.Type.CUSTOM) + .build() ) ) .topK(5L) @@ -342,30 +308,22 @@ class BetaMessageBatchCreateParamsTest { fun getBodyWithoutOptionalFields() { val params = BetaMessageBatchCreateParams.builder() - .requests( - listOf( - BetaMessageBatchCreateParams.Request.builder() - .customId("my-custom-id-1") - .params( - BetaMessageBatchCreateParams.Request.Params.builder() - .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content( - BetaMessageParam.Content.ofString( - "Hello, world" - ) - ) - .role(BetaMessageParam.Role.USER) - .build() - ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .build() - ) - .build() - ) + .addRequest( + BetaMessageBatchCreateParams.Request.builder() + .customId("my-custom-id-1") + .params( + BetaMessageBatchCreateParams.Request.Params.builder() + .maxTokens(1024L) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .build() + ) + .build() ) .build() val body = params.getBody() @@ -378,15 +336,11 @@ class BetaMessageBatchCreateParamsTest { .params( BetaMessageBatchCreateParams.Request.Params.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content( - BetaMessageParam.Content.ofString("Hello, world") - ) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchDeleteParamsTest.kt index 1108070..d0b8632 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchDeleteParamsTest.kt @@ -11,7 +11,7 @@ class BetaMessageBatchDeleteParamsTest { fun createBetaMessageBatchDeleteParams() { BetaMessageBatchDeleteParams.builder() .messageBatchId("message_batch_id") - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt index 6abe60a..1e4e8d4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt @@ -18,14 +18,12 @@ class BetaMessageBatchIndividualResponseTest { .message( BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + .addContent( + BetaContentBlock.ofBetaTextBlock( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -57,14 +55,12 @@ class BetaMessageBatchIndividualResponseTest { .message( BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + .addContent( + BetaContentBlock.ofBetaTextBlock( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchListParamsTest.kt index b53ce5a..52d6d70 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchListParamsTest.kt @@ -14,7 +14,7 @@ class BetaMessageBatchListParamsTest { .afterId("after_id") .beforeId("before_id") .limit(1L) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() } @@ -25,7 +25,7 @@ class BetaMessageBatchListParamsTest { .afterId("after_id") .beforeId("before_id") .limit(1L) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() val expected = QueryParams.builder() expected.put("after_id", "after_id") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchRetrieveParamsTest.kt index f89451b..673f928 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchRetrieveParamsTest.kt @@ -11,7 +11,7 @@ class BetaMessageBatchRetrieveParamsTest { fun createBetaMessageBatchRetrieveParams() { BetaMessageBatchRetrieveParams.builder() .messageBatchId("message_batch_id") - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt index 85fbce0..2552a18 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt @@ -14,14 +14,12 @@ class BetaMessageBatchSucceededResultTest { .message( BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + .addContent( + BetaContentBlock.ofBetaTextBlock( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -46,14 +44,12 @@ class BetaMessageBatchSucceededResultTest { .isEqualTo( BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + .addContent( + BetaContentBlock.ofBetaTextBlock( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt index bf819e3..21bb77c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt @@ -11,13 +11,11 @@ class BetaMessageCountTokensParamsTest { @Test fun createBetaMessageCountTokensParams() { BetaMessageCountTokensParams.builder() - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("string")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .system( @@ -43,46 +41,44 @@ class BetaMessageCountTokensParamsTest { .build() ) ) - .tools( - listOf( - BetaMessageCountTokensParams.Tool.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaMessageCountTokensParams.Tool.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) ) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() } @@ -90,13 +86,11 @@ class BetaMessageCountTokensParamsTest { fun getBody() { val params = BetaMessageCountTokensParams.builder() - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("string")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .system( @@ -122,46 +116,44 @@ class BetaMessageCountTokensParamsTest { .build() ) ) - .tools( - listOf( - BetaMessageCountTokensParams.Tool.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaMessageCountTokensParams.Tool.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) ) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() val body = params.getBody() assertThat(body).isNotNull @@ -246,13 +238,11 @@ class BetaMessageCountTokensParamsTest { fun getBodyWithoutOptionalFields() { val params = BetaMessageCountTokensParams.builder() - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("string")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt index 36e254a..068777a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt @@ -12,17 +12,15 @@ class BetaMessageCreateParamsTest { fun createBetaMessageCreateParams() { BetaMessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(BetaMetadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( BetaMessageCreateParams.System.ofBetaTextBlockParams( listOf( @@ -47,48 +45,46 @@ class BetaMessageCreateParamsTest { .build() ) ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) ) .topK(5L) .topP(0.7) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() } @@ -97,19 +93,17 @@ class BetaMessageCreateParamsTest { val params = BetaMessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( BetaMetadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( BetaMessageCreateParams.System.ofBetaTextBlockParams( listOf( @@ -134,48 +128,46 @@ class BetaMessageCreateParamsTest { .build() ) ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) ) .topK(5L) .topP(0.7) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() val body = params.getBody() assertThat(body).isNotNull @@ -268,13 +260,11 @@ class BetaMessageCreateParamsTest { val params = BetaMessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt index d0d379f..8fc58ba 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt @@ -12,14 +12,12 @@ class BetaMessageTest { val betaMessage = BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + .addContent( + BetaContentBlock.ofBetaTextBlock( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt index d0a2a08..00e2a0f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt @@ -14,14 +14,12 @@ class BetaRawMessageStartEventTest { .message( BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + .addContent( + BetaContentBlock.ofBetaTextBlock( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -46,14 +44,12 @@ class BetaRawMessageStartEventTest { .isEqualTo( BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + .addContent( + BetaContentBlock.ofBetaTextBlock( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/CompletionCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/CompletionCreateParamsTest.kt index 5fdc3c7..aa090d0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/CompletionCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/CompletionCreateParamsTest.kt @@ -14,7 +14,7 @@ class CompletionCreateParamsTest { .model(Model.CLAUDE_3_5_HAIKU_LATEST) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .temperature(1.0) .topK(5L) .topP(0.7) @@ -29,7 +29,7 @@ class CompletionCreateParamsTest { .model(Model.CLAUDE_3_5_HAIKU_LATEST) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .temperature(1.0) .topK(5L) .topP(0.7) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt index 97ea1bd..556db49 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt @@ -11,20 +11,108 @@ class MessageBatchCreateParamsTest { @Test fun createMessageBatchCreateParams() { MessageBatchCreateParams.builder() - .requests( - listOf( + .addRequest( + MessageBatchCreateParams.Request.builder() + .customId("my-custom-id-1") + .params( + MessageBatchCreateParams.Request.Params.builder() + .maxTokens(1024L) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .metadata( + Metadata.builder() + .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") + .build() + ) + .addStopSequence("string") + .stream(true) + .system( + MessageBatchCreateParams.Request.Params.System.ofTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() + ) + ) + ) + .temperature(1.0) + .toolChoice( + ToolChoice.ofToolChoiceAuto( + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() + ) + ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) + ) + ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() + ) + .topK(5L) + .topP(0.7) + .build() + ) + .build() + ) + .build() + } + + @Test + fun getBody() { + val params = + MessageBatchCreateParams.builder() + .addRequest( MessageBatchCreateParams.Request.builder() .customId("my-custom-id-1") .params( MessageBatchCreateParams.Request.Params.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( @@ -32,7 +120,7 @@ class MessageBatchCreateParamsTest { .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") .build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .stream(true) .system( MessageBatchCreateParams.Request.Params.System @@ -61,43 +149,39 @@ class MessageBatchCreateParamsTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -105,112 +189,6 @@ class MessageBatchCreateParamsTest { ) .build() ) - ) - .build() - } - - @Test - fun getBody() { - val params = - MessageBatchCreateParams.builder() - .requests( - listOf( - MessageBatchCreateParams.Request.builder() - .customId("my-custom-id-1") - .params( - MessageBatchCreateParams.Request.Params.builder() - .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content( - MessageParam.Content.ofString("Hello, world") - ) - .role(MessageParam.Role.USER) - .build() - ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .metadata( - Metadata.builder() - .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") - .build() - ) - .stopSequences(listOf("string")) - .stream(true) - .system( - MessageBatchCreateParams.Request.Params.System - .ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type( - CacheControlEphemeral.Type - .EPHEMERAL - ) - .build() - ) - .build() - ) - ) - ) - .temperature(1.0) - .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) - ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) - ) - ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .build() - ) - ) - .topK(5L) - .topP(0.7) - .build() - ) - .build() - ) - ) .build() val body = params.getBody() assertThat(body).isNotNull @@ -222,13 +200,11 @@ class MessageBatchCreateParamsTest { .params( MessageBatchCreateParams.Request.Params.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( @@ -236,7 +212,7 @@ class MessageBatchCreateParamsTest { .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") .build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .stream(true) .system( MessageBatchCreateParams.Request.Params.System @@ -265,43 +241,39 @@ class MessageBatchCreateParamsTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -316,28 +288,22 @@ class MessageBatchCreateParamsTest { fun getBodyWithoutOptionalFields() { val params = MessageBatchCreateParams.builder() - .requests( - listOf( - MessageBatchCreateParams.Request.builder() - .customId("my-custom-id-1") - .params( - MessageBatchCreateParams.Request.Params.builder() - .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content( - MessageParam.Content.ofString("Hello, world") - ) - .role(MessageParam.Role.USER) - .build() - ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .build() - ) - .build() - ) + .addRequest( + MessageBatchCreateParams.Request.builder() + .customId("my-custom-id-1") + .params( + MessageBatchCreateParams.Request.Params.builder() + .maxTokens(1024L) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .build() + ) + .build() ) .build() val body = params.getBody() @@ -350,13 +316,11 @@ class MessageBatchCreateParamsTest { .params( MessageBatchCreateParams.Request.Params.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt index d31f150..1b1dc98 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt @@ -18,14 +18,12 @@ class MessageBatchIndividualResponseTest { .message( Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -57,14 +55,12 @@ class MessageBatchIndividualResponseTest { .message( Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt index dca05ae..df63fb1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt @@ -14,14 +14,12 @@ class MessageBatchSucceededResultTest { .message( Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -46,14 +44,12 @@ class MessageBatchSucceededResultTest { .isEqualTo( Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt index f11cfa7..c87f97e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt @@ -11,13 +11,11 @@ class MessageCountTokensParamsTest { @Test fun createMessageCountTokensParams() { MessageCountTokensParams.builder() - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("string")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .system( @@ -43,41 +41,39 @@ class MessageCountTokensParamsTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .build() } @@ -86,13 +82,11 @@ class MessageCountTokensParamsTest { fun getBody() { val params = MessageCountTokensParams.builder() - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("string")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .system( @@ -118,41 +112,39 @@ class MessageCountTokensParamsTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .build() val body = params.getBody() @@ -235,13 +227,11 @@ class MessageCountTokensParamsTest { fun getBodyWithoutOptionalFields() { val params = MessageCountTokensParams.builder() - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("string")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt index ea44381..8187271 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt @@ -12,17 +12,15 @@ class MessageCreateParamsTest { fun createMessageCreateParams() { MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -47,41 +45,39 @@ class MessageCreateParamsTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -93,17 +89,15 @@ class MessageCreateParamsTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -128,41 +122,39 @@ class MessageCreateParamsTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -255,13 +247,11 @@ class MessageCreateParamsTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt index 5e5cc10..9e4321b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt @@ -12,14 +12,12 @@ class MessageTest { val message = Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt index 38eca02..9189a86 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt @@ -14,14 +14,12 @@ class RawMessageStartEventTest { .message( Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -46,14 +44,12 @@ class RawMessageStartEventTest { .isEqualTo( Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt index f58192b..cdfbe7a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt @@ -69,17 +69,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -104,41 +102,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -147,14 +143,12 @@ class ErrorHandlingTest { val expected = Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -182,17 +176,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -217,41 +209,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -273,17 +263,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -308,41 +296,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -364,17 +350,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -399,41 +383,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -459,17 +441,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -494,41 +474,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -550,17 +528,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -585,41 +561,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -645,17 +619,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -680,41 +652,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -736,17 +706,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -771,41 +739,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -831,17 +797,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -866,41 +830,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -927,17 +889,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -962,41 +922,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -1017,17 +975,15 @@ class ErrorHandlingTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -1052,41 +1008,39 @@ class ErrorHandlingTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt index 26b553f..f4b9891 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt @@ -67,17 +67,15 @@ class ServiceParamsTest { val params = MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -102,41 +100,39 @@ class ServiceParamsTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -148,14 +144,12 @@ class ServiceParamsTest { val apiResponse = Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .content( - listOf( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + .addContent( + ContentBlock.ofTextBlock( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt index 62bb6f5..131d0b9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt @@ -30,7 +30,7 @@ class CompletionServiceTest { .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .temperature(1.0) .topK(5L) .topP(0.7) @@ -58,7 +58,7 @@ class CompletionServiceTest { .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .temperature(1.0) .topK(5L) .topP(0.7) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt index 7f45e5f..fb966f0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt @@ -33,19 +33,17 @@ class MessageServiceTest { messageService.create( MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -70,41 +68,39 @@ class MessageServiceTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -127,19 +123,17 @@ class MessageServiceTest { messageService.createStreaming( MessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( MessageCreateParams.System.ofTextBlockParams( listOf( @@ -164,41 +158,39 @@ class MessageServiceTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .topK(5L) .topP(0.7) @@ -224,13 +216,11 @@ class MessageServiceTest { val messageTokensCount = messageService.countTokens( MessageCountTokensParams.builder() - .messages( - listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() - ) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("string")) + .role(MessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .system( @@ -256,41 +246,39 @@ class MessageServiceTest { .build() ) ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .build() ) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt index ac18a83..896a681 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt @@ -35,13 +35,11 @@ class MessageServiceTest { messageService.create( BetaMessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( @@ -49,7 +47,7 @@ class MessageServiceTest { .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") .build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( BetaMessageCreateParams.System.ofBetaTextBlockParams( listOf( @@ -74,48 +72,46 @@ class MessageServiceTest { .build() ) ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) ) .topK(5L) .topP(0.7) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) println(betaMessage) @@ -135,13 +131,11 @@ class MessageServiceTest { messageService.createStreaming( BetaMessageCreateParams.builder() .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("Hello, world")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata( @@ -149,7 +143,7 @@ class MessageServiceTest { .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") .build() ) - .stopSequences(listOf("string")) + .addStopSequence("string") .system( BetaMessageCreateParams.System.ofBetaTextBlockParams( listOf( @@ -174,48 +168,46 @@ class MessageServiceTest { .build() ) ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) ) .topK(5L) .topP(0.7) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) @@ -238,13 +230,11 @@ class MessageServiceTest { val betaMessageTokensCount = messageService.countTokens( BetaMessageCountTokensParams.builder() - .messages( - listOf( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) - .role(BetaMessageParam.Role.USER) - .build() - ) + .addMessage( + BetaMessageParam.builder() + .content(BetaMessageParam.Content.ofString("string")) + .role(BetaMessageParam.Role.USER) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .system( @@ -270,46 +260,44 @@ class MessageServiceTest { .build() ) ) - .tools( - listOf( - BetaMessageCountTokensParams.Tool.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + .addTool( + BetaMessageCountTokensParams.Tool.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) ) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) println(betaMessageTokensCount) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt index e1fca98..4971f68 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt @@ -37,94 +37,35 @@ class BatchServiceTest { val betaMessageBatch = batchService.create( BetaMessageBatchCreateParams.builder() - .requests( - listOf( - BetaMessageBatchCreateParams.Request.builder() - .customId("my-custom-id-1") - .params( - BetaMessageBatchCreateParams.Request.Params.builder() - .maxTokens(1024L) - .messages( - listOf( - BetaMessageParam.builder() - .content( - BetaMessageParam.Content.ofString( - "Hello, world" - ) - ) - .role(BetaMessageParam.Role.USER) - .build() - ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .metadata( - BetaMetadata.builder() - .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") - .build() - ) - .stopSequences(listOf("string")) - .stream(true) - .system( - BetaMessageBatchCreateParams.Request.Params.System - .ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral - .Type - .EPHEMERAL - ) - .build() - ) - .build() - ) - ) - ) - .temperature(1.0) - .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() + .addRequest( + BetaMessageBatchCreateParams.Request.builder() + .customId("my-custom-id-1") + .params( + BetaMessageBatchCreateParams.Request.Params.builder() + .maxTokens(1024L) + .addMessage( + BetaMessageParam.builder() + .content( + BetaMessageParam.Content.ofString("Hello, world") ) - ) - .tools( - listOf( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type( - BetaTool.InputSchema.Type.OBJECT - ) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to - "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to - "string" - ) - ) - ) - ) - .build() - ) - .name("name") + .role(BetaMessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .metadata( + BetaMetadata.builder() + .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") + .build() + ) + .addStopSequence("string") + .stream(true) + .system( + BetaMessageBatchCreateParams.Request.Params.System + .ofBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) .cacheControl( BetaCacheControlEphemeral.builder() .type( @@ -133,22 +74,67 @@ class BatchServiceTest { ) .build() ) - .description( - "Get the current weather in a given location" - ) - .type(BetaTool.Type.CUSTOM) .build() ) ) + ) + .temperature(1.0) + .toolChoice( + BetaToolChoice.ofBetaToolChoiceAuto( + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() + ) + ) + .addTool( + BetaToolUnion.ofBetaTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) + ) + ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type( + BetaCacheControlEphemeral.Type.EPHEMERAL + ) + .build() + ) + .description( + "Get the current weather in a given location" + ) + .type(BetaTool.Type.CUSTOM) + .build() ) - .topK(5L) - .topP(0.7) - .build() - ) - .build() - ) + ) + .topK(5L) + .topP(0.7) + .build() + ) + .build() ) - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) println(betaMessageBatch) @@ -167,7 +153,7 @@ class BatchServiceTest { batchService.retrieve( BetaMessageBatchRetrieveParams.builder() .messageBatchId("message_batch_id") - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) println(betaMessageBatch) @@ -200,7 +186,7 @@ class BatchServiceTest { batchService.delete( BetaMessageBatchDeleteParams.builder() .messageBatchId("message_batch_id") - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) println(betaDeletedMessageBatch) @@ -219,7 +205,7 @@ class BatchServiceTest { batchService.cancel( BetaMessageBatchCancelParams.builder() .messageBatchId("message_batch_id") - .betas(listOf(AnthropicBeta.MESSAGE_BATCHES_2024_09_24)) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) println(betaMessageBatch) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt index a23505e..75c4ac4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt @@ -35,107 +35,95 @@ class BatchServiceTest { val messageBatch = batchService.create( MessageBatchCreateParams.builder() - .requests( - listOf( - MessageBatchCreateParams.Request.builder() - .customId("my-custom-id-1") - .params( - MessageBatchCreateParams.Request.Params.builder() - .maxTokens(1024L) - .messages( - listOf( - MessageParam.builder() - .content( - MessageParam.Content.ofString( - "Hello, world" + .addRequest( + MessageBatchCreateParams.Request.builder() + .customId("my-custom-id-1") + .params( + MessageBatchCreateParams.Request.Params.builder() + .maxTokens(1024L) + .addMessage( + MessageParam.builder() + .content(MessageParam.Content.ofString("Hello, world")) + .role(MessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .metadata( + Metadata.builder() + .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") + .build() + ) + .addStopSequence("string") + .stream(true) + .system( + MessageBatchCreateParams.Request.Params.System + .ofTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type( + CacheControlEphemeral.Type + .EPHEMERAL + ) + .build() ) - ) - .role(MessageParam.Role.USER) - .build() + .build() + ) ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .metadata( - Metadata.builder() - .userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b") + ) + .temperature(1.0) + .toolChoice( + ToolChoice.ofToolChoiceAuto( + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) .build() ) - .stopSequences(listOf("string")) - .stream(true) - .system( - MessageBatchCreateParams.Request.Params.System - .ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type( - CacheControlEphemeral.Type - .EPHEMERAL + ) + .addTool( + Tool.builder() + .inputSchema( + Tool.InputSchema.builder() + .type(Tool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" ) - .build() ) - .build() + ) ) - ) - ) - .temperature(1.0) - .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) .build() ) - ) - .tools( - listOf( - Tool.builder() - .inputSchema( - Tool.InputSchema.builder() - .type(Tool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) - ) - ) - .build() - ) - .name("name") - .cacheControl( - CacheControlEphemeral.builder() - .type( - CacheControlEphemeral.Type.EPHEMERAL - ) - .build() - ) - .description( - "Get the current weather in a given location" - ) + .name("name") + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) .build() ) - ) - .topK(5L) - .topP(0.7) - .build() - ) - .build() - ) + .description( + "Get the current weather in a given location" + ) + .build() + ) + .topK(5L) + .topP(0.7) + .build() + ) + .build() ) .build() ) From e800907343dfa88baf644eafa3953098072fcda0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 05:18:24 +0000 Subject: [PATCH 3/5] chore: simplify examples involving unions (#58) --- README.md | 2 +- .../anthropic/models/BetaErrorResponseTest.kt | 10 +- .../BetaMessageBatchCreateParamsTest.kt | 313 ++++++-------- .../BetaMessageBatchErroredResultTest.kt | 20 +- .../BetaMessageBatchIndividualResponseTest.kt | 68 ++- .../BetaMessageBatchSucceededResultTest.kt | 20 +- .../BetaMessageCountTokensParamsTest.kt | 164 ++++--- .../models/BetaMessageCreateParamsTest.kt | 182 ++++---- .../anthropic/models/BetaMessageParamTest.kt | 5 +- .../com/anthropic/models/BetaMessageTest.kt | 10 +- .../BetaRawContentBlockDeltaEventTest.kt | 7 +- .../BetaRawContentBlockStartEventTest.kt | 4 +- .../models/BetaRawMessageStartEventTest.kt | 20 +- .../models/BetaToolResultBlockParamTest.kt | 2 +- .../com/anthropic/models/ErrorResponseTest.kt | 10 +- .../models/MessageBatchCreateParamsTest.kt | 114 +++-- .../models/MessageBatchErroredResultTest.kt | 20 +- .../MessageBatchIndividualResponseTest.kt | 68 ++- .../models/MessageBatchSucceededResultTest.kt | 20 +- .../models/MessageCountTokensParamsTest.kt | 93 ++-- .../models/MessageCreateParamsTest.kt | 81 ++-- .../com/anthropic/models/MessageParamTest.kt | 5 +- .../com/anthropic/models/MessageTest.kt | 10 +- .../models/RawContentBlockDeltaEventTest.kt | 6 +- .../models/RawContentBlockStartEventTest.kt | 6 +- .../models/RawMessageStartEventTest.kt | 20 +- .../models/ToolResultBlockParamTest.kt | 2 +- .../anthropic/services/ErrorHandlingTest.kt | 408 ++++++++---------- .../anthropic/services/ServiceParamsTest.kt | 48 +-- .../services/blocking/MessageServiceTest.kt | 109 +++-- .../blocking/beta/MessageServiceTest.kt | 302 ++++++------- .../beta/messages/BatchServiceTest.kt | 112 +++-- .../blocking/messages/BatchServiceTest.kt | 39 +- 33 files changed, 1007 insertions(+), 1293 deletions(-) diff --git a/README.md b/README.md index cc8e194..7ae860e 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ MessageCreateParams params = MessageCreateParams.builder() .maxTokens(1024L) .addMessage(MessageParam.builder() .role(MessageParam.Role.USER) - .content(MessageParam.Content.ofString("Hello, Claude")) + .content("Hello, Claude") .build()) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build(); diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaErrorResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaErrorResponseTest.kt index bca4925..20bfb2f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaErrorResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaErrorResponseTest.kt @@ -12,12 +12,10 @@ class BetaErrorResponseTest { val betaErrorResponse = BetaErrorResponse.builder() .error( - BetaError.ofBetaInvalidRequestError( - BetaInvalidRequestError.builder() - .message("message") - .type(BetaInvalidRequestError.Type.INVALID_REQUEST_ERROR) - .build() - ) + BetaInvalidRequestError.builder() + .message("message") + .type(BetaInvalidRequestError.Type.INVALID_REQUEST_ERROR) + .build() ) .type(BetaErrorResponse.Type.ERROR) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt index c6fa157..b23e6da 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchCreateParamsTest.kt @@ -19,7 +19,7 @@ class BetaMessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -31,69 +31,60 @@ class BetaMessageBatchCreateParamsTest { ) .addStopSequence("string") .stream(true) - .system( - BetaMessageBatchCreateParams.Request.Params.System - .ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type.EPHEMERAL - ) - .build() - ) + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) .build() ) - ) + .build() + ) ) .temperature(1.0) .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) .topK(5L) .topP(0.7) @@ -117,7 +108,7 @@ class BetaMessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -129,72 +120,60 @@ class BetaMessageBatchCreateParamsTest { ) .addStopSequence("string") .stream(true) - .system( - BetaMessageBatchCreateParams.Request.Params.System - .ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type - .EPHEMERAL - ) - .build() - ) + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) .build() ) - ) + .build() + ) ) .temperature(1.0) .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) .topK(5L) .topP(0.7) @@ -216,7 +195,7 @@ class BetaMessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -228,72 +207,60 @@ class BetaMessageBatchCreateParamsTest { ) .addStopSequence("string") .stream(true) - .system( - BetaMessageBatchCreateParams.Request.Params.System - .ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type - .EPHEMERAL - ) - .build() - ) + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) .build() ) - ) + .build() + ) ) .temperature(1.0) .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) .topK(5L) .topP(0.7) @@ -316,7 +283,7 @@ class BetaMessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -338,7 +305,7 @@ class BetaMessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchErroredResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchErroredResultTest.kt index 22bd47c..9d26ec2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchErroredResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchErroredResultTest.kt @@ -14,12 +14,10 @@ class BetaMessageBatchErroredResultTest { .error( BetaErrorResponse.builder() .error( - BetaError.ofBetaInvalidRequestError( - BetaInvalidRequestError.builder() - .message("message") - .type(BetaInvalidRequestError.Type.INVALID_REQUEST_ERROR) - .build() - ) + BetaInvalidRequestError.builder() + .message("message") + .type(BetaInvalidRequestError.Type.INVALID_REQUEST_ERROR) + .build() ) .type(BetaErrorResponse.Type.ERROR) .build() @@ -31,12 +29,10 @@ class BetaMessageBatchErroredResultTest { .isEqualTo( BetaErrorResponse.builder() .error( - BetaError.ofBetaInvalidRequestError( - BetaInvalidRequestError.builder() - .message("message") - .type(BetaInvalidRequestError.Type.INVALID_REQUEST_ERROR) - .build() - ) + BetaInvalidRequestError.builder() + .message("message") + .type(BetaInvalidRequestError.Type.INVALID_REQUEST_ERROR) + .build() ) .type(BetaErrorResponse.Type.ERROR) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt index 1e4e8d4..a0358c4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchIndividualResponseTest.kt @@ -13,37 +13,33 @@ class BetaMessageBatchIndividualResponseTest { BetaMessageBatchIndividualResponse.builder() .customId("my-custom-id-1") .result( - BetaMessageBatchResult.ofBetaMessageBatchSucceededResult( - BetaMessageBatchSucceededResult.builder() - .message( - BetaMessage.builder() - .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .addContent( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .role(BetaMessage.Role.ASSISTANT) - .stopReason(BetaMessage.StopReason.END_TURN) - .stopSequence(null) - .type(BetaMessage.Type.MESSAGE) - .usage( - BetaUsage.builder() - .cacheCreationInputTokens(2051L) - .cacheReadInputTokens(2051L) - .inputTokens(2095L) - .outputTokens(503L) - .build() - ) - .build() - ) - .type(BetaMessageBatchSucceededResult.Type.SUCCEEDED) - .build() - ) + BetaMessageBatchSucceededResult.builder() + .message( + BetaMessage.builder() + .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") + .addContent( + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .role(BetaMessage.Role.ASSISTANT) + .stopReason(BetaMessage.StopReason.END_TURN) + .stopSequence(null) + .type(BetaMessage.Type.MESSAGE) + .usage( + BetaUsage.builder() + .cacheCreationInputTokens(2051L) + .cacheReadInputTokens(2051L) + .inputTokens(2095L) + .outputTokens(503L) + .build() + ) + .build() + ) + .type(BetaMessageBatchSucceededResult.Type.SUCCEEDED) + .build() ) .build() assertThat(betaMessageBatchIndividualResponse).isNotNull @@ -56,12 +52,10 @@ class BetaMessageBatchIndividualResponseTest { BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(BetaMessage.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt index 2552a18..a8c12bd 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageBatchSucceededResultTest.kt @@ -15,12 +15,10 @@ class BetaMessageBatchSucceededResultTest { BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(BetaMessage.Role.ASSISTANT) @@ -45,12 +43,10 @@ class BetaMessageBatchSucceededResultTest { BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(BetaMessage.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt index 21bb77c..8fba7a3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCountTokensParamsTest.kt @@ -13,13 +13,81 @@ class BetaMessageCountTokensParamsTest { BetaMessageCountTokensParams.builder() .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) + .content("string") .role(BetaMessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .system( - BetaMessageCountTokensParams.System.ofBetaTextBlockParams( + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() + ) + ) + .toolChoice( + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() + ) + .addTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) + ) + ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() + ) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun getBody() { + val params = + BetaMessageCountTokensParams.builder() + .addMessage( + BetaMessageParam.builder() + .content("string") + .role(BetaMessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .systemOfBetaTextBlockParams( listOf( BetaTextBlockParam.builder() .text("Today's date is 2024-06-01.") @@ -32,17 +100,13 @@ class BetaMessageCountTokensParamsTest { .build() ) ) - ) - .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( + .toolChoice( BetaToolChoiceAuto.builder() .type(BetaToolChoiceAuto.Type.AUTO) .disableParallelToolUse(true) .build() ) - ) - .addTool( - BetaMessageCountTokensParams.Tool.ofBetaTool( + .addTool( BetaTool.builder() .inputSchema( BetaTool.InputSchema.builder() @@ -77,82 +141,6 @@ class BetaMessageCountTokensParamsTest { .type(BetaTool.Type.CUSTOM) .build() ) - ) - .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) - .build() - } - - @Test - fun getBody() { - val params = - BetaMessageCountTokensParams.builder() - .addMessage( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) - .role(BetaMessageParam.Role.USER) - .build() - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .system( - BetaMessageCountTokensParams.System.ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) - ) - ) - .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) - ) - .addTool( - BetaMessageCountTokensParams.Tool.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) - ) - ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) - ) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() val body = params.getBody() @@ -161,7 +149,7 @@ class BetaMessageCountTokensParamsTest { .isEqualTo( listOf( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) + .content("string") .role(BetaMessageParam.Role.USER) .build() ) @@ -240,7 +228,7 @@ class BetaMessageCountTokensParamsTest { BetaMessageCountTokensParams.builder() .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) + .content("string") .role(BetaMessageParam.Role.USER) .build() ) @@ -252,7 +240,7 @@ class BetaMessageCountTokensParamsTest { .isEqualTo( listOf( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) + .content("string") .role(BetaMessageParam.Role.USER) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt index 068777a..50948b9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageCreateParamsTest.kt @@ -14,15 +14,91 @@ class BetaMessageCreateParamsTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(BetaMetadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - BetaMessageCreateParams.System.ofBetaTextBlockParams( + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() + ) + ) + .temperature(1.0) + .toolChoice( + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() + ) + .addTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) + ) + ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() + ) + .topK(5L) + .topP(0.7) + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .build() + } + + @Test + fun getBody() { + val params = + BetaMessageCreateParams.builder() + .maxTokens(1024L) + .addMessage( + BetaMessageParam.builder() + .content("Hello, world") + .role(BetaMessageParam.Role.USER) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .metadata( + BetaMetadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() + ) + .addStopSequence("string") + .systemOfBetaTextBlockParams( listOf( BetaTextBlockParam.builder() .text("Today's date is 2024-06-01.") @@ -35,18 +111,14 @@ class BetaMessageCreateParamsTest { .build() ) ) - ) - .temperature(1.0) - .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( + .temperature(1.0) + .toolChoice( BetaToolChoiceAuto.builder() .type(BetaToolChoiceAuto.Type.AUTO) .disableParallelToolUse(true) .build() ) - ) - .addTool( - BetaToolUnion.ofBetaTool( + .addTool( BetaTool.builder() .inputSchema( BetaTool.InputSchema.builder() @@ -81,90 +153,6 @@ class BetaMessageCreateParamsTest { .type(BetaTool.Type.CUSTOM) .build() ) - ) - .topK(5L) - .topP(0.7) - .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) - .build() - } - - @Test - fun getBody() { - val params = - BetaMessageCreateParams.builder() - .maxTokens(1024L) - .addMessage( - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) - .role(BetaMessageParam.Role.USER) - .build() - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .metadata( - BetaMetadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() - ) - .addStopSequence("string") - .system( - BetaMessageCreateParams.System.ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) - ) - ) - .temperature(1.0) - .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) - ) - .addTool( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) - ) - ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) - ) .topK(5L) .topP(0.7) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) @@ -176,7 +164,7 @@ class BetaMessageCreateParamsTest { .isEqualTo( listOf( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -262,7 +250,7 @@ class BetaMessageCreateParamsTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -275,7 +263,7 @@ class BetaMessageCreateParamsTest { .isEqualTo( listOf( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageParamTest.kt index 99fc7e3..beadcf7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageParamTest.kt @@ -10,10 +10,7 @@ class BetaMessageParamTest { @Test fun createBetaMessageParam() { val betaMessageParam = - BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) - .role(BetaMessageParam.Role.USER) - .build() + BetaMessageParam.builder().content("string").role(BetaMessageParam.Role.USER).build() assertThat(betaMessageParam).isNotNull assertThat(betaMessageParam.content()) .isEqualTo(BetaMessageParam.Content.ofString("string")) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt index 8fc58ba..8aa0d32 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaMessageTest.kt @@ -13,12 +13,10 @@ class BetaMessageTest { BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(BetaMessage.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockDeltaEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockDeltaEventTest.kt index 3141ae2..8ab31e3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockDeltaEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockDeltaEventTest.kt @@ -12,12 +12,7 @@ class BetaRawContentBlockDeltaEventTest { val betaRawContentBlockDeltaEvent = BetaRawContentBlockDeltaEvent.builder() .delta( - BetaRawContentBlockDeltaEvent.Delta.ofBetaTextDelta( - BetaTextDelta.builder() - .text("text") - .type(BetaTextDelta.Type.TEXT_DELTA) - .build() - ) + BetaTextDelta.builder().text("text").type(BetaTextDelta.Type.TEXT_DELTA).build() ) .index(0L) .type(BetaRawContentBlockDeltaEvent.Type.CONTENT_BLOCK_DELTA) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockStartEventTest.kt index 4e65379..cf13d95 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawContentBlockStartEventTest.kt @@ -12,9 +12,7 @@ class BetaRawContentBlockStartEventTest { val betaRawContentBlockStartEvent = BetaRawContentBlockStartEvent.builder() .contentBlock( - BetaRawContentBlockStartEvent.ContentBlock.ofBetaTextBlock( - BetaTextBlock.builder().text("text").type(BetaTextBlock.Type.TEXT).build() - ) + BetaTextBlock.builder().text("text").type(BetaTextBlock.Type.TEXT).build() ) .index(0L) .type(BetaRawContentBlockStartEvent.Type.CONTENT_BLOCK_START) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt index 00e2a0f..2faa43c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaRawMessageStartEventTest.kt @@ -15,12 +15,10 @@ class BetaRawMessageStartEventTest { BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(BetaMessage.Role.ASSISTANT) @@ -45,12 +43,10 @@ class BetaRawMessageStartEventTest { BetaMessage.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - BetaContentBlock.ofBetaTextBlock( - BetaTextBlock.builder() - .text("Hi! My name is Claude.") - .type(BetaTextBlock.Type.TEXT) - .build() - ) + BetaTextBlock.builder() + .text("Hi! My name is Claude.") + .type(BetaTextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(BetaMessage.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaToolResultBlockParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaToolResultBlockParamTest.kt index f811766..b6e8744 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaToolResultBlockParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/BetaToolResultBlockParamTest.kt @@ -18,7 +18,7 @@ class BetaToolResultBlockParamTest { .type(BetaCacheControlEphemeral.Type.EPHEMERAL) .build() ) - .content(BetaToolResultBlockParam.Content.ofString("string")) + .content("string") .isError(true) .build() assertThat(betaToolResultBlockParam).isNotNull diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/ErrorResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/ErrorResponseTest.kt index 45ad98e..20fca91 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/ErrorResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/ErrorResponseTest.kt @@ -12,12 +12,10 @@ class ErrorResponseTest { val errorResponse = ErrorResponse.builder() .error( - ErrorObject.ofInvalidRequestError( - InvalidRequestError.builder() - .message("message") - .type(InvalidRequestError.Type.INVALID_REQUEST_ERROR) - .build() - ) + InvalidRequestError.builder() + .message("message") + .type(InvalidRequestError.Type.INVALID_REQUEST_ERROR) + .build() ) .type(ErrorResponse.Type.ERROR) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt index 556db49..a8e724f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchCreateParamsTest.kt @@ -19,7 +19,7 @@ class MessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -31,29 +31,25 @@ class MessageBatchCreateParamsTest { ) .addStopSequence("string") .stream(true) - .system( - MessageBatchCreateParams.Request.Params.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -110,7 +106,7 @@ class MessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -122,32 +118,25 @@ class MessageBatchCreateParamsTest { ) .addStopSequence("string") .stream(true) - .system( - MessageBatchCreateParams.Request.Params.System - .ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type( - CacheControlEphemeral.Type.EPHEMERAL - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) .build() ) - ) + .build() + ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -202,7 +191,7 @@ class MessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -214,32 +203,25 @@ class MessageBatchCreateParamsTest { ) .addStopSequence("string") .stream(true) - .system( - MessageBatchCreateParams.Request.Params.System - .ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type( - CacheControlEphemeral.Type.EPHEMERAL - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) .build() ) - ) + .build() + ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -296,7 +278,7 @@ class MessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -318,7 +300,7 @@ class MessageBatchCreateParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchErroredResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchErroredResultTest.kt index b86592f..d8d27aa 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchErroredResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchErroredResultTest.kt @@ -14,12 +14,10 @@ class MessageBatchErroredResultTest { .error( ErrorResponse.builder() .error( - ErrorObject.ofInvalidRequestError( - InvalidRequestError.builder() - .message("message") - .type(InvalidRequestError.Type.INVALID_REQUEST_ERROR) - .build() - ) + InvalidRequestError.builder() + .message("message") + .type(InvalidRequestError.Type.INVALID_REQUEST_ERROR) + .build() ) .type(ErrorResponse.Type.ERROR) .build() @@ -31,12 +29,10 @@ class MessageBatchErroredResultTest { .isEqualTo( ErrorResponse.builder() .error( - ErrorObject.ofInvalidRequestError( - InvalidRequestError.builder() - .message("message") - .type(InvalidRequestError.Type.INVALID_REQUEST_ERROR) - .build() - ) + InvalidRequestError.builder() + .message("message") + .type(InvalidRequestError.Type.INVALID_REQUEST_ERROR) + .build() ) .type(ErrorResponse.Type.ERROR) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt index 1b1dc98..91dde91 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchIndividualResponseTest.kt @@ -13,37 +13,33 @@ class MessageBatchIndividualResponseTest { MessageBatchIndividualResponse.builder() .customId("my-custom-id-1") .result( - MessageBatchResult.ofMessageBatchSucceededResult( - MessageBatchSucceededResult.builder() - .message( - Message.builder() - .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") - .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) - ) - .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .role(Message.Role.ASSISTANT) - .stopReason(Message.StopReason.END_TURN) - .stopSequence(null) - .type(Message.Type.MESSAGE) - .usage( - Usage.builder() - .cacheCreationInputTokens(2051L) - .cacheReadInputTokens(2051L) - .inputTokens(2095L) - .outputTokens(503L) - .build() - ) - .build() - ) - .type(MessageBatchSucceededResult.Type.SUCCEEDED) - .build() - ) + MessageBatchSucceededResult.builder() + .message( + Message.builder() + .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") + .addContent( + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() + ) + .model(Model.CLAUDE_3_5_HAIKU_LATEST) + .role(Message.Role.ASSISTANT) + .stopReason(Message.StopReason.END_TURN) + .stopSequence(null) + .type(Message.Type.MESSAGE) + .usage( + Usage.builder() + .cacheCreationInputTokens(2051L) + .cacheReadInputTokens(2051L) + .inputTokens(2095L) + .outputTokens(503L) + .build() + ) + .build() + ) + .type(MessageBatchSucceededResult.Type.SUCCEEDED) + .build() ) .build() assertThat(messageBatchIndividualResponse).isNotNull @@ -56,12 +52,10 @@ class MessageBatchIndividualResponseTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt index df63fb1..d6b528b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageBatchSucceededResultTest.kt @@ -15,12 +15,10 @@ class MessageBatchSucceededResultTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) @@ -45,12 +43,10 @@ class MessageBatchSucceededResultTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt index c87f97e..7c0e033 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCountTokensParamsTest.kt @@ -12,34 +12,27 @@ class MessageCountTokensParamsTest { fun createMessageCountTokensParams() { MessageCountTokensParams.builder() .addMessage( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() + MessageParam.builder().content("string").role(MessageParam.Role.USER).build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .system( - MessageCountTokensParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -83,34 +76,27 @@ class MessageCountTokensParamsTest { val params = MessageCountTokensParams.builder() .addMessage( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() + MessageParam.builder().content("string").role(MessageParam.Role.USER).build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .system( - MessageCountTokensParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -152,10 +138,7 @@ class MessageCountTokensParamsTest { assertThat(body.messages()) .isEqualTo( listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() + MessageParam.builder().content("string").role(MessageParam.Role.USER).build() ) ) assertThat(body.model()).isEqualTo(Model.CLAUDE_3_5_HAIKU_LATEST) @@ -228,10 +211,7 @@ class MessageCountTokensParamsTest { val params = MessageCountTokensParams.builder() .addMessage( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() + MessageParam.builder().content("string").role(MessageParam.Role.USER).build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .build() @@ -240,10 +220,7 @@ class MessageCountTokensParamsTest { assertThat(body.messages()) .isEqualTo( listOf( - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() + MessageParam.builder().content("string").role(MessageParam.Role.USER).build() ) ) assertThat(body.model()).isEqualTo(Model.CLAUDE_3_5_HAIKU_LATEST) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt index 8187271..9e05972 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageCreateParamsTest.kt @@ -13,37 +13,30 @@ class MessageCreateParamsTest { MessageCreateParams.builder() .maxTokens(1024L) .addMessage( - MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) - .role(MessageParam.Role.USER) - .build() + MessageParam.builder().content("Hello, world").role(MessageParam.Role.USER).build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -91,36 +84,32 @@ class MessageCreateParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -166,7 +155,7 @@ class MessageCreateParamsTest { .isEqualTo( listOf( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -249,7 +238,7 @@ class MessageCreateParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -262,7 +251,7 @@ class MessageCreateParamsTest { .isEqualTo( listOf( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageParamTest.kt index 60a8454..5833314 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageParamTest.kt @@ -10,10 +10,7 @@ class MessageParamTest { @Test fun createMessageParam() { val messageParam = - MessageParam.builder() - .content(MessageParam.Content.ofString("string")) - .role(MessageParam.Role.USER) - .build() + MessageParam.builder().content("string").role(MessageParam.Role.USER).build() assertThat(messageParam).isNotNull assertThat(messageParam.content()).isEqualTo(MessageParam.Content.ofString("string")) assertThat(messageParam.role()).isEqualTo(MessageParam.Role.USER) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt index 9e4321b..dcdc261 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/MessageTest.kt @@ -13,12 +13,10 @@ class MessageTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockDeltaEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockDeltaEventTest.kt index a09dcb7..857c4f6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockDeltaEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockDeltaEventTest.kt @@ -11,11 +11,7 @@ class RawContentBlockDeltaEventTest { fun createRawContentBlockDeltaEvent() { val rawContentBlockDeltaEvent = RawContentBlockDeltaEvent.builder() - .delta( - RawContentBlockDeltaEvent.Delta.ofTextDelta( - TextDelta.builder().text("text").type(TextDelta.Type.TEXT_DELTA).build() - ) - ) + .delta(TextDelta.builder().text("text").type(TextDelta.Type.TEXT_DELTA).build()) .index(0L) .type(RawContentBlockDeltaEvent.Type.CONTENT_BLOCK_DELTA) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockStartEventTest.kt index 13d1188..991f79d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawContentBlockStartEventTest.kt @@ -11,11 +11,7 @@ class RawContentBlockStartEventTest { fun createRawContentBlockStartEvent() { val rawContentBlockStartEvent = RawContentBlockStartEvent.builder() - .contentBlock( - RawContentBlockStartEvent.ContentBlock.ofTextBlock( - TextBlock.builder().text("text").type(TextBlock.Type.TEXT).build() - ) - ) + .contentBlock(TextBlock.builder().text("text").type(TextBlock.Type.TEXT).build()) .index(0L) .type(RawContentBlockStartEvent.Type.CONTENT_BLOCK_START) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt index 9189a86..8f6e407 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/RawMessageStartEventTest.kt @@ -15,12 +15,10 @@ class RawMessageStartEventTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) @@ -45,12 +43,10 @@ class RawMessageStartEventTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/ToolResultBlockParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/ToolResultBlockParamTest.kt index 70005da..d87f081 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/ToolResultBlockParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/ToolResultBlockParamTest.kt @@ -18,7 +18,7 @@ class ToolResultBlockParamTest { .type(CacheControlEphemeral.Type.EPHEMERAL) .build() ) - .content(ToolResultBlockParam.Content.ofString("string")) + .content("string") .isError(true) .build() assertThat(toolResultBlockParam).isNotNull diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt index cdfbe7a..29403b7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ErrorHandlingTest.kt @@ -18,7 +18,6 @@ import com.anthropic.errors.UnauthorizedException import com.anthropic.errors.UnexpectedStatusCodeException import com.anthropic.errors.UnprocessableEntityException import com.anthropic.models.CacheControlEphemeral -import com.anthropic.models.ContentBlock import com.anthropic.models.Message import com.anthropic.models.MessageCreateParams import com.anthropic.models.MessageParam @@ -27,7 +26,6 @@ import com.anthropic.models.Model import com.anthropic.models.TextBlock import com.anthropic.models.TextBlockParam import com.anthropic.models.Tool -import com.anthropic.models.ToolChoice import com.anthropic.models.ToolChoiceAuto import com.anthropic.models.Usage import com.fasterxml.jackson.databind.json.JsonMapper @@ -71,36 +69,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -144,12 +138,10 @@ class ErrorHandlingTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) @@ -178,36 +170,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -265,36 +253,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -352,36 +336,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -443,36 +423,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -530,36 +506,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -621,36 +593,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -708,36 +676,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -799,36 +763,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -891,36 +851,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -977,36 +933,32 @@ class ErrorHandlingTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt index f4b9891..7021cf3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/ServiceParamsTest.kt @@ -7,7 +7,6 @@ import com.anthropic.client.okhttp.AnthropicOkHttpClient import com.anthropic.core.JsonValue import com.anthropic.core.jsonMapper import com.anthropic.models.CacheControlEphemeral -import com.anthropic.models.ContentBlock import com.anthropic.models.Message import com.anthropic.models.MessageCreateParams import com.anthropic.models.MessageParam @@ -16,7 +15,6 @@ import com.anthropic.models.Model import com.anthropic.models.TextBlock import com.anthropic.models.TextBlockParam import com.anthropic.models.Tool -import com.anthropic.models.ToolChoice import com.anthropic.models.ToolChoiceAuto import com.anthropic.models.Usage import com.fasterxml.jackson.databind.json.JsonMapper @@ -69,36 +67,32 @@ class ServiceParamsTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -145,12 +139,10 @@ class ServiceParamsTest { Message.builder() .id("msg_013Zva2CMHLNnXjNJJKqJ2EF") .addContent( - ContentBlock.ofTextBlock( - TextBlock.builder() - .text("Hi! My name is Claude.") - .type(TextBlock.Type.TEXT) - .build() - ) + TextBlock.builder() + .text("Hi! My name is Claude.") + .type(TextBlock.Type.TEXT) + .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) .role(Message.Role.ASSISTANT) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt index fb966f0..a2eb14f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/MessageServiceTest.kt @@ -13,7 +13,6 @@ import com.anthropic.models.Metadata import com.anthropic.models.Model import com.anthropic.models.TextBlockParam import com.anthropic.models.Tool -import com.anthropic.models.ToolChoice import com.anthropic.models.ToolChoiceAuto import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -35,7 +34,7 @@ class MessageServiceTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -44,29 +43,25 @@ class MessageServiceTest { Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() ) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -125,7 +120,7 @@ class MessageServiceTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -134,29 +129,25 @@ class MessageServiceTest { Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() ) .addStopSequence("string") - .system( - MessageCreateParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() @@ -218,33 +209,29 @@ class MessageServiceTest { MessageCountTokensParams.builder() .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("string")) + .content("string") .role(MessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .system( - MessageCountTokensParams.System.ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type(CacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt index 896a681..1727316 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MessageServiceTest.kt @@ -13,9 +13,7 @@ import com.anthropic.models.BetaMessageParam import com.anthropic.models.BetaMetadata import com.anthropic.models.BetaTextBlockParam import com.anthropic.models.BetaTool -import com.anthropic.models.BetaToolChoice import com.anthropic.models.BetaToolChoiceAuto -import com.anthropic.models.BetaToolUnion import com.anthropic.models.Model import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -37,7 +35,7 @@ class MessageServiceTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -48,66 +46,60 @@ class MessageServiceTest { .build() ) .addStopSequence("string") - .system( - BetaMessageCreateParams.System.ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) .topK(5L) .topP(0.7) @@ -133,7 +125,7 @@ class MessageServiceTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -144,66 +136,60 @@ class MessageServiceTest { .build() ) .addStopSequence("string") - .system( - BetaMessageCreateParams.System.ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .build() ) ) .temperature(1.0) .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() ) .topK(5L) .topP(0.7) @@ -232,71 +218,65 @@ class MessageServiceTest { BetaMessageCountTokensParams.builder() .addMessage( BetaMessageParam.builder() - .content(BetaMessageParam.Content.ofString("string")) + .content("string") .role(BetaMessageParam.Role.USER) .build() ) .model(Model.CLAUDE_3_5_HAIKU_LATEST) - .system( - BetaMessageCountTokensParams.System.ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type(BetaCacheControlEphemeral.Type.EPHEMERAL) - .build() - ) - .build() - ) - ) - ) - .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) - ) - .addTool( - BetaMessageCountTokensParams.Tool.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) - ) - ) - .build() - ) - .name("name") + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) .cacheControl( BetaCacheControlEphemeral.builder() .type(BetaCacheControlEphemeral.Type.EPHEMERAL) .build() ) - .description("Get the current weather in a given location") - .type(BetaTool.Type.CUSTOM) .build() ) ) + .toolChoice( + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() + ) + .addTool( + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) + ) + ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description("Get the current weather in a given location") + .type(BetaTool.Type.CUSTOM) + .build() + ) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt index 4971f68..e990767 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/messages/BatchServiceTest.kt @@ -16,9 +16,7 @@ import com.anthropic.models.BetaMessageParam import com.anthropic.models.BetaMetadata import com.anthropic.models.BetaTextBlockParam import com.anthropic.models.BetaTool -import com.anthropic.models.BetaToolChoice import com.anthropic.models.BetaToolChoiceAuto -import com.anthropic.models.BetaToolUnion import com.anthropic.models.Model import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -45,9 +43,7 @@ class BatchServiceTest { .maxTokens(1024L) .addMessage( BetaMessageParam.builder() - .content( - BetaMessageParam.Content.ofString("Hello, world") - ) + .content("Hello, world") .role(BetaMessageParam.Role.USER) .build() ) @@ -59,74 +55,64 @@ class BatchServiceTest { ) .addStopSequence("string") .stream(true) - .system( - BetaMessageBatchCreateParams.Request.Params.System - .ofBetaTextBlockParams( - listOf( - BetaTextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(BetaTextBlockParam.Type.TEXT) - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type - .EPHEMERAL - ) - .build() + .systemOfBetaTextBlockParams( + listOf( + BetaTextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(BetaTextBlockParam.Type.TEXT) + .cacheControl( + BetaCacheControlEphemeral.builder() + .type( + BetaCacheControlEphemeral.Type.EPHEMERAL ) .build() ) - ) + .build() + ) ) .temperature(1.0) .toolChoice( - BetaToolChoice.ofBetaToolChoiceAuto( - BetaToolChoiceAuto.builder() - .type(BetaToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + BetaToolChoiceAuto.builder() + .type(BetaToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( - BetaToolUnion.ofBetaTool( - BetaTool.builder() - .inputSchema( - BetaTool.InputSchema.builder() - .type(BetaTool.InputSchema.Type.OBJECT) - .properties( - JsonValue.from( - mapOf( - "location" to - mapOf( - "description" to - "The city and state, e.g. San Francisco, CA", - "type" to "string" - ), - "unit" to - mapOf( - "description" to - "Unit for the output - one of (celsius, fahrenheit)", - "type" to "string" - ) - ) + BetaTool.builder() + .inputSchema( + BetaTool.InputSchema.builder() + .type(BetaTool.InputSchema.Type.OBJECT) + .properties( + JsonValue.from( + mapOf( + "location" to + mapOf( + "description" to + "The city and state, e.g. San Francisco, CA", + "type" to "string" + ), + "unit" to + mapOf( + "description" to + "Unit for the output - one of (celsius, fahrenheit)", + "type" to "string" + ) ) ) - .build() - ) - .name("name") - .cacheControl( - BetaCacheControlEphemeral.builder() - .type( - BetaCacheControlEphemeral.Type.EPHEMERAL - ) - .build() - ) - .description( - "Get the current weather in a given location" - ) - .type(BetaTool.Type.CUSTOM) - .build() - ) + ) + .build() + ) + .name("name") + .cacheControl( + BetaCacheControlEphemeral.builder() + .type(BetaCacheControlEphemeral.Type.EPHEMERAL) + .build() + ) + .description( + "Get the current weather in a given location" + ) + .type(BetaTool.Type.CUSTOM) + .build() ) .topK(5L) .topP(0.7) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt index 75c4ac4..b197bcb 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/messages/BatchServiceTest.kt @@ -16,7 +16,6 @@ import com.anthropic.models.Metadata import com.anthropic.models.Model import com.anthropic.models.TextBlockParam import com.anthropic.models.Tool -import com.anthropic.models.ToolChoice import com.anthropic.models.ToolChoiceAuto import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -43,7 +42,7 @@ class BatchServiceTest { .maxTokens(1024L) .addMessage( MessageParam.builder() - .content(MessageParam.Content.ofString("Hello, world")) + .content("Hello, world") .role(MessageParam.Role.USER) .build() ) @@ -55,33 +54,25 @@ class BatchServiceTest { ) .addStopSequence("string") .stream(true) - .system( - MessageBatchCreateParams.Request.Params.System - .ofTextBlockParams( - listOf( - TextBlockParam.builder() - .text("Today's date is 2024-06-01.") - .type(TextBlockParam.Type.TEXT) - .cacheControl( - CacheControlEphemeral.builder() - .type( - CacheControlEphemeral.Type - .EPHEMERAL - ) - .build() - ) + .systemOfTextBlockParams( + listOf( + TextBlockParam.builder() + .text("Today's date is 2024-06-01.") + .type(TextBlockParam.Type.TEXT) + .cacheControl( + CacheControlEphemeral.builder() + .type(CacheControlEphemeral.Type.EPHEMERAL) .build() ) - ) + .build() + ) ) .temperature(1.0) .toolChoice( - ToolChoice.ofToolChoiceAuto( - ToolChoiceAuto.builder() - .type(ToolChoiceAuto.Type.AUTO) - .disableParallelToolUse(true) - .build() - ) + ToolChoiceAuto.builder() + .type(ToolChoiceAuto.Type.AUTO) + .disableParallelToolUse(true) + .build() ) .addTool( Tool.builder() From 421a9ab64779d1bb34fb10cd7ad014defe2660df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 05:52:52 +0000 Subject: [PATCH 4/5] docs: don't mention a non-existent SDK (#59) --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 7ae860e..11297ef 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,6 @@ The Anthropic Java SDK provides convenient access to the Anthropic REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property. -The Anthropic Java SDK is similar to the Anthropic Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. - ## Documentation The REST API documentation can be foundĀ on [docs.anthropic.com](https://docs.anthropic.com/claude/reference/). From 55c71e33ede26108724371c4e820e65afb874aa7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 05:53:12 +0000 Subject: [PATCH 5/5] release: 0.1.0-alpha.8 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 16 ++++++++++++++++ README.md | 6 +++--- build.gradle.kts | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b5db7ce..c373724 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.7" + ".": "0.1.0-alpha.8" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4493b69..e8862af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 0.1.0-alpha.8 (2025-01-15) + +Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/anthropics/anthropic-sdk-java/compare/v0.1.0-alpha.7...v0.1.0-alpha.8) + +### Chores + +* **internal:** add and tweak check functions ([#55](https://github.com/anthropics/anthropic-sdk-java/issues/55)) ([16f8002](https://github.com/anthropics/anthropic-sdk-java/commit/16f80028849f54f8feab7314e33d557e4a923581)) +* **internal:** tweak client options nullability handling ([16f8002](https://github.com/anthropics/anthropic-sdk-java/commit/16f80028849f54f8feab7314e33d557e4a923581)) +* simplify examples involving lists ([#57](https://github.com/anthropics/anthropic-sdk-java/issues/57)) ([b9f1145](https://github.com/anthropics/anthropic-sdk-java/commit/b9f114543501938c386f659417e312844900dd56)) +* simplify examples involving unions ([#58](https://github.com/anthropics/anthropic-sdk-java/issues/58)) ([e800907](https://github.com/anthropics/anthropic-sdk-java/commit/e800907343dfa88baf644eafa3953098072fcda0)) + + +### Documentation + +* don't mention a non-existent SDK ([#59](https://github.com/anthropics/anthropic-sdk-java/issues/59)) ([421a9ab](https://github.com/anthropics/anthropic-sdk-java/commit/421a9ab64779d1bb34fb10cd7ad014defe2660df)) + ## 0.1.0-alpha.7 (2025-01-14) Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/anthropics/anthropic-sdk-java/compare/v0.1.0-alpha.6...v0.1.0-alpha.7) diff --git a/README.md b/README.md index 11297ef..563f6b1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.anthropic/anthropic-java)](https://central.sonatype.com/artifact/com.anthropic/anthropic-java/0.1.0-alpha.7) +[![Maven Central](https://img.shields.io/maven-central/v/com.anthropic/anthropic-java)](https://central.sonatype.com/artifact/com.anthropic/anthropic-java/0.1.0-alpha.8) @@ -30,7 +30,7 @@ The REST API documentation can be foundĀ on [docs.anthropic.com](https://docs.an ```kotlin -implementation("com.anthropic:anthropic-java:0.1.0-alpha.7") +implementation("com.anthropic:anthropic-java:0.1.0-alpha.8") ``` #### Maven @@ -39,7 +39,7 @@ implementation("com.anthropic:anthropic-java:0.1.0-alpha.7") com.anthropic anthropic-java - 0.1.0-alpha.7 + 0.1.0-alpha.8 ``` diff --git a/build.gradle.kts b/build.gradle.kts index a43a6e1..fca8937 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "com.anthropic" - version = "0.1.0-alpha.7" // x-release-please-version + version = "0.1.0-alpha.8" // x-release-please-version } subprojects {