diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ClaudeConfig.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ClaudeConfig.java index 21017b6..ab6aaa6 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ClaudeConfig.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ClaudeConfig.java @@ -9,10 +9,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +/** + * Configuration class for Claude + */ @Configuration @Conditional(OnClaude.class) public class ClaudeConfig { + /** + * Bean for ClaudeService + * @param client BedrockRuntimeClient + * @param properties ClaudeProperties + * @return BedrockService + */ @Bean(name = "claudeService") public BedrockService claudeService(BedrockRuntimeClient client, ClaudeProperties properties) { return new ClaudeService(client, properties); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/JurassicConfig.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/JurassicConfig.java index 58ffcd9..c548b09 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/JurassicConfig.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/JurassicConfig.java @@ -9,10 +9,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +/** + * Configuration class for Jurassic + */ @Configuration @Conditional(OnJurassic.class) public class JurassicConfig { + /** + * Bean for JurassicService + * @param client BedrockRuntimeClient + * @param properties JurassicProperties + * @return BedrockService + */ @Bean(name = "jurassicService") public BedrockService jurassicService(BedrockRuntimeClient client, JurassicProperties properties) { return new JurassicService(client, properties); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/LlamaConfig.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/LlamaConfig.java index 1c47c86..f54d0f7 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/LlamaConfig.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/LlamaConfig.java @@ -8,10 +8,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +/** + * Configuration class for Llama + */ @Configuration @ConditionalOnProperty(name = "aws.bedrock.model.llama.id", havingValue = "meta.llama2-13b-chat-v1") public class LlamaConfig { + /** + * Bean for LlamaService + * @param client BedrockRuntimeClient + * @param properties LlamaProperties + * @return BedrockService + */ @Bean(name = "llamaService") public BedrockService llamaService(BedrockRuntimeClient client, LlamaProperties properties) { return new LlamaService(client, properties); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ModelPropertiesAutoConfiguration.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ModelPropertiesAutoConfiguration.java index cfe7aee..ad1253a 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ModelPropertiesAutoConfiguration.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/ModelPropertiesAutoConfiguration.java @@ -7,6 +7,9 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; +/** + * Configuration class for ModelProperties + */ @Configuration @EnableConfigurationProperties({ ClaudeProperties.class, JurassicProperties.class, LlamaProperties.class, TitanProperties.class }) diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnClaude.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnClaude.java index a57cc64..c81becb 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnClaude.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnClaude.java @@ -3,22 +3,37 @@ import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +/** + * Condition class for Claude + */ class OnClaude extends AnyNestedCondition { + /** + * Constructor + */ OnClaude() { super(ConfigurationPhase.PARSE_CONFIGURATION); } + /** + * Condition for Claude v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.claude.id", havingValue = "anthropic.claude-v2") static class OnClaudeV2 { } + /** + * Condition for Claude v1 + */ @ConditionalOnProperty(name = "aws.bedrock.model.claude.id", havingValue = "anthropic.claude-v1") static class OnClaudeV1 { } + /** + * Condition for Claude Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.claude.id", havingValue = "anthropic.claude-instant-v1") static class OnClaudeInstantV1 { diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnJurassic.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnJurassic.java index 322ce31..5ae73a9 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnJurassic.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnJurassic.java @@ -3,37 +3,61 @@ import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +/** + * Condition class for Jurassic + */ class OnJurassic extends AnyNestedCondition { + /** + * Constructor + */ OnJurassic() { super(ConfigurationPhase.PARSE_CONFIGURATION); } + /** + * Condition for Jurassic v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.jurassic.id", havingValue = "ai21.j2-grande-instruct") static class OnJurassic2GrandeInstruct { } + /** + * Condition for Jurassic v1 + */ @ConditionalOnProperty(name = "aws.bedrock.model.jurassic.id", havingValue = "ai21.j2-jumbo-instruct") static class OnJurassic2JumboInstruct { } + /** + * Condition for Jurassic Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.jurassic.id", havingValue = "ai21.j2-mid") static class OnJurassic2Mid { } + /** + * Condition for Jurassic Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.jurassic.id", havingValue = "ai21.j2-mid-v1") static class OnJurassic2MidV1 { } + /** + * Condition for Jurassic Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.jurassic.id", havingValue = "ai21.j2-ultra") static class OnCJurassic2Ultra { } + /** + * Condition for Jurassic Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.jurassic.idd", havingValue = "ai21.j2-ultra-v1") static class OnCJurassic2UltraV1 { diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnTitan.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnTitan.java index e13cd1b..476de7f 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnTitan.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/OnTitan.java @@ -3,37 +3,61 @@ import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +/** + * Condition class for Titan + */ class OnTitan extends AnyNestedCondition { + /** + * Constructor + */ OnTitan() { super(ConfigurationPhase.PARSE_CONFIGURATION); } + /** + * Condition for Titan v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.titan.id", havingValue = "amazon.titan-tg1-large") static class OnTitanLarge { } + /** + * Condition for Titan v1 + */ @ConditionalOnProperty(name = "aws.bedrock.model.titan.id", havingValue = "amazon.titan-tg1-medium") static class OnTitanMedium { } + /** + * Condition for Titan Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.titan.id", havingValue = "amazon.titan-embed-g1-text-02") static class OnTitanTextEmbeddingsV2 { } + /** + * Condition for Titan Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.titan.id", havingValue = "amazon.titan-text-lite-v1") static class OnTitanTextLiteV1 { } + /** + * Condition for Titan Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.titan.id", havingValue = "amazon.titan-text-express-v1") static class OnTitanTextExpressV1 { } + /** + * Condition for Titan Instant v2 + */ @ConditionalOnProperty(name = "aws.bedrock.model.titan.id", havingValue = "amazon.titan-embed-text-v1") static class OnTitanTextEmbeddingsV1 { diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/TitanConfig.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/TitanConfig.java index 102e9d9..07779fd 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/TitanConfig.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/aimodels/TitanConfig.java @@ -8,10 +8,19 @@ import org.springframework.context.annotation.Configuration; import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; +/** + * Configuration class for Titan + */ @Configuration @Conditional(OnTitan.class) public class TitanConfig { + /** + * Bean for TitanService + * @param client BedrockRuntimeClient + * @param properties TitanProperties + * @return BedrockService + */ @Bean(name = "titanService") public BedrockService titanService(BedrockRuntimeClient client, TitanProperties properties) { return new TitanService(client, properties); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/clients/BedrockClientConfig.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/clients/BedrockClientConfig.java index c931683..b587fe3 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/clients/BedrockClientConfig.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/autoconfigure/clients/BedrockClientConfig.java @@ -12,25 +12,46 @@ import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; +/** + * Configuration class for BedrockClient + */ @Configuration public class BedrockClientConfig { + /** + * AwsCredentialsProvider + */ private AwsCredentialsProvider awsCredentialsProvider; + /** + * Region + */ @Value("${aws.region}") private String region; + /** + * Constructor + * @param awsCredentialsProvider AwsCredentialsProvider + */ @Autowired public BedrockClientConfig(AwsCredentialsProvider awsCredentialsProvider) { this.awsCredentialsProvider = awsCredentialsProvider; } + /** + * Bean for BedrockClient + * @return BedrockClient + */ @Bean @ConditionalOnProperty(name = "bedrock.client.type", havingValue = "sync") public BedrockClient bedrockClient() { return BedrockClient.builder().region(Region.of(region)).credentialsProvider(awsCredentialsProvider).build(); } + /** + * Bean for BedrockRuntimeClient + * @return BedrockRuntimeClient + */ @Bean public BedrockRuntimeClient bedrockRuntimeClient() { return BedrockRuntimeClient.builder() @@ -39,6 +60,10 @@ public BedrockRuntimeClient bedrockRuntimeClient() { .build(); } + /** + * Bean for BedrockRuntimeAsyncClient + * @return BedrockRuntimeAsyncClient + */ @Bean @ConditionalOnProperty(name = "bedrock.client.type", havingValue = "async") public BedrockRuntimeAsyncClient bedrockRuntimeAsyncClient() { @@ -48,6 +73,10 @@ public BedrockRuntimeAsyncClient bedrockRuntimeAsyncClient() { .build(); } + /** + * Bean for BedrockAsyncClient + * @return BedrockAsyncClient + */ @Bean @ConditionalOnProperty(name = "bedrock.client.type", havingValue = "async") public BedrockAsyncClient bedrockAsyncClient() { diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/ClaudeProperties.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/ClaudeProperties.java index 3d5d6a6..0126f87 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/ClaudeProperties.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/ClaudeProperties.java @@ -9,6 +9,15 @@ import java.util.List; import java.util.Optional; +/** + * Sample properties aws.bedrock.model.claude.id=anthropic.claude-v2 + * aws.bedrock.model.claude.prePrompt=Human: + * aws.bedrock.model.claude.postPrompt=Assistant: aws.bedrock.model.claude.maxTokens=100 + * aws.bedrock.model.claude.temperature=0.5 aws.bedrock.model.claude.stopSequences=Human:, + * Assistant: + * + * @see ... + */ @Validated @ConfigurationProperties(prefix = "aws.bedrock.model.claude") public record ClaudeProperties( @@ -17,6 +26,15 @@ public record ClaudeProperties( @DecimalMin("0.0") @DecimalMax("1.0") Double temperature, @Min(1) @Max(100000) Integer maxTokens, @Nullable List stopSequences) { + /** + * Constructor + * @param id String + * @param prePrompt String + * @param postPrompt String + * @param temperature Double + * @param maxTokens Integer + * @param stopSequences List + */ public ClaudeProperties(String id, String prePrompt, String postPrompt, Double temperature, Integer maxTokens, List stopSequences) { this.id = Optional.ofNullable(id).orElse("anthropic.claude-v2"); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/JurassicProperties.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/JurassicProperties.java index dc8122b..2529a1a 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/JurassicProperties.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/JurassicProperties.java @@ -17,10 +17,20 @@ @Validated @ConfigurationProperties(prefix = "aws.bedrock.model.jurassic") public record JurassicProperties(@Pattern( + /** + * Model ID + */ regexp = "ai21.j2-grande-instruct|ai21.j2-jumbo-instruct|ai21.j2-mid|ai21.j2-mid-v1|ai21.j2-ultra|ai21.j2-ultra-v1") String id, @Nullable String prePrompt, @Min(1) @Max(8192) Integer maxTokens, @DecimalMin("0.0") @DecimalMax("1.0") Double temperature) { + /** + * Constructor + * @param id String + * @param prePrompt String + * @param maxTokens Integer + * @param temperature Double + */ public JurassicProperties(String id, String prePrompt, Integer maxTokens, Double temperature) { this.id = Optional.ofNullable(id).orElse("ai21.j2-mid-v1"); this.prePrompt = Optional.ofNullable(prePrompt).orElse("Human: "); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/LlamaProperties.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/LlamaProperties.java index dc2583a..5b367ff 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/LlamaProperties.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/LlamaProperties.java @@ -9,12 +9,26 @@ import java.util.List; import java.util.Optional; +/** + * Sample properties aws.bedrock.model.llama2.modelId=meta.llama2-13b-chat-v1 + * aws.bedrock.model.llama2.topP=0.9 aws.bedrock.model.llama2.temperature=0.5 + * aws.bedrock.model.llama2.maxTokens=100 + * + * @see ... + */ @Validated @ConfigurationProperties(prefix = "aws.bedrock.model.llama2") public record LlamaProperties(@Pattern(regexp = "meta.llama2-13b-chat-v1") String id, @DecimalMin("0.0") @DecimalMax("1.0") Double topP, @DecimalMin("0.0") @DecimalMax("1.0") Double temperature, @Min(1) @Max(4000) Integer maxTokens) { + /** + * Constructor + * @param id String + * @param topP Double + * @param temperature Double + * @param maxTokens Integer + */ public LlamaProperties(String id, Double topP, Double temperature, Integer maxTokens) { this.id = Optional.ofNullable(id).orElse("meta.llama2-13b-chat-v1"); this.temperature = Optional.ofNullable(temperature).orElse(0.5); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/TitanProperties.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/TitanProperties.java index abe2eed..dd54ea7 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/TitanProperties.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/config/TitanProperties.java @@ -9,6 +9,14 @@ import java.util.List; import java.util.Optional; +/** + * Sample properties aws.bedrock.model.titan.id=amazon.titan-text-express-v1 + * aws.bedrock.model.titan.temperature=0.5 aws.bedrock.model.titan.topP=0.9 + * aws.bedrock.model.titan.maxTokens=100 aws.bedrock.model.titan.stopSequences=Human:, + * Assistant: + * + * @see ... + */ @Validated @ConfigurationProperties(prefix = "aws.bedrock.model.titan") public record TitanProperties(@Pattern( @@ -16,6 +24,14 @@ public record TitanProperties(@Pattern( @DecimalMin("0.0") @DecimalMax("1.0") Double temperature, @DecimalMin("0.0") @DecimalMax("1.0") Double topP, @Min(1) @Max(8192) Integer maxTokens, @Nullable List stopSequences) { + /** + * Constructor + * @param id String + * @param temperature Double + * @param topP Double + * @param maxTokens Integer + * @param stopSequences List + */ public TitanProperties(String id, Double temperature, Double topP, Integer maxTokens, List stopSequences) { this.id = Optional.ofNullable(id).orElse("amazon.titan-text-express-v1"); this.temperature = Optional.ofNullable(temperature).orElse(0.0); diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/BedrockService.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/BedrockService.java index 3b1347f..7d6bf9b 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/BedrockService.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/BedrockService.java @@ -2,8 +2,17 @@ import com.fasterxml.jackson.core.JsonProcessingException; +/** + * Service interface for Bedrock + */ public interface BedrockService { + /** + * Invoke the model + * @param prompt String + * @return String + * @throws JsonProcessingException JsonProcessingException + */ String invoke(String prompt) throws JsonProcessingException; } \ No newline at end of file diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeService.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeService.java index 37945bc..031d491 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeService.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeService.java @@ -12,20 +12,43 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; +/** + * Service class for Claude - Implementation of BedrockService + */ public class ClaudeService implements BedrockService { + /** + * Logger + */ private static final Logger log = LoggerFactory.getLogger(ClaudeService.class); + /** + * BedrockRuntimeClient + */ private final BedrockRuntimeClient client; + /** + * ClaudeProperties + */ private final ClaudeProperties properties; + /** + * Constructor + * @param client BedrockRuntimeClient + * @param properties ClaudeProperties + */ public ClaudeService(BedrockRuntimeClient client, ClaudeProperties properties) { this.client = client; this.properties = properties; log.info("Instantiating ClaudeService"); } + /** + * Invoke the model + * @param prompt String + * @return String + * @throws JsonProcessingException JsonProcessingException + */ @Override public String invoke(String prompt) throws JsonProcessingException { try { diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/JurassicService.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/JurassicService.java index 9299f38..0e0a0ad 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/JurassicService.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/JurassicService.java @@ -12,20 +12,41 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; +/** + * Service class for Jurassic - Implementation of BedrockService + */ public class JurassicService implements BedrockService { + /** Logger */ private static final Logger log = LoggerFactory.getLogger(JurassicService.class); + /** + * BedrockRuntimeClient + */ private final BedrockRuntimeClient client; + /** + * JurassicProperties + */ private final JurassicProperties properties; + /** + * Constructor + * @param client + * @param properties + */ public JurassicService(BedrockRuntimeClient client, JurassicProperties properties) { this.client = client; this.properties = properties; log.info("Instantiating JurassicService"); } + /** + * Invoke the model + * @param prompt + * @return + * @throws JsonProcessingException + */ @Override public String invoke(String prompt) throws JsonProcessingException { try { diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/LlamaService.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/LlamaService.java index cd18d82..c052c8d 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/LlamaService.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/LlamaService.java @@ -12,20 +12,43 @@ import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest; +/** + * Service class for Llama - Implementation of BedrockService + */ public class LlamaService implements BedrockService { + /** + * Logger + */ private static final Logger log = LoggerFactory.getLogger(LlamaService.class); + /** + * BedrockRuntimeClient + */ private final BedrockRuntimeClient client; + /** + * LlamaProperties + */ private final LlamaProperties properties; + /** + * Constructor + * @param client BedrockRuntimeClient + * @param properties LlamaProperties + */ public LlamaService(BedrockRuntimeClient client, LlamaProperties properties) { this.client = client; this.properties = properties; log.info("Instantiating LlamaService"); } + /** + * Invoke the model + * @param prompt String + * @return String + * @throws JsonProcessingException JsonProcessingException + */ @Override public String invoke(String prompt) throws JsonProcessingException { try { diff --git a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/TitanService.java b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/TitanService.java index c403f51..abfb619 100644 --- a/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/TitanService.java +++ b/src/main/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/TitanService.java @@ -13,20 +13,43 @@ import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest; +/** + * Service class for Titan - Implementation of BedrockService + */ public class TitanService implements BedrockService { + /** + * Logger + */ private static final Logger log = LoggerFactory.getLogger(TitanService.class); + /** + * BedrockRuntimeClient + */ private final BedrockRuntimeClient client; + /** + * TitanProperties + */ private final TitanProperties properties; + /** + * Constructor + * @param client BedrockRuntimeClient + * @param properties TitanProperties + */ public TitanService(BedrockRuntimeClient client, TitanProperties properties) { this.client = client; this.properties = properties; log.info("Instantiating TitanService"); } + /** + * Invoke the model + * @param prompt String + * @return String + * @throws JsonProcessingException JsonProcessingException + */ @Override public String invoke(String prompt) throws JsonProcessingException { try { diff --git a/src/test/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeServiceTest.java b/src/test/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeServiceTest.java index 15b620b..82c0d23 100644 --- a/src/test/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeServiceTest.java +++ b/src/test/java/io/clue2solve/aws/bedrock/springboot/starter/service/impl/ClaudeServiceTest.java @@ -17,6 +17,9 @@ import static org.junit.jupiter.api.Assertions.*; +/** + * Test for Service class for Claude - Implementation of BedrockService + */ @SpringBootTest @TestPropertySource(properties = { "aws.region=us-west-2", "aws.bedrock.model.claude.id=anthropic.claude-v2" }) @EnabledIf(