From defb948d7600caf89759717a05415932fc1db90b Mon Sep 17 00:00:00 2001 From: AoElite Date: Thu, 20 Jun 2024 11:22:12 -0400 Subject: [PATCH] add 3.5 sonnet --- src/main/java/com/aoelite/claude/ClaudeClient.java | 2 +- .../java/com/aoelite/claude/data/ClaudeRequest.java | 6 ++---- .../java/com/aoelite/claude/data/types/AIModel.java | 7 +++++++ .../types/{ClaudeModel.java => ClaudeAIModel.java} | 11 ++++++----- .../java/com/aoelite/claude/example/ExampleA.java | 4 ++-- 5 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/aoelite/claude/data/types/AIModel.java rename src/main/java/com/aoelite/claude/data/types/{ClaudeModel.java => ClaudeAIModel.java} (59%) diff --git a/src/main/java/com/aoelite/claude/ClaudeClient.java b/src/main/java/com/aoelite/claude/ClaudeClient.java index 00038a6..3c9c07b 100644 --- a/src/main/java/com/aoelite/claude/ClaudeClient.java +++ b/src/main/java/com/aoelite/claude/ClaudeClient.java @@ -105,7 +105,7 @@ private JsonObject sendRequestAndGetJson(ClaudeRequest request) { public JsonObject generateJsonRequest(ClaudeRequest request) { JsonObject object = new JsonObject(); - object.addProperty("model", request.getModel().getId()); + object.addProperty("model", request.getAIModel().getId()); object.addProperty("max_tokens", request.getMax_tokens()); object.addProperty("temperature", request.getTemperature()); diff --git a/src/main/java/com/aoelite/claude/data/ClaudeRequest.java b/src/main/java/com/aoelite/claude/data/ClaudeRequest.java index c5cb033..2e9290f 100644 --- a/src/main/java/com/aoelite/claude/data/ClaudeRequest.java +++ b/src/main/java/com/aoelite/claude/data/ClaudeRequest.java @@ -1,9 +1,7 @@ package com.aoelite.claude.data; -import com.aoelite.claude.data.input.ClaudeMessage; import com.aoelite.claude.data.input.RoleInput; -import com.aoelite.claude.data.input.TextMessage; -import com.aoelite.claude.data.types.ClaudeModel; +import com.aoelite.claude.data.types.AIModel; import lombok.*; import org.jetbrains.annotations.Nullable; @@ -15,7 +13,7 @@ @Builder public class ClaudeRequest { - @NonNull private final ClaudeModel model; + @NonNull private final AIModel AIModel; @Builder.Default private final int max_tokens = 1000; @Nullable private String system; @Nullable @Singular private List stop_sequences; diff --git a/src/main/java/com/aoelite/claude/data/types/AIModel.java b/src/main/java/com/aoelite/claude/data/types/AIModel.java new file mode 100644 index 0000000..7461104 --- /dev/null +++ b/src/main/java/com/aoelite/claude/data/types/AIModel.java @@ -0,0 +1,7 @@ +package com.aoelite.claude.data.types; + +public interface AIModel { + + String getId(); + +} diff --git a/src/main/java/com/aoelite/claude/data/types/ClaudeModel.java b/src/main/java/com/aoelite/claude/data/types/ClaudeAIModel.java similarity index 59% rename from src/main/java/com/aoelite/claude/data/types/ClaudeModel.java rename to src/main/java/com/aoelite/claude/data/types/ClaudeAIModel.java index f66e843..38bdda8 100644 --- a/src/main/java/com/aoelite/claude/data/types/ClaudeModel.java +++ b/src/main/java/com/aoelite/claude/data/types/ClaudeAIModel.java @@ -3,20 +3,21 @@ import lombok.Getter; @Getter -public enum ClaudeModel { +public enum ClaudeAIModel implements AIModel { HAIKU("claude-3-haiku-20240307"), SONNET("claude-3-sonnet-20240229"), - OPUS("claude-3-opus-20240229"); + OPUS("claude-3-opus-20240229"), + SONNET_3_5("claude-3-5-sonnet-20240620"); private final String id; - ClaudeModel(String id) { + ClaudeAIModel(String id) { this.id = id; } - public static ClaudeModel fromId(String id) { - for (ClaudeModel model : values()) { + public static ClaudeAIModel fromId(String id) { + for (ClaudeAIModel model : values()) { if (model.id.equals(id)) { return model; } diff --git a/src/main/java/com/aoelite/claude/example/ExampleA.java b/src/main/java/com/aoelite/claude/example/ExampleA.java index 2957134..c4c8400 100644 --- a/src/main/java/com/aoelite/claude/example/ExampleA.java +++ b/src/main/java/com/aoelite/claude/example/ExampleA.java @@ -6,7 +6,7 @@ import com.aoelite.claude.data.ClaudeResponse; import com.aoelite.claude.data.input.RoleInput; import com.aoelite.claude.data.input.TextMessage; -import com.aoelite.claude.data.types.ClaudeModel; +import com.aoelite.claude.data.types.ClaudeAIModel; import com.aoelite.claude.data.types.ClaudeRole; public class ExampleA { @@ -16,7 +16,7 @@ public static void main(String[] args) { ClaudeAPI client = new ClaudeClient("YOUR_API_KEY"); ClaudeResponse response = client.sendRequest(ClaudeRequest.builder() - .model(ClaudeModel.HAIKU) + .AIModel(ClaudeAIModel.HAIKU) .max_tokens(100) .temperature(0) .stop_sequence("###")