diff --git a/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAIChatModel.java b/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAiChatModel.java similarity index 91% rename from langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAIChatModel.java rename to langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAiChatModel.java index c0e644d1a..8bf3af14f 100644 --- a/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAIChatModel.java +++ b/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAiChatModel.java @@ -17,8 +17,8 @@ import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse; @Getter @SuperBuilder -public class BedrockMistralAiChatModel extends AbstractBedrockChatModel { - +public class BedrockMistralAiChatModel extends AbstractBedrockChatModel { + @Builder.Default private final int topK = 200; @Builder.Default @@ -42,27 +42,27 @@ public class BedrockMistralAiChatModel extends AbstractBedrockChatModel generate(List messages) { String prompt = buildPrompt(messages); - + final Map requestParameters = getRequestParameters(prompt); final String body = Json.toJson(requestParameters); - + InvokeModelResponse invokeModelResponse = withRetry(() -> invoke(body), getMaxRetries()); final String response = invokeModelResponse.body().asUtf8String().trim(); - final BedrockMistralAIChatModelResponse result = Json.fromJson(response, getResponseClassType()); - + final BedrockMistralAiChatModelResponse result = Json.fromJson(response, getResponseClassType()); + return new Response<>(new AiMessage(result.getOutputText()), result.getTokenUsage(), result.getFinishReason()); } - + private String buildPrompt(List messages) { StringBuilder promptBuilder = new StringBuilder(); promptBuilder.append(""); - + for (ChatMessage message : messages) { switch (message.type()) { case USER: @@ -75,14 +75,14 @@ public class BedrockMistralAiChatModel extends AbstractBedrockChatModel"); return promptBuilder.toString(); } - + @Override - public Class getResponseClassType() { - return BedrockMistralAIChatModelResponse.class; + public Class getResponseClassType() { + return BedrockMistralAiChatModelResponse.class; } /** diff --git a/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAIChatModelResponse.java b/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAiChatModelResponse.java similarity index 92% rename from langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAIChatModelResponse.java rename to langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAiChatModelResponse.java index d5afe0349..77eedcf7a 100644 --- a/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAIChatModelResponse.java +++ b/langchain4j-bedrock/src/main/java/dev/langchain4j/model/bedrock/BedrockMistralAiChatModelResponse.java @@ -12,7 +12,7 @@ import lombok.Setter; */ @Getter @Setter -public class BedrockMistralAiChatModelResponse implements BedrockChatModelResponse { +class BedrockMistralAiChatModelResponse implements BedrockChatModelResponse { private List outputs;