Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null key check for remote inference integration tests #1113

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

public class RestMLRemoteInferenceIT extends MLCommonsRestTestCase {

private final String OPENAI_KEY = System.getenv("OPENAI_KEY");
private final String COHERE_KEY = System.getenv("COHERE_KEY");

private final String completionModelConnectorEntity = "{\n"
+ "\"name\": \"OpenAI Connector\",\n"
+ "\"description\": \"The connector to public OpenAI model service for GPT 3.5\",\n"
Expand All @@ -39,7 +42,7 @@ public class RestMLRemoteInferenceIT extends MLCommonsRestTestCase {
+ " },\n"
+ " \"credential\": {\n"
+ " \"openAI_key\": \""
+ System.getenv("OPENAI_KEY")
+ OPENAI_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
Expand Down Expand Up @@ -133,6 +136,10 @@ public void testDeployRemoteModel() throws IOException, InterruptedException {

@Ignore
public void testPredictRemoteModel() throws IOException, InterruptedException {
// Skip test if key is null
if (OPENAI_KEY == null) {
return;
}
Response response = createConnector(completionModelConnectorEntity);
Map responseMap = parseResponseToMap(response);
String connectorId = (String) responseMap.get("connector_id");
Expand Down Expand Up @@ -186,6 +193,10 @@ public void testUndeployRemoteModel() throws IOException, InterruptedException {

@Ignore
public void testOpenAIChatCompletionModel() throws IOException, InterruptedException {
// Skip test if key is null
if (OPENAI_KEY == null) {
return;
}
String entity = "{\n"
+ " \"name\": \"OpenAI chat model Connector\",\n"
+ " \"description\": \"The connector to public OpenAI model service for GPT 3.5\",\n"
Expand All @@ -201,7 +212,7 @@ public void testOpenAIChatCompletionModel() throws IOException, InterruptedExcep
+ " },\n"
+ " \"credential\": {\n"
+ " \"openAI_key\": \""
+ System.getenv("OPENAI_KEY")
+ OPENAI_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
Expand Down Expand Up @@ -243,6 +254,10 @@ public void testOpenAIChatCompletionModel() throws IOException, InterruptedExcep

@Ignore
public void testOpenAIEditsModel() throws IOException, InterruptedException {
// Skip test if key is null
if (OPENAI_KEY == null) {
return;
}
String entity = "{\n"
+ " \"name\": \"OpenAI Edit model Connector\",\n"
+ " \"description\": \"The connector to public OpenAI edit model service\",\n"
Expand All @@ -256,7 +271,7 @@ public void testOpenAIEditsModel() throws IOException, InterruptedException {
+ " },\n"
+ " \"credential\": {\n"
+ " \"openAI_key\": \""
+ System.getenv("OPENAI_KEY")
+ OPENAI_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
Expand Down Expand Up @@ -309,6 +324,10 @@ public void testOpenAIEditsModel() throws IOException, InterruptedException {

@Ignore
public void testOpenAIModerationsModel() throws IOException, InterruptedException {
// Skip test if key is null
if (OPENAI_KEY == null) {
return;
}
String entity = "{\n"
+ " \"name\": \"OpenAI moderations model Connector\",\n"
+ " \"description\": \"The connector to public OpenAI moderations model service\",\n"
Expand All @@ -322,7 +341,7 @@ public void testOpenAIModerationsModel() throws IOException, InterruptedExceptio
+ " },\n"
+ " \"credential\": {\n"
+ " \"openAI_key\": \""
+ System.getenv("OPENAI_KEY")
+ OPENAI_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
Expand Down Expand Up @@ -372,6 +391,10 @@ public void testOpenAIModerationsModel() throws IOException, InterruptedExceptio

@Ignore
public void testOpenAITextEmbeddingModel() throws IOException, InterruptedException {
// Skip test if key is null
if (OPENAI_KEY == null) {
return;
}
String entity = "{\n"
+ " \"name\": \"OpenAI text embedding model Connector\",\n"
+ " \"description\": \"The connector to public OpenAI text embedding model service\",\n"
Expand All @@ -385,7 +408,7 @@ public void testOpenAITextEmbeddingModel() throws IOException, InterruptedExcept
+ " },\n"
+ " \"credential\": {\n"
+ " \"openAI_key\": \""
+ System.getenv("OPENAI_KEY")
+ OPENAI_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
Expand Down Expand Up @@ -430,6 +453,10 @@ public void testOpenAITextEmbeddingModel() throws IOException, InterruptedExcept
}

public void testCohereGenerateTextModel() throws IOException, InterruptedException {
// Skip test if key is null
if (COHERE_KEY == null) {
return;
}
String entity = "{\n"
+ " \"name\": \"Cohere generate text model Connector\",\n"
+ " \"description\": \"The connector to public Cohere generate text model service\",\n"
Expand All @@ -443,7 +470,7 @@ public void testCohereGenerateTextModel() throws IOException, InterruptedExcepti
+ " },\n"
+ " \"credential\": {\n"
+ " \"cohere_key\": \""
+ System.getenv("COHERE_KEY")
+ COHERE_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
Expand Down Expand Up @@ -491,6 +518,10 @@ public void testCohereGenerateTextModel() throws IOException, InterruptedExcepti
}

public void testCohereClassifyModel() throws IOException, InterruptedException {
// Skip test if key is null
if (COHERE_KEY == null) {
return;
}
String entity = "{\n"
+ " \"name\": \"Cohere classify model Connector\",\n"
+ " \"description\": \"The connector to public Cohere classify model service\",\n"
Expand All @@ -504,7 +535,7 @@ public void testCohereClassifyModel() throws IOException, InterruptedException {
+ " },\n"
+ " \"credential\": {\n"
+ " \"cohere_key\": \""
+ System.getenv("COHERE_KEY")
+ COHERE_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
Expand Down