|
@@ -18,6 +18,7 @@ import org.elasticsearch.common.logging.DeprecationLogger;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.util.LazyInitializable;
|
|
|
import org.elasticsearch.core.Nullable;
|
|
|
+import org.elasticsearch.core.Strings;
|
|
|
import org.elasticsearch.core.TimeValue;
|
|
|
import org.elasticsearch.inference.ChunkedInference;
|
|
|
import org.elasticsearch.inference.ChunkingSettings;
|
|
@@ -111,6 +112,13 @@ public class ElasticsearchInternalService extends BaseElasticsearchInternalServi
|
|
|
private static final Logger logger = LogManager.getLogger(ElasticsearchInternalService.class);
|
|
|
private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(ElasticsearchInternalService.class);
|
|
|
|
|
|
+ /**
|
|
|
+ * Fix for https://github.com/elastic/elasticsearch/issues/124675
|
|
|
+ * In 8.13.0 we transitioned from model_version to model_id. Any elser inference endpoints created prior to 8.13.0 will still use
|
|
|
+ * service_settings.model_version.
|
|
|
+ */
|
|
|
+ private static final String OLD_MODEL_ID_FIELD_NAME = "model_version";
|
|
|
+
|
|
|
private final Settings settings;
|
|
|
|
|
|
public ElasticsearchInternalService(InferenceServiceExtension.InferenceServiceFactoryContext context) {
|
|
@@ -489,6 +497,8 @@ public class ElasticsearchInternalService extends BaseElasticsearchInternalServi
|
|
|
Map<String, Object> serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS);
|
|
|
Map<String, Object> taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS);
|
|
|
|
|
|
+ migrateModelVersionToModelId(serviceSettingsMap);
|
|
|
+
|
|
|
ChunkingSettings chunkingSettings = null;
|
|
|
if (TaskType.TEXT_EMBEDDING.equals(taskType) || TaskType.SPARSE_EMBEDDING.equals(taskType)) {
|
|
|
chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMap(config, ModelConfigurations.CHUNKING_SETTINGS));
|
|
@@ -496,7 +506,9 @@ public class ElasticsearchInternalService extends BaseElasticsearchInternalServi
|
|
|
|
|
|
String modelId = (String) serviceSettingsMap.get(MODEL_ID);
|
|
|
if (modelId == null) {
|
|
|
- throw new IllegalArgumentException("Error parsing request config, model id is missing");
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ Strings.format("Error parsing request config, model id is missing for inference id: %s", inferenceEntityId)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
if (MULTILINGUAL_E5_SMALL_VALID_IDS.contains(modelId)) {
|
|
@@ -536,6 +548,18 @@ public class ElasticsearchInternalService extends BaseElasticsearchInternalServi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Fix for https://github.com/elastic/elasticsearch/issues/124675
|
|
|
+ * In 8.13.0 we transitioned from model_version to model_id. Any elser inference endpoints created prior to 8.13.0 will still use
|
|
|
+ * service_settings.model_version. We need to look for that key and migrate it to model_id.
|
|
|
+ */
|
|
|
+ private void migrateModelVersionToModelId(Map<String, Object> serviceSettingsMap) {
|
|
|
+ if (serviceSettingsMap.containsKey(OLD_MODEL_ID_FIELD_NAME)) {
|
|
|
+ String modelId = ServiceUtils.removeAsType(serviceSettingsMap, OLD_MODEL_ID_FIELD_NAME, String.class);
|
|
|
+ serviceSettingsMap.put(ElserInternalServiceSettings.MODEL_ID, modelId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void checkModelConfig(Model model, ActionListener<Model> listener) {
|
|
|
if (model instanceof CustomElandEmbeddingModel elandModel && elandModel.getTaskType() == TaskType.TEXT_EMBEDDING) {
|