Skip to content

Commit

Permalink
add 3.5 sonnet
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Jun 20, 2024
1 parent c752a13 commit defb948
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/aoelite/claude/ClaudeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/aoelite/claude/data/ClaudeRequest.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<String> stop_sequences;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/aoelite/claude/data/types/AIModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.aoelite.claude.data.types;

public interface AIModel {

String getId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/aoelite/claude/example/ExampleA.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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("###")
Expand Down

0 comments on commit defb948

Please sign in to comment.