Skip to content

Commit b6f5e34

Browse files
committed
Removed downcasting and using moveToFirstToken
1 parent ca1b6d5 commit b6f5e34

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ protected void doInfer(
222222
return;
223223
}
224224

225-
var completionModel = (GoogleVertexAiCompletionModel) model;
225+
GoogleVertexAiModel googleVertexAiModel = (GoogleVertexAiModel) model;
226226

227227
var actionCreator = new GoogleVertexAiActionCreator(getSender(), getServiceComponents());
228228

229-
var action = completionModel.accept(actionCreator, taskSettings);
229+
var action = googleVertexAiModel.accept(actionCreator, taskSettings);
230230
action.execute(inputs, timeout, listener);
231231
}
232232

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.io.IOException;
2222
import java.nio.charset.StandardCharsets;
2323

24+
import static org.elasticsearch.xpack.inference.external.response.XContentUtils.moveToFirstToken;
25+
2426
public class GoogleVertexAiCompletionResponseEntity {
2527
/**
2628
* Parses the response from Google Vertex AI's generateContent endpoint
@@ -91,7 +93,7 @@ public static InferenceServiceResults fromResponse(Request request, HttpResult r
9193
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
9294
.createParser(XContentParserConfiguration.EMPTY, responseJson)
9395
) {
94-
parser.nextToken();
96+
moveToFirstToken(parser);
9597
chunk = GoogleVertexAiUnifiedStreamingProcessor.GoogleVertexAiChatCompletionChunkParser.parse(parser);
9698
}
9799
var results = chunk.choices().stream().map(choice -> choice.delta().content()).map(ChatCompletionResults.Result::new).toList();

0 commit comments

Comments
 (0)