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] 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() )