Skip to content

Commit ce555bc

Browse files
nathaliellenaagithub-actions[bot]
authored andcommitted
Add deepseek as a trusted endpoint. (#3440)
Signed-off-by: Nathalie Jonathan <nathhjo@amazon.com> (cherry picked from commit 06a6021)
1 parent a852152 commit ce555bc

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ private MLCommonsSettings() {}
165165
"^https://api\\.sagemaker\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",
166166
"^https://api\\.openai\\.com/.*$",
167167
"^https://api\\.cohere\\.ai/.*$",
168+
"^https://api\\.deepseek\\.com/.*$",
168169
"^https://bedrock-runtime\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",
169170
"^https://bedrock-agent-runtime\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",
170171
"^https://bedrock\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",

plugin/src/test/java/org/opensearch/ml/action/connector/TransportCreateConnectorActionTests.java

+59-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ public class TransportCreateConnectorActionTests extends OpenSearchTestCase {
118118
private ArgumentCaptor<PutDataObjectRequest> putDataObjectRequestArgumentCaptor;
119119

120120
private static final List<String> TRUSTED_CONNECTOR_ENDPOINTS_REGEXES = ImmutableList
121-
.of("^https://runtime\\.sagemaker\\..*\\.amazonaws\\.com/.*$", "^https://api\\.openai\\.com/.*$", "^https://api\\.cohere\\.ai/.*$");
121+
.of(
122+
"^https://runtime\\.sagemaker\\..*\\.amazonaws\\.com/.*$",
123+
"^https://api\\.openai\\.com/.*$",
124+
"^https://api\\.cohere\\.ai/.*$",
125+
"^https://api\\.deepseek\\.com/.*$"
126+
);
122127

123128
@Before
124129
public void setup() {
@@ -539,4 +544,57 @@ public void test_execute_URL_notMatchingExpression_exception() {
539544
argumentCaptor.getValue().getMessage()
540545
);
541546
}
547+
548+
public void test_connector_creation_success_deepseek() {
549+
TransportCreateConnectorAction action = new TransportCreateConnectorAction(
550+
transportService,
551+
actionFilters,
552+
mlIndicesHandler,
553+
client,
554+
sdkClient,
555+
mlEngine,
556+
connectorAccessControlHelper,
557+
settings,
558+
clusterService,
559+
mlModelManager,
560+
mlFeatureEnabledSetting
561+
);
562+
doAnswer(invocation -> {
563+
ActionListener<Boolean> listener = invocation.getArgument(0);
564+
listener.onResponse(true);
565+
return null;
566+
}).when(mlIndicesHandler).initMLConnectorIndex(isA(ActionListener.class));
567+
568+
doAnswer(invocation -> {
569+
ActionListener<IndexResponse> listener = invocation.getArgument(1);
570+
listener.onResponse(indexResponse);
571+
return null;
572+
}).when(client).index(any(IndexRequest.class), isA(ActionListener.class));
573+
574+
List<ConnectorAction> actions = new ArrayList<>();
575+
actions
576+
.add(
577+
ConnectorAction
578+
.builder()
579+
.actionType(ConnectorAction.ActionType.PREDICT)
580+
.method("POST")
581+
.url("https://api.deepseek.com/v1/chat/completions")
582+
.build()
583+
);
584+
585+
Map<String, String> credential = ImmutableMap.of("access_key", "mockKey", "secret_key", "mockSecret");
586+
MLCreateConnectorInput mlCreateConnectorInput = MLCreateConnectorInput
587+
.builder()
588+
.name(randomAlphaOfLength(5))
589+
.description(randomAlphaOfLength(10))
590+
.version("1")
591+
.protocol(ConnectorProtocols.HTTP)
592+
.credential(credential)
593+
.actions(actions)
594+
.build();
595+
596+
MLCreateConnectorRequest request = new MLCreateConnectorRequest(mlCreateConnectorInput);
597+
action.doExecute(task, request, actionListener);
598+
verify(actionListener).onResponse(any(MLCreateConnectorResponse.class));
599+
}
542600
}

0 commit comments

Comments
 (0)