Fix Bedrock chat model enum names consistency
- doc update - fix code formatting Resolves #231
This commit is contained in:
committed by
Christian Tzolov
parent
2f89124350
commit
0b87df07e5
@@ -89,4 +89,4 @@ Use the `BedrockAnthropicChatProperties` to configure the Bedrock Llama2 Chat cl
|
||||
| spring.ai.bedrock.anthropic.chat.temperature | Controls the randomness of the output. Values can range over [0.0,1.0] | 0.8 |
|
||||
| spring.ai.bedrock.anthropic.chat.topP | The maximum cumulative probability of tokens to consider when sampling. | AWS Bedrock default |
|
||||
| spring.ai.bedrock.anthropic.chat.maxGenLen | Specify the maximum number of tokens to use in the generated response. | 300 |
|
||||
| spring.ai.bedrock.anthropic.chat.model | The model id to use. See the `Llama2ChatCompletionModel` for the supported models. | meta.llama2-70b-chat-v1 |
|
||||
| spring.ai.bedrock.anthropic.chat.model | The model id to use. See the `Llama2ChatModel` for the supported models. | meta.llama2-70b-chat-v1 |
|
||||
|
||||
@@ -18,7 +18,7 @@ Here is a simple snippet how to use the api programmatically:
|
||||
|
||||
```java
|
||||
Llama2ChatBedrockApi llama2ChatApi = new Llama2ChatBedrockApi(
|
||||
Llama2ChatCompletionModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
Region.US_EAST_1.id());
|
||||
|
||||
Llama2ChatRequest request = Llama2ChatRequest.builder("Hello, my name is")
|
||||
@@ -51,7 +51,7 @@ You can use like this:
|
||||
@Bean
|
||||
public Llama2ChatBedrockApi llama2Api() {
|
||||
return new Llama2ChatBedrockApi(
|
||||
Llama2ChatCompletionModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(),
|
||||
new ObjectMapper());
|
||||
@@ -87,5 +87,5 @@ Use the `BedrockLlama2ChatProperties` to configure the Bedrock Llama2 Chat clien
|
||||
| spring.ai.bedrock.llama2.chat.temperature | Controls the randomness of the output. Values can range over [0.0,1.0] | 0.7 |
|
||||
| spring.ai.bedrock.llama2.chat.topP | The maximum cumulative probability of tokens to consider when sampling. | AWS Bedrock default |
|
||||
| spring.ai.bedrock.llama2.chat.maxGenLen | Specify the maximum number of tokens to use in the generated response. | 300 |
|
||||
| spring.ai.bedrock.llama2.chat.model | The model id to use. See the `Llama2ChatCompletionModel` for the supported models. | meta.llama2-70b-chat-v1 |
|
||||
| spring.ai.bedrock.llama2.chat.model | The model id to use. See the `Llama2ChatModel` for the supported models. | meta.llama2-70b-chat-v1 |
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Ai21Jurassic2ChatBedrockApi extends
|
||||
* Create a new Ai21Jurassic2ChatBedrockApi instance using the default credentials provider chain, the default
|
||||
* object mapper, default temperature and topP values.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link Ai21Jurassic2ChatCompletionModel} for the supported models.
|
||||
* @param modelId The model id to use. See the {@link Ai21Jurassic2ChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
*/
|
||||
public Ai21Jurassic2ChatBedrockApi(String modelId, String region) {
|
||||
@@ -243,7 +243,7 @@ public class Ai21Jurassic2ChatBedrockApi extends
|
||||
/**
|
||||
* Ai21 Jurassic2 models version.
|
||||
*/
|
||||
public enum Ai21Jurassic2ChatCompletionModel {
|
||||
public enum Ai21Jurassic2ChatModel {
|
||||
|
||||
/**
|
||||
* ai21.j2-mid-v1
|
||||
@@ -264,7 +264,7 @@ public class Ai21Jurassic2ChatBedrockApi extends
|
||||
return id;
|
||||
}
|
||||
|
||||
Ai21Jurassic2ChatCompletionModel(String value) {
|
||||
Ai21Jurassic2ChatModel(String value) {
|
||||
this.id = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Llama2ChatBedrockApi extends
|
||||
* Create a new Llama2ChatBedrockApi instance using the default credentials provider chain, the default object
|
||||
* mapper, default temperature and topP values.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link Llama2ChatCompletionModel} for the supported models.
|
||||
* @param modelId The model id to use. See the {@link Llama2ChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
*/
|
||||
public Llama2ChatBedrockApi(String modelId, String region) {
|
||||
@@ -52,7 +52,7 @@ public class Llama2ChatBedrockApi extends
|
||||
/**
|
||||
* Create a new Llama2ChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link Llama2ChatCompletionModel} for the supported models.
|
||||
* @param modelId The model id to use. See the {@link Llama2ChatModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
@@ -161,7 +161,7 @@ public class Llama2ChatBedrockApi extends
|
||||
/**
|
||||
* Llama2 models version.
|
||||
*/
|
||||
public enum Llama2ChatCompletionModel {
|
||||
public enum Llama2ChatModel {
|
||||
|
||||
/**
|
||||
* meta.llama2-13b-chat-v1
|
||||
@@ -182,7 +182,7 @@ public class Llama2ChatBedrockApi extends
|
||||
return id;
|
||||
}
|
||||
|
||||
Llama2ChatCompletionModel(String value) {
|
||||
Llama2ChatModel(String value) {
|
||||
this.id = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatCompletionModel;
|
||||
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel;
|
||||
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatRequest;
|
||||
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatResponse;
|
||||
|
||||
@@ -35,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*")
|
||||
public class Ai21Jurassic2ChatBedrockApiIT {
|
||||
|
||||
Ai21Jurassic2ChatBedrockApi api = new Ai21Jurassic2ChatBedrockApi(
|
||||
Ai21Jurassic2ChatCompletionModel.AI21_J2_ULTRA_V1.id(), Region.US_EAST_1.id());
|
||||
Ai21Jurassic2ChatBedrockApi api = new Ai21Jurassic2ChatBedrockApi(Ai21Jurassic2ChatModel.AI21_J2_ULTRA_V1.id(),
|
||||
Region.US_EAST_1.id());
|
||||
|
||||
@Test
|
||||
public void chatCompletion() {
|
||||
|
||||
@@ -14,7 +14,7 @@ import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsPro
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatCompletionModel;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatModel;
|
||||
import org.springframework.ai.chat.Generation;
|
||||
import org.springframework.ai.parser.BeanOutputParser;
|
||||
import org.springframework.ai.parser.ListOutputParser;
|
||||
@@ -158,7 +158,7 @@ class BedrockLlama2ChatClientIT {
|
||||
|
||||
@Bean
|
||||
public Llama2ChatBedrockApi llama2Api() {
|
||||
return new Llama2ChatBedrockApi(Llama2ChatCompletionModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
return new Llama2ChatBedrockApi(Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatCompletionModel;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatModel;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatRequest;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatResponse;
|
||||
|
||||
@@ -36,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*")
|
||||
public class Llama2ChatBedrockApiIT {
|
||||
|
||||
private Llama2ChatBedrockApi llama2ChatApi = new Llama2ChatBedrockApi(
|
||||
Llama2ChatCompletionModel.LLAMA2_70B_CHAT_V1.id(), Region.US_EAST_1.id());
|
||||
private Llama2ChatBedrockApi llama2ChatApi = new Llama2ChatBedrockApi(Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
Region.US_EAST_1.id());
|
||||
|
||||
@Test
|
||||
public void chatCompletion() {
|
||||
|
||||
@@ -101,6 +101,6 @@ The prefix `spring.ai.bedrock.llama2.chat` is the property prefix that configure
|
||||
| spring.ai.bedrock.llama2.chat.max-gen-len | Specify the maximum number of tokens to use in the generated response. The model truncates the response once the generated text exceeds maxGenLen. | 300
|
||||
|====
|
||||
|
||||
Look at the Spring AI enumeration, `Llama2ChatCompletionModel` for other model IDs. The other value supported is `meta.llama2-13b-chat-v1`.
|
||||
Look at the Spring AI enumeration, `Llama2ChatModel` for other model IDs. The other value supported is `meta.llama2-13b-chat-v1`.
|
||||
|
||||
Model ID values can also be found in the https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids-arns.html[AWS Bedrock documentation for base model IDs].
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.ai.autoconfigure.bedrock.llama2;
|
||||
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatCompletionModel;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatModel;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
@@ -58,10 +58,9 @@ public class BedrockLlama2ChatProperties {
|
||||
private Integer maxGenLen = 300;
|
||||
|
||||
/**
|
||||
* The model id to use. See the {@link Llama2ChatCompletionModel} for the supported
|
||||
* models.
|
||||
* The model id to use. See the {@link Llama2ChatModel} for the supported models.
|
||||
*/
|
||||
private String model = Llama2ChatCompletionModel.LLAMA2_70B_CHAT_V1.id();
|
||||
private String model = Llama2ChatModel.LLAMA2_70B_CHAT_V1.id();
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
|
||||
@@ -28,7 +28,7 @@ import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties;
|
||||
import org.springframework.ai.bedrock.llama2.BedrockLlama2ChatClient;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatCompletionModel;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatModel;
|
||||
import org.springframework.ai.chat.Generation;
|
||||
import org.springframework.ai.prompt.Prompt;
|
||||
import org.springframework.ai.prompt.SystemPromptTemplate;
|
||||
@@ -52,7 +52,7 @@ public class BedrockLlama2ChatAutoConfigurationIT {
|
||||
"spring.ai.bedrock.aws.access-key=" + System.getenv("AWS_ACCESS_KEY_ID"),
|
||||
"spring.ai.bedrock.aws.secret-key=" + System.getenv("AWS_SECRET_ACCESS_KEY"),
|
||||
"spring.ai.bedrock.aws.region=" + Region.US_EAST_1.id(),
|
||||
"spring.ai.bedrock.llama2.chat.model=" + Llama2ChatCompletionModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
"spring.ai.bedrock.llama2.chat.model=" + Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
"spring.ai.bedrock.llama2.chat.temperature=0.5", "spring.ai.bedrock.llama2.chat.maxGenLen=500")
|
||||
.withConfiguration(AutoConfigurations.of(BedrockLlama2ChatAutoConfiguration.class));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user