Skip to content

Commit 133ef4e

Browse files
Missing a few changes
1 parent c211d83 commit 133ef4e

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/custom/response/ErrorResponseParser.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
package org.elasticsearch.xpack.inference.services.custom.response;
99

10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
12+
import org.elasticsearch.common.Strings;
1013
import org.elasticsearch.common.ValidationException;
1114
import org.elasticsearch.common.io.stream.StreamInput;
1215
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -31,6 +34,7 @@
3134

3235
public class ErrorResponseParser implements ToXContentFragment, Function<HttpResult, ErrorResponse> {
3336

37+
private static final Logger logger = LogManager.getLogger(ErrorResponseParser.class);
3438
public static final String MESSAGE_PATH = "path";
3539

3640
private final String messagePath;
@@ -90,7 +94,6 @@ public ErrorResponse apply(HttpResult httpResult) {
9094
.createParser(XContentParserConfiguration.EMPTY, httpResult.body())
9195
) {
9296
var map = jsonParser.map();
93-
9497
// NOTE: This deviates from what we've done in the past. In the ErrorMessageResponseEntity logic
9598
// if we find the top level error field we'll return a response with an empty message but indicate
9699
// that we found the structure of the error object. Here if we're missing the final field we will return
@@ -101,7 +104,14 @@ public ErrorResponse apply(HttpResult httpResult) {
101104
var errorText = toType(MapPathExtractor.extract(map, messagePath).extractedObject(), String.class, messagePath);
102105
return new ErrorResponse(errorText);
103106
} catch (Exception e) {
104-
// swallow the error
107+
logger.info(
108+
Strings.format(
109+
"Failed to parse error object for custom service inference id [%s], message path: [%s]",
110+
httpResult.request().inferenceEntityId(),
111+
messagePath
112+
),
113+
e
114+
);
105115
}
106116

107117
return ErrorResponse.UNDEFINED_ERROR;

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/custom/CustomServiceTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.elasticsearch.action.support.PlainActionFuture;
1111
import org.elasticsearch.core.Nullable;
12+
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
1213
import org.elasticsearch.inference.InferenceServiceResults;
1314
import org.elasticsearch.inference.InputType;
1415
import org.elasticsearch.inference.Model;
@@ -227,9 +228,12 @@ private static CustomModel createInternalEmbeddingModel(
227228
TaskType.TEXT_EMBEDDING,
228229
CustomService.NAME,
229230
new CustomServiceSettings(
230-
similarityMeasure,
231-
123,
232-
456,
231+
new CustomServiceSettings.TextEmbeddingSettings(
232+
SimilarityMeasure.DOT_PRODUCT,
233+
123,
234+
456,
235+
DenseVectorFieldMapper.ElementType.FLOAT
236+
),
233237
url,
234238
Map.of("key", "value"),
235239
QueryParameters.EMPTY,
@@ -249,9 +253,7 @@ private static CustomModel createCustomModel(TaskType taskType, CustomResponsePa
249253
taskType,
250254
CustomService.NAME,
251255
new CustomServiceSettings(
252-
null,
253-
null,
254-
null,
256+
CustomServiceSettings.TextEmbeddingSettings.EMPTY,
255257
url,
256258
Map.of("key", "value"),
257259
QueryParameters.EMPTY,

0 commit comments

Comments
 (0)