Skip to content

Commit 1be3aca

Browse files
author
Max Hniebergall
committed
Avoid using immutable map for constructing EISCompletionModel
1 parent 8ebe833 commit 1be3aca

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
@@ -303,7 +303,21 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M
303303
Map<String, Object> taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS);
304304

305305
if (DEFAULT_EIS_COMPLETION_ENDPOINT_ID.equals(inferenceEntityId)) {
306-
return V1_EIS_COMPLETION_MODEL;
306+
var defaultServiceSettings = new HashMap<String, Object>(1);
307+
var serviceSettings = ElasticInferenceServiceCompletionServiceSettings.fromMap(
308+
defaultServiceSettings,
309+
ConfigurationParseContext.PERSISTENT
310+
);
311+
312+
return new ElasticInferenceServiceCompletionModel(
313+
V1_EIS_COMPLETION_MODEL_ID,
314+
TaskType.COMPLETION,
315+
NAME,
316+
serviceSettings,
317+
EmptyTaskSettings.INSTANCE,
318+
null,
319+
null
320+
);
307321
} else {
308322
return createModelFromPersistent(
309323
inferenceEntityId,
@@ -316,15 +330,7 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M
316330
}
317331
}
318332

319-
private static final Model V1_EIS_COMPLETION_MODEL = new ElasticInferenceServiceCompletionModel(
320-
V1_EIS_COMPLETION_MODEL_ID,
321-
TaskType.COMPLETION,
322-
NAME,
323-
(ElasticInferenceServiceCompletionServiceSettings) Map.of(MODEL_ID, DEFAULT_EIS_COMPLETION_ENDPOINT_ID),
324-
EmptyTaskSettings.INSTANCE,
325-
null,
326-
null
327-
);
333+
328334

329335
@Override
330336
public TransportVersion getMinimalSupportedVersion() {

0 commit comments

Comments
 (0)