|
16 | 16 | import org.elasticsearch.common.logging.DeprecationCategory;
|
17 | 17 | import org.elasticsearch.common.logging.DeprecationLogger;
|
18 | 18 | import org.elasticsearch.core.Nullable;
|
| 19 | +import org.elasticsearch.core.Strings; |
19 | 20 | import org.elasticsearch.core.TimeValue;
|
20 | 21 | import org.elasticsearch.inference.ChunkedInferenceServiceResults;
|
21 | 22 | import org.elasticsearch.inference.ChunkingOptions;
|
@@ -91,6 +92,13 @@ public class ElasticsearchInternalService extends BaseElasticsearchInternalServi
|
91 | 92 | private static final Logger logger = LogManager.getLogger(ElasticsearchInternalService.class);
|
92 | 93 | private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(ElasticsearchInternalService.class);
|
93 | 94 |
|
| 95 | + /** |
| 96 | + * Fix for https://github.com/elastic/elasticsearch/issues/124675 |
| 97 | + * 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 |
| 98 | + * service_settings.model_version. |
| 99 | + */ |
| 100 | + private static final String OLD_MODEL_ID_FIELD_NAME = "model_version"; |
| 101 | + |
94 | 102 | public ElasticsearchInternalService(InferenceServiceExtension.InferenceServiceFactoryContext context) {
|
95 | 103 | super(context);
|
96 | 104 | }
|
@@ -433,14 +441,18 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M
|
433 | 441 | Map<String, Object> serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS);
|
434 | 442 | Map<String, Object> taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS);
|
435 | 443 |
|
| 444 | + migrateModelVersionToModelId(serviceSettingsMap); |
| 445 | + |
436 | 446 | ChunkingSettings chunkingSettings = null;
|
437 | 447 | if (TaskType.TEXT_EMBEDDING.equals(taskType) || TaskType.SPARSE_EMBEDDING.equals(taskType)) {
|
438 | 448 | chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMap(config, ModelConfigurations.CHUNKING_SETTINGS));
|
439 | 449 | }
|
440 | 450 |
|
441 | 451 | String modelId = (String) serviceSettingsMap.get(ElasticsearchInternalServiceSettings.MODEL_ID);
|
442 | 452 | if (modelId == null) {
|
443 |
| - throw new IllegalArgumentException("Error parsing request config, model id is missing"); |
| 453 | + throw new IllegalArgumentException( |
| 454 | + Strings.format("Error parsing request config, model id is missing for inference id: %s", inferenceEntityId) |
| 455 | + ); |
444 | 456 | }
|
445 | 457 |
|
446 | 458 | if (MULTILINGUAL_E5_SMALL_VALID_IDS.contains(modelId)) {
|
@@ -472,6 +484,18 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M
|
472 | 484 | }
|
473 | 485 | }
|
474 | 486 |
|
| 487 | + /** |
| 488 | + * Fix for https://github.com/elastic/elasticsearch/issues/124675 |
| 489 | + * 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 |
| 490 | + * service_settings.model_version. We need to look for that key and migrate it to model_id. |
| 491 | + */ |
| 492 | + private void migrateModelVersionToModelId(Map<String, Object> serviceSettingsMap) { |
| 493 | + if (serviceSettingsMap.containsKey(OLD_MODEL_ID_FIELD_NAME)) { |
| 494 | + String modelId = ServiceUtils.removeAsType(serviceSettingsMap, OLD_MODEL_ID_FIELD_NAME, String.class); |
| 495 | + serviceSettingsMap.put(ElserInternalServiceSettings.MODEL_ID, modelId); |
| 496 | + } |
| 497 | + } |
| 498 | + |
475 | 499 | @Override
|
476 | 500 | public void checkModelConfig(Model model, ActionListener<Model> listener) {
|
477 | 501 | if (model instanceof CustomElandEmbeddingModel elandModel && elandModel.getTaskType() == TaskType.TEXT_EMBEDDING) {
|
|
0 commit comments