Skip to content

Add new additional_config field to model_config and DefaultModelConfig class #3786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.opensearch.ml.common.dataset.MLInputDataType;
import org.opensearch.ml.common.input.MLInput;
import org.opensearch.ml.common.input.parameter.clustering.KMeansParams;
import org.opensearch.ml.common.model.GeneralModelConfig;
import org.opensearch.ml.common.model.MLModelConfig;
import org.opensearch.ml.common.model.MLModelFormat;
import org.opensearch.ml.common.model.TextEmbeddingModelConfig;
import org.opensearch.ml.common.transport.register.MLRegisterModelInput;

@RunWith(MockitoJUnitRunner.class)
Expand Down Expand Up @@ -67,11 +67,11 @@ public void setUp() throws Exception {
.parameters(KMeansParams.builder().centroids(1).build())
.inputDataset(DataFrameInputDataset.builder().dataFrame(dataFrame).build())
.build();
MLModelConfig config = TextEmbeddingModelConfig
MLModelConfig config = GeneralModelConfig
.builder()
.modelType("testModelType")
.allConfig("{\"field1\":\"value1\",\"field2\":\"value2\"}")
.frameworkType(TextEmbeddingModelConfig.FrameworkType.SENTENCE_TRANSFORMERS)
.frameworkType(GeneralModelConfig.FrameworkType.SENTENCE_TRANSFORMERS)
.embeddingDimension(100)
.build();
MLRegisterModelInput registerModelInput = MLRegisterModelInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.opensearch.ml.common.dataset.MLInputDataType;
import org.opensearch.ml.common.input.MLInput;
import org.opensearch.ml.common.input.parameter.clustering.KMeansParams;
import org.opensearch.ml.common.model.GeneralModelConfig;
import org.opensearch.ml.common.model.MLModelConfig;
import org.opensearch.ml.common.model.MLModelFormat;
import org.opensearch.ml.common.model.TextEmbeddingModelConfig;
import org.opensearch.ml.common.transport.register.MLRegisterModelInput;

@RunWith(MockitoJUnitRunner.class)
Expand Down Expand Up @@ -72,11 +72,11 @@ public void setUp() throws Exception {
.parameters(KMeansParams.builder().centroids(1).build())
.inputDataset(DataFrameInputDataset.builder().dataFrame(dataFrame).build())
.build();
MLModelConfig config = TextEmbeddingModelConfig
MLModelConfig config = GeneralModelConfig
.builder()
.modelType("testModelType")
.allConfig("{\"field1\":\"value1\",\"field2\":\"value2\"}")
.frameworkType(TextEmbeddingModelConfig.FrameworkType.SENTENCE_TRANSFORMERS)
.frameworkType(GeneralModelConfig.FrameworkType.SENTENCE_TRANSFORMERS)
.embeddingDimension(100)
.build();
registerModelInput = MLRegisterModelInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.ml.common.FunctionName;
import org.opensearch.ml.common.model.GeneralModelConfig;
import org.opensearch.ml.common.model.MLModelConfig;
import org.opensearch.ml.common.model.MLModelFormat;
import org.opensearch.ml.common.model.TextEmbeddingModelConfig;

public class MLRegisterModelRequestTest {

Expand All @@ -23,11 +23,11 @@ public class MLRegisterModelRequestTest {
@Before
public void setUp() {

TextEmbeddingModelConfig config = TextEmbeddingModelConfig
GeneralModelConfig config = GeneralModelConfig
.builder()
.modelType("testModelType")
.allConfig("{\"field1\":\"value1\",\"field2\":\"value2\"}")
.frameworkType(TextEmbeddingModelConfig.FrameworkType.SENTENCE_TRANSFORMERS)
.frameworkType(GeneralModelConfig.FrameworkType.SENTENCE_TRANSFORMERS)
.embeddingDimension(100)
.build();

Expand Down Expand Up @@ -63,7 +63,7 @@ public void writeTo_Success() throws IOException {
assertTrue(request.getRegisterModelInput().isDeployModel());
String[] modelNodeIds = request.getRegisterModelInput().getModelNodeIds();
assertEquals("modelNodeIds", modelNodeIds[0]);
assertEquals("TEXT_EMBEDDING", config1.getWriteableName());
assertEquals("general", config1.getWriteableName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
Expand All @@ -18,26 +20,29 @@
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.ml.common.FunctionName;
import org.opensearch.ml.common.model.GeneralModelConfig;
import org.opensearch.ml.common.model.MLModelFormat;
import org.opensearch.ml.common.model.MLModelState;
import org.opensearch.ml.common.model.TextEmbeddingModelConfig;
import org.opensearch.ml.common.model.TextEmbeddingModelConfig.FrameworkType;

public class MLRegisterModelMetaRequestTest {

TextEmbeddingModelConfig config;
GeneralModelConfig config;
MLRegisterModelMetaInput mlRegisterModelMetaInput;

@Before
public void setUp() {
config = new TextEmbeddingModelConfig(
Map<String, Object> additionalConfig = new HashMap<>();
additionalConfig.put("test_key", "test_value");

config = new GeneralModelConfig(
"Model Type",
123,
FrameworkType.SENTENCE_TRANSFORMERS,
"All Config",
TextEmbeddingModelConfig.PoolingMode.MEAN,
GeneralModelConfig.FrameworkType.SENTENCE_TRANSFORMERS,
"\"test_key1\":\"test_value1\"",
GeneralModelConfig.PoolingMode.MEAN,
true,
512
512,
additionalConfig
);
mlRegisterModelMetaInput = new MLRegisterModelMetaInput(
"Model Name",
Expand Down
Loading