|
@@ -9,13 +9,13 @@ package org.elasticsearch.xpack.inference.external.request.elastic;
|
|
|
|
|
|
import org.apache.http.HttpHeaders;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.client.methods.HttpRequestBase;
|
|
|
import org.apache.http.entity.ByteArrayEntity;
|
|
|
import org.apache.http.message.BasicHeader;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.inference.InputType;
|
|
|
import org.elasticsearch.xcontent.XContentType;
|
|
|
import org.elasticsearch.xpack.inference.common.Truncator;
|
|
|
-import org.elasticsearch.xpack.inference.external.request.HttpRequest;
|
|
|
import org.elasticsearch.xpack.inference.external.request.Request;
|
|
|
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceSparseEmbeddingsModel;
|
|
|
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceUsageContext;
|
|
@@ -26,7 +26,7 @@ import java.net.URI;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
-public class ElasticInferenceServiceSparseEmbeddingsRequest implements ElasticInferenceServiceRequest {
|
|
|
+public class ElasticInferenceServiceSparseEmbeddingsRequest extends ElasticInferenceServiceRequest {
|
|
|
|
|
|
private final URI uri;
|
|
|
private final ElasticInferenceServiceSparseEmbeddingsModel model;
|
|
@@ -40,8 +40,10 @@ public class ElasticInferenceServiceSparseEmbeddingsRequest implements ElasticIn
|
|
|
Truncator.TruncationResult truncationResult,
|
|
|
ElasticInferenceServiceSparseEmbeddingsModel model,
|
|
|
TraceContext traceContext,
|
|
|
+ String productOrigin,
|
|
|
InputType inputType
|
|
|
) {
|
|
|
+ super(productOrigin);
|
|
|
this.truncator = truncator;
|
|
|
this.truncationResult = truncationResult;
|
|
|
this.model = Objects.requireNonNull(model);
|
|
@@ -51,7 +53,7 @@ public class ElasticInferenceServiceSparseEmbeddingsRequest implements ElasticIn
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRequest createHttpRequest() {
|
|
|
+ public HttpRequestBase createHttpRequestBase() {
|
|
|
var httpPost = new HttpPost(uri);
|
|
|
var usageContext = inputTypeToUsageContext(inputType);
|
|
|
var requestEntity = Strings.toString(
|
|
@@ -68,7 +70,7 @@ public class ElasticInferenceServiceSparseEmbeddingsRequest implements ElasticIn
|
|
|
traceContextHandler.propagateTraceContext(httpPost);
|
|
|
httpPost.setHeader(new BasicHeader(HttpHeaders.CONTENT_TYPE, XContentType.JSON.mediaType()));
|
|
|
|
|
|
- return new HttpRequest(httpPost, getInferenceEntityId());
|
|
|
+ return httpPost;
|
|
|
}
|
|
|
|
|
|
public TraceContext getTraceContext() {
|
|
@@ -93,6 +95,7 @@ public class ElasticInferenceServiceSparseEmbeddingsRequest implements ElasticIn
|
|
|
truncatedInput,
|
|
|
model,
|
|
|
traceContextHandler.traceContext(),
|
|
|
+ getProductOrigin(),
|
|
|
inputType
|
|
|
);
|
|
|
}
|