Skip to content

Commit 59862c6

Browse files
committed
Removed GoogleVertexAiChatCompletionResponseEntity and refactored code around it.
1 parent 848dc7a commit 59862c6

File tree

5 files changed

+6
-351
lines changed

5 files changed

+6
-351
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiCompletionRequestManager.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.elasticsearch.xpack.inference.external.http.sender.UnifiedChatInput;
2020
import org.elasticsearch.xpack.inference.services.googlevertexai.completion.GoogleVertexAiChatCompletionModel;
2121
import org.elasticsearch.xpack.inference.services.googlevertexai.request.GoogleVertexAiUnifiedChatCompletionRequest;
22-
import org.elasticsearch.xpack.inference.services.googlevertexai.response.GoogleVertexAiChatCompletionResponseEntity;
2322

2423
import java.util.Objects;
2524
import java.util.function.Supplier;
@@ -31,10 +30,7 @@ public class GoogleVertexAiCompletionRequestManager extends GoogleVertexAiReques
3130
private static final ResponseHandler HANDLER = createGoogleVertexAiResponseHandler();
3231

3332
private static ResponseHandler createGoogleVertexAiResponseHandler() {
34-
return new GoogleVertexAiUnifiedChatCompletionResponseHandler(
35-
"Google Vertex AI chat completion",
36-
GoogleVertexAiChatCompletionResponseEntity::fromResponse
37-
);
33+
return new GoogleVertexAiUnifiedChatCompletionResponseHandler("Google Vertex AI chat completion");
3834
}
3935

4036
private final GoogleVertexAiChatCompletionModel model;

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiUnifiedChatCompletionResponseHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public class GoogleVertexAiUnifiedChatCompletionResponseHandler extends GoogleVe
4141
private static final String ERROR_MESSAGE_FIELD = "message";
4242
private static final String ERROR_STATUS_FIELD = "status";
4343

44-
public GoogleVertexAiUnifiedChatCompletionResponseHandler(String requestType, ResponseParser parseFunction) {
45-
super(requestType, parseFunction, GoogleVertexAiErrorResponse::fromResponse, true);
44+
private static final ResponseParser noopParseFunction = (a, b) -> null;
45+
46+
public GoogleVertexAiUnifiedChatCompletionResponseHandler(String requestType) {
47+
super(requestType, noopParseFunction, GoogleVertexAiErrorResponse::fromResponse, true);
4648
}
4749

4850
@Override

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/response/GoogleVertexAiChatCompletionResponseEntity.java

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

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiUnifiedChatCompletionResponseHandlerTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ public class GoogleVertexAiUnifiedChatCompletionResponseHandlerTests extends EST
3333
private static final String INFERENCE_ID = "vertexAiInference";
3434

3535
private final GoogleVertexAiUnifiedChatCompletionResponseHandler responseHandler =
36-
new GoogleVertexAiUnifiedChatCompletionResponseHandler(
37-
"chat_completion",
38-
(parser, xContentRegistry) -> mock() // Dummy parse function, not used in these error tests
39-
);
36+
new GoogleVertexAiUnifiedChatCompletionResponseHandler("chat_completion");
4037

4138
public void testFailValidationWithAllErrorFields() throws IOException {
4239
var responseJson = """

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/response/GoogleVertexAiChatCompletionResponseEntityTests.java

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

0 commit comments

Comments
 (0)