Skip to content

Commit 09da796

Browse files
Upgrade Bedrock Claude models in integration tests to improve rate limits (#4742)
- Replace claude-3-5-sonnet with Sonnet 4.5 (us.anthropic.claude-sonnet-4-5) for vision and image tasks in RestMLRAGSearchProcessorIT - Replace claude-3-sonnet and claude-3-5-sonnet with Haiku 4.5 (us.anthropic.claude-haiku-4-5) for simple text tasks in RestMLInferenceSearchResponseProcessorIT, RestConnectorToolIT, and RestMLRAGSearchProcessorIT document chat - Use inference profile IDs (us.anthropic. prefix) required by newer models - Remove topP from inferenceConfig as newer models don't allow both temperature and topP simultaneously - Delete unused claude-v2 connector blueprints (dead code) - Simplify redundant ternary expressions for connector blueprint selection Signed-off-by: rithin-pullela-aws <rithinp@amazon.com>
1 parent 99e5671 commit 09da796

File tree

3 files changed

+34
-108
lines changed

3 files changed

+34
-108
lines changed

plugin/src/test/java/org/opensearch/ml/rest/RestConnectorToolIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RestConnectorToolIT extends RestBaseAgentToolsIT {
3131
private static final String AWS_SESSION_TOKEN = System.getenv("AWS_SESSION_TOKEN");
3232

3333
private static final String GITHUB_CI_AWS_REGION = "us-west-2";
34-
private static final String BEDROCK_ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20240620-v1:0";
34+
private static final String BEDROCK_ANTHROPIC_CLAUDE_HAIKU_4_5 = "us.anthropic.claude-haiku-4-5-20251001-v1:0";
3535

3636
private String bedrockClaudeConnectorId;
3737
private String bedrockClaudeConnectorIdForPredict;
@@ -52,8 +52,8 @@ public void setUp() throws Exception {
5252

5353
private String createBedrockClaudeConnector(String action) throws IOException, InterruptedException {
5454
String bedrockClaudeConnectorEntity = "{\n"
55-
+ " \"name\": \"Bedrock Connector: claude 3.5\",\n"
56-
+ " \"description\": \"The connector to bedrock claude 3.5 model\",\n"
55+
+ " \"name\": \"Bedrock Connector: claude haiku 4.5\",\n"
56+
+ " \"description\": \"The connector to bedrock claude haiku 4.5 model\",\n"
5757
+ " \"version\": 1,\n"
5858
+ " \"protocol\": \"aws_sigv4\",\n"
5959
+ " \"parameters\": {\n"
@@ -62,7 +62,7 @@ private String createBedrockClaudeConnector(String action) throws IOException, I
6262
+ "\",\n"
6363
+ " \"service_name\": \"bedrock\",\n"
6464
+ " \"model\": \""
65-
+ BEDROCK_ANTHROPIC_CLAUDE_3_5_SONNET
65+
+ BEDROCK_ANTHROPIC_CLAUDE_HAIKU_4_5
6666
+ "\",\n"
6767
+ " \"system_prompt\": \"You are a helpful assistant.\",\n"
6868
+ "\"response_filter\": \"$.output.message.content[0].text\""
@@ -90,9 +90,9 @@ private String createBedrockClaudeConnector(String action) throws IOException, I
9090
+ " \"url\": \"https://bedrock-runtime."
9191
+ GITHUB_CI_AWS_REGION
9292
+ ".amazonaws.com/model/"
93-
+ BEDROCK_ANTHROPIC_CLAUDE_3_5_SONNET
93+
+ BEDROCK_ANTHROPIC_CLAUDE_HAIKU_4_5
9494
+ "/converse\",\n"
95-
+ " \"request_body\": \"{ \\\"system\\\": [{\\\"text\\\": \\\"you are a helpful assistant.\\\"}], \\\"messages\\\":[{\\\"role\\\": \\\"user\\\", \\\"content\\\":[ {\\\"type\\\": \\\"text\\\", \\\"text\\\":\\\"${parameters.messages}\\\"}]}] , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"topP\\\": 0.9, \\\"maxTokens\\\": 1000} }\"\n"
95+
+ " \"request_body\": \"{ \\\"system\\\": [{\\\"text\\\": \\\"you are a helpful assistant.\\\"}], \\\"messages\\\":[{\\\"role\\\": \\\"user\\\", \\\"content\\\":[ {\\\"type\\\": \\\"text\\\", \\\"text\\\":\\\"${parameters.messages}\\\"}]}] , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"maxTokens\\\": 1000} }\"\n"
9696
+ " }\n"
9797
+ " ]\n"
9898
+ "}";

plugin/src/test/java/org/opensearch/ml/rest/RestMLInferenceSearchResponseProcessorIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public class RestMLInferenceSearchResponseProcessorIT extends MLCommonsRestTestC
113113
+ "}";
114114

115115
private final String bedrockClaudeModelConnectorEntity = "{\n"
116-
+ " \"name\": \"Bedrock Connector: claude 3.5\",\n"
117-
+ " \"description\": \"The connector to bedrock claude 3.5 model\",\n"
116+
+ " \"name\": \"Bedrock Connector: claude haiku 4.5\",\n"
117+
+ " \"description\": \"The connector to bedrock claude haiku 4.5 model\",\n"
118118
+ " \"version\": 1,\n"
119119
+ " \"protocol\": \"aws_sigv4\",\n"
120120
+ " \"client_config\": {\n"
@@ -126,7 +126,7 @@ public class RestMLInferenceSearchResponseProcessorIT extends MLCommonsRestTestC
126126
+ "\",\n"
127127
+ " \"service_name\": \"bedrock\",\n"
128128
+ " \"model\": \""
129-
+ "anthropic.claude-3-5-sonnet-20241022-v2:0"
129+
+ "us.anthropic.claude-haiku-4-5-20251001-v1:0"
130130
+ "\",\n"
131131
+ " \"system_prompt\": \"You are a helpful assistant.\",\n"
132132
+ "\"response_filter\": \"$.output.message.content[0].text\""
@@ -154,9 +154,9 @@ public class RestMLInferenceSearchResponseProcessorIT extends MLCommonsRestTestC
154154
+ " \"url\": \"https://bedrock-runtime."
155155
+ GITHUB_CI_AWS_REGION
156156
+ ".amazonaws.com/model/"
157-
+ "anthropic.claude-3-5-sonnet-20241022-v2:0"
157+
+ "us.anthropic.claude-haiku-4-5-20251001-v1:0"
158158
+ "/converse\",\n"
159-
+ " \"request_body\": \"{ \\\"system\\\": [{\\\"text\\\": \\\"you are a helpful assistant.\\\"}], \\\"messages\\\":[{\\\"role\\\": \\\"user\\\", \\\"content\\\":[ {\\\"type\\\": \\\"text\\\", \\\"text\\\":\\\"${parameters.prompt}\\\"}]}] , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"topP\\\": 0.9, \\\"maxTokens\\\": 1000} }\"\n"
159+
+ " \"request_body\": \"{ \\\"system\\\": [{\\\"text\\\": \\\"you are a helpful assistant.\\\"}], \\\"messages\\\":[{\\\"role\\\": \\\"user\\\", \\\"content\\\":[ {\\\"type\\\": \\\"text\\\", \\\"text\\\":\\\"${parameters.prompt}\\\"}]}] , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"maxTokens\\\": 1000} }\"\n"
160160
+ " }\n"
161161
+ " ]\n"
162162
+ "}";

plugin/src/test/java/org/opensearch/ml/rest/RestMLRAGSearchProcessorIT.java

Lines changed: 23 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
107107
private static final String AWS_SESSION_TOKEN = System.getenv("AWS_SESSION_TOKEN");
108108
private static final String GITHUB_CI_AWS_REGION = "us-west-2";
109109

110-
private static final String BEDROCK_ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20241022-v2:0";
111-
private static final String BEDROCK_ANTHROPIC_CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0";
110+
private static final String BEDROCK_ANTHROPIC_CLAUDE_SONNET_4_5 = "us.anthropic.claude-sonnet-4-5-20250929-v1:0";
111+
private static final String BEDROCK_ANTHROPIC_CLAUDE_HAIKU_4_5 = "us.anthropic.claude-haiku-4-5-20251001-v1:0";
112112

113113
private static final String BEDROCK_CONNECTOR_BLUEPRINT_INVOKE = "{\n"
114-
+ " \"name\": \"Bedrock Connector: claude 3.5\",\n"
115-
+ " \"description\": \"The connector to bedrock claude 3.5 model\",\n"
114+
+ " \"name\": \"Bedrock Connector: claude sonnet 4.5\",\n"
115+
+ " \"description\": \"The connector to bedrock claude sonnet 4.5 model\",\n"
116116
+ " \"version\": 1,\n"
117117
+ " \"protocol\": \"aws_sigv4\",\n"
118118
+ " \"parameters\": {\n"
@@ -121,7 +121,7 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
121121
+ "\",\n"
122122
+ " \"service_name\": \"bedrock\",\n"
123123
+ " \"model\": \""
124-
+ "anthropic.claude-3-5-sonnet-20240620-v1:0"
124+
+ "us.anthropic.claude-sonnet-4-5-20250929-v1:0"
125125
+ "\",\n"
126126
+ " \"system_prompt\": \"You are a helpful assistant.\",\n"
127127
+ "\"response_filter\": \"$.content[0].text\""
@@ -149,86 +149,16 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
149149
+ " \"url\": \"https://bedrock-runtime."
150150
+ GITHUB_CI_AWS_REGION
151151
+ ".amazonaws.com/model/"
152-
+ "anthropic.claude-3-5-sonnet-20240620-v1:0"
152+
+ "us.anthropic.claude-sonnet-4-5-20250929-v1:0"
153153
+ "/invoke\",\n"
154154
+ " \"request_body\": \"{\\\"messages\\\":[{\\\"role\\\": \\\"user\\\", \\\"content\\\":[ {\\\"type\\\": \\\"text\\\", \\\"text\\\":\\\"${parameters.inputs}\\\"}]}], \\\"max_tokens\\\":300, \\\"temperature\\\":0.5, \\\"anthropic_version\\\":\\\"bedrock-2023-05-31\\\" }\"\n"
155155
+ " }\n"
156156
+ " ]\n"
157157
+ "}";
158158

159-
private static final String BEDROCK_CONNECTOR_BLUEPRINT1 = "{\n"
160-
+ " \"name\": \"Bedrock Connector: claude2\",\n"
161-
+ " \"description\": \"The connector to bedrock claude2 model\",\n"
162-
+ " \"version\": 1,\n"
163-
+ " \"protocol\": \"aws_sigv4\",\n"
164-
+ " \"parameters\": {\n"
165-
+ " \"region\": \""
166-
+ GITHUB_CI_AWS_REGION
167-
+ "\",\n"
168-
+ " \"service_name\": \"bedrock\"\n"
169-
+ " },\n"
170-
+ " \"credential\": {\n"
171-
+ " \"access_key\": \""
172-
+ AWS_ACCESS_KEY_ID
173-
+ "\",\n"
174-
+ " \"secret_key\": \""
175-
+ AWS_SECRET_ACCESS_KEY
176-
+ "\",\n"
177-
+ " \"session_token\": \""
178-
+ AWS_SESSION_TOKEN
179-
+ "\"\n"
180-
+ " },\n"
181-
+ " \"actions\": [\n"
182-
+ " {\n"
183-
+ " \"action_type\": \"predict\",\n"
184-
+ " \"method\": \"POST\",\n"
185-
+ " \"headers\": {\n"
186-
+ " \"content-type\": \"application/json\"\n"
187-
+ " },\n"
188-
+ " \"url\": \"https://bedrock-runtime."
189-
+ GITHUB_CI_AWS_REGION
190-
+ ".amazonaws.com/model/anthropic.claude-v2/invoke\",\n"
191-
+ " \"request_body\": \"{\\\"prompt\\\":\\\"\\\\n\\\\nHuman: ${parameters.inputs}\\\\n\\\\nAssistant:\\\",\\\"max_tokens_to_sample\\\":300,\\\"temperature\\\":0.5,\\\"top_k\\\":250,\\\"top_p\\\":1,\\\"stop_sequences\\\":[\\\"\\\\\\\\n\\\\\\\\nHuman:\\\"]}\"\n"
192-
+ " }\n"
193-
+ " ]\n"
194-
+ "}";
195-
private static final String BEDROCK_CONNECTOR_BLUEPRINT2 = "{\n"
196-
+ " \"name\": \"Bedrock Connector: claude2\",\n"
197-
+ " \"description\": \"The connector to bedrock claude2 model\",\n"
198-
+ " \"version\": 1,\n"
199-
+ " \"protocol\": \"aws_sigv4\",\n"
200-
+ " \"parameters\": {\n"
201-
+ " \"region\": \""
202-
+ GITHUB_CI_AWS_REGION
203-
+ "\",\n"
204-
+ " \"service_name\": \"bedrock\"\n"
205-
+ " },\n"
206-
+ " \"credential\": {\n"
207-
+ " \"access_key\": \""
208-
+ AWS_ACCESS_KEY_ID
209-
+ "\",\n"
210-
+ " \"secret_key\": \""
211-
+ AWS_SECRET_ACCESS_KEY
212-
+ "\"\n"
213-
+ " },\n"
214-
+ " \"actions\": [\n"
215-
+ " {\n"
216-
+ " \"action_type\": \"predict\",\n"
217-
+ " \"method\": \"POST\",\n"
218-
+ " \"headers\": {\n"
219-
+ " \"content-type\": \"application/json\"\n"
220-
+ " },\n"
221-
+ " \"url\": \"https://bedrock-runtime."
222-
+ GITHUB_CI_AWS_REGION
223-
+ ".amazonaws.com/model/anthropic.claude-v2/invoke\",\n"
224-
+ " \"request_body\": \"{\\\"prompt\\\":\\\"\\\\n\\\\nHuman: ${parameters.inputs}\\\\n\\\\nAssistant:\\\",\\\"max_tokens_to_sample\\\":300,\\\"temperature\\\":0.5,\\\"top_k\\\":250,\\\"top_p\\\":1,\\\"stop_sequences\\\":[\\\"\\\\\\\\n\\\\\\\\nHuman:\\\"]}\"\n"
225-
+ " }\n"
226-
+ " ]\n"
227-
+ "}";
228-
229159
static final String BEDROCK_CONVERSE_CONNECTOR_BLUEPRINT2 = "{\n"
230-
+ " \"name\": \"Bedrock Connector: claude 3.5\",\n"
231-
+ " \"description\": \"The connector to bedrock claude 3.5 model\",\n"
160+
+ " \"name\": \"Bedrock Connector: claude sonnet 4.5\",\n"
161+
+ " \"description\": \"The connector to bedrock claude sonnet 4.5 model\",\n"
232162
+ " \"version\": 1,\n"
233163
+ " \"protocol\": \"aws_sigv4\",\n"
234164
+ " \"client_config\": {\n"
@@ -240,7 +170,7 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
240170
+ "\",\n"
241171
+ " \"service_name\": \"bedrock\",\n"
242172
+ " \"model\": \""
243-
+ BEDROCK_ANTHROPIC_CLAUDE_3_5_SONNET
173+
+ BEDROCK_ANTHROPIC_CLAUDE_SONNET_4_5
244174
+ "\",\n"
245175
+ " \"system_prompt\": \"You are a helpful assistant.\"\n"
246176
+ " },\n"
@@ -265,16 +195,16 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
265195
+ " \"url\": \"https://bedrock-runtime."
266196
+ GITHUB_CI_AWS_REGION
267197
+ ".amazonaws.com/model/"
268-
+ BEDROCK_ANTHROPIC_CLAUDE_3_5_SONNET
198+
+ BEDROCK_ANTHROPIC_CLAUDE_SONNET_4_5
269199
+ "/converse\",\n"
270-
+ " \"request_body\": \"{ \\\"system\\\": [{\\\"text\\\": \\\"you are a helpful assistant.\\\"}], \\\"messages\\\": ${parameters.messages} , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"topP\\\": 0.9, \\\"maxTokens\\\": 1000} }\"\n"
200+
+ " \"request_body\": \"{ \\\"system\\\": [{\\\"text\\\": \\\"you are a helpful assistant.\\\"}], \\\"messages\\\": ${parameters.messages} , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"maxTokens\\\": 1000} }\"\n"
271201
+ " }\n"
272202
+ " ]\n"
273203
+ "}";
274204

275205
private static final String BEDROCK_DOCUMENT_CONVERSE_CONNECTOR_BLUEPRINT2 = "{\n"
276-
+ " \"name\": \"Bedrock Connector: claude 3\",\n"
277-
+ " \"description\": \"The connector to bedrock claude 3 model\",\n"
206+
+ " \"name\": \"Bedrock Connector: claude haiku 4.5\",\n"
207+
+ " \"description\": \"The connector to bedrock claude haiku 4.5 model\",\n"
278208
+ " \"version\": 1,\n"
279209
+ " \"protocol\": \"aws_sigv4\",\n"
280210
+ " \"parameters\": {\n"
@@ -283,7 +213,7 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
283213
+ "\",\n"
284214
+ " \"service_name\": \"bedrock\",\n"
285215
+ " \"model\": \""
286-
+ BEDROCK_ANTHROPIC_CLAUDE_3_SONNET
216+
+ BEDROCK_ANTHROPIC_CLAUDE_HAIKU_4_5
287217
+ "\",\n"
288218
+ " \"system_prompt\": \"You are a helpful assistant.\"\n"
289219
+ " },\n"
@@ -308,20 +238,16 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
308238
+ " \"url\": \"https://bedrock-runtime."
309239
+ GITHUB_CI_AWS_REGION
310240
+ ".amazonaws.com/model/"
311-
+ BEDROCK_ANTHROPIC_CLAUDE_3_SONNET
241+
+ BEDROCK_ANTHROPIC_CLAUDE_HAIKU_4_5
312242
+ "/converse\",\n"
313-
+ " \"request_body\": \"{ \\\"messages\\\": ${parameters.messages} , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"topP\\\": 0.9, \\\"maxTokens\\\": 1000} }\"\n"
243+
+ " \"request_body\": \"{ \\\"messages\\\": ${parameters.messages} , \\\"inferenceConfig\\\": {\\\"temperature\\\": 0.0, \\\"maxTokens\\\": 1000} }\"\n"
314244
+ " }\n"
315245
+ " ]\n"
316246
+ "}";
317247

318-
private static final String BEDROCK_CONNECTOR_BLUEPRINT = AWS_SESSION_TOKEN == null
319-
? BEDROCK_CONNECTOR_BLUEPRINT_INVOKE
320-
: BEDROCK_CONNECTOR_BLUEPRINT_INVOKE;
248+
private static final String BEDROCK_CONNECTOR_BLUEPRINT = BEDROCK_CONNECTOR_BLUEPRINT_INVOKE;
321249

322-
private static final String BEDROCK_CONVERSE_CONNECTOR_BLUEPRINT = AWS_SESSION_TOKEN == null
323-
? BEDROCK_CONVERSE_CONNECTOR_BLUEPRINT2
324-
: BEDROCK_CONVERSE_CONNECTOR_BLUEPRINT2;
250+
private static final String BEDROCK_CONVERSE_CONNECTOR_BLUEPRINT = BEDROCK_CONVERSE_CONNECTOR_BLUEPRINT2;
325251

326252
private static final String COHERE_KEY = System.getenv("COHERE_KEY");
327253
private static final String COHERE_CONNECTOR_BLUEPRINT = "{\n"
@@ -533,8 +459,8 @@ public class RestMLRAGSearchProcessorIT extends MLCommonsRestTestCase {
533459
private static final String OPENAI_MODEL = "gpt-3.5-turbo";
534460
private static final String OPENAI_40_MODEL = "gpt-4o-mini";
535461
private static final String BEDROCK_ANTHROPIC_CLAUDE = "bedrock/anthropic-claude";
536-
private static final String BEDROCK_CONVERSE_ANTHROPIC_CLAUDE = "bedrock-converse/" + BEDROCK_ANTHROPIC_CLAUDE_3_5_SONNET;
537-
private static final String BEDROCK_CONVERSE_ANTHROPIC_CLAUDE_3 = "bedrock-converse/" + BEDROCK_ANTHROPIC_CLAUDE_3_SONNET;
462+
private static final String BEDROCK_CONVERSE_ANTHROPIC_CLAUDE_SONNET_4_5 = "bedrock-converse/" + BEDROCK_ANTHROPIC_CLAUDE_SONNET_4_5;
463+
private static final String BEDROCK_CONVERSE_ANTHROPIC_CLAUDE_HAIKU_4_5 = "bedrock-converse/" + BEDROCK_ANTHROPIC_CLAUDE_HAIKU_4_5;
538464
private static final String TEST_DOC_PATH = "org/opensearch/ml/rest/test_data/";
539465
private static Set<String> testDocs = Set.of("qa_doc1.json", "qa_doc2.json", "qa_doc3.json");
540466
private static final String DEFAULT_USER_AGENT = "Kibana";
@@ -826,7 +752,7 @@ public void testBM25WithBedrockConverse() throws Exception {
826752
SearchRequestParameters requestParameters = new SearchRequestParameters();
827753
requestParameters.source = "text";
828754
requestParameters.match = "president";
829-
requestParameters.llmModel = BEDROCK_CONVERSE_ANTHROPIC_CLAUDE;
755+
requestParameters.llmModel = BEDROCK_CONVERSE_ANTHROPIC_CLAUDE_SONNET_4_5;
830756
requestParameters.llmQuestion = "who is lincoln";
831757
requestParameters.contextSize = 5;
832758
requestParameters.interactionSize = 5;
@@ -886,7 +812,7 @@ public void testBM25WithBedrockConverseUsingLlmMessages() throws Exception {
886812

887813
requestParameters.source = "text";
888814
requestParameters.match = "president";
889-
requestParameters.llmModel = BEDROCK_CONVERSE_ANTHROPIC_CLAUDE;
815+
requestParameters.llmModel = BEDROCK_CONVERSE_ANTHROPIC_CLAUDE_SONNET_4_5;
890816
requestParameters.llmQuestion = "describe the image and answer the question: would lincoln have liked this place";
891817
requestParameters.contextSize = 5;
892818
requestParameters.interactionSize = 5;
@@ -948,7 +874,7 @@ public void testBM25WithBedrockConverseUsingLlmMessagesForDocumentChat() throws
948874
requestParameters = new SearchRequestParameters();
949875
requestParameters.source = "text";
950876
requestParameters.match = "president";
951-
requestParameters.llmModel = BEDROCK_CONVERSE_ANTHROPIC_CLAUDE_3;
877+
requestParameters.llmModel = BEDROCK_CONVERSE_ANTHROPIC_CLAUDE_HAIKU_4_5;
952878
requestParameters.llmQuestion = "use the information from the attached document to tell me something interesting about lincoln";
953879
requestParameters.contextSize = 5;
954880
requestParameters.interactionSize = 5;

0 commit comments

Comments
 (0)