Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle committed Dec 13, 2024
1 parent 430ae9d commit baf0373
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
import org.elasticsearch.inference.ChunkedInferenceServiceResults;
import org.elasticsearch.inference.EmptySettingsConfiguration;
import org.elasticsearch.inference.InferenceChunks;
import org.elasticsearch.inference.InferenceServiceConfiguration;
Expand All @@ -39,7 +38,6 @@
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceEmbeddingFloat;
import org.elasticsearch.xpack.core.inference.results.InferenceChunkedTextEmbeddingFloatResults;
import org.elasticsearch.xpack.core.inference.results.InferenceTextEmbeddingFloatResults;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.elasticsearch.common.util.LazyInitializable;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.inference.ChunkedInferenceServiceResults;
import org.elasticsearch.inference.EmptySettingsConfiguration;
import org.elasticsearch.inference.InferenceChunks;
import org.elasticsearch.inference.InferenceServiceConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.elasticsearch.common.util.LazyInitializable;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.inference.ChunkedInferenceServiceResults;
import org.elasticsearch.inference.EmptySettingsConfiguration;
import org.elasticsearch.inference.InferenceChunks;
import org.elasticsearch.inference.InferenceServiceConfiguration;
Expand All @@ -37,9 +36,7 @@
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceEmbeddingSparse;
import org.elasticsearch.xpack.core.inference.results.InferenceChunkedSparseEmbeddingResults;
import org.elasticsearch.xpack.core.inference.results.SparseEmbeddingResults;
import org.elasticsearch.xpack.core.ml.inference.results.MlChunkedTextExpansionResults;
import org.elasticsearch.xpack.core.ml.search.WeightedToken;

import java.io.IOException;
Expand Down Expand Up @@ -178,8 +175,13 @@ private List<InferenceChunks> makeChunkedResults(List<String> input) {
}
results.add(
new ChunkedInferenceEmbeddingSparse(
List.of(new ChunkedInferenceEmbeddingSparse.SparseEmbeddingChunk(tokens, input.get(i),
new InferenceChunks.TextOffset(0, input.get(i).length())))
List.of(
new ChunkedInferenceEmbeddingSparse.SparseEmbeddingChunk(
tokens,
input.get(i),
new InferenceChunks.TextOffset(0, input.get(i).length())
)
)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.elasticsearch.common.xcontent.ChunkedToXContent;
import org.elasticsearch.common.xcontent.ChunkedToXContentHelper;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.inference.ChunkedInferenceServiceResults;
import org.elasticsearch.inference.EmptySettingsConfiguration;
import org.elasticsearch.inference.InferenceChunks;
import org.elasticsearch.inference.InferenceServiceConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.elasticsearch.inference.UnparsedModel;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.xpack.core.inference.results.ErrorChunkedInferenceResults;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceError;
import org.elasticsearch.xpack.inference.mapper.SemanticTextField;
import org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper;
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
Expand Down Expand Up @@ -282,11 +282,11 @@ public void onResponse(List<InferenceChunks> results) {
for (InferenceChunks result : results) {
var request = requestsIterator.next();
var acc = inferenceResults.get(request.index);
if (result instanceof ErrorChunkedInferenceResults error) {
if (result instanceof ChunkedInferenceError error) {
acc.addFailure(
new ElasticsearchException(
"Exception when running inference id [{}] on field [{}]",
error.getException(),
error.exception(),
inferenceProvider.model.getInferenceEntityId(),
request.field
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
import org.elasticsearch.inference.ChunkedInferenceServiceResults;
import org.elasticsearch.inference.InferenceChunks;
import org.elasticsearch.inference.Model;
import org.elasticsearch.inference.SimilarityMeasure;
Expand Down Expand Up @@ -307,7 +306,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}

/**
* Converts the provided {@link ChunkedInferenceServiceResults} into a list of {@link Chunk}.
* Converts the provided {@link InferenceChunks} into a list of {@link Chunk}.
*/
public static List<Chunk> toSemanticTextFieldChunks(List<InferenceChunks> results, XContentType contentType) throws IOException {
List<Chunk> chunks = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceEmbeddingByte;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceEmbeddingFloat;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceError;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceEmbeddingSparse;
import org.elasticsearch.xpack.core.inference.results.ChunkedInferenceError;
import org.elasticsearch.xpack.core.inference.results.InferenceTextEmbeddingByteResults;
import org.elasticsearch.xpack.core.inference.results.InferenceTextEmbeddingFloatResults;
import org.elasticsearch.xpack.core.inference.results.SparseEmbeddingResults;
Expand Down Expand Up @@ -504,9 +504,9 @@ public void testListenerErrorsWithWrongNumberOfResponses() {
var listener = new ActionListener<List<InferenceChunks>>() {

@Override
public void onResponse(List<InferenceChunks> chunkedInferenceServiceResults) {
assertThat(chunkedInferenceServiceResults.get(0), instanceOf(ChunkedInferenceError.class));
var error = (ChunkedInferenceError) chunkedInferenceServiceResults.get(0);
public void onResponse(List<InferenceChunks> chunkedResults) {
assertThat(chunkedResults.get(0), instanceOf(ChunkedInferenceError.class));
var error = (ChunkedInferenceError) chunkedResults.get(0);
failureMessage.set(error.exception().getMessage());
}

Expand Down

0 comments on commit baf0373

Please sign in to comment.