Skip to content

Commit eb90411

Browse files
committed
Revert "Performance Analysis (#555)"
This reverts commit 173279a.
1 parent 37edac9 commit eb90411

File tree

16 files changed

+11
-346
lines changed

16 files changed

+11
-346
lines changed

center/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ dependencies {
5151
// compile group: 'org.postgresql', name: 'postgresql', version: '42.2.14'
5252

5353
compile group: 'org.springframework.security', name: 'spring-security-oauth2-client', version: '5.2.2.RELEASE'
54-
compile group: 'com.azure', name: 'azure-ai-openai', version: '1.0.0-beta.3'
5554

5655
compile('org.springdoc:springdoc-openapi-core:1.1.49')
5756
compile('org.springdoc:springdoc-openapi-ui:1.4.1')

center/src/main/java/com/microsoft/hydralab/center/openai/AzureOpenAIServiceClient.java

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.JSONObject;
5-
import com.azure.ai.openai.models.ChatChoice;
6-
import com.azure.ai.openai.models.ChatCompletions;
7-
import com.azure.ai.openai.models.ChatCompletionsOptions;
8-
import com.azure.ai.openai.models.ChatMessage;
9-
import com.azure.ai.openai.models.ChatRole;
10-
import com.microsoft.hydralab.center.openai.data.ChatRequest;
115
import okhttp3.MediaType;
126
import okhttp3.OkHttpClient;
137
import okhttp3.Request;
@@ -16,55 +10,23 @@
1610
import org.slf4j.Logger;
1711
import org.slf4j.LoggerFactory;
1812

19-
import com.azure.ai.openai.OpenAIClient;
20-
import com.azure.ai.openai.OpenAIClientBuilder;
21-
import com.azure.core.credential.AzureKeyCredential;
22-
23-
import java.util.ArrayList;
24-
import java.util.List;
2513
import java.util.Objects;
2614

27-
// Copyright (c) Microsoft Corporation.
15+
// Copyright (c) Microsoft Corporation.
2816
// Licensed under the MIT License.
29-
public class AzureOpenAIServiceClient {
17+
public class AzureOpenAIServiceClient {
3018
public static final String API_VERSION_CHAT = "2023-03-15-preview";
3119
public static final String API_VERSION_IMAGE = "2023-06-01-preview";
3220
private final Logger logger = LoggerFactory.getLogger(AzureOpenAIServiceClient.class);
3321
private final String apiKey;
3422
private final String endpoint;
3523
private final String deployment;
3624
OkHttpClient client = new OkHttpClient();
37-
private OpenAIClient azureClient = null;
3825

3926
public AzureOpenAIServiceClient(String apiKey, String deployment, String endpoint) {
40-
this.apiKey = apiKey == null ? "" : apiKey;
41-
this.endpoint = endpoint == null ? "" : endpoint.endsWith("/") ? endpoint.substring(0, endpoint.length() - 1) : endpoint;
42-
this.deployment = deployment == null ? "" : deployment;
43-
if (!apiKey.isEmpty()) {
44-
this.azureClient = new OpenAIClientBuilder()
45-
.endpoint(endpoint)
46-
.credential(new AzureKeyCredential(apiKey))
47-
.buildClient();
48-
}
49-
}
50-
51-
public String completion(String question) {
52-
if (azureClient == null) {
53-
return "";
54-
}
55-
List<ChatMessage> chatMessages = new ArrayList<>();
56-
chatMessages.add(new ChatMessage(ChatRole.SYSTEM, "You are a helpful assistant."));
57-
chatMessages.add(new ChatMessage(ChatRole.USER, question));
58-
59-
ChatCompletionsOptions options = new ChatCompletionsOptions(chatMessages);
60-
options.setN(1);
61-
62-
ChatCompletions chatCompletions = azureClient.getChatCompletions(deployment, options);
63-
64-
for (ChatChoice choice : chatCompletions.getChoices()) {
65-
return choice.getMessage().getContent();
66-
}
67-
return "";
27+
this.apiKey = apiKey;
28+
this.endpoint = endpoint.endsWith("/") ? endpoint.substring(0, endpoint.length() - 1) : endpoint;
29+
this.deployment = deployment;
6830
}
6931

7032
public String chatCompletion(ChatRequest request) {
@@ -74,10 +36,13 @@ public String chatCompletion(ChatRequest request) {
7436
private String callAzureOpenAIAPI(String operation, String requestBodyString, String apiVersion) {
7537
MediaType mediaType = MediaType.parse("application/json");
7638
String url = String.format("%s/openai/deployments/%s/%s?api-version=%s", endpoint, deployment, operation, apiVersion);
39+
7740
logger.info("Request body: {}", requestBodyString);
41+
7842
RequestBody body = RequestBody.create(requestBodyString, mediaType);
7943
Request httpRequest = new Request.Builder().url(url).post(body)
8044
.addHeader("api-key", apiKey).build();
45+
8146
try (Response response = client.newCall(httpRequest).execute()) {
8247
if (!response.isSuccessful()) {
8348
throw new RuntimeException("Unexpected response code: " + response);

center/src/main/java/com/microsoft/hydralab/center/openai/data/ChatMessage.java renamed to center/src/main/java/com/microsoft/hydralab/center/openai/ChatMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.microsoft.hydralab.center.openai.data;
1+
package com.microsoft.hydralab.center.openai;
22

33
import lombok.Data;
44

center/src/main/java/com/microsoft/hydralab/center/openai/data/ChatRequest.java renamed to center/src/main/java/com/microsoft/hydralab/center/openai/ChatRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.microsoft.hydralab.center.openai.data;
1+
package com.microsoft.hydralab.center.openai;
22

33
import com.alibaba.fastjson.annotation.JSONField;
44
import lombok.Data;

center/src/main/java/com/microsoft/hydralab/center/openai/SuggestionService.java

Lines changed: 0 additions & 211 deletions
This file was deleted.

center/src/main/java/com/microsoft/hydralab/center/openai/data/ExceptionSuggestion.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

center/src/main/java/com/microsoft/hydralab/center/openai/data/SimplifiedPerformanceDataSet.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

center/src/main/java/com/microsoft/hydralab/center/openai/data/SimplifiedPerformanceResult.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

center/src/main/java/com/microsoft/hydralab/center/service/DeviceAgentManagementService.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.alibaba.fastjson.JSONArray;
88
import com.alibaba.fastjson.JSONObject;
99
import com.android.ddmlib.IDevice;
10-
import com.microsoft.hydralab.center.openai.SuggestionService;
1110
import com.microsoft.hydralab.center.repository.AgentUserRepository;
1211
import com.microsoft.hydralab.center.util.MetricUtil;
1312
import com.microsoft.hydralab.common.entity.agent.MobileDevice;
@@ -111,9 +110,6 @@ public class DeviceAgentManagementService {
111110
StorageServiceClientProxy storageServiceClientProxy;
112111
@Resource
113112
StorageTokenManageService storageTokenManageService;
114-
@Resource
115-
SuggestionService suggestionService;
116-
117113
@Value("${app.storage.type}")
118114
private String storageType;
119115

@@ -287,13 +283,11 @@ private void handleQualifiedAgentMessage(Message message, AgentSessionInfo saved
287283
TestTask testTask = (TestTask) message.getBody();
288284
boolean isFinished = testTask.getStatus().equals(TestTask.TestStatus.FINISHED);
289285
testDataService.saveTestTaskDataFromAgent(testTask, isFinished, savedSession.agentUser.getId());
286+
290287
//after the task finishing, update the status of device used
291288
if (isFinished) {
292289
List<TestRun> deviceTestResults = testTask.getDeviceTestResults();
293290
for (TestRun deviceTestResult : deviceTestResults) {
294-
if (testTask.isEnablePerformanceSuggestion()) {
295-
suggestionService.performanceAnalyze(deviceTestResult);
296-
}
297291
String[] identifiers = deviceTestResult.getDeviceSerialNumber().split(",");
298292
for (String identifier : identifiers) {
299293
updateDeviceStatus(identifier, DeviceInfo.ONLINE, null);

0 commit comments

Comments
 (0)