AWS code-library documentation change
Summary
Removed AI21 Labs Jurassic-2 model documentation and code examples from Bedrock Runtime guide
Security assessment
The changes remove references to AI21 Labs Jurassic-2 model integration examples but show no evidence of addressing security vulnerabilities. This appears to be routine documentation maintenance rather than security-related updates. No security advisories, vulnerability fixes, or security feature additions are mentioned in the diff.
Diff
diff --git a/code-library/latest/ug/java_2_bedrock-runtime_code_examples.md b/code-library/latest/ug/java_2_bedrock-runtime_code_examples.md index 734dd8f19..69c8132d5 100644 --- a//code-library/latest/ug/java_2_bedrock-runtime_code_examples.md +++ b//code-library/latest/ug/java_2_bedrock-runtime_code_examples.md @@ -5 +5 @@ -ScenariosAI21 Labs Jurassic-2Amazon NovaAmazon Nova CanvasAmazon Titan Image GeneratorAmazon Titan TextAmazon Titan Text EmbeddingsAnthropic ClaudeCohere CommandMeta LlamaMistral AIStable Diffusion +ScenariosAmazon NovaAmazon Nova CanvasAmazon Titan Image GeneratorAmazon Titan TextAmazon Titan Text EmbeddingsAnthropic ClaudeCohere CommandMeta LlamaMistral AIStable Diffusion @@ -21,2 +20,0 @@ Each example includes a link to the complete source code, where you can find ins - * AI21 Labs Jurassic-2 - @@ -691,242 +688,0 @@ The Converse API action with a tool configuration. -## AI21 Labs Jurassic-2 - -The following code example shows how to send a text message to AI21 Labs Jurassic-2, using Bedrock's Converse API. - -**SDK for Java 2.x** - - -###### Note - -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/bedrock-runtime#code-examples). - -Send a text message to AI21 Labs Jurassic-2, using Bedrock's Converse API. - - - // Use the Converse API to send a text message to AI21 Labs Jurassic-2. - - import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; - import software.amazon.awssdk.core.exception.SdkClientException; - import software.amazon.awssdk.regions.Region; - import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; - import software.amazon.awssdk.services.bedrockruntime.model.ContentBlock; - import software.amazon.awssdk.services.bedrockruntime.model.ConversationRole; - import software.amazon.awssdk.services.bedrockruntime.model.ConverseResponse; - import software.amazon.awssdk.services.bedrockruntime.model.Message; - - public class Converse { - - public static String converse() { - - // Create a Bedrock Runtime client in the AWS Region you want to use. - // Replace the DefaultCredentialsProvider with your preferred credentials provider. - var client = BedrockRuntimeClient.builder() - .credentialsProvider(DefaultCredentialsProvider.create()) - .region(Region.US_EAST_1) - .build(); - - // Set the model ID, e.g., Jurassic-2 Mid. - var modelId = "ai21.j2-mid-v1"; - - // Create the input text and embed it in a message object with the user role. - var inputText = "Describe the purpose of a 'hello world' program in one line."; - var message = Message.builder() - .content(ContentBlock.fromText(inputText)) - .role(ConversationRole.USER) - .build(); - - try { - // Send the message with a basic inference configuration. - ConverseResponse response = client.converse(request -> request - .modelId(modelId) - .messages(message) - .inferenceConfig(config -> config - .maxTokens(512) - .temperature(0.5F) - .topP(0.9F))); - - // Retrieve the generated text from Bedrock's response object. - var responseText = response.output().message().content().get(0).text(); - System.out.println(responseText); - - return responseText; - - } catch (SdkClientException e) { - System.err.printf("ERROR: Can't invoke '%s'. Reason: %s", modelId, e.getMessage()); - throw new RuntimeException(e); - } - } - - public static void main(String[] args) { - converse(); - } - } - - - -Send a text message to AI21 Labs Jurassic-2, using Bedrock's Converse API with the async Java client. - - - // Use the Converse API to send a text message to AI21 Labs Jurassic-2 - // with the async Java client. - - import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; - import software.amazon.awssdk.regions.Region; - import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; - import software.amazon.awssdk.services.bedrockruntime.model.ContentBlock; - import software.amazon.awssdk.services.bedrockruntime.model.ConversationRole; - import software.amazon.awssdk.services.bedrockruntime.model.Message; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class ConverseAsync { - - public static String converseAsync() { - - // Create a Bedrock Runtime client in the AWS Region you want to use. - // Replace the DefaultCredentialsProvider with your preferred credentials provider. - var client = BedrockRuntimeAsyncClient.builder() - .credentialsProvider(DefaultCredentialsProvider.create()) - .region(Region.US_EAST_1) - .build(); - - // Set the model ID, e.g., Jurassic-2 Mid. - var modelId = "ai21.j2-mid-v1"; - - // Create the input text and embed it in a message object with the user role. - var inputText = "Describe the purpose of a 'hello world' program in one line."; - var message = Message.builder() - .content(ContentBlock.fromText(inputText)) - .role(ConversationRole.USER) - .build(); - - // Send the message with a basic inference configuration. - var request = client.converse(params -> params - .modelId(modelId) - .messages(message) - .inferenceConfig(config -> config - .maxTokens(512) - .temperature(0.5F) - .topP(0.9F)) - ); - - // Prepare a future object to handle the asynchronous response. - CompletableFuture<String> future = new CompletableFuture<>(); - - // Handle the response or error using the future object. - request.whenComplete((response, error) -> { - if (error == null) { - // Extract the generated text from Bedrock's response object. - String responseText = response.output().message().content().get(0).text(); - future.complete(responseText); - } else { - future.completeExceptionally(error); - } - }); - - try { - // Wait for the future object to complete and retrieve the generated text. - String responseText = future.get(); - System.out.println(responseText); - - return responseText; - - } catch (ExecutionException | InterruptedException e) { - System.err.printf("Can't invoke '%s': %s", modelId, e.getMessage()); - throw new RuntimeException(e); - } - } - - public static void main(String[] args) { - converseAsync(); - } - } - - - - * For API details, see [Converse](https://docs.aws.amazon.com/goto/SdkForJavaV2/bedrock-runtime-2023-09-30/Converse) in _AWS SDK for Java 2.x API Reference_. - - - - -The following code example shows how to send a text message to AI21 Labs Jurassic-2, using the Invoke Model API. - -**SDK for Java 2.x** - - -###### Note - -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/bedrock-runtime#code-examples). - -Use the Invoke Model API to send a text message. - - - // Use the native inference API to send a text message to AI21 Labs Jurassic-2. - - import org.json.JSONObject; - import org.json.JSONPointer; - import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; - import software.amazon.awssdk.core.SdkBytes; - import software.amazon.awssdk.core.exception.SdkClientException; - import software.amazon.awssdk.regions.Region; - import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; - - public class InvokeModel { - - public static String invokeModel() { - - // Create a Bedrock Runtime client in the AWS Region you want to use. - // Replace the DefaultCredentialsProvider with your preferred credentials provider.