Skip to content

Commit 73d9e1e

Browse files
author
Max Hniebergall
committed
Avoid using immutable map for constructing EISCompletionModel
1 parent 5e6cc5e commit 73d9e1e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,21 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M
306306
Map<String, Object> taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS);
307307

308308
if (DEFAULT_EIS_COMPLETION_ENDPOINT_ID.equals(inferenceEntityId)) {
309-
return V1_EIS_COMPLETION_MODEL;
309+
var defaultServiceSettings = new HashMap<String, Object>(1);
310+
var serviceSettings = ElasticInferenceServiceCompletionServiceSettings.fromMap(
311+
defaultServiceSettings,
312+
ConfigurationParseContext.PERSISTENT
313+
);
314+
315+
return new ElasticInferenceServiceCompletionModel(
316+
V1_EIS_COMPLETION_MODEL_ID,
317+
TaskType.COMPLETION,
318+
NAME,
319+
serviceSettings,
320+
EmptyTaskSettings.INSTANCE,
321+
null,
322+
null
323+
);
310324
} else {
311325
return createModelFromPersistent(
312326
inferenceEntityId,
@@ -319,15 +333,7 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M
319333
}
320334
}
321335

322-
private static final Model V1_EIS_COMPLETION_MODEL = new ElasticInferenceServiceCompletionModel(
323-
V1_EIS_COMPLETION_MODEL_ID,
324-
TaskType.COMPLETION,
325-
NAME,
326-
(ElasticInferenceServiceCompletionServiceSettings) Map.of(MODEL_ID, DEFAULT_EIS_COMPLETION_ENDPOINT_ID),
327-
EmptyTaskSettings.INSTANCE,
328-
null,
329-
null
330-
);
336+
331337

332338
@Override
333339
public TransportVersion getMinimalSupportedVersion() {

0 commit comments

Comments
 (0)