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

[Backport 2.19] Remove the integ test case cause cohere classify is deprecated in its llm service #3532

Merged
merged 1 commit into from
Feb 12, 2025
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 @@ -740,120 +740,6 @@ public void testCohereGenerateTextModel() throws IOException, InterruptedExcepti
assertFalse(((String) responseMap.get("text")).isEmpty());
}

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"
+ " \"version\": 1,\n"
+ " \"client_config\": {\n"
+ " \"max_connection\": 20,\n"
+ " \"connection_timeout\": 50000,\n"
+ " \"read_timeout\": 50000\n"
+ " },\n"
+ " \"protocol\": \"http\",\n"
+ " \"parameters\": {\n"
+ " \"endpoint\": \"api.cohere.ai\",\n"
+ " \"auth\": \"API_Key\",\n"
+ " \"content_type\": \"application/json\",\n"
+ " \"max_tokens\": \"20\"\n"
+ " },\n"
+ " \"credential\": {\n"
+ " \"cohere_key\": \""
+ COHERE_KEY
+ "\"\n"
+ " },\n"
+ " \"actions\": [\n"
+ " {\n"
+ " \"action_type\": \"predict\",\n"
+ " \"method\": \"POST\",\n"
+ " \"url\": \"https://${parameters.endpoint}/v1/classify\",\n"
+ " \"headers\": { \n"
+ " \"Authorization\": \"Bearer ${credential.cohere_key}\"\n"
+ " },\n"
+ " \"request_body\": \"{ \\\"inputs\\\": ${parameters.inputs}, \\\"examples\\\": ${parameters.examples}, \\\"truncate\\\": \\\"END\\\" }\"\n"
+ " }\n"
+ " ]\n"
+ "}";
Response response = createConnector(entity);
Map responseMap = parseResponseToMap(response);
String connectorId = (String) responseMap.get("connector_id");
response = registerRemoteModel("cohere classify model", connectorId);
responseMap = parseResponseToMap(response);
String taskId = (String) responseMap.get("task_id");
waitForTask(taskId, MLTaskState.COMPLETED);
response = getTask(taskId);
responseMap = parseResponseToMap(response);
String modelId = (String) responseMap.get("model_id");
response = deployRemoteModel(modelId);
responseMap = parseResponseToMap(response);
taskId = (String) responseMap.get("task_id");
waitForTask(taskId, MLTaskState.COMPLETED);
String predictInput = "{\n"
+ " \"parameters\": {\n"
+ " \"inputs\": [\n"
+ " \"Confirm your email address\",\n"
+ " \"hey i need u to send some $\"\n"
+ " ],\n"
+ " \"examples\": [\n"
+ " {\n"
+ " \"text\": \"Dermatologists don't like her!\",\n"
+ " \"label\": \"Spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Hello, open to this?\",\n"
+ " \"label\": \"Spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"I need help please wire me $1000 right now\",\n"
+ " \"label\": \"Spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Nice to know you ;)\",\n"
+ " \"label\": \"Spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Please help me?\",\n"
+ " \"label\": \"Spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Your parcel will be delivered today\",\n"
+ " \"label\": \"Not spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Review changes to our Terms and Conditions\",\n"
+ " \"label\": \"Not spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Weekly sync notes\",\n"
+ " \"label\": \"Not spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Re: Follow up from todays meeting\",\n"
+ " \"label\": \"Not spam\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Pre-read for tomorrow\",\n"
+ " \"label\": \"Not spam\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";

response = predictRemoteModel(modelId, predictInput);
responseMap = parseResponseToMap(response);
List responseList = (List) responseMap.get("inference_results");
responseMap = (Map) responseList.get(0);
responseList = (List) responseMap.get("output");
responseMap = (Map) responseList.get(0);
responseMap = (Map) responseMap.get("dataAsMap");
responseList = (List) responseMap.get("classifications");
assertFalse(responseList.isEmpty());
}

public static Response createConnector(String input) throws IOException {
try {
return TestHelper.makeRequest(client(), "POST", "/_plugins/_ml/connectors/_create", null, TestHelper.toHttpEntity(input), null);
Expand Down
Loading